Skip to content

delegation: remove method call generation - #156541

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
aerooneqq:delegation-no-method-call
May 26, 2026
Merged

delegation: remove method call generation#156541
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
aerooneqq:delegation-no-method-call

Conversation

@aerooneqq

@aerooneqqaerooneqq commented May 13, 2026

Copy link
Copy Markdown
Contributor

View all comments

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.

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

r? @petrochenkov

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

Copy link
Copy Markdown
Contributor

Example of static trait functions reuses that are now working:

Is there specific motivation for this? I wouldn't expect this to work.

I actually think we need to change the design to ignore the target expression entirely if there's no self parameter.
In that case both static and non-static methods will be able to be delegated together.

reuseTrait::{method, static_fn}{self.field}

=>

fnmethod(&self,a:A,b:B){self.field.method(a, b)// behavior, not exact desugaring}fnstatic_fn(a:A,b:B){Trait::static_fn(a, b)// no self, so the target expr is ignored}

Comment threadtests/ui/delegation/generics/generics-aux-pass.rs
@petrochenkov

Copy link
Copy Markdown
Contributor

ignore the target expression entirely if there's no self parameter

Or rather generate something like

fnstatic_fn(a:A,b:B){
target_expr;// usually dead code and noopTrait::static_fn(a, b)// no self, so the target expr is ignored}

to avoid issues like #154363 (comment).

Comment threadcompiler/rustc_ast_lowering/src/delegation.rs Outdated
Comment threadcompiler/rustc_ast_lowering/src/delegation.rs
Comment threadcompiler/rustc_hir_analysis/src/delegation.rs Outdated
Comment threadcompiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
Comment threadcompiler/rustc_hir_typeck/src/callee.rs Outdated
@petrochenkovpetrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 15, 2026
@rustbotrustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 21, 2026
Comment threadtests/ui/delegation/self-coercion-errors.rs
Comment threadcompiler/rustc_hir_typeck/src/callee.rs Outdated
Comment threadcompiler/rustc_hir_typeck/src/callee.rs Outdated
Comment threadcompiler/rustc_hir_typeck/src/callee.rs Outdated
Comment threadcompiler/rustc_hir_typeck/src/callee.rs Outdated
Comment threadcompiler/rustc_hir_typeck/src/callee.rs
Comment threadcompiler/rustc_hir_typeck/src/callee.rs Outdated
@petrochenkovpetrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 22, 2026
@rust-log-analyzer

This comment has been minimized.

@aerooneqq

Copy link
Copy Markdown
ContributorAuthor

@rustbot ready

@rustbotrustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 25, 2026
@rust-log-analyzer

This comment has been minimized.

@aerooneqq
aerooneqqforce-pushed the delegation-no-method-call branch from 5734b0d to 0c5f5bdCompareMay 25, 2026 06:22
@rustbot

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@petrochenkov

Copy link
Copy Markdown
Contributor

Let's run benchmarks, get_scope_for_method_call_adjustments now accesses some HIR on a good path for all calls, which may potentially cause issues in incremental mode.
@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbotrustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label May 25, 2026
@rust-bors

This comment has been minimized.

rust-borsBot pushed a commit that referenced this pull request May 25, 2026
@petrochenkovpetrochenkov removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 25, 2026
@rust-bors

rust-borsBot commented May 25, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 507e776 (507e776eb6c7dbce11a65799367ea71749babf4c, parent: 6083f7891b5088184968e050d0eaecc7bcfd2b3d)

@rust-timer

This comment has been minimized.

@aerooneqq
aerooneqqforce-pushed the delegation-no-method-call branch from 0c5f5bd to 40a7821CompareMay 26, 2026 05:06
@aerooneqq

Copy link
Copy Markdown
ContributorAuthor

@rustbot ready

@rustbotrustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 26, 2026
@petrochenkov

Copy link
Copy Markdown
Contributor

@bors r+

@rust-bors

rust-borsBot commented May 26, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 40a7821 has been approved by petrochenkov

It is now in the queue for this repository.

@rust-borsrust-borsBot 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 May 26, 2026
@rust-bors

This comment has been minimized.

rust-borsBot pushed a commit that referenced this pull request May 26, 2026
…henkov
delegation: remove method call generation
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.
Finally this PR solves issues from parent generics propagation from #155906.
r? @petrochenkov
@rust-borsrust-borsBot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels May 26, 2026
@rust-bors

rust-borsBot commented May 26, 2026

Copy link
Copy Markdown
Contributor

💔 Test for 9db232a failed: CI. Failed job:

@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

A job failed! Check out the build log: (web)(plain enhanced)(plain)

Click to see the possible cause of the failure (guessed by this bot)

@JonathanBrouwer

Copy link
Copy Markdown
Member

@bors retry

@rust-borsrust-borsBot 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 May 26, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request May 26, 2026
…l, r=petrochenkov
delegation: remove method call generation
This PR removes method call generation from delegations, now we always generate default call. Part of rust-lang#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.
Finally this PR solves issues from parent generics propagation from rust-lang#155906.
r? @petrochenkov
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request May 26, 2026
…l, r=petrochenkov
delegation: remove method call generation
This PR removes method call generation from delegations, now we always generate default call. Part of rust-lang#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.
Finally this PR solves issues from parent generics propagation from rust-lang#155906.
r? @petrochenkov
This was referenced May 26, 2026
rust-borsBot pushed a commit that referenced this pull request May 26, 2026
…uwer
Rollup of 9 pull requests
Successful merges:
- #156959 (stdarch subtree update)
- #156541 (delegation: remove method call generation)
- #156161 (rustc_on_unimplemented: introduce format specifiers)
- #156752 (fix E0371 description)
- #156761 (tidy: remove duplicate entry and alphabetize OS constants list)
- #156872 (Drop skip_move_check_fns query.)
- #156899 (fix breakpoint callback registration in `lldb_batchmode`)
- #156927 (Reorganize `tests/ui/issues` [1/N])
- #156947 (Update mdbook to 0.5.3)
@rust-bors
rust-borsBot merged commit f09612e into rust-lang:mainMay 26, 2026
11 of 12 checks passed
@rustbotrustbot added this to the 1.98.0 milestone May 26, 2026
rust-timer added a commit that referenced this pull request May 26, 2026
Rollup merge of #156541 - aerooneqq:delegation-no-method-call, r=petrochenkov
delegation: remove method call generation
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.
Finally this PR solves issues from parent generics propagation from #155906.
r? @petrochenkov
github-actionsBot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request May 30, 2026
…uwer
Rollup of 9 pull requests
Successful merges:
- rust-lang/rust#156959 (stdarch subtree update)
- rust-lang/rust#156541 (delegation: remove method call generation)
- rust-lang/rust#156161 (rustc_on_unimplemented: introduce format specifiers)
- rust-lang/rust#156752 (fix E0371 description)
- rust-lang/rust#156761 (tidy: remove duplicate entry and alphabetize OS constants list)
- rust-lang/rust#156872 (Drop skip_move_check_fns query.)
- rust-lang/rust#156899 (fix breakpoint callback registration in `lldb_batchmode`)
- rust-lang/rust#156927 (Reorganize `tests/ui/issues` [1/N])
- rust-lang/rust#156947 (Update mdbook to 0.5.3)
github-actionsBot pushed a commit to rust-lang/stdarch that referenced this pull request Jun 8, 2026
…uwer
Rollup of 9 pull requests
Successful merges:
- rust-lang/rust#156959 (stdarch subtree update)
- rust-lang/rust#156541 (delegation: remove method call generation)
- rust-lang/rust#156161 (rustc_on_unimplemented: introduce format specifiers)
- rust-lang/rust#156752 (fix E0371 description)
- rust-lang/rust#156761 (tidy: remove duplicate entry and alphabetize OS constants list)
- rust-lang/rust#156872 (Drop skip_move_check_fns query.)
- rust-lang/rust#156899 (fix breakpoint callback registration in `lldb_batchmode`)
- rust-lang/rust#156927 (Reorganize `tests/ui/issues` [1/N])
- rust-lang/rust#156947 (Update mdbook to 0.5.3)
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

F-fn_delegation`#![feature(fn_delegation)]`S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-compilerRelevant 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.

6 participants

@aerooneqq@petrochenkov@rust-log-analyzer@rustbot@rust-timer@JonathanBrouwer