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

Unknown ICE #48740

Closed
sgrif opened this issue Mar 4, 2018 · 2 comments
Closed

Unknown ICE #48740

sgrif opened this issue Mar 4, 2018 · 2 comments
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@sgrif
Copy link
Contributor

sgrif commented Mar 4, 2018

This code causes Rust to ICE on stable, beta, and nightly.

Playground link

pub trait Reborrow<'a, 'b>
where
    Self: 'a,
    'a: 'b,
{
    type Output: 'b;
    
    fn reborrow(self) -> Self::Output;
}

impl<'a, 'b, T> Reborrow<'a, 'b> for &'a mut T
where
    'a: 'b,
{
    type Output = &'b mut T;
    
    fn reborrow(self) -> Self::Output {
        &mut *self
    }
}

impl<'a, 'b, T: Copy> Reborrow<'a, 'b> for T {
    type Output = Self;
    
    fn reborrow(self) -> Self::Output {
        self
    }
}

fn main() {}

It is specifically the second impl (the one with the Copy bound) that causes the ICE.

Backtrace
thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', libcore/option.rs:335:21
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
   1: std::sys_common::backtrace::print
   2: std::panicking::default_hook::{{closure}}
   3: std::panicking::default_hook
   4: std::panicking::rust_panic_with_hook
   5: std::panicking::begin_panic
   6: std::panicking::begin_panic_fmt
   7: rust_begin_unwind
   8: core::panicking::panic_fmt
   9: core::panicking::panic
  10: <std::thread::local::LocalKey<T>>::with
  11: rustc::ty::context::GlobalCtxt::enter_local
  12: rustc::traits::coherence::overlapping_impls
  13: rustc::traits::specialize::specialization_graph::Graph::insert
  14: rustc::traits::specialize::specialization_graph_provider
  15: rustc::dep_graph::graph::DepGraph::with_task_impl
  16: rustc_errors::Handler::track_diagnostics
  17: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::cycle_check
  18: rustc::ty::maps::<impl rustc::ty::maps::queries::specialization_graph_of<'tcx>>::force
  19: rustc::ty::maps::<impl rustc::ty::maps::queries::specialization_graph_of<'tcx>>::try_get
  20: rustc::ty::maps::TyCtxtAt::specialization_graph_of
  21: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::specialization_graph_of
  22: rustc_typeck::coherence::coherent_trait
  23: rustc::dep_graph::graph::DepGraph::with_task_impl
  24: rustc_errors::Handler::track_diagnostics
  25: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::cycle_check
  26: rustc::ty::maps::<impl rustc::ty::maps::queries::coherent_trait<'tcx>>::force
  27: rustc::ty::maps::<impl rustc::ty::maps::queries::coherent_trait<'tcx>>::try_get
  28: rustc::ty::maps::TyCtxtAt::coherent_trait
  29: rustc::ty::maps::<impl rustc::ty::maps::queries::coherent_trait<'tcx>>::ensure
  30: rustc_typeck::coherence::check_coherence
  31: rustc_typeck::check_crate
  32: <std::thread::local::LocalKey<T>>::with
  33: <std::thread::local::LocalKey<T>>::with
  34: rustc::ty::context::TyCtxt::create_and_enter
  35: rustc_driver::driver::compile_input
  36: rustc_driver::run_compiler

Tested on rustc 1.23.0 (766bd11c8 2018-01-01), rustc 1.25.0-beta.7 (da64ca931 2018-03-03), and rustc 1.26.0-nightly (e026b59cf 2018-03-03)

@sgrif sgrif added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Mar 4, 2018
@TimNN TimNN added the C-bug Category: This is a bug. label Mar 6, 2018
@varkor
Copy link
Member

varkor commented Mar 22, 2018

This error is coming from a very similar location to #48728. Maybe it's the same bug?

@Mark-Simulacrum
Copy link
Member

This code no longer ICEs.

error[E0119]: conflicting implementations of trait `Reborrow<'_, '_>` for type `&mut _`:
  --> src/main.rs:22:1
   |
11 | / impl<'a, 'b, T> Reborrow<'a, 'b> for &'a mut T
12 | | where
13 | |     'a: 'b,
14 | | {
...  |
19 | |     }
20 | | }
   | |_- first implementation here
21 | 
22 |   impl<'a, 'b, T: Copy> Reborrow<'a, 'b> for T {
   |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `&mut _`
   |
   = note: downstream crates may implement trait `std::marker::Copy` for type `&mut _`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0119`.
error: Could not compile `playground`.

To learn more, run the command again with --verbose.

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. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

4 participants