fix SelfVisitor::is_self_ty ICE

This commit is contained in:
Takayuki Maeda 2022-10-19 11:17:46 +09:00
parent ee1c3b385b
commit 0b2716415f
3 changed files with 19 additions and 3 deletions

View file

@ -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,
}

View file

@ -0,0 +1,7 @@
struct S {}
impl S {
fn f(self: &S::x) {} //~ ERROR ambiguous associated type
}
fn main() {}

View file

@ -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: `<S as Trait>::x`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0223`.