Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

ICE instead of coherence error #57162

Closed
Closed

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

Activity

  1. added
    I-ICE
    A-trait-system
    on Dec 28, 2018
  2. sugar700 commented on Dec 28, 2018

    @sugar700
    Contributor

    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.

  3. added
    regression-from-stable-to-nightly
    on Dec 28, 2018
  4. alexreg commented on Dec 28, 2018

    @alexreg
    ContributorAuthor

    @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.
  5. alexreg commented on Dec 28, 2018

    @alexreg
    ContributorAuthor

    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() {}
  6. added
    T-compiler
    P-high
    on Jan 3, 2019
  7. self-assigned this
    on Jan 3, 2019
  8. nagisa commented on Jan 3, 2019

    @nagisa
    Member

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

  9. nagisa commented on Jan 3, 2019

    @nagisa
    Member

    Bisected to #56481. cc @nikomatsakis @arielb1

  10. alexreg commented on Jan 4, 2019

    @alexreg
    ContributorAuthor

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

    Are you guys okay to resolve this?

  11. arielb1 commented on Jan 4, 2019

    @arielb1
    Contributor

    I'll look at it

  12. arielb1 commented on Jan 4, 2019

    @arielb1
    Contributor

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

  13. arielb1 commented on Jan 4, 2019

    @arielb1
    Contributor

    Yup found it.

  14. added 2 commits that reference this issue on Jan 4, 2019
    366815d
    c213b0d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-trait-systemI-ICEP-highT-compilerregression-from-stable-to-nightly

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions