@@ -7,6 +7,7 @@ use rustc::middle::cstore::{LinkagePreference, NativeLibrary,
77 EncodedMetadata , ForeignModule } ;
88use rustc:: hir:: def:: CtorKind ;
99use rustc:: hir:: def_id:: { CrateNum , CRATE_DEF_INDEX , DefIndex , DefId , LocalDefId , LOCAL_CRATE } ;
10+ use rustc:: hir:: GenericParamKind ;
1011use rustc:: hir:: map:: definitions:: DefPathTable ;
1112use rustc_data_structures:: fingerprint:: Fingerprint ;
1213use rustc:: middle:: dependency_format:: Linkage ;
@@ -1352,25 +1353,22 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
13521353 }
13531354 }
13541355
1355- fn encode_info_for_ty_param ( & mut self ,
1356- ( def_id, Untracked ( has_default) ) : ( DefId , Untracked < bool > ) )
1357- -> Entry < ' tcx > {
1358- debug ! ( "IsolatedEncoder::encode_info_for_ty_param({:?})" , def_id) ;
1356+ fn encode_info_for_generic_param (
1357+ & mut self ,
1358+ def_id : DefId ,
1359+ entry_kind : EntryKind < ' tcx > ,
1360+ encode_type : bool ,
1361+ ) -> Entry < ' tcx > {
13591362 let tcx = self . tcx ;
13601363 Entry {
1361- kind : EntryKind :: Type ,
1364+ kind : entry_kind ,
13621365 visibility : self . lazy ( & ty:: Visibility :: Public ) ,
13631366 span : self . lazy ( & tcx. def_span ( def_id) ) ,
13641367 attributes : LazySeq :: empty ( ) ,
13651368 children : LazySeq :: empty ( ) ,
13661369 stability : None ,
13671370 deprecation : None ,
1368-
1369- ty : if has_default {
1370- Some ( self . encode_item_type ( def_id) )
1371- } else {
1372- None
1373- } ,
1371+ ty : if encode_type { Some ( self . encode_item_type ( def_id) ) } else { None } ,
13741372 inherent_impls : LazySeq :: empty ( ) ,
13751373 variances : LazySeq :: empty ( ) ,
13761374 generics : None ,
@@ -1381,27 +1379,20 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
13811379 }
13821380 }
13831381
1384- fn encode_info_for_const_param ( & mut self , def_id : DefId ) -> Entry < ' tcx > {
1385- debug ! ( "IsolatedEncoder::encode_info_for_const_param({:?})" , def_id) ;
1386- let tcx = self . tcx ;
1387- Entry {
1388- kind : EntryKind :: Type ,
1389- visibility : self . lazy ( & ty:: Visibility :: Public ) ,
1390- span : self . lazy ( & tcx. def_span ( def_id) ) ,
1391- attributes : LazySeq :: empty ( ) ,
1392- children : LazySeq :: empty ( ) ,
1393- stability : None ,
1394- deprecation : None ,
1395-
1396- ty : Some ( self . encode_item_type ( def_id) ) ,
1397- inherent_impls : LazySeq :: empty ( ) ,
1398- variances : LazySeq :: empty ( ) ,
1399- generics : None ,
1400- predicates : None ,
1401- predicates_defined_on : None ,
1382+ fn encode_info_for_ty_param (
1383+ & mut self ,
1384+ ( def_id, Untracked ( encode_type) ) : ( DefId , Untracked < bool > ) ,
1385+ ) -> Entry < ' tcx > {
1386+ debug ! ( "IsolatedEncoder::encode_info_for_ty_param({:?})" , def_id) ;
1387+ self . encode_info_for_generic_param ( def_id, EntryKind :: TypeParam , encode_type)
1388+ }
14021389
1403- mir : None ,
1404- }
1390+ fn encode_info_for_const_param (
1391+ & mut self ,
1392+ def_id : DefId ,
1393+ ) -> Entry < ' tcx > {
1394+ debug ! ( "IsolatedEncoder::encode_info_for_const_param({:?})" , def_id) ;
1395+ self . encode_info_for_generic_param ( def_id, EntryKind :: ConstParam , true )
14051396 }
14061397
14071398 fn encode_info_for_closure ( & mut self , def_id : DefId ) -> Entry < ' tcx > {
@@ -1748,18 +1739,18 @@ impl<'a, 'b, 'tcx> IndexBuilder<'a, 'b, 'tcx> {
17481739
17491740 fn encode_info_for_generics ( & mut self , generics : & hir:: Generics ) {
17501741 for param in & generics. params {
1742+ let def_id = self . tcx . hir ( ) . local_def_id_from_hir_id ( param. hir_id ) ;
17511743 match param. kind {
1752- hir:: GenericParamKind :: Lifetime { .. } => { }
1753- hir:: GenericParamKind :: Type { ref default, .. } => {
1754- let def_id = self . tcx . hir ( ) . local_def_id_from_hir_id ( param. hir_id ) ;
1755- let has_default = Untracked ( default. is_some ( ) ) ;
1756- let encode_info = IsolatedEncoder :: encode_info_for_ty_param;
1757- self . record ( def_id, encode_info, ( def_id, has_default) ) ;
1744+ GenericParamKind :: Lifetime { .. } => continue ,
1745+ GenericParamKind :: Type { ref default, .. } => {
1746+ self . record (
1747+ def_id,
1748+ IsolatedEncoder :: encode_info_for_ty_param,
1749+ ( def_id, Untracked ( default. is_some ( ) ) ) ,
1750+ ) ;
17581751 }
1759- hir:: GenericParamKind :: Const { .. } => {
1760- let def_id = self . tcx . hir ( ) . local_def_id_from_hir_id ( param. hir_id ) ;
1761- let encode_info = IsolatedEncoder :: encode_info_for_const_param;
1762- self . record ( def_id, encode_info, def_id) ;
1752+ GenericParamKind :: Const { .. } => {
1753+ self . record ( def_id, IsolatedEncoder :: encode_info_for_const_param, def_id) ;
17631754 }
17641755 }
17651756 }
0 commit comments