@@ -1000,6 +1000,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
10001000 itctx : & ImplTraitContext ,
10011001 ) -> hir:: TypeBinding < ' hir > {
10021002 debug ! ( "lower_assoc_ty_constraint(constraint={:?}, itctx={:?})" , constraint, itctx) ;
1003+ let hir_id = self . lower_node_id ( constraint. id ) ;
10031004 // lower generic arguments of identifier in constraint
10041005 let gen_args = if let Some ( ref gen_args) = constraint. gen_args {
10051006 let gen_args_ctor = match gen_args {
@@ -1095,7 +1096,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
10951096 } ;
10961097
10971098 hir:: TypeBinding {
1098- hir_id : self . lower_node_id ( constraint . id ) ,
1099+ hir_id,
10991100 ident : self . lower_ident ( constraint. ident ) ,
11001101 gen_args,
11011102 kind,
@@ -1222,6 +1223,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
12221223 && let Some ( partial_res) = self . resolver . get_partial_res ( t. id )
12231224 && let Some ( Res :: Def ( DefKind :: Trait | DefKind :: TraitAlias , _) ) = partial_res. full_res ( )
12241225 {
1226+ let hir_id = self . next_id ( ) ;
12251227 let ( bounds, lifetime_bound) = self . with_dyn_type_scope ( true , |this| {
12261228 let poly_trait_ref = this. ast_arena . ptr . alloc ( PolyTraitRef {
12271229 bound_generic_params : vec ! [ ] ,
@@ -1237,7 +1239,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
12371239 ( bounds, lifetime_bound)
12381240 } ) ;
12391241 let kind = hir:: TyKind :: TraitObject ( bounds, & lifetime_bound, TraitObjectSyntax :: None ) ;
1240- return hir:: Ty { kind, span : self . lower_span ( t. span ) , hir_id : self . next_id ( ) } ;
1242+ return hir:: Ty { kind, span : self . lower_span ( t. span ) , hir_id } ;
12411243 }
12421244
12431245 let id = self . lower_node_id ( t. id ) ;
@@ -1254,6 +1256,14 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
12541256 }
12551257
12561258 fn lower_ty_direct ( & mut self , t : & Ty , itctx : & ImplTraitContext ) -> hir:: Ty < ' hir > {
1259+ if let TyKind :: Paren ( ref ty) = t. kind {
1260+ return self . lower_ty_direct ( ty, itctx) ;
1261+ }
1262+ if let TyKind :: Path ( ref qself, ref path) = t. kind {
1263+ return self . lower_path_ty ( t, qself, path, ParamMode :: Explicit , itctx) ;
1264+ }
1265+ // alloc hir_id
1266+ let hir_id = self . lower_node_id ( t. id ) ;
12571267 let kind = match t. kind {
12581268 TyKind :: Infer => hir:: TyKind :: Infer ,
12591269 TyKind :: Err => hir:: TyKind :: Err ,
@@ -1289,12 +1299,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
12891299 TyKind :: Tup ( ref tys) => hir:: TyKind :: Tup (
12901300 self . arena . alloc_from_iter ( tys. iter ( ) . map ( |ty| self . lower_ty_direct ( ty, itctx) ) ) ,
12911301 ) ,
1292- TyKind :: Paren ( ref ty) => {
1293- return self . lower_ty_direct ( ty, itctx) ;
1294- }
1295- TyKind :: Path ( ref qself, ref path) => {
1296- return self . lower_path_ty ( t, qself, path, ParamMode :: Explicit , itctx) ;
1297- }
12981302 TyKind :: ImplicitSelf => {
12991303 let hir_id = self . next_id ( ) ;
13001304 let res = self . expect_full_res ( t. id ) ;
@@ -1414,9 +1418,10 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
14141418 ) ;
14151419 hir:: TyKind :: Err
14161420 }
1421+ _ => panic ! ( "unexpected type: {:?}" , t) ,
14171422 } ;
14181423
1419- hir:: Ty { kind, span : self . lower_span ( t. span ) , hir_id : self . lower_node_id ( t . id ) }
1424+ hir:: Ty { kind, span : self . lower_span ( t. span ) , hir_id : hir_id }
14201425 }
14211426
14221427 /// Lowers a `ReturnPositionOpaqueTy` (`-> impl Trait`) or a `TypeAliasesOpaqueTy` (`type F =
@@ -2069,6 +2074,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
20692074 span : Span ,
20702075 mut nested_impl_trait_context : ImplTraitContext ,
20712076 ) -> hir:: GenericBound < ' hir > {
2077+ let hir_id = self . next_id ( ) ;
20722078 // Compute the `T` in `Future<Output = T>` from the return type.
20732079 let output_ty = match output {
20742080 FnRetTy :: Ty ( ty) => {
@@ -2092,7 +2098,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
20922098 // ::std::future::Future<future_params>
20932099 hir:: LangItem :: Future ,
20942100 self . lower_span ( span) ,
2095- self . next_id ( ) ,
2101+ hir_id ,
20962102 future_args,
20972103 )
20982104 }
@@ -2128,6 +2134,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
21282134 ident : Ident ,
21292135 res : LifetimeRes ,
21302136 ) -> & ' hir hir:: Lifetime {
2137+ let hir_id = self . lower_node_id ( id) ;
21312138 let name = match res {
21322139 LifetimeRes :: Param { param, .. } => {
21332140 let p_name = ParamName :: Plain ( ident) ;
@@ -2148,11 +2155,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
21482155 } ;
21492156
21502157 debug ! ( ?name) ;
2151- self . arena . alloc ( hir:: Lifetime {
2152- hir_id : self . lower_node_id ( id) ,
2153- span : self . lower_span ( span) ,
2154- name,
2155- } )
2158+ self . arena . alloc ( hir:: Lifetime { hir_id, span : self . lower_span ( span) , name } )
21562159 }
21572160
21582161 #[ instrument( level = "debug" , skip( self ) ) ]
@@ -2180,9 +2183,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
21802183
21812184 #[ instrument( level = "trace" , skip( self ) ) ]
21822185 fn lower_generic_param ( & mut self , param : & GenericParam ) -> hir:: GenericParam < ' hir > {
2186+ let hir_id = self . lower_node_id ( param. id ) ;
21832187 let ( name, kind) = self . lower_generic_param_kind ( param) ;
21842188
2185- let hir_id = self . lower_node_id ( param. id ) ;
21862189 self . lower_attrs ( hir_id, & param. attrs ) ;
21872190 hir:: GenericParam {
21882191 hir_id,
@@ -2237,11 +2240,12 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
22372240 }
22382241
22392242 fn lower_trait_ref ( & mut self , p : & TraitRef , itctx : & ImplTraitContext ) -> hir:: TraitRef < ' hir > {
2243+ let hir_id = self . lower_node_id ( p. ref_id ) ;
22402244 let path = match self . lower_qpath ( p. ref_id , & None , & p. path , ParamMode :: Explicit , itctx) {
22412245 hir:: QPath :: Resolved ( None , path) => path,
22422246 qpath => panic ! ( "lower_trait_ref: unexpected QPath `{:?}`" , qpath) ,
22432247 } ;
2244- hir:: TraitRef { path, hir_ref_id : self . lower_node_id ( p . ref_id ) }
2248+ hir:: TraitRef { path, hir_ref_id : hir_id }
22452249 }
22462250
22472251 #[ instrument( level = "debug" , skip( self ) ) ]
0 commit comments