@@ -1000,6 +1000,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1000
1000
itctx : & ImplTraitContext ,
1001
1001
) -> hir:: TypeBinding < ' hir > {
1002
1002
debug ! ( "lower_assoc_ty_constraint(constraint={:?}, itctx={:?})" , constraint, itctx) ;
1003
+ let hir_id = self . lower_node_id ( constraint. id ) ;
1003
1004
// lower generic arguments of identifier in constraint
1004
1005
let gen_args = if let Some ( ref gen_args) = constraint. gen_args {
1005
1006
let gen_args_ctor = match gen_args {
@@ -1095,7 +1096,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1095
1096
} ;
1096
1097
1097
1098
hir:: TypeBinding {
1098
- hir_id : self . lower_node_id ( constraint . id ) ,
1099
+ hir_id,
1099
1100
ident : self . lower_ident ( constraint. ident ) ,
1100
1101
gen_args,
1101
1102
kind,
@@ -1222,6 +1223,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1222
1223
&& let Some ( partial_res) = self . resolver . get_partial_res ( t. id )
1223
1224
&& let Some ( Res :: Def ( DefKind :: Trait | DefKind :: TraitAlias , _) ) = partial_res. full_res ( )
1224
1225
{
1226
+ let hir_id = self . next_id ( ) ;
1225
1227
let ( bounds, lifetime_bound) = self . with_dyn_type_scope ( true , |this| {
1226
1228
let poly_trait_ref = this. ast_arena . ptr . alloc ( PolyTraitRef {
1227
1229
bound_generic_params : vec ! [ ] ,
@@ -1237,7 +1239,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1237
1239
( bounds, lifetime_bound)
1238
1240
} ) ;
1239
1241
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 } ;
1241
1243
}
1242
1244
1243
1245
let id = self . lower_node_id ( t. id ) ;
@@ -1254,6 +1256,14 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1254
1256
}
1255
1257
1256
1258
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 ) ;
1257
1267
let kind = match t. kind {
1258
1268
TyKind :: Infer => hir:: TyKind :: Infer ,
1259
1269
TyKind :: Err => hir:: TyKind :: Err ,
@@ -1289,12 +1299,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1289
1299
TyKind :: Tup ( ref tys) => hir:: TyKind :: Tup (
1290
1300
self . arena . alloc_from_iter ( tys. iter ( ) . map ( |ty| self . lower_ty_direct ( ty, itctx) ) ) ,
1291
1301
) ,
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
- }
1298
1302
TyKind :: ImplicitSelf => {
1299
1303
let hir_id = self . next_id ( ) ;
1300
1304
let res = self . expect_full_res ( t. id ) ;
@@ -1414,9 +1418,10 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1414
1418
) ;
1415
1419
hir:: TyKind :: Err
1416
1420
}
1421
+ _ => panic ! ( "unexpected type: {:?}" , t) ,
1417
1422
} ;
1418
1423
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 }
1420
1425
}
1421
1426
1422
1427
/// Lowers a `ReturnPositionOpaqueTy` (`-> impl Trait`) or a `TypeAliasesOpaqueTy` (`type F =
@@ -2069,6 +2074,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
2069
2074
span : Span ,
2070
2075
mut nested_impl_trait_context : ImplTraitContext ,
2071
2076
) -> hir:: GenericBound < ' hir > {
2077
+ let hir_id = self . next_id ( ) ;
2072
2078
// Compute the `T` in `Future<Output = T>` from the return type.
2073
2079
let output_ty = match output {
2074
2080
FnRetTy :: Ty ( ty) => {
@@ -2092,7 +2098,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
2092
2098
// ::std::future::Future<future_params>
2093
2099
hir:: LangItem :: Future ,
2094
2100
self . lower_span ( span) ,
2095
- self . next_id ( ) ,
2101
+ hir_id ,
2096
2102
future_args,
2097
2103
)
2098
2104
}
@@ -2128,6 +2134,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
2128
2134
ident : Ident ,
2129
2135
res : LifetimeRes ,
2130
2136
) -> & ' hir hir:: Lifetime {
2137
+ let hir_id = self . lower_node_id ( id) ;
2131
2138
let name = match res {
2132
2139
LifetimeRes :: Param { param, .. } => {
2133
2140
let p_name = ParamName :: Plain ( ident) ;
@@ -2148,11 +2155,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
2148
2155
} ;
2149
2156
2150
2157
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 } )
2156
2159
}
2157
2160
2158
2161
#[ instrument( level = "debug" , skip( self ) ) ]
@@ -2180,9 +2183,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
2180
2183
2181
2184
#[ instrument( level = "trace" , skip( self ) ) ]
2182
2185
fn lower_generic_param ( & mut self , param : & GenericParam ) -> hir:: GenericParam < ' hir > {
2186
+ let hir_id = self . lower_node_id ( param. id ) ;
2183
2187
let ( name, kind) = self . lower_generic_param_kind ( param) ;
2184
2188
2185
- let hir_id = self . lower_node_id ( param. id ) ;
2186
2189
self . lower_attrs ( hir_id, & param. attrs ) ;
2187
2190
hir:: GenericParam {
2188
2191
hir_id,
@@ -2237,11 +2240,12 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
2237
2240
}
2238
2241
2239
2242
fn lower_trait_ref ( & mut self , p : & TraitRef , itctx : & ImplTraitContext ) -> hir:: TraitRef < ' hir > {
2243
+ let hir_id = self . lower_node_id ( p. ref_id ) ;
2240
2244
let path = match self . lower_qpath ( p. ref_id , & None , & p. path , ParamMode :: Explicit , itctx) {
2241
2245
hir:: QPath :: Resolved ( None , path) => path,
2242
2246
qpath => panic ! ( "lower_trait_ref: unexpected QPath `{:?}`" , qpath) ,
2243
2247
} ;
2244
- hir:: TraitRef { path, hir_ref_id : self . lower_node_id ( p . ref_id ) }
2248
+ hir:: TraitRef { path, hir_ref_id : hir_id }
2245
2249
}
2246
2250
2247
2251
#[ instrument( level = "debug" , skip( self ) ) ]
0 commit comments