Skip to content

[do not merge] Add a Move marker trait #144679

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
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

yoshuawuyts
Copy link
Member

This PR implements the Move marker trait for the purposes of testing potential performance regressions in combination with #120706. For context about this experiment see this Zulip thread.

r? @lcnr

impl Move for more types
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jul 30, 2025
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@lcnr
Copy link
Contributor

lcnr commented Jul 30, 2025

@bors2 try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@rust-bors
Copy link

rust-bors bot commented Jul 30, 2025

⌛ Trying commit 7dfabd6 with merge ce349ac

To cancel the try build, run the command @bors try cancel.

rust-bors bot added a commit that referenced this pull request Jul 30, 2025
[do not merge] Add a `Move` marker trait
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jul 30, 2025
@rust-log-analyzer

This comment has been minimized.

@yoshuawuyts
Copy link
Member Author

warning: the ICE couldn't be written to /checkout/rustc-ice-2025-07-30T12_37_40-12840.txt: Read-only file system (os error 30)

Ohh, I think we've hit an ICE here?

@fmease
Copy link
Member

fmease commented Jul 30, 2025

warning: the ICE couldn't be written to /checkout/rustc-ice-2025-07-30T12_37_40-12840.txt: Read-only file system (os error 30)

Ohh, I think we've hit an ICE here?

Ye, more specifically: https://triage.rust-lang.org/gha-logs/rust-lang/rust/47029834962#2025-07-30T12:37:47.0296013Z (arg requirement already exists, that's just a failed assertion in the diagnostic infra). The more pressing issue is the fact that core doesn't compile under these changes. See all the compiler errors in the (plain enhanced) log.

@yoshuawuyts
Copy link
Member Author

Talked with @lcnr on the Zulip thread, and they recommended adding #[rustc_unsafe_specialization_marker] to the trait definition to work around this. I've pushed that up in the latest commit.

@rust-bors
Copy link

rust-bors bot commented Jul 30, 2025

💔 Test failed (CI). Failed jobs:

@rust-log-analyzer

This comment has been minimized.

@lqd
Copy link
Member

lqd commented Jul 30, 2025

@yoshuawuyts can this PR build core now? If so I'll send to the perfbot, but from the CI results I'm not sure it does.

@yoshuawuyts
Copy link
Member Author

That would be: ./x.py build --stage 1 library/core right? Currently trying that locally to confirm whether that builds.

@yoshuawuyts
Copy link
Member Author

Oh, that was quick. No, it doesn't compile. It fails with the same error we're seeing in CI:

Compiling core v0.0.0 (/Users/yosh/Code/rust/library/core)
error[E0038]: the trait `error::Error` is not dyn compatible
    --> library/core/src/error.rs:219:6
     |
 219 | impl dyn Error + 'static {
     |      ^^^^^^^^^^^^^^^^^^^ `error::Error` is not dyn compatible
     |
note: for a trait to be dyn compatible it needs to allow building a vtable
      for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
    --> library/core/src/error.rs:105:15

@yoshuawuyts
Copy link
Member Author

cc/ @Bryanskiy as the author of #120706, this might be interesting to you too

@Bryanskiy
Copy link
Contributor

Here is a predicate that the compiler tries to prove:

Receiver[Self => T]: DispatchFromDyn<Receiver[Self => dyn Trait]> (See receiver_is_dispatchable doc comment)

The documentation also says:

In practice, we cannot use dyn Trait explicitly in the obligation because it would result in a new check that Trait is dyn-compatible, creating a cycle. Instead, we emulate a placeholder by introducing a new type parameter U such that Self: Unsize<U> and U: Trait + ?Sized, and use U in place of dyn Trait.

The situation is that there is an implicit T: Move bound in DispatchFromDyn<T>. But U is not Move. So, the compiler fails to prove the predicate.

To fix it you have to add ?Move in DispatchFromDyn:

#[lang = "dispatch_from_dyn"]
pub trait DispatchFromDyn<T: ?Move> {}

@rust-log-analyzer

This comment has been minimized.

@Bryanskiy
Copy link
Contributor

Bryanskiy commented Jul 30, 2025

Ouch, we also need

#[lang = "unsize"]
pub trait Unsize<T: ?Sized + ?Move> {
    // Empty.
}

And maybe something else. I need to take a closer look.

@yoshuawuyts
Copy link
Member Author

I've relaxed the bounds on Unsized, but I think you're right and it's not quite enough yet.

@rust-log-analyzer

This comment has been minimized.

@Bryanskiy
Copy link
Contributor

The next step is to fix DispatchFromDyn implementations. For example in core/src/ops/unsize.rs there is a following impl:

impl<'a, T: PointeeSized + Unsize<U>, U: PointeeSized> DispatchFromDyn<&'a U> for &'a T {}

We also have implicit T: Move and U: Move here.

Imagine we have a trait Trait with a method fn foo(&self) and a trait object t with a type &dyn Trait. When calling t.foo() a predicate like &Self: DispatchFromDyn<&U> is generated as a dyn-compatibility check. But Self and U are not Move here. Thus, the implementation will not be selected.

To solve the problem, Move bounds need to be relaxed in impl:

impl<'a, T: PointeeSized + Unsize<U> + ?Move, U: PointeeSized + ?Move> DispatchFromDyn<&'a U> for &'a T {}

Same for other impls.

@rust-log-analyzer

This comment has been minimized.

@yoshuawuyts
Copy link
Member Author

@Bryanskiy thank you so much! I think we're getting closer. I started by adding the bounds you pointed out, and kept adding them to types until the dyn diagnostic errors stopped. Unfortunately this patch is still causing an ICE locally, and I'm not sure what to do about that.

I've pushed the patch up, and expect CI to fail with the same error. But just in case, here are my local logs.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@yoshuawuyts
Copy link
Member Author

yoshuawuyts commented Aug 1, 2025

I believe we are hitting this check, which was added very recently:

debug_assert!(
!self.args.contains_key(&name) || self.args.get(&name) == Some(&value),
"arg {} already exists",
name
);

My suspicion is that this is picking up an existing issue in the implementation - which we weren't aware of because we've not been actively exercising the impl.

If I disable the check, we get a lot further with compilation. But eventually it bottoms out with this error: logs. I'm not sure whether this is me doing something wrong, or that disabling the check was actually really bad. I suspect a bit of both - but figured I'd include it either way.

