@@ -253,7 +253,7 @@ enum ImplTraitContext {
253
253
/// equivalent to a fresh universal parameter like `fn foo<T: Debug>(x: T)`.
254
254
///
255
255
/// Newly generated parameters should be inserted into the given `Vec`.
256
- Universal ( LocalDefId ) ,
256
+ Universal ,
257
257
258
258
/// Treat `impl Trait` as shorthand for a new opaque type.
259
259
/// Example: `fn foo() -> impl Debug`, where `impl Debug` is conceptually
@@ -895,7 +895,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
895
895
hir:: TypeBindingKind :: Equality { term }
896
896
}
897
897
AssocConstraintKind :: Bound { ref bounds } => {
898
- let mut parent_def_id = self . current_hir_id_owner ;
899
898
// Piggy-back on the `impl Trait` context to figure out the correct behavior.
900
899
let ( desugar_to_impl_trait, itctx) = match itctx {
901
900
// We are in the return position:
@@ -915,10 +914,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
915
914
// so desugar to
916
915
//
917
916
// fn foo(x: dyn Iterator<Item = impl Debug>)
918
- ImplTraitContext :: Universal ( parent) if self . is_in_dyn_type => {
919
- parent_def_id = parent;
920
- ( true , itctx)
921
- }
917
+ ImplTraitContext :: Universal if self . is_in_dyn_type => ( true , itctx) ,
922
918
923
919
// In `type Foo = dyn Iterator<Item: Debug>` we desugar to
924
920
// `type Foo = dyn Iterator<Item = impl Debug>` but we have to override the
@@ -944,6 +940,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
944
940
// Desugar `AssocTy: Bounds` into `AssocTy = impl Bounds`. We do this by
945
941
// constructing the HIR for `impl bounds...` and then lowering that.
946
942
943
+ let parent_def_id = self . current_hir_id_owner ;
947
944
let impl_trait_node_id = self . resolver . next_node_id ( ) ;
948
945
self . resolver . create_def (
949
946
parent_def_id,
@@ -1186,12 +1183,12 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1186
1183
|this| this. lower_param_bounds ( bounds, nested_itctx) ,
1187
1184
)
1188
1185
}
1189
- ImplTraitContext :: Universal ( parent_def_id ) => {
1186
+ ImplTraitContext :: Universal => {
1190
1187
// Add a definition for the in-band `Param`.
1191
1188
let def_id = self . resolver . local_def_id ( def_node_id) ;
1192
1189
1193
- let hir_bounds = self
1194
- . lower_param_bounds ( bounds, ImplTraitContext :: Universal ( parent_def_id ) ) ;
1190
+ let hir_bounds =
1191
+ self . lower_param_bounds ( bounds, ImplTraitContext :: Universal ) ;
1195
1192
// Set the name to `impl Bound1 + Bound2`.
1196
1193
let ident = Ident :: from_str_and_span ( & pprust:: ty_to_string ( t) , span) ;
1197
1194
let param = hir:: GenericParam {
@@ -1401,10 +1398,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1401
1398
}
1402
1399
let inputs = self . arena . alloc_from_iter ( inputs. iter ( ) . map ( |param| {
1403
1400
if fn_node_id. is_some ( ) {
1404
- self . lower_ty_direct (
1405
- & param. ty ,
1406
- ImplTraitContext :: Universal ( self . current_hir_id_owner ) ,
1407
- )
1401
+ self . lower_ty_direct ( & param. ty , ImplTraitContext :: Universal )
1408
1402
} else {
1409
1403
self . lower_ty_direct (
1410
1404
& param. ty ,
0 commit comments