Skip to content

ICE: assertion failed Alias(Projection, .. != FreshTy(0) #127138

Closed
@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

#![feature(effects)]
#[const_trait]
trait Trait {}

fn main() {
    let _: &dyn ~const Trait;
}

original:

#![feature(const_trait_impl)]
// FIXME(effects) add effects
//@ edition: 2021

#[const_trait]
trait Trait {}

fn main() {
    let _: &dyn const Trait; //~ ERROR const trait bounds are not allowed in trait object types
    let _: &dyn ~const Trait; //~ ERROR `~const` is not allowed here
}

// Regression test for issue #119525.
trait NonConst {}
const fn handle(_: &dyn const NonConst) {}
//~^ ERROR const trait bounds are not allowed in trait object types
const fn take(_: &dyn ~const NonConst) {}
//~^ ERROR `~const` is not allowed here

Version information

rustc 1.81.0-nightly (ba1d7f4a0 2024-06-29)
binary: rustc
commit-hash: ba1d7f4a083e6402679105115ded645512a7aea8
commit-date: 2024-06-29
host: x86_64-unknown-linux-gnu
release: 1.81.0-nightly
LLVM version: 18.1.7

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zcrate-attr=feature(effects) --edition=2018

Program output

error: `~const` is not allowed here
 --> /tmp/icemaker_global_tempdir.U9NvpFL4hBFS/rustc_testrunner_tmpdir_reporting.rtzJvTxisvQ5/mvce.rs:5:17
  |
5 |     let _: &dyn ~const Trait;
  |                 ^^^^^^
  |
  = note: trait objects cannot have `~const` trait bounds

error[E0658]: const trait impls are experimental
 --> /tmp/icemaker_global_tempdir.U9NvpFL4hBFS/rustc_testrunner_tmpdir_reporting.rtzJvTxisvQ5/mvce.rs:5:17
  |
5 |     let _: &dyn ~const Trait;
  |                 ^^^^^^
  |
  = note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information
  = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
  = note: this compiler was built on 2024-06-29; consider upgrading it if it is out of date

error[E0658]: `const_trait` is a temporary placeholder for marking a trait that is suitable for `const` `impls` and all default bodies as `const`, which may be removed or renamed in the future.
 --> /tmp/icemaker_global_tempdir.U9NvpFL4hBFS/rustc_testrunner_tmpdir_reporting.rtzJvTxisvQ5/mvce.rs:1:1
  |
1 | #[const_trait]
  | ^^^^^^^^^^^^^^
  |
  = note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information
  = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable
  = note: this compiler was built on 2024-06-29; consider upgrading it if it is out of date

warning: the feature `effects` is incomplete and may not be safe to use and/or cause compiler crashes
 --> <crate attribute>:1:9
  |
1 | feature(effects)
  |         ^^^^^^^
  |
  = note: see issue #102090 <https://github.com/rust-lang/rust/issues/102090> for more information
  = note: `#[warn(incomplete_features)]` on by default

error[E0225]: only auto traits can be used as additional traits in a trait object
 --> /tmp/icemaker_global_tempdir.U9NvpFL4hBFS/rustc_testrunner_tmpdir_reporting.rtzJvTxisvQ5/mvce.rs:5:17
  |
5 |     let _: &dyn ~const Trait;
  |                 ^^^^^^^^^^^^
  |                 |
  |                 additional non-auto trait
  |                 first non-auto trait
  |
  = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: Compat + Trait {}`
  = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits>

thread 'rustc' panicked at compiler/rustc_hir_analysis/src/hir_ty_lowering/object_safety.rs:220:17:
assertion `left == right` failed
  left: Alias(Projection, AliasTy { args: [FreshTy(0)], def_id: DefId(0:5 ~ mvce[9951]::Trait::{synthetic#0}) })
 right: FreshTy(0)
stack backtrace:
   0:     0x7b4542dd22b5 - std::backtrace_rs::backtrace::libunwind::trace::h9fec972da723f824
                               at /rustc/ba1d7f4a083e6402679105115ded645512a7aea8/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5
   1:     0x7b4542dd22b5 - std::backtrace_rs::backtrace::trace_unsynchronized::h6750dc8e20aabcad
                               at /rustc/ba1d7f4a083e6402679105115ded645512a7aea8/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7b4542dd22b5 - std::sys::backtrace::_print_fmt::h112c52e5e2edb557
                               at /rustc/ba1d7f4a083e6402679105115ded645512a7aea8/library/std/src/sys/backtrace.rs:68:5
   3:     0x7b4542dd22b5 - <std::sys::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h4713d06d34163f46
                               at /rustc/ba1d7f4a083e6402679105115ded645512a7aea8/library/std/src/sys/backtrace.rs:44:22
   4:     0x7b4542e21d9b - core::fmt::rt::Argument::fmt::h919dfde74ebabb2a
                               at /rustc/ba1d7f4a083e6402679105115ded645512a7aea8/library/core/src/fmt/rt.rs:173:76
   5:     0x7b4542e21d9b - core::fmt::write::h63ad278710fcf618
                               at /rustc/ba1d7f4a083e6402679105115ded645512a7aea8/library/core/src/fmt/mod.rs:1174:21
   6:     0x7b4542dc6e9f - std::io::Write::write_fmt::h48f75cc65a268f9a
                               at /rustc/ba1d7f4a083e6402679105115ded645512a7aea8/library/std/src/io/mod.rs:1835:15
   7:     0x7b4542dd208e - std::sys::backtrace::_print::ha47bd77a3336440c
                               at /rustc/ba1d7f4a083e6402679105115ded645512a7aea8/library/std/src/sys/backtrace.rs:47:5
   8:     0x7b4542dd208e - std::sys::backtrace::print::hd71c23c2433456bf
                               at /rustc/ba1d7f4a083e6402679105115ded645512a7aea8/library/std/src/sys/backtrace.rs:34:9
   9:     0x7b4542dd49d9 - std::panicking::default_hook::{{closure}}::ha7861419c6fed626
  10:     0x7b4542dd477c - std::panicking::default_hook::hdb522e40b65d9458
                               at /rustc/ba1d7f4a083e6402679105115ded645512a7aea8/library/std/src/panicking.rs:292:9
  11:     0x7b453f5b18a0 - std[ee1287dda0decb26]::panicking::update_hook::<alloc[ebf157a0a0183114]::boxed::Box<rustc_driver_impl[b3016c550210facb]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7b4542dd52af - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h8a54893ded3fcd8c
                               at /rustc/ba1d7f4a083e6402679105115ded645512a7aea8/library/alloc/src/boxed.rs:2078:9
  13:     0x7b4542dd52af - std::panicking::rust_panic_with_hook::h79c7320e6dd14ff0
                               at /rustc/ba1d7f4a083e6402679105115ded645512a7aea8/library/std/src/panicking.rs:804:13
  14:     0x7b4542dd4ed7 - std::panicking::begin_panic_handler::{{closure}}::h6bf6d623eeb925ff
                               at /rustc/ba1d7f4a083e6402679105115ded645512a7aea8/library/std/src/panicking.rs:670:13
  15:     0x7b4542dd2779 - std::sys::backtrace::__rust_end_short_backtrace::hae9fda2e5a3f99dc
                               at /rustc/ba1d7f4a083e6402679105115ded645512a7aea8/library/std/src/sys/backtrace.rs:171:18
  16:     0x7b4542dd4bb4 - rust_begin_unwind
                               at /rustc/ba1d7f4a083e6402679105115ded645512a7aea8/library/std/src/panicking.rs:661:5
  17:     0x7b4542e1e353 - core::panicking::panic_fmt::h1a6b0ab626f31f34
                               at /rustc/ba1d7f4a083e6402679105115ded645512a7aea8/library/core/src/panicking.rs:74:14
  18:     0x7b4542e1e85e - core::panicking::assert_failed_inner::h966c5e9d880e17e0
                               at /rustc/ba1d7f4a083e6402679105115ded645512a7aea8/library/core/src/panicking.rs:410:17
  19:     0x7b453f69c573 - core[a458eee17fffdec1]::panicking::assert_failed::<rustc_middle[375bbde5f17fb8ea]::ty::Ty, rustc_middle[375bbde5f17fb8ea]::ty::Ty>
  20:     0x7b454164f142 - <core[a458eee17fffdec1]::iter::adapters::chain::Chain<core[a458eee17fffdec1]::iter::adapters::chain::Chain<core[a458eee17fffdec1]::iter::adapters::map::Map<core[a458eee17fffdec1]::iter::adapters::map::Map<core[a458eee17fffdec1]::slice::iter::Iter<rustc_trait_selection[19ae2f0c85cb8e17]::traits::util::TraitAliasExpansionInfo>, <dyn rustc_hir_analysis[190a10ac9c7209da]::hir_ty_lowering::HirTyLowerer>::lower_trait_object_ty::{closure#0}::{closure#9}>, <dyn rustc_hir_analysis[190a10ac9c7209da]::hir_ty_lowering::HirTyLowerer>::lower_trait_object_ty::{closure#0}::{closure#11}>, core[a458eee17fffdec1]::iter::adapters::map::Map<core[a458eee17fffdec1]::iter::adapters::map::Map<core[a458eee17fffdec1]::slice::iter::Iter<(rustc_type_ir[170e3520cb44ff2d]::binder::Binder<rustc_middle[375bbde5f17fb8ea]::ty::context::TyCtxt, rustc_type_ir[170e3520cb44ff2d]::predicate::ProjectionPredicate<rustc_middle[375bbde5f17fb8ea]::ty::context::TyCtxt>>, rustc_span[a32535cd2922901f]::span_encoding::Span)>, <dyn rustc_hir_analysis[190a10ac9c7209da]::hir_ty_lowering::HirTyLowerer>::lower_trait_object_ty::{closure#0}::{closure#10}>, <dyn rustc_hir_analysis[190a10ac9c7209da]::hir_ty_lowering::HirTyLowerer>::lower_trait_object_ty::{closure#0}::{closure#13}>>, core[a458eee17fffdec1]::iter::adapters::map::Map<alloc[ebf157a0a0183114]::vec::into_iter::IntoIter<rustc_trait_selection[19ae2f0c85cb8e17]::traits::util::TraitAliasExpansionInfo>, <dyn rustc_hir_analysis[190a10ac9c7209da]::hir_ty_lowering::HirTyLowerer>::lower_trait_object_ty::{closure#0}::{closure#12}>> as core[a458eee17fffdec1]::iter::traits::iterator::Iterator>::next
  21:     0x7b454164b599 - <dyn rustc_hir_analysis[190a10ac9c7209da]::hir_ty_lowering::HirTyLowerer>::lower_trait_object_ty::{closure#0}
  22:     0x7b454118c4ed - <dyn rustc_hir_analysis[190a10ac9c7209da]::hir_ty_lowering::HirTyLowerer>::lower_ty_common::{closure#0}
  23:     0x7b454118bb81 - <dyn rustc_hir_analysis[190a10ac9c7209da]::hir_ty_lowering::HirTyLowerer>::lower_ty_common::{closure#0}
  24:     0x7b454144fee8 - <rustc_hir_typeck[2dc35516be686cd]::gather_locals::GatherLocalsVisitor>::declare
  25:     0x7b453d82fb52 - <rustc_hir_typeck[2dc35516be686cd]::gather_locals::GatherLocalsVisitor as rustc_hir[9cb815a008d04811]::intravisit::Visitor>::visit_expr
  26:     0x7b4540cfc32d - rustc_hir_typeck[2dc35516be686cd]::check::check_fn
  27:     0x7b4540cf1f5a - rustc_hir_typeck[2dc35516be686cd]::typeck
  28:     0x7b4540cf1909 - rustc_query_impl[e193fcc3be99e64a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[e193fcc3be99e64a]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[375bbde5f17fb8ea]::query::erase::Erased<[u8; 8usize]>>
  29:     0x7b4540c45773 - rustc_query_system[ab5481f6c869ba71]::query::plumbing::try_execute_query::<rustc_query_impl[e193fcc3be99e64a]::DynamicConfig<rustc_query_system[ab5481f6c869ba71]::query::caches::VecCache<rustc_span[a32535cd2922901f]::def_id::LocalDefId, rustc_middle[375bbde5f17fb8ea]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[e193fcc3be99e64a]::plumbing::QueryCtxt, false>
  30:     0x7b4540c4494d - rustc_query_impl[e193fcc3be99e64a]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  31:     0x7b4540c44548 - <rustc_middle[375bbde5f17fb8ea]::hir::map::Map>::par_body_owners::<rustc_hir_analysis[190a10ac9c7209da]::check_crate::{closure#4}>::{closure#0}
  32:     0x7b4540c428c5 - rustc_hir_analysis[190a10ac9c7209da]::check_crate
  33:     0x7b4541145455 - rustc_interface[ab25a569cec44e98]::passes::analysis
  34:     0x7b4541145015 - rustc_query_impl[e193fcc3be99e64a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[e193fcc3be99e64a]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[375bbde5f17fb8ea]::query::erase::Erased<[u8; 1usize]>>
  35:     0x7b454181c2e5 - rustc_query_system[ab5481f6c869ba71]::query::plumbing::try_execute_query::<rustc_query_impl[e193fcc3be99e64a]::DynamicConfig<rustc_query_system[ab5481f6c869ba71]::query::caches::SingleCache<rustc_middle[375bbde5f17fb8ea]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[e193fcc3be99e64a]::plumbing::QueryCtxt, false>
  36:     0x7b454181c04f - rustc_query_impl[e193fcc3be99e64a]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  37:     0x7b454175037f - rustc_interface[ab25a569cec44e98]::interface::run_compiler::<core[a458eee17fffdec1]::result::Result<(), rustc_span[a32535cd2922901f]::ErrorGuaranteed>, rustc_driver_impl[b3016c550210facb]::run_compiler::{closure#0}>::{closure#1}
  38:     0x7b45416dc649 - std[ee1287dda0decb26]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[ab25a569cec44e98]::util::run_in_thread_with_globals<rustc_interface[ab25a569cec44e98]::util::run_in_thread_pool_with_globals<rustc_interface[ab25a569cec44e98]::interface::run_compiler<core[a458eee17fffdec1]::result::Result<(), rustc_span[a32535cd2922901f]::ErrorGuaranteed>, rustc_driver_impl[b3016c550210facb]::run_compiler::{closure#0}>::{closure#1}, core[a458eee17fffdec1]::result::Result<(), rustc_span[a32535cd2922901f]::ErrorGuaranteed>>::{closure#0}, core[a458eee17fffdec1]::result::Result<(), rustc_span[a32535cd2922901f]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[a458eee17fffdec1]::result::Result<(), rustc_span[a32535cd2922901f]::ErrorGuaranteed>>
  39:     0x7b45416dc3fa - <<std[ee1287dda0decb26]::thread::Builder>::spawn_unchecked_<rustc_interface[ab25a569cec44e98]::util::run_in_thread_with_globals<rustc_interface[ab25a569cec44e98]::util::run_in_thread_pool_with_globals<rustc_interface[ab25a569cec44e98]::interface::run_compiler<core[a458eee17fffdec1]::result::Result<(), rustc_span[a32535cd2922901f]::ErrorGuaranteed>, rustc_driver_impl[b3016c550210facb]::run_compiler::{closure#0}>::{closure#1}, core[a458eee17fffdec1]::result::Result<(), rustc_span[a32535cd2922901f]::ErrorGuaranteed>>::{closure#0}, core[a458eee17fffdec1]::result::Result<(), rustc_span[a32535cd2922901f]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[a458eee17fffdec1]::result::Result<(), rustc_span[a32535cd2922901f]::ErrorGuaranteed>>::{closure#2} as core[a458eee17fffdec1]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  40:     0x7b4542ddf10b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hc6d49d49179bb535
                               at /rustc/ba1d7f4a083e6402679105115ded645512a7aea8/library/alloc/src/boxed.rs:2064:9
  41:     0x7b4542ddf10b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h7270f16d3abba4aa
                               at /rustc/ba1d7f4a083e6402679105115ded645512a7aea8/library/alloc/src/boxed.rs:2064:9
  42:     0x7b4542ddf10b - std::sys::pal::unix::thread::Thread::new::thread_start::h3929f25d671aa35f
                               at /rustc/ba1d7f4a083e6402679105115ded645512a7aea8/library/std/src/sys/pal/unix/thread.rs:108:17
  43:     0x7b453c0a6ded - <unknown>
  44:     0x7b453c12a0dc - <unknown>
  45:                0x0 - <unknown>

error: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: please make sure that you have updated to the latest nightly

note: rustc 1.81.0-nightly (ba1d7f4a0 2024-06-29) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z crate-attr=feature(effects) -Z dump-mir-dir=dir

query stack during panic:
#0 [typeck] type-checking `main`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 4 previous errors; 1 warning emitted

Some errors have detailed explanations: E0225, E0658.
For more information about an error, try `rustc --explain E0225`.

@rustbot label +F-const_trait_impl +F-effects

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-const_trait_impl`#![feature(const_trait_impl)]`F-effects`#![feature(effects)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-lowLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions