Skip to content

Conversation

dingxiangfei2009
Copy link
Contributor

@dingxiangfei2009 dingxiangfei2009 commented Sep 1, 2025

Receiver chain has been an extension of Deref chain, but the consequence has been questioned as this would admit method signatures that are deemed dubious.

It is also debatable that Receiver trait which determines applicable Self type should have anything to do with dereference operation in general.

This patch separate the two traits and isolate their use in the language. This means that in method probing, we will chase down a Deref chain for an applicable type for the variable self, from which we additionally chase down a Receiver chain for an applicable Self type from a list of methods that accepts one of these possible types of self.

To facilitate discussion, we can use the Zulip thread #t-lang > Consequences of making Deref a subtrait of Receiver.

Pending items

  • First, gather feedback on the proposed change and assess the impact on the overall feature.
  • Stomp out UI test changes due to lost diagnostics, by enabling search through Receiver side-chains, so that we can suggest enabling arbitrary_self_types gate again.

@rustbot
Copy link
Collaborator

rustbot commented Sep 1, 2025

r? @jackh726

rustbot has assigned @jackh726.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@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. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Sep 1, 2025
@rustbot
Copy link
Collaborator

rustbot commented Sep 1, 2025

This PR changes a file inside tests/crashes. If a crash was fixed, please move into the corresponding ui subdir and add 'Fixes #' to the PR description to autoclose the issue upon merge.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@dingxiangfei2009
Copy link
Contributor Author

@rustbot label +F-arbitrary_self_types

@rustbot rustbot added the F-arbitrary_self_types `#![feature(arbitrary_self_types)]` label Sep 2, 2025
Receiver chain has been an extension of Deref chain,
but the consequence has been questioned as this would admit method
signatures that are deemed dubious.

It is also debatable that Receiver trait which determines applicable
`Self` type should have anything to do with dereference operation
in general.

This patch separate the two traits and isolate their use in the language.
This means that in method probing, we will chase down a Deref chain for
an applicable type for the variable `self`, from which we additionally
chase down a Receiver chain for an applicable `Self` type from a list of
methods that accepts one of these possible types of `self`.
@rustbot
Copy link
Collaborator

rustbot commented Sep 2, 2025

The Miri subtree was changed

cc @rust-lang/miri

Some changes occurred in compiler/rustc_codegen_gcc

cc @antoyo, @GuillaumeGomez

@rustbot
Copy link
Collaborator

rustbot commented Sep 2, 2025

This PR was rebased onto a different master 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.

@rust-log-analyzer
Copy link
Collaborator

The job aarch64-gnu-llvm-19-2 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
[RUSTC-TIMING] ____ test:false 0.023
##[endgroup]
##[group][AOT] arbitrary_self_types_pointers_and_wrappers
[AOT] arbitrary_self_types_pointers_and_wrappers
error[E0307]: invalid `self` parameter type: `Ptr<Wrapper<i32>>`
##[error]  --> example/arbitrary_self_types_pointers_and_wrappers.rs:41:26
   |
41 |     fn ptr_wrapper(self: Ptr<Wrapper<Self>>) -> i32 {
   |                          ^^^^^^^^^^^^^^^^^^
   |
   = note: type of `self` must be `Self` or some type implementing `Receiver`
   = help: consider changing to `self`, `&self`, `&mut self`, or a type implementing `Receiver` such as `self: Box<Self>`, `self: Rc<Self>`, or `self: Arc<Self>`

error[E0307]: invalid `self` parameter type: `Wrapper<Ptr<i32>>`
##[error]  --> example/arbitrary_self_types_pointers_and_wrappers.rs:44:26
   |
44 |     fn wrapper_ptr(self: Wrapper<Ptr<Self>>) -> i32 {
   |                          ^^^^^^^^^^^^^^^^^^
   |
   = note: type of `self` must be `Self` or some type implementing `Receiver`
   = help: consider changing to `self`, `&self`, `&mut self`, or a type implementing `Receiver` such as `self: Box<Self>`, `self: Rc<Self>`, or `self: Arc<Self>`

error[E0307]: invalid `self` parameter type: `Wrapper<Ptr<Wrapper<i32>>>`
##[error]  --> example/arbitrary_self_types_pointers_and_wrappers.rs:47:34
   |
47 |     fn wrapper_ptr_wrapper(self: Wrapper<Ptr<Wrapper<Self>>>) -> i32 {
   |                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: type of `self` must be `Self` or some type implementing `Receiver`
   = help: consider changing to `self`, `&self`, `&mut self`, or a type implementing `Receiver` such as `self: Box<Self>`, `self: Rc<Self>`, or `self: Arc<Self>`

error[E0307]: invalid `self` parameter type: `Ptr<Wrapper<Self>>`
##[error]  --> example/arbitrary_self_types_pointers_and_wrappers.rs:35:26
   |
35 |     fn ptr_wrapper(self: Ptr<Wrapper<Self>>) -> i32;
   |                          ^^^^^^^^^^^^^^^^^^
   |
   = note: type of `self` must be `Self` or some type implementing `Receiver`
   = help: consider changing to `self`, `&self`, `&mut self`, or a type implementing `Receiver` such as `self: Box<Self>`, `self: Rc<Self>`, or `self: Arc<Self>`

error[E0307]: invalid `self` parameter type: `Wrapper<Ptr<Self>>`
##[error]  --> example/arbitrary_self_types_pointers_and_wrappers.rs:36:26
   |
36 |     fn wrapper_ptr(self: Wrapper<Ptr<Self>>) -> i32;
   |                          ^^^^^^^^^^^^^^^^^^
   |
   = note: type of `self` must be `Self` or some type implementing `Receiver`
   = help: consider changing to `self`, `&self`, `&mut self`, or a type implementing `Receiver` such as `self: Box<Self>`, `self: Rc<Self>`, or `self: Arc<Self>`

error[E0307]: invalid `self` parameter type: `Wrapper<Ptr<Wrapper<Self>>>`
##[error]  --> example/arbitrary_self_types_pointers_and_wrappers.rs:37:34
   |
37 |     fn wrapper_ptr_wrapper(self: Wrapper<Ptr<Wrapper<Self>>>) -> i32;
   |                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: type of `self` must be `Self` or some type implementing `Receiver`
   = help: consider changing to `self`, `&self`, `&mut self`, or a type implementing `Receiver` such as `self: Box<Self>`, `self: Rc<Self>`, or `self: Arc<Self>`

error: aborting due to 6 previous errors

For more information about this error, try `rustc --explain E0307`.
"/checkout/obj/build/aarch64-unknown-linux-gnu/stage2-codegen/cg_clif/dist/rustc-clif" "-Csymbol-mangling-version=v0" "-Zrandomize-layout" "-Zunstable-options" "--check-cfg=cfg(bootstrap)" "--check-cfg=cfg(llvm_enzyme)" "-Zmacro-backtrace" "-Csplit-debuginfo=off" "-Clink-arg=-L/usr/lib/llvm-19/lib" "-Cllvm-args=-import-instr-limit=10" "-Clink-args=-Wl,-z,origin" "-Clink-args=-Wl,-rpath,$ORIGIN/../lib" "-Alinker-messages" "-L" "crate=/checkout/obj/build/aarch64-unknown-linux-gnu/stage2-codegen/cg_clif/build/example" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2-codegen/cg_clif/build/example" "-Cdebuginfo=2" "--target" "aarch64-unknown-linux-gnu" "-Cpanic=abort" "--check-cfg=cfg(jit)" "example/arbitrary_self_types_pointers_and_wrappers.rs" exited with status ExitStatus(unix_wait_status(256))
Command `/checkout/obj/build/aarch64-unknown-linux-gnu/stage0/bin/cargo run --target aarch64-unknown-linux-gnu -Zbinary-dep-depinfo -j 4 -Zroot-dir=/checkout --locked --color always --release --manifest-path /checkout/compiler/rustc_codegen_cranelift/build_system/Cargo.toml -- test --download-dir /checkout/obj/build/cg_clif_download --out-dir /checkout/obj/build/aarch64-unknown-linux-gnu/stage2-codegen/cg_clif --no-unstable-features --use-backend cranelift --sysroot llvm --skip-test testsuite.extended_sysroot [workdir=/checkout/compiler/rustc_codegen_cranelift]` failed with exit code 1
Created at: src/bootstrap/src/core/build_steps/test.rs:3645:25
Executed at: src/bootstrap/src/core/build_steps/test.rs:3686:26

Command has failed. Rerun with -v to see more details.
Bootstrap failed while executing `--stage 2 test --skip tests --skip coverage-map --skip coverage-run --skip library --skip tidyselftest`
Build completed unsuccessfully in 0:25:15
  local time: Tue Sep  2 09:16:17 UTC 2025
  network time: Tue, 02 Sep 2025 09:16:17 GMT
##[error]Process completed with exit code 1.

@jackh726
Copy link
Member

jackh726 commented Sep 3, 2025

Is this waiting on discussion and a decision from the lang team?

@dingxiangfei2009
Copy link
Contributor Author

@jackh726 Sorry I was not very clear. Indeed it would need a lang team discussion.

To support the discussion, I am writing a report to describe what changes this would bring to the feature.

cc @traviscross @tmandry

@traviscross traviscross added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. S-waiting-on-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). I-lang-radar Items that are on lang's radar and will need eventual work or consideration. T-lang Relevant to the language team and removed T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Sep 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-arbitrary_self_types `#![feature(arbitrary_self_types)]` I-lang-radar Items that are on lang's radar and will need eventual work or consideration. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. S-waiting-on-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants