@@ -31,7 +31,6 @@ use rustc::ty::{self, AdtKind, ToPolyTraitRef, Ty, TyCtxt};
31
31
use rustc:: ty:: { ReprOptions , ToPredicate } ;
32
32
use rustc:: util:: captures:: Captures ;
33
33
use rustc:: util:: nodemap:: FxHashMap ;
34
- use rustc_data_structures:: sync:: Lrc ;
35
34
use rustc_target:: spec:: abi;
36
35
37
36
use syntax:: ast;
@@ -178,7 +177,7 @@ impl<'a, 'tcx> AstConv<'tcx, 'tcx> for ItemCtxt<'a, 'tcx> {
178
177
}
179
178
180
179
fn get_type_parameter_bounds ( & self , span : Span , def_id : DefId )
181
- -> Lrc < ty:: GenericPredicates < ' tcx > > {
180
+ -> & ' tcx ty:: GenericPredicates < ' tcx > {
182
181
self . tcx
183
182
. at ( span)
184
183
. type_param_predicates ( ( self . item_def_id , def_id) )
@@ -243,7 +242,7 @@ impl<'a, 'tcx> AstConv<'tcx, 'tcx> for ItemCtxt<'a, 'tcx> {
243
242
fn type_param_predicates < ' a , ' tcx > (
244
243
tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
245
244
( item_def_id, def_id) : ( DefId , DefId ) ,
246
- ) -> Lrc < ty:: GenericPredicates < ' tcx > > {
245
+ ) -> & ' tcx ty:: GenericPredicates < ' tcx > {
247
246
use rustc:: hir:: * ;
248
247
249
248
// In the AST, bounds can derive from two places. Either
@@ -264,16 +263,11 @@ fn type_param_predicates<'a, 'tcx>(
264
263
tcx. generics_of ( item_def_id) . parent
265
264
} ;
266
265
267
- let mut result = parent. map_or_else (
268
- || Lrc :: new ( ty:: GenericPredicates {
269
- parent : None ,
270
- predicates : vec ! [ ] ,
271
- } ) ,
272
- |parent| {
273
- let icx = ItemCtxt :: new ( tcx, parent) ;
274
- icx. get_type_parameter_bounds ( DUMMY_SP , def_id)
275
- } ,
276
- ) ;
266
+ let result = parent. map_or ( & tcx. common . empty_predicates , |parent| {
267
+ let icx = ItemCtxt :: new ( tcx, parent) ;
268
+ icx. get_type_parameter_bounds ( DUMMY_SP , def_id)
269
+ } ) ;
270
+ let mut extend = None ;
277
271
278
272
let item_hir_id = tcx. hir ( ) . as_local_hir_id ( item_def_id) . unwrap ( ) ;
279
273
let ast_generics = match tcx. hir ( ) . get_by_hir_id ( item_hir_id) {
@@ -298,9 +292,7 @@ fn type_param_predicates<'a, 'tcx>(
298
292
// Implied `Self: Trait` and supertrait bounds.
299
293
if param_id == item_hir_id {
300
294
let identity_trait_ref = ty:: TraitRef :: identity ( tcx, item_def_id) ;
301
- Lrc :: make_mut ( & mut result)
302
- . predicates
303
- . push ( ( identity_trait_ref. to_predicate ( ) , item. span ) ) ;
295
+ extend = Some ( ( identity_trait_ref. to_predicate ( ) , item. span ) ) ;
304
296
}
305
297
generics
306
298
}
@@ -317,11 +309,12 @@ fn type_param_predicates<'a, 'tcx>(
317
309
} ;
318
310
319
311
let icx = ItemCtxt :: new ( tcx, item_def_id) ;
320
- Lrc :: make_mut ( & mut result)
321
- . predicates
322
- . extend ( icx. type_parameter_bounds_in_generics ( ast_generics, param_id, ty,
323
- OnlySelfBounds ( true ) ) ) ;
324
- result
312
+ let mut result = ( * result) . clone ( ) ;
313
+ result. predicates . extend ( extend. into_iter ( ) ) ;
314
+ result. predicates
315
+ . extend ( icx. type_parameter_bounds_in_generics ( ast_generics, param_id, ty,
316
+ OnlySelfBounds ( true ) ) ) ;
317
+ tcx. arena . alloc ( result)
325
318
}
326
319
327
320
impl < ' a , ' tcx > ItemCtxt < ' a , ' tcx > {
@@ -690,7 +683,7 @@ fn adt_def<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx ty::Ad
690
683
fn super_predicates_of < ' a , ' tcx > (
691
684
tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
692
685
trait_def_id : DefId ,
693
- ) -> Lrc < ty:: GenericPredicates < ' tcx > > {
686
+ ) -> & ' tcx ty:: GenericPredicates < ' tcx > {
694
687
debug ! ( "super_predicates(trait_def_id={:?})" , trait_def_id) ;
695
688
let trait_hir_id = tcx. hir ( ) . as_local_hir_id ( trait_def_id) . unwrap ( ) ;
696
689
@@ -734,7 +727,7 @@ fn super_predicates_of<'a, 'tcx>(
734
727
}
735
728
}
736
729
737
- Lrc :: new ( ty:: GenericPredicates {
730
+ tcx . arena . alloc ( ty:: GenericPredicates {
738
731
parent : None ,
739
732
predicates : superbounds,
740
733
} )
@@ -1842,7 +1835,7 @@ fn early_bound_lifetimes_from_generics<'a, 'tcx>(
1842
1835
fn predicates_defined_on < ' a , ' tcx > (
1843
1836
tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
1844
1837
def_id : DefId ,
1845
- ) -> Lrc < ty:: GenericPredicates < ' tcx > > {
1838
+ ) -> & ' tcx ty:: GenericPredicates < ' tcx > {
1846
1839
debug ! ( "predicates_defined_on({:?})" , def_id) ;
1847
1840
let mut result = tcx. explicit_predicates_of ( def_id) ;
1848
1841
debug ! (
@@ -1858,9 +1851,9 @@ fn predicates_defined_on<'a, 'tcx>(
1858
1851
def_id,
1859
1852
inferred_outlives,
1860
1853
) ;
1861
- Lrc :: make_mut ( & mut result)
1862
- . predicates
1863
- . extend ( inferred_outlives . iter ( ) . map ( | & p| ( p , span ) ) ) ;
1854
+ let mut predicates = ( * result) . clone ( ) ;
1855
+ predicates . predicates . extend ( inferred_outlives . iter ( ) . map ( | & p| ( p , span ) ) ) ;
1856
+ result = tcx . arena . alloc ( predicates ) ;
1864
1857
}
1865
1858
debug ! ( "predicates_defined_on({:?}) = {:?}" , def_id, result) ;
1866
1859
result
@@ -1872,7 +1865,7 @@ fn predicates_defined_on<'a, 'tcx>(
1872
1865
fn predicates_of < ' a , ' tcx > (
1873
1866
tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
1874
1867
def_id : DefId ,
1875
- ) -> Lrc < ty:: GenericPredicates < ' tcx > > {
1868
+ ) -> & ' tcx ty:: GenericPredicates < ' tcx > {
1876
1869
let mut result = tcx. predicates_defined_on ( def_id) ;
1877
1870
1878
1871
if tcx. is_trait ( def_id) {
@@ -1889,9 +1882,9 @@ fn predicates_of<'a, 'tcx>(
1889
1882
// used, and adding the predicate into this list ensures
1890
1883
// that this is done.
1891
1884
let span = tcx. def_span ( def_id) ;
1892
- Lrc :: make_mut ( & mut result)
1893
- . predicates
1894
- . push ( ( ty :: TraitRef :: identity ( tcx, def_id ) . to_predicate ( ) , span ) ) ;
1885
+ let mut predicates = ( * result) . clone ( ) ;
1886
+ predicates . predicates . push ( ( ty :: TraitRef :: identity ( tcx , def_id ) . to_predicate ( ) , span ) ) ;
1887
+ result = tcx. arena . alloc ( predicates ) ;
1895
1888
}
1896
1889
debug ! ( "predicates_of(def_id={:?}) = {:?}" , def_id, result) ;
1897
1890
result
@@ -1902,7 +1895,7 @@ fn predicates_of<'a, 'tcx>(
1902
1895
fn explicit_predicates_of < ' a , ' tcx > (
1903
1896
tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
1904
1897
def_id : DefId ,
1905
- ) -> Lrc < ty:: GenericPredicates < ' tcx > > {
1898
+ ) -> & ' tcx ty:: GenericPredicates < ' tcx > {
1906
1899
use rustc:: hir:: * ;
1907
1900
use rustc_data_structures:: fx:: FxHashSet ;
1908
1901
@@ -2017,7 +2010,7 @@ fn explicit_predicates_of<'a, 'tcx>(
2017
2010
2018
2011
if impl_trait_fn. is_some ( ) {
2019
2012
// impl Trait
2020
- return Lrc :: new ( ty:: GenericPredicates {
2013
+ return tcx . arena . alloc ( ty:: GenericPredicates {
2021
2014
parent : None ,
2022
2015
predicates : bounds. predicates ( tcx, opaque_ty) ,
2023
2016
} ) ;
@@ -2228,7 +2221,7 @@ fn explicit_predicates_of<'a, 'tcx>(
2228
2221
) ;
2229
2222
}
2230
2223
2231
- let result = Lrc :: new ( ty:: GenericPredicates {
2224
+ let result = tcx . arena . alloc ( ty:: GenericPredicates {
2232
2225
parent : generics. parent ,
2233
2226
predicates,
2234
2227
} ) ;
0 commit comments