@@ -7,6 +7,7 @@ use rustc::middle::cstore::{LinkagePreference, NativeLibrary,
7
7
EncodedMetadata , ForeignModule } ;
8
8
use rustc:: hir:: def:: CtorKind ;
9
9
use rustc:: hir:: def_id:: { CrateNum , CRATE_DEF_INDEX , DefIndex , DefId , LocalDefId , LOCAL_CRATE } ;
10
+ use rustc:: hir:: GenericParamKind ;
10
11
use rustc:: hir:: map:: definitions:: DefPathTable ;
11
12
use rustc_data_structures:: fingerprint:: Fingerprint ;
12
13
use rustc:: middle:: dependency_format:: Linkage ;
@@ -1352,25 +1353,22 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
1352
1353
}
1353
1354
}
1354
1355
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 > {
1359
1362
let tcx = self . tcx ;
1360
1363
Entry {
1361
- kind : EntryKind :: Type ,
1364
+ kind : entry_kind ,
1362
1365
visibility : self . lazy ( & ty:: Visibility :: Public ) ,
1363
1366
span : self . lazy ( & tcx. def_span ( def_id) ) ,
1364
1367
attributes : LazySeq :: empty ( ) ,
1365
1368
children : LazySeq :: empty ( ) ,
1366
1369
stability : None ,
1367
1370
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 } ,
1374
1372
inherent_impls : LazySeq :: empty ( ) ,
1375
1373
variances : LazySeq :: empty ( ) ,
1376
1374
generics : None ,
@@ -1381,27 +1379,20 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
1381
1379
}
1382
1380
}
1383
1381
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
+ }
1402
1389
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 )
1405
1396
}
1406
1397
1407
1398
fn encode_info_for_closure ( & mut self , def_id : DefId ) -> Entry < ' tcx > {
@@ -1748,18 +1739,18 @@ impl<'a, 'b, 'tcx> IndexBuilder<'a, 'b, 'tcx> {
1748
1739
1749
1740
fn encode_info_for_generics ( & mut self , generics : & hir:: Generics ) {
1750
1741
for param in & generics. params {
1742
+ let def_id = self . tcx . hir ( ) . local_def_id_from_hir_id ( param. hir_id ) ;
1751
1743
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
+ ) ;
1758
1751
}
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) ;
1763
1754
}
1764
1755
}
1765
1756
}
0 commit comments