1
Fork 0

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:
bors 2020-10-25 07:03:58 +00:00
commit 3e0dd24a6c
9 changed files with 98 additions and 19 deletions

View file

@ -163,4 +163,17 @@ impl<'a, 'hir> intravisit::Visitor<'hir> for HirIdValidator<'a, 'hir> {
// we are currently in. So for those it's correct that they have a
// 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
{
// Synthetic impl trait parameters are owned by the node of the desugared type.
// This means it is correct for them to have a different owner.
} else {
intravisit::walk_generic_param(self, param);
}
}
}