about summary refs log tree commit diff
path: root/compiler/rustc_passes
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-10-25 07:03:58 +0000
committerbors <bors@rust-lang.org>2020-10-25 07:03:58 +0000
commit3e0dd24a6c0812eedbb02182a75c352f8a7e184a (patch)
treeff4818aee54f87a34953d5285643e97a252e6452 /compiler/rustc_passes
parent17cc9b6256c95c31944591aec683884fead4e3b6 (diff)
parent567d55ef9ef4c441365227aeb14880eef639c349 (diff)
downloadrust-3e0dd24a6c0812eedbb02182a75c352f8a7e184a.tar.gz
rust-3e0dd24a6c0812eedbb02182a75c352f8a7e184a.zip
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`
Diffstat (limited to 'compiler/rustc_passes')
-rw-r--r--compiler/rustc_passes/src/hir_id_validator.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/compiler/rustc_passes/src/hir_id_validator.rs b/compiler/rustc_passes/src/hir_id_validator.rs
index 24695f5cdfa..6d1a5fcc10b 100644
--- a/compiler/rustc_passes/src/hir_id_validator.rs
+++ b/compiler/rustc_passes/src/hir_id_validator.rs
@@ -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);
+        }
+    }
 }