Auto merge of #77546 - lcnr:impl-trait-closure, r=eddyb
fix def collector for impl trait fixes #77329 We now consistently make `impl Trait` a hir owner, requiring some special casing for synthetic generic params. r? `@eddyb`
This commit is contained in:
commit
3e0dd24a6c
9 changed files with 98 additions and 19 deletions
|
@ -538,6 +538,12 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
|||
}
|
||||
self.visit_fn_ret_ty(&f.decl.output)
|
||||
}
|
||||
TyKind::ImplTrait(def_node_id, _) => {
|
||||
self.lctx.allocate_hir_id_counter(def_node_id);
|
||||
self.with_hir_id_owner(Some(def_node_id), |this| {
|
||||
visit::walk_ty(this, t);
|
||||
});
|
||||
}
|
||||
_ => visit::walk_ty(self, t),
|
||||
}
|
||||
}
|
||||
|
@ -1347,10 +1353,14 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
|||
// Add a definition for the in-band `Param`.
|
||||
let def_id = self.resolver.local_def_id(def_node_id);
|
||||
|
||||
let hir_bounds = self.lower_param_bounds(
|
||||
bounds,
|
||||
ImplTraitContext::Universal(in_band_ty_params),
|
||||
);
|
||||
self.allocate_hir_id_counter(def_node_id);
|
||||
|
||||
let hir_bounds = self.with_hir_id_owner(def_node_id, |this| {
|
||||
this.lower_param_bounds(
|
||||
bounds,
|
||||
ImplTraitContext::Universal(in_band_ty_params),
|
||||
)
|
||||
});
|
||||
// Set the name to `impl Bound1 + Bound2`.
|
||||
let ident = Ident::from_str_and_span(&pprust::ty_to_string(t), span);
|
||||
in_band_ty_params.push(hir::GenericParam {
|
||||
|
@ -2201,7 +2211,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
|||
.attrs
|
||||
.iter()
|
||||
.filter(|attr| self.sess.check_name(attr, sym::rustc_synthetic))
|
||||
.map(|_| hir::SyntheticTyParamKind::ImplTrait)
|
||||
.map(|_| hir::SyntheticTyParamKind::FromAttr)
|
||||
.next(),
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue