Skip to content

Commit 8b54259

Browse files
committed
Use PathParameters even if just the lifetimes field is used
1 parent 1cfb628 commit 8b54259

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

src/librustc/hir/lowering.rs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,7 +1169,7 @@ impl<'a> LoweringContext<'a> {
11691169
lctx.lower_bounds(bounds, itctx)
11701170
});
11711171

1172-
let (lifetimes, lifetime_defs) = self.lifetimes_from_impl_trait_bounds(
1172+
let (path_params, params) = self.generics_from_impl_trait_bounds(
11731173
exist_ty_node_id,
11741174
exist_ty_def_index,
11751175
&hir_bounds,
@@ -1178,7 +1178,7 @@ impl<'a> LoweringContext<'a> {
11781178
self.with_hir_id_owner(exist_ty_node_id, |lctx| {
11791179
let exist_ty_item_kind = hir::ItemExistential(hir::ExistTy {
11801180
generics: hir::Generics {
1181-
params: lifetime_defs,
1181+
params,
11821182
where_clause: hir::WhereClause {
11831183
id: lctx.next_id().node_id,
11841184
predicates: Vec::new().into(),
@@ -1216,7 +1216,7 @@ impl<'a> LoweringContext<'a> {
12161216
id: exist_ty_id.node_id
12171217
},
12181218
DefId::local(exist_ty_def_index),
1219-
lifetimes,
1219+
path_params.lifetimes,
12201220
)
12211221
})
12221222
}
@@ -1280,12 +1280,12 @@ impl<'a> LoweringContext<'a> {
12801280
})
12811281
}
12821282

1283-
fn lifetimes_from_impl_trait_bounds(
1283+
fn generics_from_impl_trait_bounds(
12841284
&mut self,
12851285
exist_ty_id: NodeId,
12861286
parent_index: DefIndex,
12871287
bounds: &hir::TyParamBounds,
1288-
) -> (HirVec<hir::Lifetime>, HirVec<hir::GenericParam>) {
1288+
) -> (hir::PathParameters, HirVec<hir::GenericParam>) {
12891289
// This visitor walks over impl trait bounds and creates defs for all lifetimes which
12901290
// appear in the bounds, excluding lifetimes that are created within the bounds.
12911291
// e.g. 'a, 'b, but not 'c in `impl for<'c> SomeTrait<'a, 'b, 'c>`
@@ -1297,7 +1297,7 @@ impl<'a> LoweringContext<'a> {
12971297
currently_bound_lifetimes: Vec<hir::LifetimeName>,
12981298
already_defined_lifetimes: HashSet<hir::LifetimeName>,
12991299
output_lifetimes: Vec<hir::Lifetime>,
1300-
output_lifetime_params: Vec<hir::GenericParam>,
1300+
output_params: Vec<hir::GenericParam>,
13011301
}
13021302

13031303
impl<'r, 'a: 'r, 'v> hir::intravisit::Visitor<'v> for ImplTraitLifetimeCollector<'r, 'a> {
@@ -1405,7 +1405,7 @@ impl<'a> LoweringContext<'a> {
14051405
span: lifetime.span,
14061406
name,
14071407
};
1408-
self.output_lifetime_params
1408+
self.output_params
14091409
.push(hir::GenericParam::Lifetime(hir::LifetimeDef {
14101410
lifetime: def_lifetime,
14111411
bounds: Vec::new().into(),
@@ -1424,16 +1424,21 @@ impl<'a> LoweringContext<'a> {
14241424
currently_bound_lifetimes: Vec::new(),
14251425
already_defined_lifetimes: HashSet::new(),
14261426
output_lifetimes: Vec::new(),
1427-
output_lifetime_params: Vec::new(),
1427+
output_params: Vec::new(),
14281428
};
14291429

14301430
for bound in bounds {
14311431
hir::intravisit::walk_ty_param_bound(&mut lifetime_collector, &bound);
14321432
}
14331433

14341434
(
1435-
lifetime_collector.output_lifetimes.into(),
1436-
lifetime_collector.output_lifetime_params.into(),
1435+
hir::PathParameters {
1436+
lifetimes: lifetime_collector.output_lifetimes.into(),
1437+
types: HirVec::new(),
1438+
bindings: HirVec::new(),
1439+
parenthesized: false,
1440+
},
1441+
lifetime_collector.output_params.into(),
14371442
)
14381443
}
14391444

0 commit comments

Comments
 (0)