Skip to content

ICE: None in canonicalizer No 2 #120026

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

Closed
matthiaskrgr opened this issue Jan 16, 2024 · 3 comments
Closed

ICE: None in canonicalizer No 2 #120026

matthiaskrgr opened this issue Jan 16, 2024 · 3 comments
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

auto-reduced (treereduce-rust):

struct GenericStruct<const MY_NUM: usize> {
    val: i64,
}

impl<const T: u128> From<GenericStruct<T>> for GenericStruct<{}> {}

#![feature(with_negative_coherence)]

original:

// check-pass

#![feature(generic_const_exprs)]
#![allow(incomplete_features)]

struct GenericStruct<const MY_NUM: usize> { val: i64 }

impl<const T: u128> From<GenericStruct<T>> for GenericStruct<{STRATEGIES + 1}> {
    fn from(arr: [i32; X]) -> Self {
        Self { ptr: core::ptr::NonNull::new(dst as *mut _).unwrap() }
    }
}

impl<const ShortName: char> From<GenericStruct<{T + 1}>> for GenericStruct<T> {
    fn from(other: ErrTy<{T + 1}>) -> Self {
        Arr { _offset_type: PhantomData }
    }
}

fn main(value: Struct<3>) {}

Version information

rustc 1.77.0-nightly (714b29a17 2024-01-15)
binary: rustc
commit-hash: 714b29a17ff5fa727c794bbb60bfd335f8e75d42
commit-date: 2024-01-15
host: x86_64-unknown-linux-gnu
release: 1.77.0-nightly
LLVM version: 17.0.6

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

Program output

error[E0601]: `main` function not found in crate `mvce`
 --> /tmp/icemaker_global_tempdir.00CvHgbV6yYt/rustc_testrunner_tmpdir_reporting.dJfPsRLu2SA2/mvce.rs:5:68
  |
