Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

arbitrary_self_types: Split the Autoderef chain #146095

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
dingxiangfei2009 wants to merge 1 commit into rust-lang:master
base: master
Choose a base branch
Loading
from dingxiangfei2009:autoderef-split

Conversation

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.

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
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.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

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

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.

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: 2025年9月02日 09:16:17 GMT
##[error]Process completed with exit code 1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers
No reviews
Labels
F-arbitrary_self_types `#![feature(arbitrary_self_types)]` 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.
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /