Delegation: support coercion for target expression by Bryanskiy · Pull Request #126699 · rust-lang/rust

@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

Jun 19, 2024

@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

Jun 19, 2024

@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

Jun 24, 2024

petrochenkov

@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

Jun 25, 2024

compiler-errors added a commit to compiler-errors/rust that referenced this pull request

Jun 25, 2024
…ctoring, r=petrochenkov

Delegation: ast lowering refactor

refactoring changes for rust-lang#126699

r? `@petrochenkov`

workingjubilee added a commit to workingjubilee/rustc that referenced this pull request

Jun 25, 2024
…ctoring, r=petrochenkov

Delegation: ast lowering refactor

refactoring changes for rust-lang#126699

r? ``@petrochenkov``

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request

Jun 25, 2024
…ctoring, r=petrochenkov

Delegation: ast lowering refactor

refactoring changes for rust-lang#126699

r? ```@petrochenkov```

rust-timer added a commit to rust-lang-ci/rust that referenced this pull request

Jun 25, 2024
Rollup merge of rust-lang#126947 - Bryanskiy:delegation-lowering-refactoring, r=petrochenkov

Delegation: ast lowering refactor

refactoring changes for rust-lang#126699

r? ```@petrochenkov```

@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

Jun 27, 2024

petrochenkov

compiler-errors

petrochenkov

@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

Jul 16, 2024

compiler-errors

@Bryanskiy

@bors bors 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

Jul 16, 2024

bors added a commit to rust-lang-ci/rust that referenced this pull request

Jul 16, 2024
Rollup of 7 pull requests

Successful merges:

 - rust-lang#124033 (Sync ar_archive_writer to LLVM 18.1.3)
 - rust-lang#126699 (Delegation: support coercion for target expression)
 - rust-lang#126762 (Deny keyword lifetimes pre-expansion)
 - rust-lang#126967 (Promote the `wasm32-wasip2` target to Tier 2)
 - rust-lang#127390 (Migrate `raw-dylib-inline-cross-dylib` and `raw-dylib-custom-dlltool` `run-make` tests to rmake)
 - rust-lang#127501 (Invert infer `error_reporting` mod struture)
 - rust-lang#127816 (Update method name to reflect changes to its internals)

r? `@ghost`
`@rustbot` modify labels: rollup

rust-timer added a commit to rust-lang-ci/rust that referenced this pull request

Jul 17, 2024
Rollup merge of rust-lang#126699 - Bryanskiy:delegation-coercion, r=compiler-errors

Delegation: support coercion for target expression

(solves rust-lang#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

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

reuse <u8 as Trait>::foo;
```

We would like to generate such a code:

```rust
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`