Skip to content

Commit 7ee4b21

Browse files
authored
Rollup merge of #103221 - TaKO8Ki:fix-103202, r=oli-obk
Fix `SelfVisitor::is_self_ty` ICE Fixes #103202
2 parents 5ffa67d + 9a9e2fe commit 7ee4b21

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

compiler/rustc_resolve/src/late.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1939,11 +1939,11 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
19391939
match ty.kind {
19401940
TyKind::ImplicitSelf => true,
19411941
TyKind::Path(None, _) => {
1942-
let path_res = self.r.partial_res_map[&ty.id].expect_full_res();
1943-
if let Res::SelfTyParam { .. } | Res::SelfTyAlias { .. } = path_res {
1942+
let path_res = self.r.partial_res_map[&ty.id].full_res();
1943+
if let Some(Res::SelfTyParam { .. } | Res::SelfTyAlias { .. }) = path_res {
19441944
return true;
19451945
}
1946-
Some(path_res) == self.impl_self
1946+
self.impl_self.is_some() && path_res == self.impl_self
19471947
}
19481948
_ => false,
19491949
}

src/test/ui/resolve/issue-103202.rs

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
struct S {}
2+
3+
impl S {
4+
fn f(self: &S::x) {} //~ ERROR ambiguous associated type
5+
}
6+
7+
fn main() {}
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0223]: ambiguous associated type
2+
--> $DIR/issue-103202.rs:4:17
3+
|
4+
LL | fn f(self: &S::x) {}
5+
| ^^^^ help: use fully-qualified syntax: `<S as Trait>::x`
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0223`.

0 commit comments

Comments
 (0)