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

Compiler panic with trait aliases #56006

Closed
amesgen opened this issue Nov 16, 2018 · 4 comments
Closed

Compiler panic with trait aliases #56006

amesgen opened this issue Nov 16, 2018 · 4 comments
Labels
A-metadata Area: Crate metadata A-traits Area: Trait system C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@amesgen
Copy link

amesgen commented Nov 16, 2018

Playing around with the new trait aliases I encountered a compiler panic. This is a minimized example (play.rust-lang.org):

#![feature(trait_alias)]

use std::ops::Neg;

trait Number = Sized + Neg<Output = Self>;

Error message:

internal compiler error: librustc_metadata/encoder.rs:1158: cannot encode info for item Item { name: Number, id: NodeId(17), hir_id: HirId { owner: DefIndex(0:4), local_id: 0 }, attrs: [], node: TraitAlias(Generics { params: [], where_clause: WhereClause { id: NodeId(18), predicates: [] }, span: src/lib.rs:1:1: 1:1 }, [Trait(PolyTraitRef { bound_generic_params: [], trait_ref: TraitRef { path: path(Sized), ref_id: NodeId(19), hir_ref_id: HirId { owner: DefIndex(0:4), local_id: 3 } }, span: src/lib.rs:5:16: 5:21 }, None), Trait(PolyTraitRef { bound_generic_params: [], trait_ref: TraitRef { path: path(Neg<Output = Self>), ref_id: NodeId(21), hir_ref_id: HirId { owner: DefIndex(0:4), local_id: 8 } }, span: src/lib.rs:5:24: 5:42 }, None)]), vis: Spanned { node: Inherited, span: src/lib.rs:5:1: 5:1 }, span: src/lib.rs:5:1: 5:43 }

Update: even smaller repro case
Another update: see here (even more minimal)

Meta

$ rustc --version --verbose
rustc 1.32.0-nightly (f37247f88 2018-11-17)
binary: rustc
commit-hash: f37247f885026d29bf26fd4aed6e9135e4f32ebf
commit-date: 2018-11-17
host: x86_64-unknown-linux-gnu
release: 1.32.0-nightly
LLVM version: 8.0

Backtrace:

thread 'main' panicked at 'Box<Any>', librustc_errors/lib.rs:600:9
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::_print
             at libstd/sys_common/backtrace.rs:71
   2: std::panicking::default_hook::{{closure}}
             at libstd/sys_common/backtrace.rs:59
             at libstd/panicking.rs:211
   3: std::panicking::default_hook
             at libstd/panicking.rs:227
   4: rustc::util::common::panic_hook
   5: std::panicking::rust_panic_with_hook
             at libstd/panicking.rs:480
   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_metadata::encoder::<impl rustc_metadata::isolated_encoder::IsolatedEncoder<'a, 'b, 'tcx>>::encode_info_for_item
  15: rustc::ty::context::tls::with_context
  16: <rustc_metadata::encoder::EncodeVisitor<'a, 'b, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_item
  17: rustc::hir::Crate::visit_all_item_likes
  18: rustc_metadata::encoder::encode_metadata
  19: rustc_metadata::cstore_impl::<impl rustc::middle::cstore::CrateStore for rustc_metadata::cstore::CStore>::encode_metadata
  20: rustc::ty::context::TyCtxt::encode_metadata
  21: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::ExtraBackendMethods>::write_metadata
  22: rustc::util::common::time
  23: rustc_codegen_ssa::base::codegen_crate
  24: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_utils::codegen_backend::CodegenBackend>::codegen_crate
  25: rustc::util::common::time
  26: rustc_driver::driver::phase_4_codegen
  27: rustc_driver::driver::compile_input::{{closure}}
  28: rustc::ty::context::tls::enter_context
  29: <std::thread::local::LocalKey<T>>::with
  30: rustc::ty::context::TyCtxt::create_and_enter
  31: rustc_driver::driver::compile_input
  32: rustc_driver::run_compiler_with_pool
  33: <scoped_tls::ScopedKey<T>>::set
  34: rustc_driver::run_compiler
  35: syntax::with_globals
  36: __rust_maybe_catch_panic
             at libpanic_unwind/lib.rs:102
  37: rustc_driver::run
  38: rustc_driver::main
  39: std::rt::lang_start::{{closure}}
  40: std::panicking::try::do_call
             at libstd/rt.rs:59
             at libstd/panicking.rs:310
  41: __rust_maybe_catch_panic
             at libpanic_unwind/lib.rs:102
  42: std::rt::lang_start_internal
             at libstd/panicking.rs:289
             at libstd/panic.rs:398
             at libstd/rt.rs:58
  43: main
  44: __libc_start_main
  45: <unknown>
query stack during panic:
end of query stack
error: aborting due to previous error
@cuviper cuviper added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ A-metadata Area: Crate metadata A-traits Area: Trait system T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. labels Nov 16, 2018
@amesgen amesgen changed the title Compiler panic with trait aliases and num-traits Compiler panic with trait aliases Nov 20, 2018
@DutchGhost
Copy link
Contributor

Even more minimal:

#![feature(trait_alias)]

trait bug = 'static;

Or:

#![feature(trait_alias)]

trait bug<'a> = 'a;

The ICE message for those is the same as posted here.

@meh
Copy link
Contributor

meh commented Nov 26, 2018

This is happening to me as well and it's making me very sad 😞

@arielb1
Copy link
Contributor

arielb1 commented Nov 27, 2018

cc #41517

@amesgen
Copy link
Author

amesgen commented Feb 12, 2019

This issue seems to be fixed, thanks! Closing.

@amesgen amesgen closed this as completed Feb 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-metadata Area: Crate metadata A-traits Area: Trait system C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ 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