Skip to content

ICE: coherence: assertion failed: obligations.is_empty() / unexpected infer in QueryInput  #125556

Closed
@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

#![feature(generic_const_exprs)]

mod v20 {

    pub type v11 = [[usize; v4]; v4];

    const v0: [[usize; v4]; v4] = v6(v8);
    pub struct v17<const v10: usize, const v7: v11> {
        _p: (),
    }

    impl v17<512, v0> {
        pub const fn v21() -> v18 {}
    }

    impl v17<v10, v2> {
        pub const fn v21() -> v18 {}
    }
}

original:

#![feature(generic_const_exprs)]

mod v20 {
    const v0: usize = 512;
    pub type v11 = [[usize; v4]; v4];
    const v2: v11 = [[256; v4]; v4];

    const v0: [[usize; v4]; v4] = v6(v8);
    pub struct v17<const v10: usize, const v7: v11> {
        _p: (),
    }

    impl v17<512, v0> {
        pub const fn v21() -> v18 {}
    }

    impl<const v10: usize> v17<v10, v2> {
        pub const fn v21() -> v18 {
            v18 { _p: () }
        }
    }
}
pub use v20::{v13, v17};
fn main() {}

Version information

rustc 1.80.0-nightly (48f00110d 2024-05-25)
binary: rustc
commit-hash: 48f00110d0dae38b3046a9ac05d20ea321fd6637
commit-date: 2024-05-25
host: x86_64-unknown-linux-gnu
release: 1.80.0-nightly
LLVM version: 18.1.6

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Znext-solver=coherence

Program output

error[E0425]: cannot find value `v4` in this scope
 --> /tmp/icemaker_global_tempdir.iEGYn0XYvA4f/rustc_testrunner_tmpdir_reporting.rHVhnk0l6xFH/mvce.rs:5:29
  |
5 |     pub type v11 = [[usize; v4]; v4];
  |                             ^^ help: a constant with a similar name exists: `v0`
6 |
7 |     const v0: [[usize; v4]; v4] = v6(v8);
  |     ------------------------------------- similarly named constant `v0` defined here

error[E0425]: cannot find value `v4` in this scope
 --> /tmp/icemaker_global_tempdir.iEGYn0XYvA4f/rustc_testrunner_tmpdir_reporting.rHVhnk0l6xFH/mvce.rs:5:34
  |
5 |     pub type v11 = [[usize; v4]; v4];
  |                                  ^^ help: a constant with a similar name exists: `v0`
6 |
7 |     const v0: [[usize; v4]; v4] = v6(v8);
  |     ------------------------------------- similarly named constant `v0` defined here

error[E0425]: cannot find value `v4` in this scope
 --> /tmp/icemaker_global_tempdir.iEGYn0XYvA4f/rustc_testrunner_tmpdir_reporting.rHVhnk0l6xFH/mvce.rs:7:24
  |
7 |     const v0: [[usize; v4]; v4] = v6(v8);
  |                        ^^ not found in this scope

error[E0425]: cannot find value `v4` in this scope
 --> /tmp/icemaker_global_tempdir.iEGYn0XYvA4f/rustc_testrunner_tmpdir_reporting.rHVhnk0l6xFH/mvce.rs:7:29
  |
7 |     const v0: [[usize; v4]; v4] = v6(v8);
  |                             ^^ not found in this scope

error[E0425]: cannot find value `v8` in this scope
 --> /tmp/icemaker_global_tempdir.iEGYn0XYvA4f/rustc_testrunner_tmpdir_reporting.rHVhnk0l6xFH/mvce.rs:7:38
  |
7 |     const v0: [[usize; v4]; v4] = v6(v8);
  |                                      ^^ not found in this scope

error[E0412]: cannot find type `v18` in this scope
  --> /tmp/icemaker_global_tempdir.iEGYn0XYvA4f/rustc_testrunner_tmpdir_reporting.rHVhnk0l6xFH/mvce.rs:13:31
   |
5  |     pub type v11 = [[usize; v4]; v4];
   |     --------------------------------- similarly named type alias `v11` defined here
...
13 |         pub const fn v21() -> v18 {}
   |                               ^^^ help: a type alias with a similar name exists: `v11`

error[E0412]: cannot find type `v10` in this scope
  --> /tmp/icemaker_global_tempdir.iEGYn0XYvA4f/rustc_testrunner_tmpdir_reporting.rHVhnk0l6xFH/mvce.rs:16:14
   |
5  |     pub type v11 = [[usize; v4]; v4];
   |     --------------------------------- similarly named type alias `v11` defined here
...
16 |     impl v17<v10, v2> {
   |              ^^^
   |
help: a type alias with a similar name exists
   |
16 |     impl v17<v11, v2> {
   |              ~~~
help: you might be missing a type parameter
   |
16 |     impl<v10> v17<v10, v2> {
   |         +++++

error[E0412]: cannot find type `v2` in this scope
  --> /tmp/icemaker_global_tempdir.iEGYn0XYvA4f/rustc_testrunner_tmpdir_reporting.rHVhnk0l6xFH/mvce.rs:16:19
   |
16 |     impl v17<v10, v2> {
   |                   ^^ not found in this scope
   |
help: you might be missing a type parameter
   |
16 |     impl<v2> v17<v10, v2> {
   |         ++++

error[E0412]: cannot find type `v18` in this scope
  --> /tmp/icemaker_global_tempdir.iEGYn0XYvA4f/rustc_testrunner_tmpdir_reporting.rHVhnk0l6xFH/mvce.rs:17:31
   |
5  |     pub type v11 = [[usize; v4]; v4];
   |     --------------------------------- similarly named type alias `v11` defined here
...
17 |         pub const fn v21() -> v18 {}
   |                               ^^^ help: a type alias with a similar name exists: `v11`

warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes
 --> /tmp/icemaker_global_tempdir.iEGYn0XYvA4f/rustc_testrunner_tmpdir_reporting.rHVhnk0l6xFH/mvce.rs:1:12
  |
1 | #![feature(generic_const_exprs)]
  |            ^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
  = note: `#[warn(incomplete_features)]` on by default

warning: type `v11` should have an upper camel case name
 --> /tmp/icemaker_global_tempdir.iEGYn0XYvA4f/rustc_testrunner_tmpdir_reporting.rHVhnk0l6xFH/mvce.rs:5:14
  |
5 |     pub type v11 = [[usize; v4]; v4];
  |              ^^^ help: convert the identifier to upper camel case (notice the capitalization): `V11`
  |
  = note: `#[warn(non_camel_case_types)]` on by default

warning: type `v17` should have an upper camel case name
 --> /tmp/icemaker_global_tempdir.iEGYn0XYvA4f/rustc_testrunner_tmpdir_reporting.rHVhnk0l6xFH/mvce.rs:8:16
  |
8 |     pub struct v17<const v10: usize, const v7: v11> {
  |                ^^^ help: convert the identifier to upper camel case (notice the capitalization): `V17`

error[E0601]: `main` function not found in crate `mvce`
  --> /tmp/icemaker_global_tempdir.iEGYn0XYvA4f/rustc_testrunner_tmpdir_reporting.rHVhnk0l6xFH/mvce.rs:19:2
   |
19 | }
   |  ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.iEGYn0XYvA4f/rustc_testrunner_tmpdir_reporting.rHVhnk0l6xFH/mvce.rs`

error[E0425]: cannot find function `v6` in this scope
 --> /tmp/icemaker_global_tempdir.iEGYn0XYvA4f/rustc_testrunner_tmpdir_reporting.rHVhnk0l6xFH/mvce.rs:7:35
  |
7 |     const v0: [[usize; v4]; v4] = v6(v8);
  |                                   ^^ not found in this scope

error: `[[usize; v4]; v4]` is forbidden as the type of a const generic parameter
 --> /tmp/icemaker_global_tempdir.iEGYn0XYvA4f/rustc_testrunner_tmpdir_reporting.rHVhnk0l6xFH/mvce.rs:8:48
  |
8 |     pub struct v17<const v10: usize, const v7: v11> {
  |                                                ^^^
  |
  = note: the only supported types are integers, `bool` and `char`
help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
  |
3 + #![feature(adt_const_params)]
  |

error[E0747]: unresolved item provided when a constant was expected
  --> /tmp/icemaker_global_tempdir.iEGYn0XYvA4f/rustc_testrunner_tmpdir_reporting.rHVhnk0l6xFH/mvce.rs:16:14
   |
16 |     impl v17<v10, v2> {
   |              ^^^
   |
help: if this generic argument was intended as a const parameter, surround it with braces
   |
16 |     impl v17<{ v10 }, v2> {
   |              +     +

thread 'rustc' panicked at compiler/rustc_trait_selection/src/solve/eval_ctxt/canonical.rs:354:13:
assertion failed: obligations.is_empty()
stack backtrace:
   0:     0x786ef26b3075 - std::backtrace_rs::backtrace::libunwind::trace::h42aea1e7bd0a8d0f
                               at /rustc/48f00110d0dae38b3046a9ac05d20ea321fd6637/library/std/src/../../backtrace/src/backtrace/libunwind.rs:105:5
   1:     0x786ef26b3075 - std::backtrace_rs::backtrace::trace_unsynchronized::hf3ac14f94797a8ff
                               at /rustc/48f00110d0dae38b3046a9ac05d20ea321fd6637/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x786ef26b3075 - std::sys_common::backtrace::_print_fmt::hfdeb6f5ed3f5afaa
                               at /rustc/48f00110d0dae38b3046a9ac05d20ea321fd6637/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x786ef26b3075 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h3a3bab3a7e07f684
                               at /rustc/48f00110d0dae38b3046a9ac05d20ea321fd6637/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x786ef270218b - core::fmt::rt::Argument::fmt::h827eaf91b0235e22
                               at /rustc/48f00110d0dae38b3046a9ac05d20ea321fd6637/library/core/src/fmt/rt.rs:165:63
   5:     0x786ef270218b - core::fmt::write::h3c9de6e4b056660b
                               at /rustc/48f00110d0dae38b3046a9ac05d20ea321fd6637/library/core/src/fmt/mod.rs:1172:21
   6:     0x786ef26a7dcf - std::io::Write::write_fmt::h4989c38cc46ac4a9
                               at /rustc/48f00110d0dae38b3046a9ac05d20ea321fd6637/library/std/src/io/mod.rs:1835:15
   7:     0x786ef26b2e4e - std::sys_common::backtrace::_print::hf88b29e9f4397d20
                               at /rustc/48f00110d0dae38b3046a9ac05d20ea321fd6637/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x786ef26b2e4e - std::sys_common::backtrace::print::ha9d7657d2fccb9ae
                               at /rustc/48f00110d0dae38b3046a9ac05d20ea321fd6637/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x786ef26b5879 - std::panicking::default_hook::{{closure}}::hc05689f1cbee5d27
  10:     0x786ef26b561a - std::panicking::default_hook::hd873922dd239ed0b
                               at /rustc/48f00110d0dae38b3046a9ac05d20ea321fd6637/library/std/src/panicking.rs:298:9
  11:     0x786eef0f9eef - std[f497e4f3b89fc98e]::panicking::update_hook::<alloc[98811ad6430038c6]::boxed::Box<rustc_driver_impl[54b05657baa3450f]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x786ef26b5fab - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hf701087af7d36f49
                               at /rustc/48f00110d0dae38b3046a9ac05d20ea321fd6637/library/alloc/src/boxed.rs:2077:9
  13:     0x786ef26b5fab - std::panicking::rust_panic_with_hook::haff0763df51daf39
                               at /rustc/48f00110d0dae38b3046a9ac05d20ea321fd6637/library/std/src/panicking.rs:799:13
  14:     0x786ef26b5ceb - std::panicking::begin_panic_handler::{{closure}}::hc16ab47bd0d35526
                               at /rustc/48f00110d0dae38b3046a9ac05d20ea321fd6637/library/std/src/panicking.rs:656:13
  15:     0x786ef26b3539 - std::sys_common::backtrace::__rust_end_short_backtrace::h65417fe81de7a832
                               at /rustc/48f00110d0dae38b3046a9ac05d20ea321fd6637/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x786ef26b5a57 - rust_begin_unwind
                               at /rustc/48f00110d0dae38b3046a9ac05d20ea321fd6637/library/std/src/panicking.rs:652:5
  17:     0x786ef26fe753 - core::panicking::panic_fmt::h94f1edd420c4d371
                               at /rustc/48f00110d0dae38b3046a9ac05d20ea321fd6637/library/core/src/panicking.rs:72:14
  18:     0x786ef26fe7fc - core::panicking::panic::h3e16a54ff7079537
                               at /rustc/48f00110d0dae38b3046a9ac05d20ea321fd6637/library/core/src/panicking.rs:146:5
  19:     0x786ef08bcc27 - <rustc_trait_selection[63ce0d138858f6da]::solve::eval_ctxt::EvalCtxt<rustc_infer[4c65ead5c75e00e7]::infer::InferCtxt, rustc_middle[8d1200f20c5736b5]::ty::context::TyCtxt>>::unify_query_var_values
  20:     0x786ef10acf5e - <rustc_trait_selection[63ce0d138858f6da]::solve::eval_ctxt::EvalCtxt<rustc_infer[4c65ead5c75e00e7]::infer::InferCtxt, rustc_middle[8d1200f20c5736b5]::ty::context::TyCtxt>>::evaluate_goal_raw
  21:     0x786ef10b17c0 - <rustc_trait_selection[63ce0d138858f6da]::solve::eval_ctxt::EvalCtxt<rustc_infer[4c65ead5c75e00e7]::infer::InferCtxt, rustc_middle[8d1200f20c5736b5]::ty::context::TyCtxt>>::try_evaluate_added_goals
  22:     0x786ef10b9f43 - <rustc_trait_selection[63ce0d138858f6da]::solve::search_graph::SearchGraph<rustc_middle[8d1200f20c5736b5]::ty::context::TyCtxt>>::with_new_goal::<<rustc_trait_selection[63ce0d138858f6da]::solve::eval_ctxt::EvalCtxt<rustc_infer[4c65ead5c75e00e7]::infer::InferCtxt, rustc_middle[8d1200f20c5736b5]::ty::context::TyCtxt>>::evaluate_canonical_goal::{closure#0}::{closure#0}::{closure#0}>::{closure#2}
  23:     0x786ef10b2f46 - <rustc_trait_selection[63ce0d138858f6da]::solve::search_graph::SearchGraph<rustc_middle[8d1200f20c5736b5]::ty::context::TyCtxt>>::with_new_goal::<<rustc_trait_selection[63ce0d138858f6da]::solve::eval_ctxt::EvalCtxt<rustc_infer[4c65ead5c75e00e7]::infer::InferCtxt, rustc_middle[8d1200f20c5736b5]::ty::context::TyCtxt>>::evaluate_canonical_goal::{closure#0}::{closure#0}::{closure#0}>
  24:     0x786ef10ac904 - <rustc_trait_selection[63ce0d138858f6da]::solve::eval_ctxt::EvalCtxt<rustc_infer[4c65ead5c75e00e7]::infer::InferCtxt, rustc_middle[8d1200f20c5736b5]::ty::context::TyCtxt>>::evaluate_goal_raw
  25:     0x786ef10abc11 - <rustc_infer[4c65ead5c75e00e7]::infer::InferCtxt as rustc_trait_selection[63ce0d138858f6da]::solve::eval_ctxt::InferCtxtEvalExt>::evaluate_root_goal
  26:     0x786ef10ab560 - <rustc_trait_selection[63ce0d138858f6da]::solve::fulfill::FulfillmentCtxt as rustc_infer[4c65ead5c75e00e7]::traits::engine::TraitEngine>::select_where_possible
  27:     0x786ef06d5a7a - <rustc_trait_selection[63ce0d138858f6da]::traits::engine::ObligationCtxt>::select_all_or_error
  28:     0x786ef08be83d - rustc_trait_selection[63ce0d138858f6da]::traits::coherence::overlap
  29:     0x786ef13cd078 - rustc_trait_selection[63ce0d138858f6da]::traits::coherence::overlapping_impls
  30:     0x786ef13cc479 - <rustc_hir_analysis[773f5f9066629b08]::coherence::inherent_impls_overlap::InherentOverlapChecker>::check_for_overlapping_inherent_impls
  31:     0x786ef0a66c1b - rustc_hir_analysis[773f5f9066629b08]::coherence::inherent_impls_overlap::crate_inherent_impls_overlap_check
  32:     0x786ef0a664e7 - rustc_query_impl[f809864b4f0d0f3d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[f809864b4f0d0f3d]::query_impl::crate_inherent_impls_overlap_check::dynamic_query::{closure#2}::{closure#0}, rustc_middle[8d1200f20c5736b5]::query::erase::Erased<[u8; 1usize]>>
  33:     0x786ef11553a5 - rustc_query_system[7155d4f1ed1184a2]::query::plumbing::try_execute_query::<rustc_query_impl[f809864b4f0d0f3d]::DynamicConfig<rustc_query_system[7155d4f1ed1184a2]::query::caches::SingleCache<rustc_middle[8d1200f20c5736b5]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[f809864b4f0d0f3d]::plumbing::QueryCtxt, false>
  34:     0x786ef115518f - rustc_query_impl[f809864b4f0d0f3d]::query_impl::crate_inherent_impls_overlap_check::get_query_non_incr::__rust_end_short_backtrace
  35:     0x786ef07acbb7 - rustc_hir_analysis[773f5f9066629b08]::check_crate
  36:     0x786ef078d07e - rustc_interface[58067e46342fbaaa]::passes::analysis
  37:     0x786ef078cbd5 - rustc_query_impl[f809864b4f0d0f3d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[f809864b4f0d0f3d]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[8d1200f20c5736b5]::query::erase::Erased<[u8; 1usize]>>
  38:     0x786ef11553a5 - rustc_query_system[7155d4f1ed1184a2]::query::plumbing::try_execute_query::<rustc_query_impl[f809864b4f0d0f3d]::DynamicConfig<rustc_query_system[7155d4f1ed1184a2]::query::caches::SingleCache<rustc_middle[8d1200f20c5736b5]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[f809864b4f0d0f3d]::plumbing::QueryCtxt, false>
  39:     0x786ef115510f - rustc_query_impl[f809864b4f0d0f3d]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  40:     0x786ef0fcac5c - rustc_interface[58067e46342fbaaa]::interface::run_compiler::<core[e093d3f8342b0aab]::result::Result<(), rustc_span[f743e6227e8610a7]::ErrorGuaranteed>, rustc_driver_impl[54b05657baa3450f]::run_compiler::{closure#0}>::{closure#1}
  41:     0x786ef0fb6d09 - std[f497e4f3b89fc98e]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[58067e46342fbaaa]::util::run_in_thread_with_globals<rustc_interface[58067e46342fbaaa]::util::run_in_thread_pool_with_globals<rustc_interface[58067e46342fbaaa]::interface::run_compiler<core[e093d3f8342b0aab]::result::Result<(), rustc_span[f743e6227e8610a7]::ErrorGuaranteed>, rustc_driver_impl[54b05657baa3450f]::run_compiler::{closure#0}>::{closure#1}, core[e093d3f8342b0aab]::result::Result<(), rustc_span[f743e6227e8610a7]::ErrorGuaranteed>>::{closure#0}, core[e093d3f8342b0aab]::result::Result<(), rustc_span[f743e6227e8610a7]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[e093d3f8342b0aab]::result::Result<(), rustc_span[f743e6227e8610a7]::ErrorGuaranteed>>
  42:     0x786ef0fb6ac8 - <<std[f497e4f3b89fc98e]::thread::Builder>::spawn_unchecked_<rustc_interface[58067e46342fbaaa]::util::run_in_thread_with_globals<rustc_interface[58067e46342fbaaa]::util::run_in_thread_pool_with_globals<rustc_interface[58067e46342fbaaa]::interface::run_compiler<core[e093d3f8342b0aab]::result::Result<(), rustc_span[f743e6227e8610a7]::ErrorGuaranteed>, rustc_driver_impl[54b05657baa3450f]::run_compiler::{closure#0}>::{closure#1}, core[e093d3f8342b0aab]::result::Result<(), rustc_span[f743e6227e8610a7]::ErrorGuaranteed>>::{closure#0}, core[e093d3f8342b0aab]::result::Result<(), rustc_span[f743e6227e8610a7]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[e093d3f8342b0aab]::result::Result<(), rustc_span[f743e6227e8610a7]::ErrorGuaranteed>>::{closure#2} as core[e093d3f8342b0aab]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  43:     0x786ef26bfd8b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h07c51d08fbe7b366
                               at /rustc/48f00110d0dae38b3046a9ac05d20ea321fd6637/library/alloc/src/boxed.rs:2063:9
  44:     0x786ef26bfd8b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h59743c0df790be85
                               at /rustc/48f00110d0dae38b3046a9ac05d20ea321fd6637/library/alloc/src/boxed.rs:2063:9
  45:     0x786ef26bfd8b - std::sys::pal::unix::thread::Thread::new::thread_start::h35133497d39238f8
                               at /rustc/48f00110d0dae38b3046a9ac05d20ea321fd6637/library/std/src/sys/pal/unix/thread.rs:108:17
  46:     0x786eebeaa1cf - <unknown>
  47:     0x786eebf2b6ec - <unknown>
  48:                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.80.0-nightly (48f00110d 2024-05-25) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z next-solver=coherence -Z dump-mir-dir=dir

query stack during panic:
#0 [crate_inherent_impls_overlap_check] check for overlap between inherent impls defined in this crate
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 13 previous errors; 3 warnings emitted

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

@rustbot label +F-generic_const_exprs

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-generic_const_exprs`#![feature(generic_const_exprs)]`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