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 instead of coherence error #57162

Closed
alexreg opened this issue Dec 28, 2018 · 9 comments
Closed

ICE instead of coherence error #57162

alexreg opened this issue Dec 28, 2018 · 9 comments
Assignees
Labels
A-traits Area: Trait system I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@alexreg
Copy link
Contributor

alexreg commented Dec 28, 2018

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

@Centril Centril added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ A-traits Area: Trait system labels Dec 28, 2018
@KamilaBorowska
Copy link
Contributor

KamilaBorowska commented Dec 28, 2018

That doesn't seem incoherent to me, dyn Send cannot be Sized (due to the definition of trait objects), so the implementations for dyn Send and <T: Send + Sized> T (+ Sized is implicit here) don't conflict.

Should be tagged as regression-from-stable-to-nightly however.

@arielb1 arielb1 added the regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. label Dec 28, 2018
@alexreg
Copy link
Contributor Author

alexreg commented Dec 28, 2018

@xfix Hmm, I forgot about the implicit Sized bound on T. You're probably right. I'm not sure what's going on here exactly, in any case.

Some observations:

  • Adding ?Sized to the bound on T in the second impl gives the expected incoherence error.
  • Removing either the first or the second impl allows the code to compile fine.

@alexreg
Copy link
Contributor Author

alexreg commented Dec 28, 2018

For the record, the following gives the same ICE:

trait Foo {}

impl Foo for dyn Send {}

impl<T: Sync + Sync> Foo for T {}

fn main() {}

@nagisa nagisa added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. P-high High priority labels Jan 3, 2019
@nagisa nagisa self-assigned this Jan 3, 2019
@nagisa
Copy link
Member

nagisa commented Jan 3, 2019

Discussed at T-compiler meeting. Assigning to self to bisect.

@nagisa
Copy link
Member

nagisa commented Jan 3, 2019

Bisected to #56481. cc @nikomatsakis @arielb1

@alexreg
Copy link
Contributor Author

alexreg commented Jan 4, 2019

Aha, I had a suspicion it might have been @arielb1's PR (or mine). :-)

Are you guys okay to resolve this?

@arielb1
Copy link
Contributor

arielb1 commented Jan 4, 2019

I'll look at it

@arielb1
Copy link
Contributor

arielb1 commented Jan 4, 2019

I'll note that #56837 fixes that issue, but that's not something we can backport.

@arielb1
Copy link
Contributor

arielb1 commented Jan 4, 2019

Yup found it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-traits Area: Trait system I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. 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

5 participants