bodge
This commit is contained in:
parent
a5d2db4a58
commit
f865e3d22f
3 changed files with 44 additions and 9 deletions
|
@ -538,9 +538,10 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||||
}
|
}
|
||||||
self.visit_fn_ret_ty(&f.decl.output)
|
self.visit_fn_ret_ty(&f.decl.output)
|
||||||
}
|
}
|
||||||
TyKind::ImplTrait(_, ref bounds) => {
|
TyKind::ImplTrait(def_node_id, _) => {
|
||||||
self.with_hir_id_owner(None, |this| {
|
self.lctx.allocate_hir_id_counter(def_node_id);
|
||||||
walk_list!(this, visit_param_bound, bounds);
|
self.with_hir_id_owner(Some(def_node_id), |this| {
|
||||||
|
visit::walk_ty(this, t);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
_ => visit::walk_ty(self, t),
|
_ => visit::walk_ty(self, t),
|
||||||
|
@ -1351,10 +1352,14 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||||
// Add a definition for the in-band `Param`.
|
// Add a definition for the in-band `Param`.
|
||||||
let def_id = self.resolver.local_def_id(def_node_id);
|
let def_id = self.resolver.local_def_id(def_node_id);
|
||||||
|
|
||||||
let hir_bounds = self.lower_param_bounds(
|
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,
|
bounds,
|
||||||
ImplTraitContext::Universal(in_band_ty_params),
|
ImplTraitContext::Universal(in_band_ty_params),
|
||||||
);
|
)
|
||||||
|
});
|
||||||
// Set the name to `impl Bound1 + Bound2`.
|
// Set the name to `impl Bound1 + Bound2`.
|
||||||
let ident = Ident::from_str_and_span(&pprust::ty_to_string(t), span);
|
let ident = Ident::from_str_and_span(&pprust::ty_to_string(t), span);
|
||||||
in_band_ty_params.push(hir::GenericParam {
|
in_band_ty_params.push(hir::GenericParam {
|
||||||
|
|
|
@ -360,9 +360,27 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_generic_param(&mut self, param: &'hir GenericParam<'hir>) {
|
fn visit_generic_param(&mut self, param: &'hir GenericParam<'hir>) {
|
||||||
|
if let hir::GenericParamKind::Type {
|
||||||
|
synthetic: Some(hir::SyntheticTyParamKind::ImplTrait),
|
||||||
|
..
|
||||||
|
} = param.kind
|
||||||
|
{
|
||||||
|
debug_assert_eq!(
|
||||||
|
param.hir_id.owner,
|
||||||
|
self.definitions.opt_hir_id_to_local_def_id(param.hir_id).unwrap()
|
||||||
|
);
|
||||||
|
self.with_dep_node_owner(param.hir_id.owner, param, |this, hash| {
|
||||||
|
this.insert_with_hash(param.span, param.hir_id, Node::GenericParam(param), hash);
|
||||||
|
|
||||||
|
this.with_parent(param.hir_id, |this| {
|
||||||
|
intravisit::walk_generic_param(this, param);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} else {
|
||||||
self.insert(param.span, param.hir_id, Node::GenericParam(param));
|
self.insert(param.span, param.hir_id, Node::GenericParam(param));
|
||||||
intravisit::walk_generic_param(self, param);
|
intravisit::walk_generic_param(self, param);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn visit_trait_item(&mut self, ti: &'hir TraitItem<'hir>) {
|
fn visit_trait_item(&mut self, ti: &'hir TraitItem<'hir>) {
|
||||||
debug_assert_eq!(
|
debug_assert_eq!(
|
||||||
|
|
|
@ -163,4 +163,16 @@ impl<'a, 'hir> intravisit::Visitor<'hir> for HirIdValidator<'a, 'hir> {
|
||||||
// we are currently in. So for those it's correct that they have a
|
// we are currently in. So for those it's correct that they have a
|
||||||
// different owner.
|
// different owner.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn visit_generic_param(&mut self, param: &'hir hir::GenericParam<'hir>) {
|
||||||
|
if let hir::GenericParamKind::Type {
|
||||||
|
synthetic: Some(hir::SyntheticTyParamKind::ImplTrait),
|
||||||
|
..
|
||||||
|
} = param.kind
|
||||||
|
{
|
||||||
|
// Do nothing because bodging is fun.
|
||||||
|
} else {
|
||||||
|
intravisit::walk_generic_param(self, param);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue