Skip to content

delegation: remove method call generation#156541

Open
aerooneqq wants to merge 2 commits into
rust-lang:mainfrom
aerooneqq:delegation-no-method-call
Open

delegation: remove method call generation#156541
aerooneqq wants to merge 2 commits into
rust-lang:mainfrom
aerooneqq:delegation-no-method-call

Conversation

@aerooneqq
Copy link
Copy Markdown
Contributor

@aerooneqq aerooneqq commented May 13, 2026

This PR removes method call generation from delegations, now we always generate default call. Part of #118212.

We reuse methods probing engine for finding needed adjustments, thus extending number of supported cases. In this PR adjustments are applied to trait methods (was supported before) and static functions (new feature). Free functions can be supported later.

Example of static trait functions reuses that are now working:

trait Trait: Sized {
    fn static_value(_: Self) -> i32 { 1 }
    fn static_mut_ref(_: &mut Self) -> i32 { 2 }
    fn static_ref(_: &Self) -> i32 { 3 }
}

#[derive(Default)]
struct F;
impl Trait for F {}

struct S;

impl Trait for S {
    reuse <F as Trait>::{static_value, static_mut_ref, static_ref} { F }
}

fn main() {
    assert_eq!(S::static_ref(&S), 3);
    assert_eq!(S::static_mut_ref(&mut S), 2);
    assert_eq!(S::static_value(S), 1);
}

Finally this PR solves issues from parent generics propagation from #155906.

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 May 13, 2026
@petrochenkov petrochenkov added the F-fn_delegation `#![feature(fn_delegation)]` label May 13, 2026
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-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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants