Skip to content

delegation: fix zero-args nested delegation ICE#154363

Open
aerooneqq wants to merge 1 commit intorust-lang:mainfrom
aerooneqq:nested-delegations
Open

delegation: fix zero-args nested delegation ICE#154363
aerooneqq wants to merge 1 commit intorust-lang:mainfrom
aerooneqq:nested-delegations

Conversation

@aerooneqq
Copy link
Contributor

@aerooneqq aerooneqq commented Mar 25, 2026

This PR fixes an ICE when during lowering of nested delegation we need to access information about its parent, who is also inside body of another delegation. As a fix we lower delegation body even if there are no arguments in signature function, in this case we will see an error this function takes 0 arguments but 1 argument was supplied. Fixes #154332. Part of #118212.

r? @petrochenkov

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 25, 2026
@aerooneqq aerooneqq changed the title Delegation: fix zero-args nested delegation ICE delegation: fix zero-args nested delegation ICE Mar 25, 2026
@petrochenkov petrochenkov added the F-fn_delegation `#![feature(fn_delegation)]` label Mar 25, 2026
@petrochenkov
Copy link
Contributor

The current behavior exists to support glob reuse.

#![feature(fn_delegation)]
#![allow(incomplete_features)]

trait Trait {
    fn method(&self) {}
    fn static_method() {}
}

impl Trait for u8 {}

struct Wrapper { inner: u8 }

reuse impl Trait for Wrapper { self.inner } // should probably be ok

When Trait methods have self, then self.inner is passed instead of self, when other methods are static, then self.inner is not passed at all.

The current desugaring doesn't support it though, and produces error[E0283]: type annotations needed, so this fix is ok in the meantime.

@petrochenkov
Copy link
Contributor

@bors r+

@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 25, 2026

📌 Commit 11a338d has been approved by petrochenkov

It is now in the queue for this repository.

@rust-bors rust-bors bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 25, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Mar 25, 2026
…trochenkov

delegation: fix zero-args nested delegation ICE

This PR fixes an ICE when during lowering of nested delegation we need to access information about its parent, who is also inside body of another delegation. As a fix we lower delegation body even if there are no arguments in signature function, in this case we will see an error `this function takes 0 arguments but 1 argument was supplied`. Fixes rust-lang#154332. Part of rust-lang#118212.

r? @petrochenkov
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Mar 25, 2026
…trochenkov

delegation: fix zero-args nested delegation ICE

This PR fixes an ICE when during lowering of nested delegation we need to access information about its parent, who is also inside body of another delegation. As a fix we lower delegation body even if there are no arguments in signature function, in this case we will see an error `this function takes 0 arguments but 1 argument was supplied`. Fixes rust-lang#154332. Part of rust-lang#118212.

r? @petrochenkov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

F-fn_delegation `#![feature(fn_delegation)]` S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ICE]: delegation: No HirId for DefId

3 participants