5 | impl<const T: u128> From<GenericStruct<T>> for GenericStruct<{}> {}
  |                                                                    ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.00CvHgbV6yYt/rustc_testrunner_tmpdir_reporting.dJfPsRLu2SA2/mvce.rs`

thread 'rustc' panicked at compiler/rustc_infer/src/infer/canonical/canonicalizer.rs:340:43:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0:     0x7f635e58b9c6 - std::backtrace_rs::backtrace::libunwind::trace::h68ecfa0f2c969689
                               at /rustc/714b29a17ff5fa727c794bbb60bfd335f8e75d42/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7f635e58b9c6 - std::backtrace_rs::backtrace::trace_unsynchronized::h77ca2776e0b6e626
                               at /rustc/714b29a17ff5fa727c794bbb60bfd335f8e75d42/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f635e58b9c6 - std::sys_common::backtrace::_print_fmt::h044f2cf8b72c077b
                               at /rustc/714b29a17ff5fa727c794bbb60bfd335f8e75d42/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7f635e58b9c6 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hf037d8d5f0fed317
                               at /rustc/714b29a17ff5fa727c794bbb60bfd335f8e75d42/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f635e5de060 - core::fmt::rt::Argument::fmt::h9dade43a98a44f26
                               at /rustc/714b29a17ff5fa727c794bbb60bfd335f8e75d42/library/core/src/fmt/rt.rs:142:9
   5:     0x7f635e5de060 - core::fmt::write::h2fca794570843be9
                               at /rustc/714b29a17ff5fa727c794bbb60bfd335f8e75d42/library/core/src/fmt/mod.rs:1120:17
   6:     0x7f635e57f38f - std::io::Write::write_fmt::h5f8008b3be3c0c06
                               at /rustc/714b29a17ff5fa727c794bbb60bfd335f8e75d42/library/std/src/io/mod.rs:1810:15
   7:     0x7f635e58b7a4 - std::sys_common::backtrace::_print::hfa47f5118fe40221
                               at /rustc/714b29a17ff5fa727c794bbb60bfd335f8e75d42/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f635e58b7a4 - std::sys_common::backtrace::print::h74bcc7d48499a21b
                               at /rustc/714b29a17ff5fa727c794bbb60bfd335f8e75d42/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f635e58e537 - std::panicking::default_hook::{{closure}}::hd53944ed65fb9ecb
  10:     0x7f635e58e299 - std::panicking::default_hook::h57d73aee3a23c899
                               at /rustc/714b29a17ff5fa727c794bbb60bfd335f8e75d42/library/std/src/panicking.rs:292:9
  11:     0x7f636136a49c - std[de653b49f04fe422]::panicking::update_hook::<alloc[94ed51b0c544c1d5]::boxed::Box<rustc_driver_impl[21982365783ec637]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7f635e58ec86 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h960b4868dc7033dc
                               at /rustc/714b29a17ff5fa727c794bbb60bfd335f8e75d42/library/alloc/src/boxed.rs:2030:9
  13:     0x7f635e58ec86 - std::panicking::rust_panic_with_hook::h20146c2704dd1451
                               at /rustc/714b29a17ff5fa727c794bbb60bfd335f8e75d42/library/std/src/panicking.rs:785:13
  14:     0x7f635e58e999 - std::panicking::begin_panic_handler::{{closure}}::h8e60d095569a7fc5
                               at /rustc/714b29a17ff5fa727c794bbb60bfd335f8e75d42/library/std/src/panicking.rs:651:13
  15:     0x7f635e58bec6 - std::sys_common::backtrace::__rust_end_short_backtrace::h7348f833ddbcadc6
                               at /rustc/714b29a17ff5fa727c794bbb60bfd335f8e75d42/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x7f635e58e730 - rust_begin_unwind
                               at /rustc/714b29a17ff5fa727c794bbb60bfd335f8e75d42/library/std/src/panicking.rs:647:5
  17:     0x7f635e5da765 - core::panicking::panic_fmt::ha18faad21ed34f33
                               at /rustc/714b29a17ff5fa727c794bbb60bfd335f8e75d42/library/core/src/panicking.rs:72:14
  18:     0x7f635e5da823 - core::panicking::panic::he6e0d1747038b1c9
                               at /rustc/714b29a17ff5fa727c794bbb60bfd335f8e75d42/library/core/src/panicking.rs:144:5
  19:     0x7f635f615e85 - <rustc_infer[e76d6447cdd5d740]::infer::canonical::canonicalizer::Canonicalizer as rustc_type_ir[7ceeecbfe5864a06]::fold::TypeFolder<rustc_middle[bb2e9fbab7070ad5]::ty::context::TyCtxt>>::fold_ty
  20:     0x7f636296c1f1 - <&rustc_middle[bb2e9fbab7070ad5]::ty::list::List<rustc_middle[bb2e9fbab7070ad5]::ty::generic_args::GenericArg> as rustc_type_ir[7ceeecbfe5864a06]::fold::TypeFoldable<rustc_middle[bb2e9fbab7070ad5]::ty::context::TyCtxt>>::try_fold_with::<rustc_infer[e76d6447cdd5d740]::infer::canonical::canonicalizer::Canonicalizer>
  21:     0x7f63615ddecb - <rustc_middle[bb2e9fbab7070ad5]::ty::Clause as rustc_type_ir[7ceeecbfe5864a06]::fold::TypeFoldable<rustc_middle[bb2e9fbab7070ad5]::ty::context::TyCtxt>>::try_fold_with::<rustc_infer[e76d6447cdd5d740]::infer::canonical::canonicalizer::Canonicalizer>
  22:     0x7f6361600cd4 - <<rustc_infer[e76d6447cdd5d740]::infer::InferCtxt>::canonicalize_query<(rustc_middle[bb2e9fbab7070ad5]::ty::Ty, rustc_middle[bb2e9fbab7070ad5]::ty::Ty)>::{closure#0} as core[f4fe56fc1188d523]::ops::function::FnOnce<(rustc_middle[bb2e9fbab7070ad5]::ty::context::TyCtxt, rustc_middle[bb2e9fbab7070ad5]::ty::ParamEnv, &mut rustc_middle[bb2e9fbab7070ad5]::infer::canonical::OriginalQueryValues)>>::call_once
  23:     0x7f6362755eeb - <rustc_middle[bb2e9fbab7070ad5]::infer::canonical::CanonicalParamEnvCache>::get_or_insert
  24:     0x7f636160ad78 - <rustc_infer[e76d6447cdd5d740]::infer::InferCtxt>::canonicalize_query::<(rustc_middle[bb2e9fbab7070ad5]::ty::Ty, rustc_middle[bb2e9fbab7070ad5]::ty::Ty)>
  25:     0x7f63626ac4ba - <rustc_infer[e76d6447cdd5d740]::infer::InferCtxt>::super_combine_tys::<rustc_infer[e76d6447cdd5d740]::infer::relate::equate::Equate>
  26:     0x7f636269ee68 - <rustc_infer[e76d6447cdd5d740]::infer::relate::equate::Equate as rustc_middle[bb2e9fbab7070ad5]::ty::relate::TypeRelation>::tys
  27:     0x7f6362cc403a - <rustc_infer[e76d6447cdd5d740]::infer::at::At>::eq::<rustc_middle[bb2e9fbab7070ad5]::ty::sty::TraitRef>
  28:     0x7f6362cc381f - rustc_trait_selection[db6417cdd09814d6]::traits::coherence::equate_impl_headers
  29:     0x7f6361e31540 - rustc_trait_selection[db6417cdd09814d6]::traits::coherence::impl_intersection_has_negative_obligation
  30:     0x7f6362cc501d - rustc_trait_selection[db6417cdd09814d6]::traits::coherence::overlap
  31:     0x7f6362cf609a - <rustc_middle[bb2e9fbab7070ad5]::traits::specialization_graph::Children as rustc_trait_selection[db6417cdd09814d6]::traits::specialize::specialization_graph::ChildrenExt>::insert
  32:     0x7f6362cf5604 - <rustc_middle[bb2e9fbab7070ad5]::traits::specialization_graph::Graph as rustc_trait_selection[db6417cdd09814d6]::traits::specialize::specialization_graph::GraphExt>::insert
  33:     0x7f63631626cd - rustc_trait_selection[db6417cdd09814d6]::traits::specialize::specialization_graph_provider
  34:     0x7f636316214f - rustc_query_impl[b2bfeeafe4fe0b01]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[b2bfeeafe4fe0b01]::query_impl::specialization_graph_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[bb2e9fbab7070ad5]::query::erase::Erased<[u8; 8usize]>>
  35:     0x7f636267df54 - rustc_query_system[5a3baadd8f1c36f2]::query::plumbing::try_execute_query::<rustc_query_impl[b2bfeeafe4fe0b01]::DynamicConfig<rustc_query_system[5a3baadd8f1c36f2]::query::caches::DefaultCache<rustc_span[352188020ae4ad5]::def_id::DefId, rustc_middle[bb2e9fbab7070ad5]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[b2bfeeafe4fe0b01]::plumbing::QueryCtxt, false>
  36:     0x7f636276bede - rustc_query_impl[b2bfeeafe4fe0b01]::query_impl::specialization_graph_of::get_query_non_incr::__rust_end_short_backtrace
  37:     0x7f6363083aa5 - rustc_hir_analysis[11666cb28e0c936a]::coherence::coherent_trait
  38:     0x7f6363083999 - rustc_query_impl[b2bfeeafe4fe0b01]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[b2bfeeafe4fe0b01]::query_impl::coherent_trait::dynamic_query::{closure#2}::{closure#0}, rustc_middle[bb2e9fbab7070ad5]::query::erase::Erased<[u8; 0usize]>>
  39:     0x7f6363082c3d - rustc_query_system[5a3baadd8f1c36f2]::query::plumbing::try_execute_query::<rustc_query_impl[b2bfeeafe4fe0b01]::DynamicConfig<rustc_query_system[5a3baadd8f1c36f2]::query::caches::DefaultCache<rustc_span[352188020ae4ad5]::def_id::DefId, rustc_middle[bb2e9fbab7070ad5]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[b2bfeeafe4fe0b01]::plumbing::QueryCtxt, false>
  40:     0x7f63630829cd - rustc_query_impl[b2bfeeafe4fe0b01]::query_impl::coherent_trait::get_query_non_incr::__rust_end_short_backtrace
  41:     0x7f6362c56b29 - rustc_hir_analysis[11666cb28e0c936a]::check_crate
  42:     0x7f6363242a99 - rustc_interface[21c8752f1ec28fc7]::passes::analysis
  43:     0x7f63632426df - rustc_query_impl[b2bfeeafe4fe0b01]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[b2bfeeafe4fe0b01]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[bb2e9fbab7070ad5]::query::erase::Erased<[u8; 1usize]>>
  44:     0x7f63635c4140 - rustc_query_system[5a3baadd8f1c36f2]::query::plumbing::try_execute_query::<rustc_query_impl[b2bfeeafe4fe0b01]::DynamicConfig<rustc_query_system[5a3baadd8f1c36f2]::query::caches::SingleCache<rustc_middle[bb2e9fbab7070ad5]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[b2bfeeafe4fe0b01]::plumbing::QueryCtxt, false>
  45:     0x7f63635c3f47 - rustc_query_impl[b2bfeeafe4fe0b01]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  46:     0x7f636331d9ad - rustc_interface[21c8752f1ec28fc7]::interface::run_compiler::<core[f4fe56fc1188d523]::result::Result<(), rustc_span[352188020ae4ad5]::ErrorGuaranteed>, rustc_driver_impl[21982365783ec637]::run_compiler::{closure#0}>::{closure#0}
  47:     0x7f63635f0f46 - std[de653b49f04fe422]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[21c8752f1ec28fc7]::util::run_in_thread_with_globals<rustc_interface[21c8752f1ec28fc7]::util::run_in_thread_pool_with_globals<rustc_interface[21c8752f1ec28fc7]::interface::run_compiler<core[f4fe56fc1188d523]::result::Result<(), rustc_span[352188020ae4ad5]::ErrorGuaranteed>, rustc_driver_impl[21982365783ec637]::run_compiler::{closure#0}>::{closure#0}, core[f4fe56fc1188d523]::result::Result<(), rustc_span[352188020ae4ad5]::ErrorGuaranteed>>::{closure#0}, core[f4fe56fc1188d523]::result::Result<(), rustc_span[352188020ae4ad5]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[f4fe56fc1188d523]::result::Result<(), rustc_span[352188020ae4ad5]::ErrorGuaranteed>>
  48:     0x7f63635f0d73 - <<std[de653b49f04fe422]::thread::Builder>::spawn_unchecked_<rustc_interface[21c8752f1ec28fc7]::util::run_in_thread_with_globals<rustc_interface[21c8752f1ec28fc7]::util::run_in_thread_pool_with_globals<rustc_interface[21c8752f1ec28fc7]::interface::run_compiler<core[f4fe56fc1188d523]::result::Result<(), rustc_span[352188020ae4ad5]::ErrorGuaranteed>, rustc_driver_impl[21982365783ec637]::run_compiler::{closure#0}>::{closure#0}, core[f4fe56fc1188d523]::result::Result<(), rustc_span[352188020ae4ad5]::ErrorGuaranteed>>::{closure#0}, core[f4fe56fc1188d523]::result::Result<(), rustc_span[352188020ae4ad5]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[f4fe56fc1188d523]::result::Result<(), rustc_span[352188020ae4ad5]::ErrorGuaranteed>>::{closure#1} as core[f4fe56fc1188d523]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  49:     0x7f635e598535 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h0f19092afcc582b7
                               at /rustc/714b29a17ff5fa727c794bbb60bfd335f8e75d42/library/alloc/src/boxed.rs:2016:9
  50:     0x7f635e598535 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h66aa5d72edb49fb4
                               at /rustc/714b29a17ff5fa727c794bbb60bfd335f8e75d42/library/alloc/src/boxed.rs:2016:9
  51:     0x7f635e598535 - std::sys::pal::unix::thread::Thread::new::thread_start::h63b8d4dfd3f92e2e
                               at /rustc/714b29a17ff5fa727c794bbb60bfd335f8e75d42/library/std/src/sys/pal/unix/thread.rs:108:17
  52:     0x7f635e34e9eb - <unknown>
  53:     0x7f635e3d27cc - <unknown>
  54:                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.77.0-nightly (714b29a17 2024-01-15) running on x86_64-unknown-linux-gnu

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

query stack during panic:
#0 [specialization_graph_of] building specialization graph of trait `core::convert::From`
#1 [coherent_trait] coherence checking all impls of trait `core::convert::From`
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 1 previous error

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

@matthiaskrgr matthiaskrgr added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. labels Jan 16, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 16, 2024
@compiler-errors
Copy link
Member

Yeah this is a dupe of #119381. Same root cause as that one. I like this mini repro better so I'll copy it over to that.

Also, if you're gonna name something "No 2", then could you please link to whatever you consider is "No 1"? Just easier to cross-reference things like that, even if you're not totally sure it's the same issue.

@compiler-errors compiler-errors closed this as not planned Won't fix, can't repro, duplicate, stale Jan 16, 2024
@matthiaskrgr
Copy link
Member Author

Are you sure? They seem to hit different unwraps().

@compiler-errors
Copy link
Member

Yes, they both have to do with this call:

let canonical = self.canonicalize_query(

The stack frame is just truncated here due to inlining or whatever.

@fmease fmease removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants