Skip to content

Delegation: support coercion for target expression#126699

Merged
bors merged 1 commit intorust-lang:masterfrom
Bryanskiy:delegation-coercion
Jul 17, 2024
Merged

Delegation: support coercion for target expression#126699
bors merged 1 commit intorust-lang:masterfrom
Bryanskiy:delegation-coercion

Conversation

@Bryanskiy
Copy link
Contributor

@Bryanskiy Bryanskiy commented Jun 19, 2024

(solves #118212 (comment))

The implementation consist of 2 parts. Firstly, method call is generated instead of fully qualified call in AST->HIR lowering if there were no generic arguments or Qpath were provided. These restrictions are imposed due to the loss of information after desugaring. For example in

trait Trait {
  fn foo(&self) {}
}

reuse <u8 as Trait>::foo;

We would like to generate such a code:

fn foo<u8: Trait>(x: &u8) {
  x.foo(x)
}

however, the signature is inherited during HIR analysis where u8 was discarded.

Then, we probe the single pre-resolved method.

P.S In the future, we would like to avoid restrictions on the callee path by Self autoref/autoderef in fully qualified calls, but at the moment it didn't work out.

r? @petrochenkov

Loading
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. T-types Relevant to the types 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