@@ -13,14 +13,13 @@ use rustc::hir;
1313use rustc:: hir:: itemlikevisit:: ItemLikeVisitor ;
1414use rustc:: ty:: { self , CrateInherentImpls , TyCtxt } ;
1515
16- use rustc_data_structures:: sync:: Lrc ;
1716use syntax:: ast;
1817use syntax_pos:: Span ;
1918
2019/// On-demand query: yields a map containing all types mapped to their inherent impls.
2120pub fn crate_inherent_impls < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
2221 crate_num : CrateNum )
23- -> Lrc < CrateInherentImpls > {
22+ -> & ' tcx CrateInherentImpls {
2423 assert_eq ! ( crate_num, LOCAL_CRATE ) ;
2524
2625 let krate = tcx. hir ( ) . krate ( ) ;
@@ -29,13 +28,13 @@ pub fn crate_inherent_impls<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
2928 impls_map : Default :: default ( ) ,
3029 } ;
3130 krate. visit_all_item_likes ( & mut collect) ;
32- Lrc :: new ( collect. impls_map )
31+ tcx . arena . alloc ( collect. impls_map )
3332}
3433
3534/// On-demand query: yields a vector of the inherent impls for a specific type.
3635pub fn inherent_impls < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
3736 ty_def_id : DefId )
38- -> Lrc < Vec < DefId > > {
37+ -> & ' tcx [ DefId ] {
3938 assert ! ( ty_def_id. is_local( ) ) ;
4039
4140 // NB. Until we adopt the red-green dep-tracking algorithm (see
@@ -53,15 +52,11 @@ pub fn inherent_impls<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
5352 //
5453 // [the plan]: https://github.com/rust-lang/rust-roadmap/issues/4
5554
56- thread_local ! {
57- static EMPTY_DEF_ID_VEC : Lrc <Vec <DefId >> = Lrc :: new( vec![ ] )
58- }
59-
6055 let result = tcx. dep_graph . with_ignore ( || {
6156 let crate_map = tcx. crate_inherent_impls ( ty_def_id. krate ) ;
6257 match crate_map. inherent_impls . get ( & ty_def_id) {
63- Some ( v) => v . clone ( ) ,
64- None => EMPTY_DEF_ID_VEC . with ( |v| v . clone ( ) )
58+ Some ( v) => & v [ .. ] ,
59+ None => & [ ] ,
6560 }
6661 } ) ;
6762
@@ -289,13 +284,8 @@ impl<'a, 'tcx> InherentCollect<'a, 'tcx> {
289284 // type def ID, if there is a base type for this implementation and
290285 // the implementation does not have any associated traits.
291286 let impl_def_id = self . tcx . hir ( ) . local_def_id_from_hir_id ( item. hir_id ) ;
292- let mut rc_vec = self . impls_map . inherent_impls
293- . entry ( def_id)
294- . or_default ( ) ;
295-
296- // At this point, there should not be any clones of the
297- // `Lrc`, so we can still safely push into it in place:
298- Lrc :: get_mut ( & mut rc_vec) . unwrap ( ) . push ( impl_def_id) ;
287+ let vec = self . impls_map . inherent_impls . entry ( def_id) . or_default ( ) ;
288+ vec. push ( impl_def_id) ;
299289 } else {
300290 struct_span_err ! ( self . tcx. sess,
301291 item. span,
0 commit comments