@@ -13,7 +13,6 @@ use rustc_ast::visit::walk_list;
1313use rustc_data_structures:: fx:: { FxHashSet , FxIndexMap , FxIndexSet } ;
1414use rustc_hir as hir;
1515use rustc_hir:: def:: { DefKind , Res } ;
16- use rustc_hir:: def_id:: LocalDefId ;
1716use rustc_hir:: intravisit:: { self , Visitor } ;
1817use rustc_hir:: { GenericArg , GenericParam , GenericParamKind , HirId , HirIdMap , LifetimeName , Node } ;
1918use rustc_macros:: extension;
@@ -22,7 +21,7 @@ use rustc_middle::middle::resolve_bound_vars::*;
2221use rustc_middle:: query:: Providers ;
2322use rustc_middle:: ty:: { self , TyCtxt , TypeSuperVisitable , TypeVisitor } ;
2423use rustc_middle:: { bug, span_bug} ;
25- use rustc_span:: def_id:: DefId ;
24+ use rustc_span:: def_id:: { DefId , LocalDefId } ;
2625use rustc_span:: symbol:: { sym, Ident } ;
2726use rustc_span:: Span ;
2827
@@ -32,7 +31,7 @@ use crate::errors;
3231impl ResolvedArg {
3332 fn early ( param : & GenericParam < ' _ > ) -> ( LocalDefId , ResolvedArg ) {
3433 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 ) )
3635 }
3736
3837 fn late ( idx : u32 , param : & GenericParam < ' _ > ) -> ( LocalDefId , ResolvedArg ) {
@@ -41,10 +40,10 @@ impl ResolvedArg {
4140 "ResolvedArg::late: idx={:?}, param={:?} depth={:?} def_id={:?}" ,
4241 idx, param, depth, param. def_id,
4342 ) ;
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 ) )
4544 }
4645
47- fn id ( & self ) -> Option < DefId > {
46+ fn id ( & self ) -> Option < LocalDefId > {
4847 match * self {
4948 ResolvedArg :: StaticLifetime | ResolvedArg :: Error ( _) => None ,
5049
@@ -288,13 +287,14 @@ fn late_arg_as_bound_arg<'tcx>(
288287) -> ty:: BoundVariableKind {
289288 match arg {
290289 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) ;
292292 match param. kind {
293293 GenericParamKind :: Lifetime { .. } => {
294- ty:: BoundVariableKind :: Region ( ty:: BrNamed ( * def_id, name) )
294+ ty:: BoundVariableKind :: Region ( ty:: BrNamed ( def_id, name) )
295295 }
296296 GenericParamKind :: Type { .. } => {
297- ty:: BoundVariableKind :: Ty ( ty:: BoundTyKind :: Param ( * def_id, name) )
297+ ty:: BoundVariableKind :: Ty ( ty:: BoundTyKind :: Param ( def_id, name) )
298298 }
299299 GenericParamKind :: Const { .. } => ty:: BoundVariableKind :: Const ,
300300 }
@@ -717,7 +717,6 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
717717 // In the future, this should be fixed and this error should be removed.
718718 let def = self . map . defs . get ( & lifetime. hir_id ) . copied ( ) ;
719719 let Some ( ResolvedArg :: LateBound ( _, _, lifetime_def_id) ) = def else { continue } ;
720- let Some ( lifetime_def_id) = lifetime_def_id. as_local ( ) else { continue } ;
721720 let lifetime_hir_id = self . tcx . local_def_id_to_hir_id ( lifetime_def_id) ;
722721
723722 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> {
11501149 . param_def_id_to_index ( self . tcx , region_def_id. to_def_id ( ) )
11511150 . is_some ( )
11521151 {
1153- break Some ( ResolvedArg :: EarlyBound ( region_def_id. to_def_id ( ) ) ) ;
1152+ break Some ( ResolvedArg :: EarlyBound ( region_def_id) ) ;
11541153 }
11551154 break None ;
11561155 }
@@ -1259,7 +1258,7 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
12591258 kind => span_bug ! (
12601259 use_span,
12611260 "did not expect to resolve lifetime to {}" ,
1262- kind. descr( param_def_id)
1261+ kind. descr( param_def_id. to_def_id ( ) )
12631262 ) ,
12641263 } ;
12651264 def = ResolvedArg :: Error ( guar) ;
@@ -1277,10 +1276,10 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
12771276 kind : hir:: ImplItemKind :: Fn ( ..) ,
12781277 ..
12791278 } ) => {
1280- def = ResolvedArg :: Free ( owner_id. to_def_id ( ) , def. id ( ) . unwrap ( ) ) ;
1279+ def = ResolvedArg :: Free ( owner_id. def_id , def. id ( ) . unwrap ( ) ) ;
12811280 }
12821281 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 ( ) ) ;
12841283 }
12851284 _ => { }
12861285 }
@@ -1351,7 +1350,7 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
13511350 . param_def_id_to_index ( self . tcx , param_def_id. to_def_id ( ) )
13521351 . is_some ( )
13531352 {
1354- break Some ( ResolvedArg :: EarlyBound ( param_def_id. to_def_id ( ) ) ) ;
1353+ break Some ( ResolvedArg :: EarlyBound ( param_def_id) ) ;
13551354 }
13561355 break None ;
13571356 }
0 commit comments