Skip to content

ICE instead of coherence error #57162

Closed
Closed
@alexreg

Description

@alexreg

On nightly (but not stable), the following code ICEs. This should produce the usual error about incoherent impls, I believe.

trait Foo {}

impl Foo for dyn Send {}

impl<T: Send> Foo for T {}

fn main() {}
error: internal compiler error: src/librustc/ty/sty.rs:575: first predicate is AutoTrait(DefId(2/0:838 ~ core[7549]::marker[0]::Send[0]))

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:590:9
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:39
   1: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:70
   2: std::panicking::default_hook::{{closure}}
             at src/libstd/sys_common/backtrace.rs:58
             at src/libstd/panicking.rs:200
   3: std::panicking::default_hook
             at src/libstd/panicking.rs:215
   4: rustc::util::common::panic_hook
   5: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:482
   6: std::panicking::begin_panic
   7: rustc_errors::Handler::bug
   8: rustc::util::bug::opt_span_bug_fmt::{{closure}}
   9: rustc::ty::context::tls::with_opt::{{closure}}
  10: rustc::ty::context::tls::with_context_opt
  11: rustc::ty::context::tls::with_opt
  12: rustc::util::bug::opt_span_bug_fmt
  13: rustc::util::bug::bug_fmt
  14: rustc::traits::coherence::ty_is_local_constructor
  15: rustc::traits::coherence::ty_is_local
  16: rustc::traits::coherence::orphan_check_trait_ref
  17: rustc::traits::coherence::trait_ref_is_knowable
  18: rustc::traits::select::SelectionContext::candidate_from_obligation_no_cache
  19: rustc::dep_graph::graph::DepGraph::with_anon_task
  20: rustc::traits::select::SelectionContext::candidate_from_obligation
  21: rustc::traits::select::SelectionContext::evaluate_stack
  22: rustc::dep_graph::graph::DepGraph::with_anon_task
  23: rustc::traits::select::SelectionContext::evaluate_predicate_recursively
  24: rustc::traits::select::SelectionContext::predicate_may_hold_fatal
  25: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  26: <core::slice::Iter<'a, T> as core::iter::iterator::Iterator>::try_fold
  27: <core::iter::Map<I, F> as core::iter::iterator::Iterator>::try_fold
  28: rustc::traits::coherence::overlap
  29: rustc::ty::context::GlobalCtxt::enter_local
  30: rustc::traits::coherence::overlapping_impls
  31: rustc::traits::specialize::specialization_graph::Graph::insert
  32: rustc::traits::specialize::specialization_graph_provider
  33: rustc::ty::query::__query_compute::specialization_graph_of
  34: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::specialization_graph_of<'tcx>>::compute
  35: rustc::dep_graph::graph::DepGraph::with_task_impl
  36: <rustc::ty::query::plumbing::JobOwner<'a, 'tcx, Q>>::start
  37: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
  38: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_get_with
  39: rustc_typeck::coherence::coherent_trait
  40: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::coherent_trait<'tcx>>::compute
  41: rustc::dep_graph::graph::DepGraph::with_task_impl
  42: <rustc::ty::query::plumbing::JobOwner<'a, 'tcx, Q>>::start
  43: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
  44: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_get_with
  45: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::ensure_query
  46: rustc_typeck::coherence::check_coherence
  47: rustc_typeck::check_crate
  48: <std::thread::local::LocalKey<T>>::with
  49: rustc::ty::context::TyCtxt::create_and_enter
  50: rustc_driver::driver::compile_input
  51: rustc_driver::run_compiler_with_pool
  52: <scoped_tls::ScopedKey<T>>::set
  53: rustc_driver::run_compiler
  54: <scoped_tls::ScopedKey<T>>::set
query stack during panic:
#0 [specialization_graph_of] processing `Foo`
#1 [coherent_trait] coherence checking all impls of trait `Foo`
end of query stack
error: aborting due to previous error


note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.33.0-nightly (a7be40c65 2018-12-26) running on x86_64-unknown-linux-gnu

note: compiler flags: -C codegen-units=1 -C debuginfo=2 --crate-type bin

note: some of the compiler flags provided by cargo are hidden

playground link

CC @nikomatsakis @arielb1

Metadata

Metadata

Assignees

Labels

A-trait-systemArea: Trait systemI-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions