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

nightly compiler panicked: assertion failed: !(self.has_self && idx == 0)', src/librustc/ty/mod.rs:786:16 #45712

Closed
d9n opened this issue Nov 2, 2017 · 2 comments
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@d9n
Copy link

d9n commented Nov 2, 2017

Today (2017/11/1) I was curious about the rx project (https://github.com/ruuda/rx), so I decided to compile it. It uses #![features] so I downloaded lastest nightly.

 $ rustup show
Default host: x86_64-apple-darwin

... 
active toolchain
----------------

nightly-x86_64-apple-darwin (default)
rustc 1.23.0-nightly (2be4cc040 2017-11-01)

Trying to compile, I got an error about impl and trait definitions differing due to a 'static bound, so I changed src/observable.rs to:

# Line 63
     fn subscribe<O>(&mut self, observer: O) -> Self::Subscription
-        where O: Observer<Self::Item, Self::Error>;
+        where O: Observer<Self::Item, Self::Error> + 'static; 

And I got this:

 $ RUST_BACKTRACE=1 cargo build
   Compiling rx v0.0.1 (file:///Users/d9n/root/src/rust/rx)
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/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.23.0-nightly (2be4cc040 2017-11-01) running on x86_64-apple-darwin

note: run with `RUST_BACKTRACE=1` for a backtrace

thread 'rustc' panicked at 'assertion failed: !(self.has_self && idx == 0)', src/librustc/ty/mod.rs:786:16
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
   0: std::sys::imp::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: rustc::ty::Generics::type_param
   7: rustc::infer::error_reporting::<impl rustc::infer::InferCtxt<'a, 'gcx, 'tcx>>::report_region_errors
   8: rustc::infer::InferCtxt::resolve_regions_and_report_errors
   9: rustc_typeck::check::regionck::<impl rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx>>::regionck_fn
  10: <std::thread::local::LocalKey<T>>::with
  11: rustc::ty::context::GlobalCtxt::enter_local
  12: _ZN12rustc_typeck5check16typeck_tables_of17hdb9bcc875ada78f7E.llvm.84D1B754
  13: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_tables_of<'tcx>>::compute_result
  14: _ZN5rustc9dep_graph5graph8DepGraph14with_task_impl17h50ec4681f521ffdaE.llvm.8F0621FC
  15: rustc_errors::Handler::track_diagnostics
  16: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::cycle_check
  17: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_tables_of<'tcx>>::force
  18: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_tables_of<'tcx>>::try_get
  19: rustc::ty::maps::TyCtxtAt::typeck_tables_of
  20: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_tables_of<'tcx>>::ensure
  21: rustc::session::Session::track_errors
  22: _ZN12rustc_typeck5check18typeck_item_bodies17h2301b442e2fa9055E.llvm.84D1B754
  23: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_item_bodies<'tcx>>::compute_result
  24: _ZN5rustc9dep_graph5graph8DepGraph14with_task_impl17h3f03d4824cbc6e12E.llvm.8F0621FC
  25: rustc_errors::Handler::track_diagnostics
  26: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::cycle_check
  27: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_item_bodies<'tcx>>::force
  28: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_item_bodies<'tcx>>::try_get
  29: rustc::ty::maps::TyCtxtAt::typeck_item_bodies
  30: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::typeck_item_bodies
  31: rustc::util::common::time
  32: rustc_typeck::check_crate
  33: <std::thread::local::LocalKey<T>>::with
  34: <std::thread::local::LocalKey<T>>::with
  35: rustc::ty::context::TyCtxt::create_and_enter
  36: rustc_driver::driver::compile_input
  37: rustc_driver::run_compiler

error: Could not compile `rx`.
@estebank estebank added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Nov 2, 2017
@hannobraun
Copy link

I'm seeing the same error in my own code, although with a different backtrace. Here's the error:

$ RUST_BACKTRACE=1 cargo build
   Compiling ice v0.1.0 (file:///home/hanno/tmp/Projects/rust-ice)
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/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.23.0-nightly (5041b3bb3 2017-11-19) running on x86_64-unknown-linux-gnu

note: run with `RUST_BACKTRACE=1` for a backtrace

thread 'rustc' panicked at 'assertion failed: !(self.has_self && idx == 0)', /checkout/src/librustc/ty/mod.rs:796:16
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
   0: std::sys::imp::backtrace::tracing::imp::unwind_backtrace
             at /checkout/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::_print
             at /checkout/src/libstd/sys_common/backtrace.rs:68
   2: std::panicking::default_hook::{{closure}}
             at /checkout/src/libstd/sys_common/backtrace.rs:57
             at /checkout/src/libstd/panicking.rs:381
   3: std::panicking::default_hook
             at /checkout/src/libstd/panicking.rs:391
   4: std::panicking::rust_panic_with_hook
             at /checkout/src/libstd/panicking.rs:577
   5: std::panicking::begin_panic
   6: rustc::ty::Generics::type_param
   7: rustc::infer::error_reporting::<impl rustc::infer::InferCtxt<'a, 'gcx, 'tcx>>::report_region_errors
   8: rustc::infer::InferCtxt::resolve_regions_and_report_errors
   9: rustc_typeck::check::regionck::<impl rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx>>::regionck_item
  10: <std::thread::local::LocalKey<T>>::with
  11: rustc::ty::context::GlobalCtxt::enter_local
  12: _ZN12rustc_typeck5check7wfcheck26CheckTypeWellFormedVisitor21check_associated_item17h6a5d2e2fa0770148E.llvm.7C6DB860
  13: rustc::hir::Crate::visit_all_item_likes
  14: rustc::session::Session::track_errors
  15: rustc::util::common::time
  16: rustc_typeck::check_crate
  17: <std::thread::local::LocalKey<T>>::with
  18: <std::thread::local::LocalKey<T>>::with
  19: rustc::ty::context::TyCtxt::create_and_enter
  20: rustc_driver::driver::compile_input
  21: rustc_driver::run_compiler

And here's the piece of code that triggers it:

pub struct MyStruct<'a, T: 'a>(&'a T);


pub trait MyTrait {
    fn my_method<'a, T, I>(&mut self, into: I)
        where I: Into<MyStruct<'a, T>>;
}

I think that the above code is incorrect and shouldn't compile. The T on my_method is missing a : 'a. If I add that, the code compiles without error. Here's the fixed code:

pub struct MyStruct<'a, T: 'a>(&'a T);


pub trait MyTrait {
    fn my_method<'a, T: 'a, I>(&mut self, into: I)
        where I: Into<MyStruct<'a, T>>;
}

@leoyvens
Copy link
Contributor

Closed by #46722.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

5 participants