@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)
   9:     0xffd0e348caa4 - std::panicking::default_hook::{{closure}}::haac60c33ad8953eb
                               at /rustc/390a0ab5dc4a895235a551e502c3893c3337731d/library/std/src/panicking.rs:300:27
  10:     0xffd0e348c900 - std::panicking::default_hook::hfbe61bc0eb59097c
                               at /rustc/390a0ab5dc4a895235a551e502c3893c3337731d/library/std/src/panicking.rs:327:9
  11:     0xffd0df961c14 - <alloc[cf75e2ab30ac120f]::boxed::Box<rustc_driver_impl[cc47a5906325ebb2]::install_ice_hook::{closure#1}> as core[86de0986de23a55d]::ops::function::Fn<(&dyn for<'a, 'b> core[86de0986de23a55d]::ops::function::Fn<(&'a std[57c45f57ec3c24e5]::panic::PanicHookInfo<'b>,), Output = ()> + core[86de0986de23a55d]::marker::Sync + core[86de0986de23a55d]::marker::Send, &std[57c45f57ec3c24e5]::panic::PanicHookInfo)>>::call
  12:     0xffd0e348d518 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h1caa90323394741e
                               at /rustc/390a0ab5dc4a895235a551e502c3893c3337731d/library/alloc/src/boxed.rs:1980:9
  13:     0xffd0e348d518 - std::panicking::rust_panic_with_hook::h448ca412e27acd2b
                               at /rustc/390a0ab5dc4a895235a551e502c3893c3337731d/library/std/src/panicking.rs:841:13
  14:     0xffd0e348d218 - std::panicking::begin_panic_handler::{{closure}}::he6c71f258db522c4
                               at /rustc/390a0ab5dc4a895235a551e502c3893c3337731d/library/std/src/panicking.rs:706:13
  15:     0xffd0e34896bc - std::sys::backtrace::__rust_end_short_backtrace::hf8d7a4365255b145
                               at /rustc/390a0ab5dc4a895235a551e502c3893c3337731d/library/std/src/sys/backtrace.rs:168:18
  16:     0xffd0e348cefc - __rustc[b7e3ce0d707010f2]::rust_begin_unwind
                               at /rustc/390a0ab5dc4a895235a551e502c3893c3337731d/library/std/src/panicking.rs:697:5
  17:     0xffd0df8946c4 - core::panicking::panic_fmt::h3247d961c5317d14
                               at /rustc/390a0ab5dc4a895235a551e502c3893c3337731d/library/core/src/panicking.rs:75:14
  18:     0xffd0e23b3d14 - <rustc_errors[40ac4bb37ab4292b]::diagnostic::Diag>::arg::<&str, rustc_trait_selection[98c3503d004748e6]::error_reporting::infer::ObligationCauseAsDiagArg>
  19:     0xffd0e23d247c - <rustc_trait_selection[98c3503d004748e6]::errors::RegionOriginNote as rustc_errors[40ac4bb37ab4292b]::diagnostic::Subdiagnostic>::add_to_diag::<rustc_span[be48632450ff045c]::ErrorGuaranteed>
  20:     0xffd0e211ce28 - <rustc_trait_selection[98c3503d004748e6]::error_reporting::TypeErrCtxt>::note_region_origin
  21:     0xffd0e211c080 - <rustc_trait_selection[98c3503d004748e6]::error_reporting::TypeErrCtxt>::report_region_errors
  22:     0xffd0e04a52e0 - rustc_hir_analysis[df1f9e53eda667ea]::check::compare_impl_item::compare_method_predicate_entailment
  23:     0xffd0e048a8a0 - rustc_hir_analysis[df1f9e53eda667ea]::check::compare_impl_item::compare_impl_item
  24:     0xffd0e1cee7e4 - rustc_query_impl[60cc3d82a4c6cd94]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[60cc3d82a4c6cd94]::query_impl::compare_impl_item::dynamic_query::{closure#2}::{closure#0}, rustc_middle[e262adc660cefa6f]::query::erase::Erased<[u8; 1usize]>>
  25:     0xffd0e1c140a0 - <rustc_query_impl[60cc3d82a4c6cd94]::query_impl::compare_impl_item::dynamic_query::{closure#2} as core[86de0986de23a55d]::ops::function::FnOnce<(rustc_middle[e262adc660cefa6f]::ty::context::TyCtxt, rustc_span[be48632450ff045c]::def_id::LocalDefId)>>::call_once
  26:     0xffd0e1c8faf0 - <std[57c45f57ec3c24e5]::thread::local::LocalKey<core[86de0986de23a55d]::cell::Cell<*const ()>>>::with::<rustc_middle[e262adc660cefa6f]::ty::context::tls::enter_context<rustc_query_system[76c1cd8a412acef1]::query::plumbing::try_load_from_disk_and_cache_in_memory<rustc_query_impl[60cc3d82a4c6cd94]::DynamicConfig<rustc_data_structures[f778079ad5acf8de]::vec_cache::VecCache<rustc_span[be48632450ff045c]::def_id::CrateNum, rustc_middle[e262adc660cefa6f]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[76c1cd8a412acef1]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[60cc3d82a4c6cd94]::plumbing::QueryCtxt>::{closure#0}, rustc_middle[e262adc660cefa6f]::query::erase::Erased<[u8; 1usize]>>::{closure#0}, rustc_middle[e262adc660cefa6f]::query::erase::Erased<[u8; 1usize]>>
  27:     0xffd0e1bb159c - rustc_query_system[76c1cd8a412acef1]::query::plumbing::try_execute_query::<rustc_query_impl[60cc3d82a4c6cd94]::DynamicConfig<rustc_data_structures[f778079ad5acf8de]::vec_cache::VecCache<rustc_span[be48632450ff045c]::def_id::LocalDefId, rustc_middle[e262adc660cefa6f]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[76c1cd8a412acef1]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[60cc3d82a4c6cd94]::plumbing::QueryCtxt, false>
  28:     0xffd0e1e7fad0 - rustc_query_impl[60cc3d82a4c6cd94]::query_impl::compare_impl_item::get_query_non_incr::__rust_end_short_backtrace
  29:     0xffd0e0457be4 - rustc_hir_analysis[df1f9e53eda667ea]::check::check::check_impl_items_against_trait
  30:     0xffd0e0452cf4 - rustc_hir_analysis[df1f9e53eda667ea]::check::check::check_item_type
  31:     0xffd0e06882d0 - rustc_hir_analysis[df1f9e53eda667ea]::check::wfcheck::check_well_formed
  32:     0xffd0e1cee64c - rustc_query_impl[60cc3d82a4c6cd94]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[60cc3d82a4c6cd94]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[e262adc660cefa6f]::query::erase::Erased<[u8; 1usize]>>
  33:     0xffd0e1c13d48 - <rustc_query_impl[60cc3d82a4c6cd94]::query_impl::check_well_formed::dynamic_query::{closure#2} as core[86de0986de23a55d]::ops::function::FnOnce<(rustc_middle[e262adc660cefa6f]::ty::context::TyCtxt, rustc_span[be48632450ff045c]::def_id::LocalDefId)>>::call_once
  34:     0xffd0e1c8faf0 - <std[57c45f57ec3c24e5]::thread::local::LocalKey<core[86de0986de23a55d]::cell::Cell<*const ()>>>::with::<rustc_middle[e262adc660cefa6f]::ty::context::tls::enter_context<rustc_query_system[76c1cd8a412acef1]::query::plumbing::try_load_from_disk_and_cache_in_memory<rustc_query_impl[60cc3d82a4c6cd94]::DynamicConfig<rustc_data_structures[f778079ad5acf8de]::vec_cache::VecCache<rustc_span[be48632450ff045c]::def_id::CrateNum, rustc_middle[e262adc660cefa6f]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[76c1cd8a412acef1]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[60cc3d82a4c6cd94]::plumbing::QueryCtxt>::{closure#0}, rustc_middle[e262adc660cefa6f]::query::erase::Erased<[u8; 1usize]>>::{closure#0}, rustc_middle[e262adc660cefa6f]::query::erase::Erased<[u8; 1usize]>>
  35:     0xffd0e1bb159c - rustc_query_system[76c1cd8a412acef1]::query::plumbing::try_execute_query::<rustc_query_impl[60cc3d82a4c6cd94]::DynamicConfig<rustc_data_structures[f778079ad5acf8de]::vec_cache::VecCache<rustc_span[be48632450ff045c]::def_id::LocalDefId, rustc_middle[e262adc660cefa6f]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[76c1cd8a412acef1]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[60cc3d82a4c6cd94]::plumbing::QueryCtxt, false>
  36:     0xffd0e1e6b8d4 - rustc_query_impl[60cc3d82a4c6cd94]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
  37:     0xffd0e0570d9c - rustc_middle[e262adc660cefa6f]::query::plumbing::query_ensure_error_guaranteed::<rustc_data_structures[f778079ad5acf8de]::vec_cache::VecCache<rustc_span[be48632450ff045c]::def_id::LocalDefId, rustc_middle[e262adc660cefa6f]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[76c1cd8a412acef1]::dep_graph::graph::DepNodeIndex>, ()>
  38:     0xffd0e0571dec - rustc_data_structures[f778079ad5acf8de]::sync::parallel::try_par_for_each_in::<&[rustc_hir[73af37212a31ebc0]::hir::ItemId], rustc_span[be48632450ff045c]::ErrorGuaranteed, <rustc_middle[e262adc660cefa6f]::hir::ModuleItems>::par_items<rustc_hir_analysis[df1f9e53eda667ea]::check::wfcheck::check_type_wf::{closure#0}>::{closure#0}>
  39:     0xffd0e0692938 - rustc_hir_analysis[df1f9e53eda667ea]::check::wfcheck::check_type_wf
  40:     0xffd0e1ce6e20 - rustc_query_impl[60cc3d82a4c6cd94]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[60cc3d82a4c6cd94]::query_impl::check_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[e262adc660cefa6f]::query::erase::Erased<[u8; 1usize]>>
  41:     0xffd0e1c009c0 - <rustc_query_impl[60cc3d82a4c6cd94]::query_impl::check_type_wf::dynamic_query::{closure#2} as core[86de0986de23a55d]::ops::function::FnOnce<(rustc_middle[e262adc660cefa6f]::ty::context::TyCtxt, ())>>::call_once
  42:     0xffd0e1c8e17c - <std[57c45f57ec3c24e5]::thread::local::LocalKey<core[86de0986de23a55d]::cell::Cell<*const ()>>>::with::<rustc_middle[e262adc660cefa6f]::ty::context::tls::enter_context<rustc_query_system[76c1cd8a412acef1]::query::plumbing::execute_job_non_incr<rustc_query_impl[60cc3d82a4c6cd94]::DynamicConfig<rustc_query_system[76c1cd8a412acef1]::query::caches::SingleCache<rustc_middle[e262adc660cefa6f]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[60cc3d82a4c6cd94]::plumbing::QueryCtxt>::{closure#0}, rustc_middle[e262adc660cefa6f]::query::erase::Erased<[u8; 1usize]>>::{closure#0}, rustc_middle[e262adc660cefa6f]::query::erase::Erased<[u8; 1usize]>>
  43:     0xffd0e1b53848 - rustc_query_system[76c1cd8a412acef1]::query::plumbing::try_execute_query::<rustc_query_impl[60cc3d82a4c6cd94]::DynamicConfig<rustc_query_system[76c1cd8a412acef1]::query::caches::SingleCache<rustc_middle[e262adc660cefa6f]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[60cc3d82a4c6cd94]::plumbing::QueryCtxt, false>
  44:     0xffd0e1e57a48 - rustc_query_impl[60cc3d82a4c6cd94]::query_impl::check_type_wf::get_query_non_incr::__rust_end_short_backtrace
  45:     0xffd0e066ea84 - <rustc_session[80b2062dd743f4d9]::session::Session>::time::<(), rustc_hir_analysis[df1f9e53eda667ea]::check_crate::{closure#0}>
  46:     0xffd0e05cb60c - rustc_hir_analysis[df1f9e53eda667ea]::check_crate
  47:     0xffd0dfb72b1c - rustc_interface[f996e06f5162e4d]::passes::analysis
  48:     0xffd0e1d04028 - rustc_query_impl[60cc3d82a4c6cd94]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[60cc3d82a4c6cd94]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[e262adc660cefa6f]::query::erase::Erased<[u8; 0usize]>>
  49:     0xffd0e1c49210 - <rustc_query_impl[60cc3d82a4c6cd94]::query_impl::analysis::dynamic_query::{closure#2} as core[86de0986de23a55d]::ops::function::FnOnce<(rustc_middle[e262adc660cefa6f]::ty::context::TyCtxt, ())>>::call_once
  50:     0xffd0e1c8e080 - <std[57c45f57ec3c24e5]::thread::local::LocalKey<core[86de0986de23a55d]::cell::Cell<*const ()>>>::with::<rustc_middle[e262adc660cefa6f]::ty::context::tls::enter_context<rustc_query_system[76c1cd8a412acef1]::query::plumbing::execute_job_non_incr<rustc_query_impl[60cc3d82a4c6cd94]::DynamicConfig<rustc_query_system[76c1cd8a412acef1]::query::caches::SingleCache<rustc_middle[e262adc660cefa6f]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[60cc3d82a4c6cd94]::plumbing::QueryCtxt>::{closure#0}, rustc_middle[e262adc660cefa6f]::query::erase::Erased<[u8; 0usize]>>::{closure#0}, rustc_middle[e262adc660cefa6f]::query::erase::Erased<[u8; 0usize]>>
  51:     0xffd0e1b51130 - rustc_query_system[76c1cd8a412acef1]::query::plumbing::try_execute_query::<rustc_query_impl[60cc3d82a4c6cd94]::DynamicConfig<rustc_query_system[76c1cd8a412acef1]::query::caches::SingleCache<rustc_middle[e262adc660cefa6f]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[60cc3d82a4c6cd94]::plumbing::QueryCtxt, false>
  52:     0xffd0e1e43ac8 - rustc_query_impl[60cc3d82a4c6cd94]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  53:     0xffd0df9325b4 - <std[57c45f57ec3c24e5]::thread::local::LocalKey<core[86de0986de23a55d]::cell::Cell<*const ()>>>::with::<rustc_middle[e262adc660cefa6f]::ty::context::tls::enter_context<<rustc_middle[e262adc660cefa6f]::ty::context::GlobalCtxt>::enter<rustc_interface[f996e06f5162e4d]::passes::create_and_enter_global_ctxt<core[86de0986de23a55d]::option::Option<rustc_interface[f996e06f5162e4d]::queries::Linker>, rustc_driver_impl[cc47a5906325ebb2]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}, core[86de0986de23a55d]::option::Option<rustc_interface[f996e06f5162e4d]::queries::Linker>>::{closure#1}, core[86de0986de23a55d]::option::Option<rustc_interface[f996e06f5162e4d]::queries::Linker>>::{closure#0}, core[86de0986de23a55d]::option::Option<rustc_interface[f996e06f5162e4d]::queries::Linker>>
  54:     0xffd0df90c188 - <rustc_middle[e262adc660cefa6f]::ty::context::TyCtxt>::create_global_ctxt::<core[86de0986de23a55d]::option::Option<rustc_interface[f996e06f5162e4d]::queries::Linker>, rustc_interface[f996e06f5162e4d]::passes::create_and_enter_global_ctxt<core[86de0986de23a55d]::option::Option<rustc_interface[f996e06f5162e4d]::queries::Linker>, rustc_driver_impl[cc47a5906325ebb2]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}>
  55:     0xffd0df8f1450 - <rustc_interface[f996e06f5162e4d]::passes::create_and_enter_global_ctxt<core[86de0986de23a55d]::option::Option<rustc_interface[f996e06f5162e4d]::queries::Linker>, rustc_driver_impl[cc47a5906325ebb2]::run_compiler::{closure#0}::{closure#2}>::{closure#2} as core[86de0986de23a55d]::ops::function::FnOnce<(&rustc_session[80b2062dd743f4d9]::session::Session, rustc_middle[e262adc660cefa6f]::ty::context::CurrentGcx, alloc[cf75e2ab30ac120f]::sync::Arc<rustc_data_structures[f778079ad5acf8de]::jobserver::Proxy>, &std[57c45f57ec3c24e5]::sync::once_lock::OnceLock<rustc_middle[e262adc660cefa6f]::ty::context::GlobalCtxt>, &rustc_data_structures[f778079ad5acf8de]::sync::worker_local::WorkerLocal<rustc_middle[e262adc660cefa6f]::arena::Arena>, &rustc_data_structures[f778079ad5acf8de]::sync::worker_local::WorkerLocal<rustc_hir[73af37212a31ebc0]::Arena>, rustc_driver_impl[cc47a5906325ebb2]::run_compiler::{closure#0}::{closure#2})>>::call_once::{shim:vtable#0}
  56:     0xffd0df9619dc - <alloc[cf75e2ab30ac120f]::boxed::Box<dyn for<'a> core[86de0986de23a55d]::ops::function::FnOnce<(&'a rustc_session[80b2062dd743f4d9]::session::Session, rustc_middle[e262adc660cefa6f]::ty::context::CurrentGcx, alloc[cf75e2ab30ac120f]::sync::Arc<rustc_data_structures[f778079ad5acf8de]::jobserver::Proxy>, &'a std[57c45f57ec3c24e5]::sync::once_lock::OnceLock<rustc_middle[e262adc660cefa6f]::ty::context::GlobalCtxt<'a>>, &'a rustc_data_structures[f778079ad5acf8de]::sync::worker_local::WorkerLocal<rustc_middle[e262adc660cefa6f]::arena::Arena<'a>>, &'a rustc_data_structures[f778079ad5acf8de]::sync::worker_local::WorkerLocal<rustc_hir[73af37212a31ebc0]::Arena<'a>>, rustc_driver_impl[cc47a5906325ebb2]::run_compiler::{closure#0}::{closure#2}), Output = core[86de0986de23a55d]::option::Option<rustc_interface[f996e06f5162e4d]::queries::Linker>>> as core[86de0986de23a55d]::ops::function::FnOnce<(&rustc_session[80b2062dd743f4d9]::session::Session, rustc_middle[e262adc660cefa6f]::ty::context::CurrentGcx, alloc[cf75e2ab30ac120f]::sync::Arc<rustc_data_structures[f778079ad5acf8de]::jobserver::Proxy>, &std[57c45f57ec3c24e5]::sync::once_lock::OnceLock<rustc_middle[e262adc660cefa6f]::ty::context::GlobalCtxt>, &rustc_data_structures[f778079ad5acf8de]::sync::worker_local::WorkerLocal<rustc_middle[e262adc660cefa6f]::arena::Arena>, &rustc_data_structures[f778079ad5acf8de]::sync::worker_local::WorkerLocal<rustc_hir[73af37212a31ebc0]::Arena>, rustc_driver_impl[cc47a5906325ebb2]::run_compiler::{closure#0}::{closure#2})>>::call_once
  57:     0xffd0df8d7740 - rustc_interface[f996e06f5162e4d]::passes::create_and_enter_global_ctxt::<core[86de0986de23a55d]::option::Option<rustc_interface[f996e06f5162e4d]::queries::Linker>, rustc_driver_impl[cc47a5906325ebb2]::run_compiler::{closure#0}::{closure#2}>
  58:     0xffd0df94114c - <scoped_tls[94b819b1bfdf8311]::ScopedKey<rustc_span[be48632450ff045c]::SessionGlobals>>::set::<rustc_interface[f996e06f5162e4d]::util::run_in_thread_with_globals<rustc_interface[f996e06f5162e4d]::util::run_in_thread_pool_with_globals<rustc_interface[f996e06f5162e4d]::interface::run_compiler<(), rustc_driver_impl[cc47a5906325ebb2]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}::{closure#0}, ()>
  59:     0xffd0df96cb98 - rustc_span[be48632450ff045c]::create_session_globals_then::<(), rustc_interface[f996e06f5162e4d]::util::run_in_thread_with_globals<rustc_interface[f996e06f5162e4d]::util::run_in_thread_pool_with_globals<rustc_interface[f996e06f5162e4d]::interface::run_compiler<(), rustc_driver_impl[cc47a5906325ebb2]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}::{closure#0}>
  60:     0xffd0df906d60 - std[57c45f57ec3c24e5]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[f996e06f5162e4d]::util::run_in_thread_with_globals<rustc_interface[f996e06f5162e4d]::util::run_in_thread_pool_with_globals<rustc_interface[f996e06f5162e4d]::interface::run_compiler<(), rustc_driver_impl[cc47a5906325ebb2]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  61:     0xffd0df94afcc - <<std[57c45f57ec3c24e5]::thread::Builder>::spawn_unchecked_<rustc_interface[f996e06f5162e4d]::util::run_in_thread_with_globals<rustc_interface[f996e06f5162e4d]::util::run_in_thread_pool_with_globals<rustc_interface[f996e06f5162e4d]::interface::run_compiler<(), rustc_driver_impl[cc47a5906325ebb2]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[86de0986de23a55d]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  62:     0xffd0e3491498 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h4301b1eb7e190497
                               at /rustc/390a0ab5dc4a895235a551e502c3893c3337731d/library/alloc/src/boxed.rs:1966:9
  63:     0xffd0e3491498 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h63c57e2bd87c106a
                               at /rustc/390a0ab5dc4a895235a551e502c3893c3337731d/library/alloc/src/boxed.rs:1966:9
  64:     0xffd0e3491498 - std::sys::pal::unix::thread::Thread::new::thread_start::h029a7b8769f51646
                               at /rustc/390a0ab5dc4a895235a551e502c3893c3337731d/library/std/src/sys/pal/unix/thread.rs:97:17
  65:     0xffd0deba4b30 - <unknown>
  66:     0xffd0dec0d88c - <unknown>
---
warning: the ICE couldn't be written to `/checkout/rustc-ice-2025-08-01T01_46_37-30323.txt`: Read-only file system (os error 30)

note: rustc 1.90.0-nightly (9e265d9c0 2025-08-01) running on aarch64-unknown-linux-gnu

note: compiler flags: --crate-type lib -C opt-level=3 -C embed-bitcode=no -C codegen-units=1 -C debug-assertions=on -C symbol-mangling-version=legacy -Z randomize-layout -Z unstable-options -Z macro-backtrace -C split-debuginfo=off -C prefer-dynamic -C llvm-args=-import-instr-limit=10 -Z inline-mir -Z inline-mir-preserve-debug -Z mir_strip_debuginfo=locals-in-tiny-functions -C link-args=-Wl,-z,origin -C link-args=-Wl,-rpath,$ORIGIN/../lib -C embed-bitcode=yes -Z unstable-options -C force-frame-pointers=non-leaf -Z crate-attr=doc(html_root_url="https://doc.rust-lang.org/nightly/") -Z binary-dep-depinfo -Z force-unstable-if-unmarked

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [compare_impl_item] checking assoc item `str::pattern::<impl at library/core/src/str/pattern.rs:972:1: 972:29>::strip_prefix_of` is compatible with trait definition
#1 [check_well_formed] checking that `str::pattern::<impl at library/core/src/str/pattern.rs:972:1: 972:29>` is well-formed
... and 2 other queries... use `env RUST_BACKTRACE=1` to see the full query stack
[RUSTC-TIMING] core test:false 7.513
error: could not compile `core` (lib)

Caused by:
  process didn't exit successfully: `/checkout/obj/build/bootstrap/debug/rustc /checkout/obj/build/bootstrap/debug/rustc --crate-name core --edition=2024 library/core/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C embed-bitcode=no -C codegen-units=1 --warn=unexpected_cfgs --check-cfg 'cfg(no_fp_fmt_parse)' --check-cfg 'cfg(feature, values(any()))' --check-cfg 'cfg(target_has_reliable_f16)' --check-cfg 'cfg(target_has_reliable_f16_math)' --check-cfg 'cfg(target_has_reliable_f128)' --check-cfg 'cfg(target_has_reliable_f128_math)' -C debug-assertions=on --check-cfg 'cfg(docsrs,test)' --check-cfg 'cfg(feature, values("debug_refcell", "optimize_for_size", "panic_immediate_abort"))' -C metadata=b01361d696c820a2 -C extra-filename=-cc134ada1cea09ca --out-dir /checkout/obj/build/aarch64-unknown-linux-gnu/stage1-std/aarch64-unknown-linux-gnu/release/deps --target aarch64-unknown-linux-gnu -L dependency=/checkout/obj/build/aarch64-unknown-linux-gnu/stage1-std/aarch64-unknown-linux-gnu/release/deps -L dependency=/checkout/obj/build/aarch64-unknown-linux-gnu/stage1-std/release/deps -Csymbol-mangling-version=legacy -Zrandomize-layout '--check-cfg=cfg(feature,values(any()))' -Zunstable-options -Zmacro-backtrace -Csplit-debuginfo=off -Cprefer-dynamic -Cllvm-args=-import-instr-limit=10 --cfg=randomized_layouts -Zinline-mir -Zinline-mir-preserve-debug -Zmir_strip_debuginfo=locals-in-tiny-functions -Clink-args=-Wl,-z,origin '-Clink-args=-Wl,-rpath,$ORIGIN/../lib' -Alinker-messages -Cembed-bitcode=yes -Zunstable-options -Cforce-frame-pointers=non-leaf '-Zcrate-attr=doc(html_root_url="https://doc.rust-lang.org/nightly/")' -Z binary-dep-depinfo` (exit status: 101)
Build completed unsuccessfully in 0:09:31
  local time: Fri Aug  1 01:46:45 UTC 2025
  network time: Fri, 01 Aug 2025 01:46:45 GMT
##[error]Process completed with exit code 1.
Post job cleanup.

@lcnr
Copy link
Contributor

lcnr commented Aug 1, 2025

I believe we are hitting this check, which was added very recently:

I think triggering this check is a bug which may already exist and is reachable now. However, it's on the error path, so when hitting this error, we're already emitting a diagnostic, so the issue should already be something before this as if it were to compile, we'd never reach this 🤔

@lcnr
Copy link
Contributor

lcnr commented Aug 1, 2025

oh :x yeah ofc

the issue is just candidate preference, before i explain this shit here, gonna write a rustc-dev-guide chapter about it, pls annoy me if i don't get to it by next tuesday

i've had to link to FCP comments or explain this myself a few times. We should just have a single doc for it

@lcnr
Copy link
Contributor

lcnr commented Aug 1, 2025

The issue is due to https://rustc-dev-guide.rust-lang.org/solve/candidate-preference.html#preference-over-impl-candidates

And the reason this happens is that we add Self: Move bounds to trait methods instead of as a super trait:

#138781 (comment)

I think this breakage is pretty much unavoidable with this approach until we support OR-region constraints, if we ever do.

@Bryanskiy
Copy link
Contributor

In this case, should we revert to the default supertraits?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-perf Status: Waiting on a perf run to be completed. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants