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 recursive delegation #126236

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
4 changes: 3 additions & 1 deletion compiler/rustc_ast_lowering/src/delegation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
return false;
};
if let Some(local_sig_id) = sig_id.as_local() {
self.resolver.delegation_fn_sigs[&local_sig_id].has_self
// The value may be missing due to recursive delegation.
// Error will be emmited later during HIR ty lowering.
self.resolver.delegation_fn_sigs.get(&local_sig_id).map_or(false, |sig| sig.has_self)
} else {
match self.tcx.def_kind(sig_id) {
DefKind::Fn => false,
Expand Down
4 changes: 0 additions & 4 deletions tests/crashes/124347.rs

This file was deleted.

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

trait Trait {
reuse Trait::foo { &self.0 }
//~^ ERROR recursive delegation is not supported yet
}

reuse foo;
//~^ ERROR recursive delegation is not supported yet

fn main() {}
14 changes: 14 additions & 0 deletions tests/ui/delegation/ice-issue-124347.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
error: recursive delegation is not supported yet
--> $DIR/ice-issue-124347.rs:5:18
|
LL | reuse Trait::foo { &self.0 }
| ^^^ callee defined here

error: recursive delegation is not supported yet
--> $DIR/ice-issue-124347.rs:9:7
|
LL | reuse foo;
| ^^^ callee defined here

error: aborting due to 2 previous errors

Loading