Skip to content
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

ICE: with_negative_coherence + specialization #100191

Closed
matthiaskrgr opened this issue Aug 6, 2022 · 0 comments · Fixed by #100514
Closed

ICE: with_negative_coherence + specialization #100191

matthiaskrgr opened this issue Aug 6, 2022 · 0 comments · Fixed by #100514
Assignees
Labels
C-bug Category: This is a bug. F-specialization `#![feature(specialization)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

Seems that both these snippets trigger the same ICE
rustc ./43037.rs -Zcrate-attr="feature(with_negative_coherence)"

Code

glacier/fixed/45814.rs

#![feature(specialization)]

pub trait Trait<T> { }

default impl<T, U> Trait<T> for U { }

impl<T> Trait<<T as Iterator>::Item> for T { }

fn main() { }

Code

glacier/fixed/43037.rs

#![crate_type = "lib"]
#![feature(specialization)] // comment this line to get the expected behavior
trait X {}
trait Y: X {}
trait Z { type Assoc: Y; }
struct A<T>(T);

impl<T> Y for T where T: X {}
impl<T: X> Z for A<T> { type Assoc = T; }

// this impl is invalid, but causes an ICE anyway
impl<T> From<<A<T> as Z>::Assoc> for T {}

fn main() {}

Meta

rustc --version --verbose:

rustc 1.64.0-nightly (55f46419a 2022-08-05)
binary: rustc
commit-hash: 55f46419afd2e49acfc6be176ad4aeadaa5686d7
commit-date: 2022-08-05
host: x86_64-unknown-linux-gnu
release: 1.64.0-nightly
LLVM version: 14.0.6

Error output


Backtrace

warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes
 --> ./43037.rs:2:12
  |
2 | #![feature(specialization)] // comment this line to get the expected behavior
  |            ^^^^^^^^^^^^^^
  |
  = note: `#[warn(incomplete_features)]` on by default
  = note: see issue #31844 <https://github.com/rust-lang/rust/issues/31844> for more information
  = help: consider using `min_specialization` instead, which is more stable and complete

error: internal compiler error: compiler/rustc_trait_selection/src/traits/coherence.rs:311:25: failed to fully normalize DefId(0:16 ~ 43037[6c8e]::{impl#2}): [FulfillmentError(Obligation(predicate=Binder(TraitPredicate(<T as X>, polarity:Positive), []), depth=1),Unimplemented)]

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/55f46419afd2e49acfc6be176ad4aeadaa5686d7/compiler/rustc_errors/src/lib.rs:1392:9
stack backtrace:
   0:     0x7fc3306189f0 - std::backtrace_rs::backtrace::libunwind::trace::he1976fae853ce905
                               at /rustc/55f46419afd2e49acfc6be176ad4aeadaa5686d7/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   1:     0x7fc3306189f0 - std::backtrace_rs::backtrace::trace_unsynchronized::h3488ea444a1a69dd
                               at /rustc/55f46419afd2e49acfc6be176ad4aeadaa5686d7/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fc3306189f0 - std::sys_common::backtrace::_print_fmt::hfad550d850e72213
                               at /rustc/55f46419afd2e49acfc6be176ad4aeadaa5686d7/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7fc3306189f0 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h42d6f8c2d1e8c740
                               at /rustc/55f46419afd2e49acfc6be176ad4aeadaa5686d7/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7fc3306743bc - core::fmt::write::ha87b736d58259280
                               at /rustc/55f46419afd2e49acfc6be176ad4aeadaa5686d7/library/core/src/fmt/mod.rs:1198:17
   5:     0x7fc330609c35 - std::io::Write::write_fmt::hf60299faac9a8340
                               at /rustc/55f46419afd2e49acfc6be176ad4aeadaa5686d7/library/std/src/io/mod.rs:1672:15
   6:     0x7fc33061b6d1 - std::sys_common::backtrace::_print::h5274cd1faa558544
                               at /rustc/55f46419afd2e49acfc6be176ad4aeadaa5686d7/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7fc33061b6d1 - std::sys_common::backtrace::print::h184de4772363b29a
                               at /rustc/55f46419afd2e49acfc6be176ad4aeadaa5686d7/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7fc33061b6d1 - std::panicking::default_hook::{{closure}}::h224bcb75892e6bc7
                               at /rustc/55f46419afd2e49acfc6be176ad4aeadaa5686d7/library/std/src/panicking.rs:295:22
   9:     0x7fc33061b39e - std::panicking::default_hook::hd243a62dc6826477
                               at /rustc/55f46419afd2e49acfc6be176ad4aeadaa5686d7/library/std/src/panicking.rs:314:9
  10:     0x7fc332e93524 - rustc_driver[f6b350ee36914076]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7fc33061bf06 - std::panicking::rust_panic_with_hook::he4db359924fe7f6e
                               at /rustc/55f46419afd2e49acfc6be176ad4aeadaa5686d7/library/std/src/panicking.rs:702:17
  12:     0x7fc333e31461 - std[79962577103da855]::panicking::begin_panic::<rustc_errors[42ff641c0a7dbad8]::ExplicitBug>::{closure#0}
  13:     0x7fc333e30956 - std[79962577103da855]::sys_common::backtrace::__rust_end_short_backtrace::<std[79962577103da855]::panicking::begin_panic<rustc_errors[42ff641c0a7dbad8]::ExplicitBug>::{closure#0}, !>
  14:     0x7fc333e12a16 - std[79962577103da855]::panicking::begin_panic::<rustc_errors[42ff641c0a7dbad8]::ExplicitBug>
  15:     0x7fc333e55d36 - std[79962577103da855]::panic::panic_any::<rustc_errors[42ff641c0a7dbad8]::ExplicitBug>
  16:     0x7fc333e55b85 - <rustc_errors[42ff641c0a7dbad8]::HandlerInner>::bug::<&alloc[849470dd3c3c5534]::string::String>
  17:     0x7fc333e558e0 - <rustc_errors[42ff641c0a7dbad8]::Handler>::bug::<&alloc[849470dd3c3c5534]::string::String>
  18:     0x7fc333e7885d - rustc_middle[3ed8dbeb8d00c629]::ty::context::tls::with_context_opt::<rustc_middle[3ed8dbeb8d00c629]::ty::context::tls::with_opt<rustc_middle[3ed8dbeb8d00c629]::util::bug::opt_span_bug_fmt<rustc_span[704994f6531b2995]::span_encoding::Span>::{closure#0}, ()>::{closure#0}, ()>
  19:     0x7fc333e7b916 - rustc_middle[3ed8dbeb8d00c629]::util::bug::opt_span_bug_fmt::<rustc_span[704994f6531b2995]::span_encoding::Span>
  20:     0x7fc3318e9093 - rustc_middle[3ed8dbeb8d00c629]::util::bug::bug_fmt
  21:     0x7fc333c486a4 - <rustc_infer[8ce69979a813aa75]::infer::InferCtxtBuilder>::enter::<bool, rustc_trait_selection[8aa47ea5b5082416]::traits::coherence::negative_impl::{closure#0}>
  22:     0x7fc333d09018 - rustc_trait_selection[8aa47ea5b5082416]::traits::coherence::negative_impl
  23:     0x7fc33299e72b - rustc_trait_selection[8aa47ea5b5082416]::traits::coherence::overlap_within_probe
  24:     0x7fc33299dfa9 - <rustc_infer[8ce69979a813aa75]::infer::InferCtxt>::probe_maybe_skip_leak_check::<core[aa10b8f86cfda392]::option::Option<rustc_trait_selection[8aa47ea5b5082416]::traits::coherence::OverlapResult>, rustc_trait_selection[8aa47ea5b5082416]::traits::coherence::overlap::{closure#0}>
  25:     0x7fc3327e9861 - <rustc_infer[8ce69979a813aa75]::infer::InferCtxtBuilder>::enter::<bool, rustc_trait_selection[8aa47ea5b5082416]::traits::coherence::overlapping_impls<<rustc_middle[3ed8dbeb8d00c629]::traits::specialization_graph::Children as rustc_trait_selection[8aa47ea5b5082416]::traits::specialize::specialization_graph::ChildrenExt>::insert::{closure#2}, <rustc_middle[3ed8dbeb8d00c629]::traits::specialization_graph::Children as rustc_trait_selection[8aa47ea5b5082416]::traits::specialize::specialization_graph::ChildrenExt>::insert::{closure#3}, core[aa10b8f86cfda392]::result::Result<(bool, bool), rustc_trait_selection[8aa47ea5b5082416]::traits::specialize::OverlapError>>::{closure#1}>
  26:     0x7fc3327e7a1c - <rustc_middle[3ed8dbeb8d00c629]::traits::specialization_graph::Children as rustc_trait_selection[8aa47ea5b5082416]::traits::specialize::specialization_graph::ChildrenExt>::insert
  27:     0x7fc3327e4b64 - <rustc_middle[3ed8dbeb8d00c629]::traits::specialization_graph::Graph as rustc_trait_selection[8aa47ea5b5082416]::traits::specialize::specialization_graph::GraphExt>::insert
  28:     0x7fc3327e3e28 - rustc_trait_selection[8aa47ea5b5082416]::traits::specialize::specialization_graph_provider
  29:     0x7fc332784e5a - rustc_query_system[cefe79c3038533a5]::query::plumbing::try_execute_query::<rustc_query_impl[40b4f3c979e2ab16]::plumbing::QueryCtxt, rustc_query_system[cefe79c3038533a5]::query::caches::ArenaCache<rustc_span[704994f6531b2995]::def_id::DefId, rustc_middle[3ed8dbeb8d00c629]::traits::specialization_graph::Graph>>
  30:     0x7fc332784af9 - rustc_query_system[cefe79c3038533a5]::query::plumbing::get_query::<rustc_query_impl[40b4f3c979e2ab16]::queries::specialization_graph_of, rustc_query_impl[40b4f3c979e2ab16]::plumbing::QueryCtxt>
  31:     0x7fc3325ab848 - rustc_typeck[e4000634b4fd5083]::coherence::coherent_trait
  32:     0x7fc3322dc4f5 - rustc_query_system[cefe79c3038533a5]::query::plumbing::try_execute_query::<rustc_query_impl[40b4f3c979e2ab16]::plumbing::QueryCtxt, rustc_query_system[cefe79c3038533a5]::query::caches::DefaultCache<rustc_span[704994f6531b2995]::def_id::DefId, ()>>
  33:     0x7fc332860692 - rustc_query_system[cefe79c3038533a5]::query::plumbing::get_query::<rustc_query_impl[40b4f3c979e2ab16]::queries::coherent_trait, rustc_query_impl[40b4f3c979e2ab16]::plumbing::QueryCtxt>
  34:     0x7fc332872739 - <rustc_session[aa654962c49ecbb3]::session::Session>::track_errors::<rustc_typeck[e4000634b4fd5083]::check_crate::{closure#3}, ()>
  35:     0x7fc33286e7cf - rustc_typeck[e4000634b4fd5083]::check_crate
  36:     0x7fc33286de97 - rustc_interface[1d8565b9d7e787d1]::passes::analysis
  37:     0x7fc332c21c15 - rustc_query_system[cefe79c3038533a5]::query::plumbing::try_execute_query::<rustc_query_impl[40b4f3c979e2ab16]::plumbing::QueryCtxt, rustc_query_system[cefe79c3038533a5]::query::caches::DefaultCache<(), core[aa10b8f86cfda392]::result::Result<(), rustc_errors[42ff641c0a7dbad8]::ErrorGuaranteed>>>
  38:     0x7fc332c2199e - rustc_query_system[cefe79c3038533a5]::query::plumbing::get_query::<rustc_query_impl[40b4f3c979e2ab16]::queries::analysis, rustc_query_impl[40b4f3c979e2ab16]::plumbing::QueryCtxt>
  39:     0x7fc33267130a - <rustc_interface[1d8565b9d7e787d1]::interface::Compiler>::enter::<rustc_driver[f6b350ee36914076]::run_compiler::{closure#1}::{closure#2}, core[aa10b8f86cfda392]::result::Result<core[aa10b8f86cfda392]::option::Option<rustc_interface[1d8565b9d7e787d1]::queries::Linker>, rustc_errors[42ff641c0a7dbad8]::ErrorGuaranteed>>
  40:     0x7fc332664d2a - rustc_span[704994f6531b2995]::with_source_map::<core[aa10b8f86cfda392]::result::Result<(), rustc_errors[42ff641c0a7dbad8]::ErrorGuaranteed>, rustc_interface[1d8565b9d7e787d1]::interface::create_compiler_and_run<core[aa10b8f86cfda392]::result::Result<(), rustc_errors[42ff641c0a7dbad8]::ErrorGuaranteed>, rustc_driver[f6b350ee36914076]::run_compiler::{closure#1}>::{closure#1}>
  41:     0x7fc332664700 - rustc_interface[1d8565b9d7e787d1]::interface::create_compiler_and_run::<core[aa10b8f86cfda392]::result::Result<(), rustc_errors[42ff641c0a7dbad8]::ErrorGuaranteed>, rustc_driver[f6b350ee36914076]::run_compiler::{closure#1}>
  42:     0x7fc332662a71 - <scoped_tls[fc5e344a71e03ad0]::ScopedKey<rustc_span[704994f6531b2995]::SessionGlobals>>::set::<rustc_interface[1d8565b9d7e787d1]::interface::run_compiler<core[aa10b8f86cfda392]::result::Result<(), rustc_errors[42ff641c0a7dbad8]::ErrorGuaranteed>, rustc_driver[f6b350ee36914076]::run_compiler::{closure#1}>::{closure#0}, core[aa10b8f86cfda392]::result::Result<(), rustc_errors[42ff641c0a7dbad8]::ErrorGuaranteed>>
  43:     0x7fc33266275f - std[79962577103da855]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[1d8565b9d7e787d1]::util::run_in_thread_pool_with_globals<rustc_interface[1d8565b9d7e787d1]::interface::run_compiler<core[aa10b8f86cfda392]::result::Result<(), rustc_errors[42ff641c0a7dbad8]::ErrorGuaranteed>, rustc_driver[f6b350ee36914076]::run_compiler::{closure#1}>::{closure#0}, core[aa10b8f86cfda392]::result::Result<(), rustc_errors[42ff641c0a7dbad8]::ErrorGuaranteed>>::{closure#0}, core[aa10b8f86cfda392]::result::Result<(), rustc_errors[42ff641c0a7dbad8]::ErrorGuaranteed>>
  44:     0x7fc332cb5759 - <<std[79962577103da855]::thread::Builder>::spawn_unchecked_<rustc_interface[1d8565b9d7e787d1]::util::run_in_thread_pool_with_globals<rustc_interface[1d8565b9d7e787d1]::interface::run_compiler<core[aa10b8f86cfda392]::result::Result<(), rustc_errors[42ff641c0a7dbad8]::ErrorGuaranteed>, rustc_driver[f6b350ee36914076]::run_compiler::{closure#1}>::{closure#0}, core[aa10b8f86cfda392]::result::Result<(), rustc_errors[42ff641c0a7dbad8]::ErrorGuaranteed>>::{closure#0}, core[aa10b8f86cfda392]::result::Result<(), rustc_errors[42ff641c0a7dbad8]::ErrorGuaranteed>>::{closure#1} as core[aa10b8f86cfda392]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  45:     0x7fc330625ed3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h8951f5312048b23c
                               at /rustc/55f46419afd2e49acfc6be176ad4aeadaa5686d7/library/alloc/src/boxed.rs:1935:9
  46:     0x7fc330625ed3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h45d7e719250fdc91
                               at /rustc/55f46419afd2e49acfc6be176ad4aeadaa5686d7/library/alloc/src/boxed.rs:1935:9
  47:     0x7fc330625ed3 - std::sys::unix::thread::Thread::new::thread_start::h865a7bb40e742e03
                               at /rustc/55f46419afd2e49acfc6be176ad4aeadaa5686d7/library/std/src/sys/unix/thread.rs:108:17
  48:     0x7fc33036454d - <unknown>
  49:     0x7fc3303e9874 - clone
  50:                0x0 - <unknown>

note: 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.64.0-nightly (55f46419a 2022-08-05) running on x86_64-unknown-linux-gnu

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

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 previous error; 1 warning emitted

@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 Aug 6, 2022
@matthiaskrgr matthiaskrgr changed the title ICE: with_negative_coherence and specialization ICE: with_negative_coherence + specialization Aug 6, 2022
@matthiaskrgr matthiaskrgr added requires-nightly This issue requires a nightly compiler in some way. F-specialization `#![feature(specialization)]` labels Aug 6, 2022
@compiler-errors compiler-errors self-assigned this Aug 13, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Aug 15, 2022
…astorino

Delay span bug when failing to normalize negative coherence impl subject due to other malformed impls

Fixes rust-lang#100191

r? `@spastorino`
@bors bors closed this as completed in a1fdea2 Aug 15, 2022
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. F-specialization `#![feature(specialization)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
2 participants