Skip to content

ICE: -Znext-solver=coherence: unexpected infer in QueryInput { .. } #118783

Closed
@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

pub struct VSet<T, const S: &'static str> {
    ,
}


impl<T> VSet<T, {  }> {
    pub fn new() -> Self {}
}


impl<T> VSet<T, {  }> {
    pub fn new() -> Self {
        
    }
}
original code

original:

#![allow(incomplete_features)]
#![feature(adt_const_params)]
#![crate_name = "foo"]

use std::marker::ConstParamTy;

#[derive(PartialEq, Eq, ConstParamTy)]
pub enum Order {
    Sorted,
    Unsorted,
}

// @has foo/struct.VSet.html '//pre[@class="rust item-decl"]' 'pub struct VSet<T, const ORDER: Order>'
// @has foo/struct.VSet.html '//*[@id="impl-Send-for-VSet%3CT,+ORDER%3E"]/h3[@class="code-header"]' 'impl<T, const ORDER: Order> Send for VSet<T, ORDER>'
// @has foo/struct.VSet.html '//*[@id="impl-Sync-for-VSet%3CT,+ORDER%3E"]/h3[@class="code-header"]' 'impl<T, const ORDER: Order> Sync for VSet<T, ORDER>'
pub struct VSet<T, const S: &'static str> {
    inner: Vec<T>,
}

// @has foo/struct.VSet.html '//*[@id="impl-VSet%3CT,+%7B+Order::Sorted+%7D%3E"]/h3[@class="code-header"]' 'impl<T> VSet<T, { Order::Sorted }>'
impl<T> VSet<T, { Order::Sorted }> {
    pub fn new() -> Self {}
}

// @has foo/struct.VSet.html '//*[@id="impl-VSet%3CT,+%7B+Order::Unsorted+%7D%3E"]/h3[@class="code-header"]' 'impl<T> VSet<T, { Order::Unsorted }>'
impl<T> VSet<T, { Order::Unsorted }> {
    pub fn new() -> Self {
        Self { inner: Vec::new() }
    }
}

pub struct Escape<const S: &'static str>;

// @has foo/struct.Escape.html '//*[@id="impl-Escape%3C%22%3Cscript%3Ealert(%5C%22Escape%5C%22);%3C/script%3E%22%3E"]/h3[@class="code-header"]' 'impl Escape<r#"<script>alert("Escape");</script>"#>'
impl Escape<r#"<script>alert("Escape");</script>"#> {
    pub fn f() {}
}

Version information

rustc 1.76.0-nightly (ae612bedc 2023-12-08)
binary: rustc
commit-hash: ae612bedcbfc7098d1711eb35bc7ca994eb17a4c
commit-date: 2023-12-08
host: x86_64-unknown-linux-gnu
release: 1.76.0-nightly
LLVM version: 17.0.5

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

Program output

error: expected identifier, found `,`
  --> /tmp/icemaker_global_tempdir.k7uu7Q3HV2DR/rustc_testrunner_tmpdir_reporting.WpKyDCisrmgv/mvce.rs:14:5
   |
13 | pub struct VSet<T, const S: &'static str> {
   |            ---- while parsing this struct
14 |     ,
   |     ^ expected identifier

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

thread 'rustc' panicked at compiler/rustc_trait_selection/src/solve/canonicalize.rs:72:9:
unexpected infer in QueryInput { goal: Goal { predicate: Binder { value: NormalizesTo(AliasTy { args: [], def_id: DefId(0:8 ~ mvce[e03b]::{impl#0}::{constant#0}) }, Term::Ct(^1_0: &'?0 str)), bound_vars: [] }, param_env: ParamEnv { caller_bounds: [], reveal: UserFacing } }, anchor: Bubble, predefined_opaques_in_body: PredefinedOpaques(PredefinedOpaquesData { opaque_types: [] }) }
stack backtrace:
   0:     0x7fdcb15cc45c - std::backtrace_rs::backtrace::libunwind::trace::hc023cf82594bd262
                               at /rustc/ae612bedcbfc7098d1711eb35bc7ca994eb17a4c/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7fdcb15cc45c - std::backtrace_rs::backtrace::trace_unsynchronized::h9ed98bf495579d82
                               at /rustc/ae612bedcbfc7098d1711eb35bc7ca994eb17a4c/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fdcb15cc45c - std::sys_common::backtrace::_print_fmt::h1211a11268324512
                               at /rustc/ae612bedcbfc7098d1711eb35bc7ca994eb17a4c/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7fdcb15cc45c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h137b3c46227e29ac
                               at /rustc/ae612bedcbfc7098d1711eb35bc7ca994eb17a4c/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7fdcb161f4a0 - core::fmt::rt::Argument::fmt::h8ec24b23ce773c3d
                               at /rustc/ae612bedcbfc7098d1711eb35bc7ca994eb17a4c/library/core/src/fmt/rt.rs:142:9
   5:     0x7fdcb161f4a0 - core::fmt::write::h130e509b28bd9faf
                               at /rustc/ae612bedcbfc7098d1711eb35bc7ca994eb17a4c/library/core/src/fmt/mod.rs:1120:17
   6:     0x7fdcb15c02bf - std::io::Write::write_fmt::h14f1c178a01176d6
                               at /rustc/ae612bedcbfc7098d1711eb35bc7ca994eb17a4c/library/std/src/io/mod.rs:1810:15
   7:     0x7fdcb15cc244 - std::sys_common::backtrace::_print::h6c3c715eb9a83636
                               at /rustc/ae612bedcbfc7098d1711eb35bc7ca994eb17a4c/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7fdcb15cc244 - std::sys_common::backtrace::print::h348f78f0a08306e5
                               at /rustc/ae612bedcbfc7098d1711eb35bc7ca994eb17a4c/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7fdcb15ceed7 - std::panicking::default_hook::{{closure}}::hd2f2770d686014d7
  10:     0x7fdcb15cec3f - std::panicking::default_hook::h89eb7b752553c214
                               at /rustc/ae612bedcbfc7098d1711eb35bc7ca994eb17a4c/library/std/src/panicking.rs:292:9
  11:     0x7fdcae2ee850 - std[b87f00a22d58bbc]::panicking::update_hook::<alloc[77b1a1b708fdb7c4]::boxed::Box<rustc_driver_impl[853436051cc34aaf]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7fdcb15cf618 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h84df13128e07b6a2
                               at /rustc/ae612bedcbfc7098d1711eb35bc7ca994eb17a4c/library/alloc/src/boxed.rs:2029:9
  13:     0x7fdcb15cf618 - std::panicking::rust_panic_with_hook::hb29ddd35ba3c20d3
                               at /rustc/ae612bedcbfc7098d1711eb35bc7ca994eb17a4c/library/std/src/panicking.rs:783:13
  14:     0x7fdcb15cf36e - std::panicking::begin_panic_handler::{{closure}}::h286ad4e1f9c74532
                               at /rustc/ae612bedcbfc7098d1711eb35bc7ca994eb17a4c/library/std/src/panicking.rs:657:13
  15:     0x7fdcb15cc926 - std::sys_common::backtrace::__rust_end_short_backtrace::h511f6dfe386703fe
                               at /rustc/ae612bedcbfc7098d1711eb35bc7ca994eb17a4c/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x7fdcb15cf0d2 - rust_begin_unwind
                               at /rustc/ae612bedcbfc7098d1711eb35bc7ca994eb17a4c/library/std/src/panicking.rs:645:5
  17:     0x7fdcb161bb65 - core::panicking::panic_fmt::h7befc05beec83a23
                               at /rustc/ae612bedcbfc7098d1711eb35bc7ca994eb17a4c/library/core/src/panicking.rs:72:14
  18:     0x7fdcaedd7ca1 - <rustc_trait_selection[6a1c4ff094925b1c]::solve::eval_ctxt::EvalCtxt>::canonicalize_goal::<rustc_middle[b86048caae43f56]::ty::Predicate>
  19:     0x7fdcaeddcce1 - <rustc_trait_selection[6a1c4ff094925b1c]::solve::eval_ctxt::EvalCtxt>::evaluate_goal
  20:     0x7fdcaee4abdf - <rustc_trait_selection[6a1c4ff094925b1c]::solve::eval_ctxt::EvalCtxt>::try_evaluate_added_goals
  21:     0x7fdcaee46f85 - <rustc_trait_selection[6a1c4ff094925b1c]::solve::eval_ctxt::EvalCtxt>::try_normalize_term
  22:     0x7fdcaedec2fe - <rustc_trait_selection[6a1c4ff094925b1c]::solve::search_graph::SearchGraph>::with_new_goal::<<rustc_trait_selection[6a1c4ff094925b1c]::solve::eval_ctxt::EvalCtxt>::evaluate_canonical_goal::{closure#0}::{closure#0}::{closure#0}>::{closure#2}
  23:     0x7fdcaede99d3 - <rustc_trait_selection[6a1c4ff094925b1c]::solve::search_graph::SearchGraph>::with_new_goal::<<rustc_trait_selection[6a1c4ff094925b1c]::solve::eval_ctxt::EvalCtxt>::evaluate_canonical_goal::{closure#0}::{closure#0}::{closure#0}>
  24:     0x7fdcaeddcf9a - <rustc_trait_selection[6a1c4ff094925b1c]::solve::eval_ctxt::EvalCtxt>::evaluate_goal
  25:     0x7fdcaee4a282 - <rustc_infer[f37cdfef595741af]::infer::InferCtxt as rustc_trait_selection[6a1c4ff094925b1c]::solve::eval_ctxt::InferCtxtEvalExt>::evaluate_root_goal
  26:     0x7fdcaedde964 - <rustc_trait_selection[6a1c4ff094925b1c]::solve::fulfill::FulfillmentCtxt as rustc_infer[f37cdfef595741af]::traits::engine::TraitEngine>::select_where_possible
  27:     0x7fdcac79210b - <rustc_infer[f37cdfef595741af]::infer::InferCtxt as rustc_trait_selection[6a1c4ff094925b1c]::traits::query::evaluate_obligation::InferCtxtExt>::evaluate_obligation
  28:     0x7fdcb034cbee - rustc_trait_selection[6a1c4ff094925b1c]::traits::coherence::overlap
  29:     0x7fdcb0199c6f - rustc_trait_selection[6a1c4ff094925b1c]::traits::coherence::overlapping_impls
  30:     0x7fdcb0198f53 - <rustc_hir_analysis[b89fcc8215517ac9]::coherence::inherent_impls_overlap::InherentOverlapChecker>::check_for_overlapping_inherent_impls
  31:     0x7fdcb019776d - rustc_hir_analysis[b89fcc8215517ac9]::coherence::inherent_impls_overlap::crate_inherent_impls_overlap_check
  32:     0x7fdcb0197649 - rustc_query_impl[f69bc6cabb3ff86d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[f69bc6cabb3ff86d]::query_impl::crate_inherent_impls_overlap_check::dynamic_query::{closure#2}::{closure#0}, rustc_middle[b86048caae43f56]::query::erase::Erased<[u8; 0usize]>>
  33:     0x7fdcb019636d - rustc_query_system[642b9b293580cb87]::query::plumbing::try_execute_query::<rustc_query_impl[f69bc6cabb3ff86d]::DynamicConfig<rustc_query_system[642b9b293580cb87]::query::caches::SingleCache<rustc_middle[b86048caae43f56]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[f69bc6cabb3ff86d]::plumbing::QueryCtxt, false>
  34:     0x7fdcb01960d1 - rustc_query_impl[f69bc6cabb3ff86d]::query_impl::crate_inherent_impls_overlap_check::get_query_non_incr::__rust_end_short_backtrace
  35:     0x7fdcb005284c - rustc_hir_analysis[b89fcc8215517ac9]::check_crate
  36:     0x7fdcafec8962 - rustc_interface[404e90b0ed735256]::passes::analysis
  37:     0x7fdcafec859d - rustc_query_impl[f69bc6cabb3ff86d]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[f69bc6cabb3ff86d]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[b86048caae43f56]::query::erase::Erased<[u8; 1usize]>>
  38:     0x7fdcb0193d80 - rustc_query_system[642b9b293580cb87]::query::plumbing::try_execute_query::<rustc_query_impl[f69bc6cabb3ff86d]::DynamicConfig<rustc_query_system[642b9b293580cb87]::query::caches::SingleCache<rustc_middle[b86048caae43f56]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[f69bc6cabb3ff86d]::plumbing::QueryCtxt, false>
  39:     0x7fdcb0193b87 - rustc_query_impl[f69bc6cabb3ff86d]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  40:     0x7fdcb0625497 - rustc_interface[404e90b0ed735256]::interface::run_compiler::<core[830e0d4e2a210027]::result::Result<(), rustc_span[adf7fe9d68e4b410]::ErrorGuaranteed>, rustc_driver_impl[853436051cc34aaf]::run_compiler::{closure#0}>::{closure#0}
  41:     0x7fdcb059dc9f - std[b87f00a22d58bbc]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[404e90b0ed735256]::util::run_in_thread_with_globals<rustc_interface[404e90b0ed735256]::util::run_in_thread_pool_with_globals<rustc_interface[404e90b0ed735256]::interface::run_compiler<core[830e0d4e2a210027]::result::Result<(), rustc_span[adf7fe9d68e4b410]::ErrorGuaranteed>, rustc_driver_impl[853436051cc34aaf]::run_compiler::{closure#0}>::{closure#0}, core[830e0d4e2a210027]::result::Result<(), rustc_span[adf7fe9d68e4b410]::ErrorGuaranteed>>::{closure#0}, core[830e0d4e2a210027]::result::Result<(), rustc_span[adf7fe9d68e4b410]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[830e0d4e2a210027]::result::Result<(), rustc_span[adf7fe9d68e4b410]::ErrorGuaranteed>>
  42:     0x7fdcb059dac9 - <<std[b87f00a22d58bbc]::thread::Builder>::spawn_unchecked_<rustc_interface[404e90b0ed735256]::util::run_in_thread_with_globals<rustc_interface[404e90b0ed735256]::util::run_in_thread_pool_with_globals<rustc_interface[404e90b0ed735256]::interface::run_compiler<core[830e0d4e2a210027]::result::Result<(), rustc_span[adf7fe9d68e4b410]::ErrorGuaranteed>, rustc_driver_impl[853436051cc34aaf]::run_compiler::{closure#0}>::{closure#0}, core[830e0d4e2a210027]::result::Result<(), rustc_span[adf7fe9d68e4b410]::ErrorGuaranteed>>::{closure#0}, core[830e0d4e2a210027]::result::Result<(), rustc_span[adf7fe9d68e4b410]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[830e0d4e2a210027]::result::Result<(), rustc_span[adf7fe9d68e4b410]::ErrorGuaranteed>>::{closure#1} as core[830e0d4e2a210027]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  43:     0x7fdcb15d94a5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h5e10d53125c64acc
                               at /rustc/ae612bedcbfc7098d1711eb35bc7ca994eb17a4c/library/alloc/src/boxed.rs:2015:9
  44:     0x7fdcb15d94a5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h0041a451249f900a
                               at /rustc/ae612bedcbfc7098d1711eb35bc7ca994eb17a4c/library/alloc/src/boxed.rs:2015:9
  45:     0x7fdcb15d94a5 - std::sys::unix::thread::Thread::new::thread_start::h9579239664cc1d8d
                               at /rustc/ae612bedcbfc7098d1711eb35bc7ca994eb17a4c/library/std/src/sys/unix/thread.rs:108:17
  46:     0x7fdcab4aa9eb - <unknown>
  47:     0x7fdcab52e7cc - <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: rustc 1.76.0-nightly (ae612bedc 2023-12-08) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z trait-solver=next-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 2 previous errors

For more information about this error, try `rustc --explain E0601`.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.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.WG-trait-system-refactorThe Rustc Trait System Refactor Initiative (-Znext-solver)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions