Skip to content

Move trait prototype - #161457

Draft
zannabianca1997 wants to merge 10 commits into
rust-lang:mainfrom
zannabianca1997:move-trait
Draft

zannabianca1997 wants to merge 10 commits into
rust-lang:mainfrom
zannabianca1997:move-trait

Conversation

@zannabianca1997

@zannabianca1997 zannabianca1997 commented Aug 21, 2026 •

Copy link
Copy Markdown

View all comments

Finishing the work started by @nia-e in #156018 :

Add a barebones implementation for Move (#149607), pending some diagnostics changes & tests.

TODO

r? jdonszelmann

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Aug 21, 2026
@rustbot

rustbot commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the pull request, and welcome! The Rust Project has assigned @lcnr (or someone else) to review your changes, you should hear from them (or someone else) within the next two weeks.

Please see the contribution instructions for more information.

@rust-log-analyzer

This comment has been minimized.

@lcnr lcnr mentioned this pull request Aug 21, 2026
2 of 3 tasks
@lcnr lcnr changed the title Move trait prototype Move trait prototype Aug 21, 2026
@zannabianca1997

Copy link
Copy Markdown
Author

A quick ./x.py test tests/ui locally to have a baseline

test result: FAILED. 9 passed; 206 failed; 21862 ignored; 0 measured; 0 filtered out; finished in 1.14s

@zannabianca1997

Copy link
Copy Markdown
Author
test result: FAILED. 21801 passed; 32 failed; 244 ignored; 0 measured; 0 filtered out; finished in 168.70s

wow that were a lot of them. looks like the next batch is a bunch of fn that now has fn() + Move

@rust-log-analyzer

This comment has been minimized.

@zannabianca1997

Copy link
Copy Markdown
Author

looking at the errors, there is also a bunch of (dyn + 'static) printing.

Those are all checks going around the trait_alias feature, that created before empty trait object and now creates what are effectively dyn Move, that are being misprinted.

That sure raises a question - can we handle them now? ummm - putting this aside in favour of lower hanging fruits

@zannabianca1997

Copy link
Copy Markdown
Author

@lcnr this last one (520bc2f)

it's better to break the ABI and accept all aymbol mangling containing Move or we have to decide a way to mangle ?Move? I know rust has no stable abi but to put it in all symbols seems a bit too much

@rust-log-analyzer

This comment has been minimized.

@rust-bors

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

.collect()
} else {
clauses.into_iter().collect()
};

@lcnr lcnr Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that one is unfortunately somewhat problematic. gather_explicit_clauses_of is used by a query whose result we write to crate metadata, so this would erase the Move bound from upstream crates which don't have the feature enabled.

Why is this needed

View changes since the review

@zannabianca1997 zannabianca1997 Aug 28, 2026 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of the changes that I made this is the one i was less sure of

I was trying to fix this test

The original test expected

error[E0091]: type parameter `N` is never used
  --> $DIR/unused-type-param-suggestion.rs:25:8
   |
LL | type D<N: ?Sized> = ();
   |        ^ unused type parameter
   |
   = help: consider removing `N` or referring to it in the body of the type alias

and after the change with Move it appeared a new help message = help: if you intended Nto be a const parameter, useconst N: /* Type */ instead

now, the help should not appear as there is a bound - so i checked from where it came, and got to read the check_type_alias_type_params_are_used that uses some sort of euristic to split huser written bounds and the sized hierarchy (?)

I honestly lost the plot there, but noticed that it was calling the _explicit_ version. And I saw the doc comment of gather_explicit_clauses_of noting that implied and inferred constraints should not appear there, and Move is indeed implicit in that case, so I just aligned it

@fmease fmease Aug 30, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And I saw the doc comment of gather_explicit_clauses_of noting that implied and inferred constraints should not appear there, and Move is indeed implicit in that case, so I just aligned it

Default bounds (or what this PR now also calls "implicit bounds") are excluded from that. Without knowing all the places where we'll perform Move elaboration I would probably revert that.

The comment on gather_explicit_clauses_of doesn't consider these bounds to be potential implied bounds (in the sense of implied supertrait bounds, implicit outlives-bounds, etc.). You can see that gather_explicit_clauses_of does elaborate sizedness & other default bounds.

That's because default bounds plus relaxed bounds are just considered syntax sugar / an early syntactic transformation.

@fmease fmease Aug 30, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now, the help should not appear as there is a bound - so i checked from where it came, and got to read the check_type_alias_type_params_are_used that uses some sort of euristic to split huser written bounds and the sized hierarchy (?)

Regarding the heuristic, it utilizes the fact that implicitly added Sized (etc.) bounds have the same span as the type parameter they annotate (in order to identify which bounds to "count").

So for (pseudo) <T>, the span of the implicit T: Sized is identical to the span of type parameter T. The span that's used comes from explicit_clauses_of / gather_explicit_clauses_of.

I would check what the span we use for implicit T: Move bounds (T type param). If it indeed shares the span with the type param, then there must be something else going on.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okkkkkkkk

managed to find the correct solution!

it was a fixme that needed handling at the time (cause spans for different lines were not able to be merged

so yeah. now it works with c372a25

@rust-bors

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-bors

This comment has been minimized.

@zannabianca1997
zannabianca1997 force-pushed the move-trait branch 2 times, most recently from 0acfa71 to c51c5c0 Compare September 2, 2026 18:04
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Nov 6, 2026
…adwinwhite

Fallible type ops

This PR adds a new `TypeOp` which is expected to properly report fulfillment errors rather than assert all obligations holds.

This is a single commit extracted from rust-lang#156018 and rust-lang#161457. It adds a currently *unused* api to mir typeck, that's required to implement the move trait, but is on its own also useful for other changes like resolving all cases of rust-lang#132279

By extracting it, we can lower the review burden on the other PRs

cc: @zannabianca1997
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Nov 6, 2026
…adwinwhite

Fallible type ops

This PR adds a new `TypeOp` which is expected to properly report fulfillment errors rather than assert all obligations holds.

This is a single commit extracted from rust-lang#156018 and rust-lang#161457. It adds a currently *unused* api to mir typeck, that's required to implement the move trait, but is on its own also useful for other changes like resolving all cases of rust-lang#132279

By extracting it, we can lower the review burden on the other PRs

cc: @zannabianca1997
@rust-log-analyzer

This comment has been minimized.

@rustbot

rustbot commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator

jdonszelmann is currently at their maximum review capacity.
They may take a while to respond.

Zalathar added a commit to Zalathar/rust that referenced this pull request Nov 7, 2026
…adwinwhite

Fallible type ops

This PR adds a new `TypeOp` which is expected to properly report fulfillment errors rather than assert all obligations holds.

This is a single commit extracted from rust-lang#156018 and rust-lang#161457. It adds a currently *unused* api to mir typeck, that's required to implement the move trait, but is on its own also useful for other changes like resolving all cases of rust-lang#132279

By extracting it, we can lower the review burden on the other PRs

cc: @zannabianca1997
rust-bors Bot pushed a commit that referenced this pull request Nov 7, 2026
Rollup merge of #165335 - jdonszelmann:fallible-type-ops, r=adwinwhite

Fallible type ops

This PR adds a new `TypeOp` which is expected to properly report fulfillment errors rather than assert all obligations holds.

This is a single commit extracted from #156018 and #161457. It adds a currently *unused* api to mir typeck, that's required to implement the move trait, but is on its own also useful for other changes like resolving all cases of #132279

By extracting it, we can lower the review burden on the other PRs

cc: @zannabianca1997
@rust-bors

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

Added the move trait itself

Added default impl to every type, unconditionally
Oh wow that got done with A LOT of tests
mostly to avoid adding to every single dynamic symbol the `+ Move`
@zannabianca1997
zannabianca1997 force-pushed the move-trait branch 2 times, most recently from ac5e23a to 41c6ddf Compare November 7, 2026 17:15
@rust-log-analyzer

This comment has been minimized.

When `move_trait` is not enabled, all types are trivially `Move`.

This is a band-aid, as the main problem will need to be addressed as
some point before stabilization

Took the chance to clean up the IncludingSized, as i had to add a twin
for move. Semantically it was used more to exclude stuff, so i gave it a
proper name. I think this is more readable
Aligned tests to the new code (mostly debug printout and/or line numbers)
found out we are losing ?Move along the road, we will need to fix that i
guess

hope i did not mess up rustdoc json
@zannabianca1997

Copy link
Copy Markdown
Author

Tests done - with the only exception of a single one regarding the reflection api (#146922, in particular #151239) that's broken by everything now having a + Move

@jdonszelmann i put a patch for diesel - plainly stripping Move from the bounds when the feature is not in. Locally perf is good (~1%) but I would run it again

@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

The job test-x86_64-gnu-gcc-core-tests failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
---- mem::type_info::test_dynamic_traits stdout ----
---- mem::type_info::test_dynamic_traits stderr ----

thread 'main' (19263) panicked at library/coretests/tests/mem/type_info.rs:360:9:
assertion `left == right` failed: unexpected ids.
actual: [TypeId(0x803862e84c23c9c0186b8480665917c0), TypeId(0x7295e9096c1a47b3ef4a2911cfb1c694)]
expected: [TypeId(0x0be30bda9f7763c8fd87c962437454e0)]
  left: {TypeId(0x803862e84c23c9c0186b8480665917c0), TypeId(0x7295e9096c1a47b3ef4a2911cfb1c694)}
 right: {TypeId(0x0be30bda9f7763c8fd87c962437454e0)}
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
---- mem::type_info::test_dynamic_traits stdout end ----

failures:
    mem::type_info::test_dynamic_traits

Important

For more information how to resolve CI failures of this job, visit this link.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) perf-regression Performance regression. PG-exploit-mitigations Project group: Exploit mitigations S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) 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. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants