Skip to content

delegation: support self ty propagation for functions in free to trait reuse#155644

Merged
rust-bors[bot] merged 2 commits intorust-lang:mainfrom
aerooneqq:delegation-self-ty-propagation-2
Apr 23, 2026
Merged

delegation: support self ty propagation for functions in free to trait reuse#155644
rust-bors[bot] merged 2 commits intorust-lang:mainfrom
aerooneqq:delegation-self-ty-propagation-2

Conversation

@aerooneqq
Copy link
Copy Markdown
Contributor

@aerooneqq aerooneqq commented Apr 22, 2026

This PR adds support for self types specified in free to trait reuse. Up to this point we always generated Self despite the fact whether self type was specified or not. Now we use it in signature inheritance. Moreover we no more generate Self for static methods. Part of #118212.

trait Trait<T> {
  fn foo<const B: bool>(&self) {}
  fn bar() {}
}

impl<T> Trait<T> for usize {}

reuse <usize as Trait>::foo;

// Desugaring (no `Self` as usize is specified)
fn foo<T, const B: bool>(self: &usize) {
  <usize as Trait::<T>>::foo::<B>(self)
}

reuse Trait::bar;

// Desugaring (no `Self` as static method)
fn bar<T>() {
  Trait::<T>::bar(); //~ERROR: type annotations needed
}

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 Apr 22, 2026
@petrochenkov petrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. F-fn_delegation `#![feature(fn_delegation)]` and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 22, 2026
Comment thread tests/ui/delegation/generics/free-to-trait-self-reuse.rs Outdated
@petrochenkov
Copy link
Copy Markdown
Contributor

r=me with the tests updated #155644 (comment).
@rustbot author

@rustbot rustbot 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 Apr 22, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 22, 2026

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@aerooneqq
Copy link
Copy Markdown
Contributor Author

@rustbot ready

@rustbot rustbot 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 Apr 23, 2026
@petrochenkov
Copy link
Copy Markdown
Contributor

@bors r+

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Apr 23, 2026

📌 Commit 78435a9 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 Apr 23, 2026
rust-bors Bot pushed a commit that referenced this pull request Apr 23, 2026
Rollup of 7 pull requests

Successful merges:

 - #155469 (Account for titlecase in casing lints)
 - #155644 (delegation: support self ty propagation for functions in free to trait reuse)
 - #154957 (Fix ICE when const closure appears inside a non-const trait method)
 - #155442 (Change keyword order for `impl` restrictions)
 - #155561 (Use singular wording for single _ placeholders in type suggestions)
 - #155637 (Fix E0191 suggestion for empty dyn trait args)
 - #155661 (Remove `AttributeLintKind` variants - part 6)
@rust-bors rust-bors Bot merged commit aebbe6b into rust-lang:main Apr 23, 2026
11 checks passed
@rustbot rustbot added this to the 1.97.0 milestone Apr 23, 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-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.

3 participants