@@ -13,7 +13,6 @@ use rustc_ast::visit::walk_list;
13
13
use rustc_data_structures:: fx:: { FxHashSet , FxIndexMap , FxIndexSet } ;
14
14
use rustc_hir as hir;
15
15
use rustc_hir:: def:: { DefKind , Res } ;
16
- use rustc_hir:: def_id:: LocalDefId ;
17
16
use rustc_hir:: intravisit:: { self , Visitor } ;
18
17
use rustc_hir:: { GenericArg , GenericParam , GenericParamKind , HirId , HirIdMap , LifetimeName , Node } ;
19
18
use rustc_macros:: extension;
@@ -22,7 +21,7 @@ use rustc_middle::middle::resolve_bound_vars::*;
22
21
use rustc_middle:: query:: Providers ;
23
22
use rustc_middle:: ty:: { self , TyCtxt , TypeSuperVisitable , TypeVisitor } ;
24
23
use rustc_middle:: { bug, span_bug} ;
25
- use rustc_span:: def_id:: DefId ;
24
+ use rustc_span:: def_id:: { DefId , LocalDefId } ;
26
25
use rustc_span:: symbol:: { sym, Ident } ;
27
26
use rustc_span:: Span ;
28
27
@@ -32,7 +31,7 @@ use crate::errors;
32
31
impl ResolvedArg {
33
32
fn early ( param : & GenericParam < ' _ > ) -> ( LocalDefId , ResolvedArg ) {
34
33
debug ! ( "ResolvedArg::early: def_id={:?}" , param. def_id) ;
35
- ( param. def_id , ResolvedArg :: EarlyBound ( param. def_id . to_def_id ( ) ) )
34
+ ( param. def_id , ResolvedArg :: EarlyBound ( param. def_id ) )
36
35
}
37
36
38
37
fn late ( idx : u32 , param : & GenericParam < ' _ > ) -> ( LocalDefId , ResolvedArg ) {
@@ -41,10 +40,10 @@ impl ResolvedArg {
41
40
"ResolvedArg::late: idx={:?}, param={:?} depth={:?} def_id={:?}" ,
42
41
idx, param, depth, param. def_id,
43
42
) ;
44
- ( param. def_id , ResolvedArg :: LateBound ( depth, idx, param. def_id . to_def_id ( ) ) )
43
+ ( param. def_id , ResolvedArg :: LateBound ( depth, idx, param. def_id ) )
45
44
}
46
45
47
- fn id ( & self ) -> Option < DefId > {
46
+ fn id ( & self ) -> Option < LocalDefId > {
48
47
match * self {
49
48
ResolvedArg :: StaticLifetime | ResolvedArg :: Error ( _) => None ,
50
49
@@ -288,13 +287,14 @@ fn late_arg_as_bound_arg<'tcx>(
288
287
) -> ty:: BoundVariableKind {
289
288
match arg {
290
289
ResolvedArg :: LateBound ( _, _, def_id) => {
291
- let name = tcx. hir ( ) . name ( tcx. local_def_id_to_hir_id ( def_id. expect_local ( ) ) ) ;
290
+ let def_id = def_id. to_def_id ( ) ;
291
+ let name = tcx. item_name ( def_id) ;
292
292
match param. kind {
293
293
GenericParamKind :: Lifetime { .. } => {
294
- ty:: BoundVariableKind :: Region ( ty:: BrNamed ( * def_id, name) )
294
+ ty:: BoundVariableKind :: Region ( ty:: BrNamed ( def_id, name) )
295
295
}
296
296
GenericParamKind :: Type { .. } => {
297
- ty:: BoundVariableKind :: Ty ( ty:: BoundTyKind :: Param ( * def_id, name) )
297
+ ty:: BoundVariableKind :: Ty ( ty:: BoundTyKind :: Param ( def_id, name) )
298
298
}
299
299
GenericParamKind :: Const { .. } => ty:: BoundVariableKind :: Const ,
300
300
}
@@ -717,7 +717,6 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
717
717
// In the future, this should be fixed and this error should be removed.
718
718
let def = self . map . defs . get ( & lifetime. hir_id ) . copied ( ) ;
719
719
let Some ( ResolvedArg :: LateBound ( _, _, lifetime_def_id) ) = def else { continue } ;
720
- let Some ( lifetime_def_id) = lifetime_def_id. as_local ( ) else { continue } ;
721
720
let lifetime_hir_id = self . tcx . local_def_id_to_hir_id ( lifetime_def_id) ;
722
721
723
722
let bad_place = match self . tcx . hir_node ( self . tcx . parent_hir_id ( lifetime_hir_id) )
@@ -1150,7 +1149,7 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
1150
1149
. param_def_id_to_index ( self . tcx , region_def_id. to_def_id ( ) )
1151
1150
. is_some ( )
1152
1151
{
1153
- break Some ( ResolvedArg :: EarlyBound ( region_def_id. to_def_id ( ) ) ) ;
1152
+ break Some ( ResolvedArg :: EarlyBound ( region_def_id) ) ;
1154
1153
}
1155
1154
break None ;
1156
1155
}
@@ -1259,7 +1258,7 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
1259
1258
kind => span_bug ! (
1260
1259
use_span,
1261
1260
"did not expect to resolve lifetime to {}" ,
1262
- kind. descr( param_def_id)
1261
+ kind. descr( param_def_id. to_def_id ( ) )
1263
1262
) ,
1264
1263
} ;
1265
1264
def = ResolvedArg :: Error ( guar) ;
@@ -1277,10 +1276,10 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
1277
1276
kind : hir:: ImplItemKind :: Fn ( ..) ,
1278
1277
..
1279
1278
} ) => {
1280
- def = ResolvedArg :: Free ( owner_id. to_def_id ( ) , def. id ( ) . unwrap ( ) ) ;
1279
+ def = ResolvedArg :: Free ( owner_id. def_id , def. id ( ) . unwrap ( ) ) ;
1281
1280
}
1282
1281
Node :: Expr ( hir:: Expr { kind : hir:: ExprKind :: Closure ( closure) , .. } ) => {
1283
- def = ResolvedArg :: Free ( closure. def_id . to_def_id ( ) , def. id ( ) . unwrap ( ) ) ;
1282
+ def = ResolvedArg :: Free ( closure. def_id , def. id ( ) . unwrap ( ) ) ;
1284
1283
}
1285
1284
_ => { }
1286
1285
}
@@ -1351,7 +1350,7 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
1351
1350
. param_def_id_to_index ( self . tcx , param_def_id. to_def_id ( ) )
1352
1351
. is_some ( )
1353
1352
{
1354
- break Some ( ResolvedArg :: EarlyBound ( param_def_id. to_def_id ( ) ) ) ;
1353
+ break Some ( ResolvedArg :: EarlyBound ( param_def_id) ) ;
1355
1354
}
1356
1355
break None ;
1357
1356
}
0 commit comments