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

Delegation: fix ICE on late diagnostics #126234

Merged
merged 1 commit into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 5 additions & 2 deletions compiler/rustc_resolve/src/late/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2041,8 +2041,11 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
ast::AssocItemKind::Fn(..) => AssocSuggestion::AssocFn { called },
ast::AssocItemKind::Type(..) => AssocSuggestion::AssocType,
ast::AssocItemKind::Delegation(..)
if self.r.delegation_fn_sigs[&self.r.local_def_id(assoc_item.id)]
.has_self =>
if self
.r
.delegation_fn_sigs
.get(&self.r.local_def_id(assoc_item.id))
.map_or(false, |sig| sig.has_self) =>
{
AssocSuggestion::MethodWithSelf { called }
}
Expand Down
6 changes: 0 additions & 6 deletions tests/crashes/124342.rs

This file was deleted.

12 changes: 12 additions & 0 deletions tests/ui/delegation/ice-issue-124342.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#![feature(fn_delegation)]
#![allow(incomplete_features)]

mod to_reuse {}

trait Trait {
reuse to_reuse::foo { foo }
//~^ ERROR cannot find function `foo` in module `to_reuse`
//~| ERROR cannot find value `foo` in this scope
}

fn main() {}
20 changes: 20 additions & 0 deletions tests/ui/delegation/ice-issue-124342.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
error[E0425]: cannot find function `foo` in module `to_reuse`
--> $DIR/ice-issue-124342.rs:7:21
|
LL | reuse to_reuse::foo { foo }
| ^^^ not found in `to_reuse`

error[E0425]: cannot find value `foo` in this scope
--> $DIR/ice-issue-124342.rs:7:27
|
LL | reuse to_reuse::foo { foo }
| ^^^
|
help: you might have meant to refer to the associated function
|
LL | reuse to_reuse::foo { Self::foo }
| ++++++

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0425`.
Loading