Skip to content

ice: effects, const_trait: assertion failed: constant / lifetime #119078

Closed as not planned
@cushionbadak

Description

@cushionbadak

Same assertion violation appeared at #117244, but has different query stack.

Found this ICE using fuzzing method (with tree-splicer mutator), seed pool is constructed with rust/tests/ui/ and rust-clippy/tests/ui/.

Code

(manual-reduced, call it qwer.rs)

#![feature(effects)]

trait Foo { }

#[const_trait]
trait Bar: ~const Foo {}

(original)

#![feature(const_trait_impl, effects)]

#[TokenStream]
trait Foo { }

#[const_trait]
trait Bar: ~const Foo {}

struct S;
impl const Foo for S {
    fn a(&self) {}
}

impl const Bar for S {}

extern "C" fn foo<T: ~const Bar>(t: &T) {
    t.a();
}

const _: () = foo(&S);

fn main() {}

Meta

/root/.cargo/bin/rustc --version --verbose:

rustc 1.76.0-nightly (6a6287132 2023-12-17)
binary: rustc
commit-hash: 6a62871320e262661bb1a0ea7f8aec9d3abeddf2
commit-date: 2023-12-17
host: x86_64-unknown-linux-gnu
release: 1.76.0-nightly
LLVM version: 17.0.6

Command

/root/.cargo/bin/rustc qwer.rs -Zno-codegen

Error output

Backtrace

error[E0658]: const trait impls are experimental
 --> qwer.rs:6:12
  |
6 | trait Bar: ~const Foo {}
  |            ^^^^^^
  |
  = 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

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.
 --> qwer.rs:5:1
  |
5 | #[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

error[E0601]: `main` function not found in crate `qwer`
 --> qwer.rs:6:25
  |
6 | trait Bar: ~const Foo {}
  |                         ^ consider adding a `main` function to `qwer.rs`

thread 'rustc' panicked at compiler/rustc_hir_analysis/src/astconv/generics.rs:377:25:
assertion `left == right` failed
  left: "constant"
 right: "lifetime"
stack backtrace:
   0:     0x7f7224fb1edc - std::backtrace_rs::backtrace::libunwind::trace::hbd96f5b5ca760e25
                               at /rustc/6a62871320e262661bb1a0ea7f8aec9d3abeddf2/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7f7224fb1edc - std::backtrace_rs::backtrace::trace_unsynchronized::h64131a6af1873394
                               at /rustc/6a62871320e262661bb1a0ea7f8aec9d3abeddf2/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f7224fb1edc - std::sys_common::backtrace::_print_fmt::h172fc171fb8edd0e
                               at /rustc/6a62871320e262661bb1a0ea7f8aec9d3abeddf2/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7f7224fb1edc - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h2fb904bfdf593293
                               at /rustc/6a62871320e262661bb1a0ea7f8aec9d3abeddf2/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f7225005040 - core::fmt::rt::Argument::fmt::h04c813bb3f4f9dfb
                               at /rustc/6a62871320e262661bb1a0ea7f8aec9d3abeddf2/library/core/src/fmt/rt.rs:142:9
   5:     0x7f7225005040 - core::fmt::write::hf0b14553553e6ae7
                               at /rustc/6a62871320e262661bb1a0ea7f8aec9d3abeddf2/library/core/src/fmt/mod.rs:1120:17
   6:     0x7f7224fa5e7f - std::io::Write::write_fmt::h67b55b820fce9842
                               at /rustc/6a62871320e262661bb1a0ea7f8aec9d3abeddf2/library/std/src/io/mod.rs:1810:15
   7:     0x7f7224fb1cc4 - std::sys_common::backtrace::_print::h0afe0dc870608b31
                               at /rustc/6a62871320e262661bb1a0ea7f8aec9d3abeddf2/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f7224fb1cc4 - std::sys_common::backtrace::print::h9c7e632153240ab4
                               at /rustc/6a62871320e262661bb1a0ea7f8aec9d3abeddf2/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f7224fb4987 - std::panicking::default_hook::{{closure}}::h03700dce8c7b3295
  10:     0x7f7224fb46ef - std::panicking::default_hook::h7f9a2c2d59169cb4
                               at /rustc/6a62871320e262661bb1a0ea7f8aec9d3abeddf2/library/std/src/panicking.rs:292:9
  11:     0x7f7221d689a0 - std[7ee343ea645c6a12]::panicking::update_hook::<alloc[af19cace5d9bbce9]::boxed::Box<rustc_driver_impl[3492dc2caf138e1f]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7f7224fb50a6 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h2a91d8c21992f1a0
                               at /rustc/6a62871320e262661bb1a0ea7f8aec9d3abeddf2/library/alloc/src/boxed.rs:2029:9
  13:     0x7f7224fb50a6 - std::panicking::rust_panic_with_hook::hda97263b2307fce0
                               at /rustc/6a62871320e262661bb1a0ea7f8aec9d3abeddf2/library/std/src/panicking.rs:783:13
  14:     0x7f7224fb4dfc - std::panicking::begin_panic_handler::{{closure}}::h88a9159ebedbb057
                               at /rustc/6a62871320e262661bb1a0ea7f8aec9d3abeddf2/library/std/src/panicking.rs:657:13
  15:     0x7f7224fb2396 - std::sys_common::backtrace::__rust_end_short_backtrace::h62b003032794192c
                               at /rustc/6a62871320e262661bb1a0ea7f8aec9d3abeddf2/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x7f7224fb4b80 - rust_begin_unwind
                               at /rustc/6a62871320e262661bb1a0ea7f8aec9d3abeddf2/library/std/src/panicking.rs:645:5
  17:     0x7f7225001745 - core::panicking::panic_fmt::h18831ead799d5be5
                               at /rustc/6a62871320e262661bb1a0ea7f8aec9d3abeddf2/library/core/src/panicking.rs:72:14
  18:     0x7f7225001cdb - core::panicking::assert_failed_inner::h62fb3536955a459c
                               at /rustc/6a62871320e262661bb1a0ea7f8aec9d3abeddf2/library/core/src/panicking.rs:342:17
  19:     0x7f7221e31efb - core[88eeaa8f9cd7aee6]::panicking::assert_failed::<&str, &str>
  20:     0x7f722393871f - <dyn rustc_hir_analysis[93f7da0bb9d56fdd]::astconv::AstConv>::instantiate_poly_trait_ref
  21:     0x7f722386703f - <dyn rustc_hir_analysis[93f7da0bb9d56fdd]::astconv::AstConv>::compute_bounds
  22:     0x7f7223866a88 - rustc_hir_analysis[93f7da0bb9d56fdd]::collect::predicates_of::implied_predicates_with_filter
  23:     0x7f722397299b - rustc_hir_analysis[93f7da0bb9d56fdd]::collect::predicates_of::super_predicates_of
  24:     0x7f72239729fe - rustc_query_impl[cebd3a41b0a13376]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[cebd3a41b0a13376]::query_impl::super_predicates_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[e69f904d46cbb93a]::query::erase::Erased<[u8; 24usize]>>
  25:     0x7f72239729ad - <rustc_query_impl[cebd3a41b0a13376]::query_impl::super_predicates_of::dynamic_query::{closure#2} as core[88eeaa8f9cd7aee6]::ops::function::FnOnce<(rustc_middle[e69f904d46cbb93a]::ty::context::TyCtxt, rustc_span[50b75e0f982c177c]::def_id::DefId)>>::call_once
  26:     0x7f72231353fb - rustc_query_system[a286237d0122231d]::query::plumbing::try_execute_query::<rustc_query_impl[cebd3a41b0a13376]::DynamicConfig<rustc_query_system[a286237d0122231d]::query::caches::DefaultCache<rustc_span[50b75e0f982c177c]::def_id::DefId, rustc_middle[e69f904d46cbb93a]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[cebd3a41b0a13376]::plumbing::QueryCtxt, false>
  27:     0x7f7223867ba3 - rustc_query_impl[cebd3a41b0a13376]::query_impl::super_predicates_of::get_query_non_incr::__rust_end_short_backtrace
  28:     0x7f72231d6585 - rustc_middle[e69f904d46cbb93a]::query::plumbing::query_get_at::<rustc_query_system[a286237d0122231d]::query::caches::DefaultCache<rustc_span[50b75e0f982c177c]::def_id::DefId, rustc_middle[e69f904d46cbb93a]::query::erase::Erased<[u8; 24usize]>>>
  29:     0x7f722351f592 - <rustc_hir_analysis[93f7da0bb9d56fdd]::collect::CollectItemTypesVisitor as rustc_hir[46e478dc7a893d06]::intravisit::Visitor>::visit_item
  30:     0x7f722351c3a9 - rustc_hir_analysis[93f7da0bb9d56fdd]::collect::collect_mod_item_types
  31:     0x7f722351c337 - rustc_query_impl[cebd3a41b0a13376]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[cebd3a41b0a13376]::query_impl::collect_mod_item_types::dynamic_query::{closure#2}::{closure#0}, rustc_middle[e69f904d46cbb93a]::query::erase::Erased<[u8; 0usize]>>
  32:     0x7f7223c55e3b - rustc_query_system[a286237d0122231d]::query::plumbing::try_execute_query::<rustc_query_impl[cebd3a41b0a13376]::DynamicConfig<rustc_query_system[a286237d0122231d]::query::caches::DefaultCache<rustc_span[50b75e0f982c177c]::def_id::LocalModDefId, rustc_middle[e69f904d46cbb93a]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[cebd3a41b0a13376]::plumbing::QueryCtxt, false>
  33:     0x7f7223c55957 - rustc_query_impl[cebd3a41b0a13376]::query_impl::collect_mod_item_types::get_query_non_incr::__rust_end_short_backtrace
  34:     0x7f7223aada1f - rustc_hir_analysis[93f7da0bb9d56fdd]::check_crate
  35:     0x7f722391b117 - rustc_interface[10542add6e558f68]::passes::analysis
  36:     0x7f722391ad5d - rustc_query_impl[cebd3a41b0a13376]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[cebd3a41b0a13376]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[e69f904d46cbb93a]::query::erase::Erased<[u8; 1usize]>>
  37:     0x7f7223f9a932 - rustc_query_system[a286237d0122231d]::query::plumbing::try_execute_query::<rustc_query_impl[cebd3a41b0a13376]::DynamicConfig<rustc_query_system[a286237d0122231d]::query::caches::SingleCache<rustc_middle[e69f904d46cbb93a]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[cebd3a41b0a13376]::plumbing::QueryCtxt, false>
  38:     0x7f7223f9a739 - rustc_query_impl[cebd3a41b0a13376]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  39:     0x7f72240544b1 - rustc_interface[10542add6e558f68]::interface::run_compiler::<core[88eeaa8f9cd7aee6]::result::Result<(), rustc_span[50b75e0f982c177c]::ErrorGuaranteed>, rustc_driver_impl[3492dc2caf138e1f]::run_compiler::{closure#0}>::{closure#0}
  40:     0x7f7223fccb46 - std[7ee343ea645c6a12]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[10542add6e558f68]::util::run_in_thread_with_globals<rustc_interface[10542add6e558f68]::util::run_in_thread_pool_with_globals<rustc_interface[10542add6e558f68]::interface::run_compiler<core[88eeaa8f9cd7aee6]::result::Result<(), rustc_span[50b75e0f982c177c]::ErrorGuaranteed>, rustc_driver_impl[3492dc2caf138e1f]::run_compiler::{closure#0}>::{closure#0}, core[88eeaa8f9cd7aee6]::result::Result<(), rustc_span[50b75e0f982c177c]::ErrorGuaranteed>>::{closure#0}, core[88eeaa8f9cd7aee6]::result::Result<(), rustc_span[50b75e0f982c177c]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[88eeaa8f9cd7aee6]::result::Result<(), rustc_span[50b75e0f982c177c]::ErrorGuaranteed>>
  41:     0x7f7223fcc973 - <<std[7ee343ea645c6a12]::thread::Builder>::spawn_unchecked_<rustc_interface[10542add6e558f68]::util::run_in_thread_with_globals<rustc_interface[10542add6e558f68]::util::run_in_thread_pool_with_globals<rustc_interface[10542add6e558f68]::interface::run_compiler<core[88eeaa8f9cd7aee6]::result::Result<(), rustc_span[50b75e0f982c177c]::ErrorGuaranteed>, rustc_driver_impl[3492dc2caf138e1f]::run_compiler::{closure#0}>::{closure#0}, core[88eeaa8f9cd7aee6]::result::Result<(), rustc_span[50b75e0f982c177c]::ErrorGuaranteed>>::{closure#0}, core[88eeaa8f9cd7aee6]::result::Result<(), rustc_span[50b75e0f982c177c]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[88eeaa8f9cd7aee6]::result::Result<(), rustc_span[50b75e0f982c177c]::ErrorGuaranteed>>::{closure#1} as core[88eeaa8f9cd7aee6]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  42:     0x7f7224fbeef5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hc2c3cc39d6b77a09
                               at /rustc/6a62871320e262661bb1a0ea7f8aec9d3abeddf2/library/alloc/src/boxed.rs:2015:9
  43:     0x7f7224fbeef5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hf074611a704c4f76
                               at /rustc/6a62871320e262661bb1a0ea7f8aec9d3abeddf2/library/alloc/src/boxed.rs:2015:9
  44:     0x7f7224fbeef5 - std::sys::unix::thread::Thread::new::thread_start::h1479436da4eb4142
                               at /rustc/6a62871320e262661bb1a0ea7f8aec9d3abeddf2/library/std/src/sys/unix/thread.rs:108:17
  45:     0x7f721ee6cac3 - <unknown>
  46:     0x7f721eefe660 - <unknown>
  47:                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 attach the file at `/rustc-ice-2023-12-18T10_46_22-64015.txt` to your bug report

note: compiler flags: -Z no-codegen

query stack during panic:
#0 [super_predicates_of] computing the super predicates of `Bar`
#1 [collect_mod_item_types] collecting item types in top-level module
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 3 previous errors

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-effects`#![feature(effects)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-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