From 0b2716415f1bd26e80887c2d8459fd436fc8e9b3 Mon Sep 17 00:00:00 2001 From: Takayuki Maeda Date: Wed, 19 Oct 2022 11:17:46 +0900 Subject: [PATCH] fix `SelfVisitor::is_self_ty` ICE --- compiler/rustc_resolve/src/late.rs | 6 +++--- src/test/ui/resolve/issue-103202.rs | 7 +++++++ src/test/ui/resolve/issue-103202.stderr | 9 +++++++++ 3 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 src/test/ui/resolve/issue-103202.rs create mode 100644 src/test/ui/resolve/issue-103202.stderr diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index cc877e2fd30..5b99cd1e264 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -1928,11 +1928,11 @@ fn is_self_ty(&self, ty: &Ty) -> bool { match ty.kind { TyKind::ImplicitSelf => true, TyKind::Path(None, _) => { - let path_res = self.r.partial_res_map[&ty.id].expect_full_res(); - if let Res::SelfTyParam { .. } | Res::SelfTyAlias { .. } = path_res { + let path_res = self.r.partial_res_map[&ty.id].full_res(); + if let Some(Res::SelfTyParam { .. } | Res::SelfTyAlias { .. }) = path_res { return true; } - Some(path_res) == self.impl_self + path_res == self.impl_self } _ => false, } diff --git a/src/test/ui/resolve/issue-103202.rs b/src/test/ui/resolve/issue-103202.rs new file mode 100644 index 00000000000..469d9d7c860 --- /dev/null +++ b/src/test/ui/resolve/issue-103202.rs @@ -0,0 +1,7 @@ +struct S {} + +impl S { + fn f(self: &S::x) {} //~ ERROR ambiguous associated type +} + +fn main() {} diff --git a/src/test/ui/resolve/issue-103202.stderr b/src/test/ui/resolve/issue-103202.stderr new file mode 100644 index 00000000000..880389371ef --- /dev/null +++ b/src/test/ui/resolve/issue-103202.stderr @@ -0,0 +1,9 @@ +error[E0223]: ambiguous associated type + --> $DIR/issue-103202.rs:4:17 + | +LL | fn f(self: &S::x) {} + | ^^^^ help: use fully-qualified syntax: `::x` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0223`.