Skip to content

ICE: "region constraints already solved'": with_negative_coherence #99662

Description

@matthiaskrgr

Code

./src/test/ui/coherence/coherence-negative-outlives-lifetimes.rs

#![feature(negative_impls)]

// FIXME: this should compile

trait MyPredicate<'a> {}
impl<'a, T> !MyPredicate<'a> for &T where T: 'a {}
trait MyTrait<'a> {}
impl<'a, T: MyPredicate<'a>> MyTrait<'a> for T {}
impl<'a, T> MyTrait<'a> for &'a T {}
//~^ ERROR: conflicting implementations of trait `MyTrait<'_>` for type `&_`

fn main() {}

Meta

rustc --version --verbose:

rustc 1.64.0-nightly (93ffde6f0 2022-07-23)
binary: rustc
commit-hash: 93ffde6f04d3d24327a4e17a2a2bf4f63c246235
commit-date: 2022-07-23
host: x86_64-unknown-linux-gnu
release: 1.64.0-nightly
LLVM version: 14.0.6

Error output

rustc ./src/test/ui/coherence/coherence-negative-outlives-lifetimes.rs "-Zcrate-attr=feature(with_negative_coherence)"

<output>
Backtrace

thread 'rustc' panicked at 'region constraints already solved', compiler/rustc_infer/src/infer/mod.rs:235:9
stack backtrace:
   0:     0x7fabb70a37a0 - std::backtrace_rs::backtrace::libunwind::trace::h763ecd2b1c94eb47
                               at /rustc/93ffde6f04d3d24327a4e17a2a2bf4f63c246235/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   1:     0x7fabb70a37a0 - std::backtrace_rs::backtrace::trace_unsynchronized::h7346e33da5e91dc9
                               at /rustc/93ffde6f04d3d24327a4e17a2a2bf4f63c246235/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fabb70a37a0 - std::sys_common::backtrace::_print_fmt::h8ca9befc16375e7f
                               at /rustc/93ffde6f04d3d24327a4e17a2a2bf4f63c246235/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7fabb70a37a0 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h35a76e8acc949815
                               at /rustc/93ffde6f04d3d24327a4e17a2a2bf4f63c246235/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7fabb70fda2c - core::fmt::write::h1966177bbb3b1b76
                               at /rustc/93ffde6f04d3d24327a4e17a2a2bf4f63c246235/library/core/src/fmt/mod.rs:1198:17
   5:     0x7fabb7094f85 - std::io::Write::write_fmt::he17142a652adbfaa
                               at /rustc/93ffde6f04d3d24327a4e17a2a2bf4f63c246235/library/std/src/io/mod.rs:1672:15
   6:     0x7fabb70a6471 - std::sys_common::backtrace::_print::h58fd682547bc6ff7
                               at /rustc/93ffde6f04d3d24327a4e17a2a2bf4f63c246235/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7fabb70a6471 - std::sys_common::backtrace::print::hb71ddfedfd79ba3f
                               at /rustc/93ffde6f04d3d24327a4e17a2a2bf4f63c246235/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7fabb70a6471 - std::panicking::default_hook::{{closure}}::h866ffdcbb9391663
                               at /rustc/93ffde6f04d3d24327a4e17a2a2bf4f63c246235/library/std/src/panicking.rs:295:22
   9:     0x7fabb70a6143 - std::panicking::default_hook::hc53d610bee87e7b5
                               at /rustc/93ffde6f04d3d24327a4e17a2a2bf4f63c246235/library/std/src/panicking.rs:314:9
  10:     0x7fabb7953731 - rustc_driver[ee492072531d29b9]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7fabb70a6c46 - std::panicking::rust_panic_with_hook::h1f2457f8494b1ce0
                               at /rustc/93ffde6f04d3d24327a4e17a2a2bf4f63c246235/library/std/src/panicking.rs:702:17
  12:     0x7fabb70a6a97 - std::panicking::begin_panic_handler::{{closure}}::h84de84c919a48b08
                               at /rustc/93ffde6f04d3d24327a4e17a2a2bf4f63c246235/library/std/src/panicking.rs:588:13
  13:     0x7fabb70a3cc4 - std::sys_common::backtrace::__rust_end_short_backtrace::h50976962eb12c97a
                               at /rustc/93ffde6f04d3d24327a4e17a2a2bf4f63c246235/library/std/src/sys_common/backtrace.rs:138:18
  14:     0x7fabb70a67c2 - rust_begin_unwind
                               at /rustc/93ffde6f04d3d24327a4e17a2a2bf4f63c246235/library/std/src/panicking.rs:584:5
  15:     0x7fabb7069b63 - core::panicking::panic_fmt::hb7aeecf8ae8bdd28
                               at /rustc/93ffde6f04d3d24327a4e17a2a2bf4f63c246235/library/core/src/panicking.rs:142:14
  16:     0x7fabb70fa651 - core::panicking::panic_display::h8a507b84231c6858
                               at /rustc/93ffde6f04d3d24327a4e17a2a2bf4f63c246235/library/core/src/panicking.rs:72:5
  17:     0x7fabb70fa5fb - core::panicking::panic_str::he42b786850f072a3
                               at /rustc/93ffde6f04d3d24327a4e17a2a2bf4f63c246235/library/core/src/panicking.rs:56:5
  18:     0x7fabb70699d6 - core::option::expect_failed::h87ab6556ec5701cd
                               at /rustc/93ffde6f04d3d24327a4e17a2a2bf4f63c246235/library/core/src/option.rs:1874:5
  19:     0x7fabb98d048d - <rustc_infer[bfbf07e5440e77e9]::infer::InferCtxt>::start_snapshot
  20:     0x7fabb989471a - <rustc_middle[ba567b0c63397382]::ty::context::TyCtxt>::for_each_relevant_impl::<<rustc_trait_selection[620490483a22fe27]::traits::select::SelectionContext>::assemble_candidates_from_impls::{closure#0}>
  21:     0x7fabb88151dc - <rustc_trait_selection[620490483a22fe27]::traits::select::SelectionContext>::assemble_candidates_from_impls
  22:     0x7fabb9815a82 - <rustc_trait_selection[620490483a22fe27]::traits::select::SelectionContext>::assemble_candidates
  23:     0x7fabb9801b41 - <rustc_trait_selection[620490483a22fe27]::traits::select::SelectionContext>::candidate_from_obligation_no_cache
  24:     0x7fabb98232e0 - <rustc_trait_selection[620490483a22fe27]::traits::select::SelectionContext>::select
  25:     0x7fabb986b388 - <rustc_trait_selection[620490483a22fe27]::traits::fulfill::FulfillProcessor as rustc_data_structures[c16dd9bc0e209753]::obligation_forest::ObligationProcessor>::process_obligation
  26:     0x7fabb98917fe - <rustc_data_structures[c16dd9bc0e209753]::obligation_forest::ObligationForest<rustc_trait_selection[620490483a22fe27]::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection[620490483a22fe27]::traits::fulfill::FulfillProcessor, rustc_data_structures[c16dd9bc0e209753]::obligation_forest::Outcome<rustc_trait_selection[620490483a22fe27]::traits::fulfill::PendingPredicateObligation, rustc_infer[bfbf07e5440e77e9]::traits::FulfillmentErrorCode>>
  27:     0x7fabb98664ea - <rustc_trait_selection[620490483a22fe27]::traits::fulfill::FulfillmentContext as rustc_infer[bfbf07e5440e77e9]::traits::engine::TraitEngine>::select_all_or_error
  28:     0x7fabb8896bfa - rustc_trait_selection[620490483a22fe27]::traits::coherence::resolve_negative_obligation
  29:     0x7fabb88960ec - rustc_trait_selection[620490483a22fe27]::traits::coherence::equate::<core[7b47b893e00d8dca]::iter::adapters::chain::Chain<core[7b47b893e00d8dca]::iter::adapters::chain::Chain<core[7b47b893e00d8dca]::iter::adapters::map::Map<core[7b47b893e00d8dca]::iter::adapters::zip::Zip<alloc[327c298d5f7f3986]::vec::into_iter::IntoIter<rustc_middle[ba567b0c63397382]::ty::Predicate>, alloc[327c298d5f7f3986]::vec::into_iter::IntoIter<rustc_span[e8a062c38fd06fcf]::span_encoding::Span>>, rustc_trait_selection[620490483a22fe27]::traits::util::predicates_for_generics::{closure#0}>, alloc[327c298d5f7f3986]::vec::into_iter::IntoIter<rustc_infer[bfbf07e5440e77e9]::traits::Obligation<rustc_middle[ba567b0c63397382]::ty::Predicate>>>, alloc[327c298d5f7f3986]::vec::into_iter::IntoIter<rustc_infer[bfbf07e5440e77e9]::traits::Obligation<rustc_middle[ba567b0c63397382]::ty::Predicate>>>>::{closure#0}
  30:     0x7fabb884d082 - <core[7b47b893e00d8dca]::iter::adapters::map::Map<core[7b47b893e00d8dca]::iter::adapters::zip::Zip<alloc[327c298d5f7f3986]::vec::into_iter::IntoIter<rustc_middle[ba567b0c63397382]::ty::Predicate>, alloc[327c298d5f7f3986]::vec::into_iter::IntoIter<rustc_span[e8a062c38fd06fcf]::span_encoding::Span>>, rustc_trait_selection[620490483a22fe27]::traits::util::predicates_for_generics::{closure#0}> as core[7b47b893e00d8dca]::iter::traits::iterator::Iterator>::try_fold::<(), core[7b47b893e00d8dca]::iter::traits::iterator::Iterator::find::check<rustc_infer[bfbf07e5440e77e9]::traits::Obligation<rustc_middle[ba567b0c63397382]::ty::Predicate>, &mut &mut &mut rustc_trait_selection[620490483a22fe27]::traits::coherence::equate<core[7b47b893e00d8dca]::iter::adapters::chain::Chain<core[7b47b893e00d8dca]::iter::adapters::chain::Chain<core[7b47b893e00d8dca]::iter::adapters::map::Map<core[7b47b893e00d8dca]::iter::adapters::zip::Zip<alloc[327c298d5f7f3986]::vec::into_iter::IntoIter<rustc_middle[ba567b0c63397382]::ty::Predicate>, alloc[327c298d5f7f3986]::vec::into_iter::IntoIter<rustc_span[e8a062c38fd06fcf]::span_encoding::Span>>, rustc_trait_selection[620490483a22fe27]::traits::util::predicates_for_generics::{closure#0}>, alloc[327c298d5f7f3986]::vec::into_iter::IntoIter<rustc_infer[bfbf07e5440e77e9]::traits::Obligation<rustc_middle[ba567b0c63397382]::ty::Predicate>>>, alloc[327c298d5f7f3986]::vec::into_iter::IntoIter<rustc_infer[bfbf07e5440e77e9]::traits::Obligation<rustc_middle[ba567b0c63397382]::ty::Predicate>>>>::{closure#0}>::{closure#0}, core[7b47b893e00d8dca]::ops::control_flow::ControlFlow<rustc_infer[bfbf07e5440e77e9]::traits::Obligation<rustc_middle[ba567b0c63397382]::ty::Predicate>>>
  31:     0x7fabb8895b22 - rustc_trait_selection[620490483a22fe27]::traits::coherence::equate::<core[7b47b893e00d8dca]::iter::adapters::chain::Chain<core[7b47b893e00d8dca]::iter::adapters::chain::Chain<core[7b47b893e00d8dca]::iter::adapters::map::Map<core[7b47b893e00d8dca]::iter::adapters::zip::Zip<alloc[327c298d5f7f3986]::vec::into_iter::IntoIter<rustc_middle[ba567b0c63397382]::ty::Predicate>, alloc[327c298d5f7f3986]::vec::into_iter::IntoIter<rustc_span[e8a062c38fd06fcf]::span_encoding::Span>>, rustc_trait_selection[620490483a22fe27]::traits::util::predicates_for_generics::{closure#0}>, alloc[327c298d5f7f3986]::vec::into_iter::IntoIter<rustc_infer[bfbf07e5440e77e9]::traits::Obligation<rustc_middle[ba567b0c63397382]::ty::Predicate>>>, alloc[327c298d5f7f3986]::vec::into_iter::IntoIter<rustc_infer[bfbf07e5440e77e9]::traits::Obligation<rustc_middle[ba567b0c63397382]::ty::Predicate>>>>
  32:     0x7fabb87e76ed - <rustc_infer[bfbf07e5440e77e9]::infer::InferCtxtBuilder>::enter::<bool, rustc_trait_selection[620490483a22fe27]::traits::coherence::negative_impl::{closure#0}>
  33:     0x7fabb88956b8 - rustc_trait_selection[620490483a22fe27]::traits::coherence::negative_impl
  34:     0x7fabba2f9b0a - rustc_trait_selection[620490483a22fe27]::traits::coherence::overlap_within_probe
  35:     0x7fabba2d1b39 - <rustc_infer[bfbf07e5440e77e9]::infer::InferCtxt>::probe_maybe_skip_leak_check::<core[7b47b893e00d8dca]::option::Option<rustc_trait_selection[620490483a22fe27]::traits::coherence::OverlapResult>, rustc_trait_selection[620490483a22fe27]::traits::coherence::overlap::{closure#0}>
  36:     0x7fabba2d09c1 - <rustc_infer[bfbf07e5440e77e9]::infer::InferCtxtBuilder>::enter::<bool, rustc_trait_selection[620490483a22fe27]::traits::coherence::overlapping_impls<<rustc_middle[ba567b0c63397382]::traits::specialization_graph::Children as rustc_trait_selection[620490483a22fe27]::traits::specialize::specialization_graph::ChildrenExt>::insert::{closure#2}, <rustc_middle[ba567b0c63397382]::traits::specialization_graph::Children as rustc_trait_selection[620490483a22fe27]::traits::specialize::specialization_graph::ChildrenExt>::insert::{closure#3}, core[7b47b893e00d8dca]::result::Result<(bool, bool), rustc_trait_selection[620490483a22fe27]::traits::specialize::OverlapError>>::{closure#1}>
  37:     0x7fabb98a2fdc - <rustc_middle[ba567b0c63397382]::traits::specialization_graph::Children as rustc_trait_selection[620490483a22fe27]::traits::specialize::specialization_graph::ChildrenExt>::insert
  38:     0x7fabb98a3bb8 - <rustc_middle[ba567b0c63397382]::traits::specialization_graph::Graph as rustc_trait_selection[620490483a22fe27]::traits::specialize::specialization_graph::GraphExt>::insert
  39:     0x7fabb9868f04 - rustc_trait_selection[620490483a22fe27]::traits::specialize::specialization_graph_provider
  40:     0x7fabba06318a - rustc_query_system[b49264403dc3266]::query::plumbing::try_execute_query::<rustc_query_impl[7dace536525edc45]::plumbing::QueryCtxt, rustc_query_system[b49264403dc3266]::query::caches::ArenaCache<rustc_span[e8a062c38fd06fcf]::def_id::DefId, rustc_middle[ba567b0c63397382]::traits::specialization_graph::Graph>>
  41:     0x7fabba0efeb9 - rustc_query_system[b49264403dc3266]::query::plumbing::get_query::<rustc_query_impl[7dace536525edc45]::queries::specialization_graph_of, rustc_query_impl[7dace536525edc45]::plumbing::QueryCtxt>
  42:     0x7fabb9de5288 - rustc_typeck[ba18a5ea3a172631]::coherence::coherent_trait
  43:     0x7fabb952d2f5 - rustc_query_system[b49264403dc3266]::query::plumbing::try_execute_query::<rustc_query_impl[7dace536525edc45]::plumbing::QueryCtxt, rustc_query_system[b49264403dc3266]::query::caches::DefaultCache<rustc_span[e8a062c38fd06fcf]::def_id::DefId, ()>>
  44:     0x7fabba0d4842 - rustc_query_system[b49264403dc3266]::query::plumbing::get_query::<rustc_query_impl[7dace536525edc45]::queries::coherent_trait, rustc_query_impl[7dace536525edc45]::plumbing::QueryCtxt>
  45:     0x7fabb9dbf7a9 - <rustc_session[82687f0a78807d1f]::session::Session>::track_errors::<rustc_typeck[ba18a5ea3a172631]::check_crate::{closure#3}, ()>
  46:     0x7fabb9e1834f - rustc_typeck[ba18a5ea3a172631]::check_crate
  47:     0x7fabb9b49e97 - rustc_interface[c2045ebdcb88575c]::passes::analysis
  48:     0x7fabba0a2735 - rustc_query_system[b49264403dc3266]::query::plumbing::try_execute_query::<rustc_query_impl[7dace536525edc45]::plumbing::QueryCtxt, rustc_query_system[b49264403dc3266]::query::caches::DefaultCache<(), core[7b47b893e00d8dca]::result::Result<(), rustc_errors[30e8870fe27fb8ba]::ErrorGuaranteed>>>
  49:     0x7fabba101b9e - rustc_query_system[b49264403dc3266]::query::plumbing::get_query::<rustc_query_impl[7dace536525edc45]::queries::analysis, rustc_query_impl[7dace536525edc45]::plumbing::QueryCtxt>
  50:     0x7fabb9b2328e - <rustc_interface[c2045ebdcb88575c]::passes::QueryContext>::enter::<rustc_driver[ee492072531d29b9]::run_compiler::{closure#1}::{closure#2}::{closure#3}, core[7b47b893e00d8dca]::result::Result<(), rustc_errors[30e8870fe27fb8ba]::ErrorGuaranteed>>
  51:     0x7fabb9b06c6e - <rustc_interface[c2045ebdcb88575c]::interface::Compiler>::enter::<rustc_driver[ee492072531d29b9]::run_compiler::{closure#1}::{closure#2}, core[7b47b893e00d8dca]::result::Result<core[7b47b893e00d8dca]::option::Option<rustc_interface[c2045ebdcb88575c]::queries::Linker>, rustc_errors[30e8870fe27fb8ba]::ErrorGuaranteed>>
  52:     0x7fabb9b02f3a - rustc_span[e8a062c38fd06fcf]::with_source_map::<core[7b47b893e00d8dca]::result::Result<(), rustc_errors[30e8870fe27fb8ba]::ErrorGuaranteed>, rustc_interface[c2045ebdcb88575c]::interface::create_compiler_and_run<core[7b47b893e00d8dca]::result::Result<(), rustc_errors[30e8870fe27fb8ba]::ErrorGuaranteed>, rustc_driver[ee492072531d29b9]::run_compiler::{closure#1}>::{closure#1}>
  53:     0x7fabb9b1f360 - rustc_interface[c2045ebdcb88575c]::interface::create_compiler_and_run::<core[7b47b893e00d8dca]::result::Result<(), rustc_errors[30e8870fe27fb8ba]::ErrorGuaranteed>, rustc_driver[ee492072531d29b9]::run_compiler::{closure#1}>
  54:     0x7fabb9b33362 - <scoped_tls[7afe57960397b723]::ScopedKey<rustc_span[e8a062c38fd06fcf]::SessionGlobals>>::set::<rustc_interface[c2045ebdcb88575c]::interface::run_compiler<core[7b47b893e00d8dca]::result::Result<(), rustc_errors[30e8870fe27fb8ba]::ErrorGuaranteed>, rustc_driver[ee492072531d29b9]::run_compiler::{closure#1}>::{closure#0}, core[7b47b893e00d8dca]::result::Result<(), rustc_errors[30e8870fe27fb8ba]::ErrorGuaranteed>>
  55:     0x7fabb9b0532f - std[af12de6c3337c1b7]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[c2045ebdcb88575c]::util::run_in_thread_pool_with_globals<rustc_interface[c2045ebdcb88575c]::interface::run_compiler<core[7b47b893e00d8dca]::result::Result<(), rustc_errors[30e8870fe27fb8ba]::ErrorGuaranteed>, rustc_driver[ee492072531d29b9]::run_compiler::{closure#1}>::{closure#0}, core[7b47b893e00d8dca]::result::Result<(), rustc_errors[30e8870fe27fb8ba]::ErrorGuaranteed>>::{closure#0}, core[7b47b893e00d8dca]::result::Result<(), rustc_errors[30e8870fe27fb8ba]::ErrorGuaranteed>>
  56:     0x7fabb9b1f7b9 - <<std[af12de6c3337c1b7]::thread::Builder>::spawn_unchecked_<rustc_interface[c2045ebdcb88575c]::util::run_in_thread_pool_with_globals<rustc_interface[c2045ebdcb88575c]::interface::run_compiler<core[7b47b893e00d8dca]::result::Result<(), rustc_errors[30e8870fe27fb8ba]::ErrorGuaranteed>, rustc_driver[ee492072531d29b9]::run_compiler::{closure#1}>::{closure#0}, core[7b47b893e00d8dca]::result::Result<(), rustc_errors[30e8870fe27fb8ba]::ErrorGuaranteed>>::{closure#0}, core[7b47b893e00d8dca]::result::Result<(), rustc_errors[30e8870fe27fb8ba]::ErrorGuaranteed>>::{closure#1} as core[7b47b893e00d8dca]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  57:     0x7fabb70b0693 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h2535c4f17d1ae00a
                               at /rustc/93ffde6f04d3d24327a4e17a2a2bf4f63c246235/library/alloc/src/boxed.rs:1935:9
  58:     0x7fabb70b0693 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h9555fa64d2fdcc1f
                               at /rustc/93ffde6f04d3d24327a4e17a2a2bf4f63c246235/library/alloc/src/boxed.rs:1935:9
  59:     0x7fabb70b0693 - std::sys::unix::thread::Thread::new::thread_start::hcd4b7b87c76163e2
                               at /rustc/93ffde6f04d3d24327a4e17a2a2bf4f63c246235/library/std/src/sys/unix/thread.rs:108:17
  60:     0x7fabb6e8054d - <unknown>
  61:     0x7fabb6f05874 - clone
  62:                0x0 - <unknown>

error: internal compiler error: unexpected panic

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 (93ffde6f0 2022-07-23) 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 `MyTrait`
#1 [coherent_trait] coherence checking all impls of trait `MyTrait`
#2 [analysis] running analysis passes on this crate
end of query stack

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-negative_impls#![feature(negative_impls)]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.glacierICE tracked in rust-lang/glacier.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions