Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SelfVisitor::is_self_ty ICE #103221

Merged
merged 2 commits into from
Oct 20, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix SelfVisitor::is_self_ty ICE
  • Loading branch information
TaKO8Ki committed Oct 19, 2022
commit 0b2716415f1bd26e80887c2d8459fd436fc8e9b3
6 changes: 3 additions & 3 deletions compiler/rustc_resolve/src/late.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1928,11 +1928,11 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
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
TaKO8Ki marked this conversation as resolved.
Show resolved Hide resolved
}
_ => false,
}
Expand Down
7 changes: 7 additions & 0 deletions src/test/ui/resolve/issue-103202.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
struct S {}

impl S {
fn f(self: &S::x) {} //~ ERROR ambiguous associated type
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm.. that error seems incorrect. Maybe we should bubble out a new ResolutionError variant from find_lifetime_for_self by changing the lifetime field of the visitor to a Result that, once set to Err simply doesn't do anything else anymore.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error does not come from find_lifetime_forself, it looks like the regular error because S` is known to be a type and we expect a type.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before this regression, rustc caused the following error:

error[E0223]: ambiguous associated type
 --> src/main.rs:4:17
  |
4 |     fn f(self: &S::x) {} //~ ERROR ambiguous associated type
  |                 ^^^^ help: use fully-qualified syntax: `<S as Trait>::x`

}

fn main() {}
9 changes: 9 additions & 0 deletions src/test/ui/resolve/issue-103202.stderr
Original file line number Diff line number Diff line change
@@ -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`.