Skip to content

Nightly Type Alias Compiler panic unexpected definition: TraitAlias #57023

Closed
@jgrowl

Description

@jgrowl

The compiler panics when using generics in trait aliases. I tried to reduce the code as much as I could while preserving the error so I apologize if it does not make any sense. Basically I had created a couple of different libraries that depended on each other.

The first library created a multi parameter generic type alias
The second library used that alias to define a slightly less generic trait alias
The third used the second to create a trait with all concrete types

I attempted to collapse some of the code to use less generics and crates, so it probably won't make sense why you'd write code like this, but it should show the error regardless.

I tried this code:

https://github.com/jgrowl/rust_nightly_790f4c566_2018-12-19_trait_alias_bug

I expected to not get a compiler panic

Meta

rustc 1.33.0-nightly (790f4c566 2018-12-19)
binary: rustc
commit-hash: 790f4c566d9802dfcadc26398dde2051cfe6ec9f
commit-date: 2018-12-19
host: x86_64-apple-darwin
release: 1.33.0-nightly
LLVM version: 8.0

Backtrace:

➜  rust_nightly_790f4c566_2018-12-19_trait_alias_bug git:(master) RUST_BACKTRACE=1 cargo test --lib
   Compiling rust_nightly_790f4c566_2018-12-19_trait_alias_bug v0.1.0 (/Users/jonathan/Code/github.com/jgrowl/rust_nightly_790f4c566_2018-12-19_trait_alias_bug)
thread 'main' panicked at 'src/librustc_resolve/build_reduced_graph.rs:693: unexpected definition: TraitAlias(DefId(10/0:9))', src/librustc/util/bug.rs:47:26
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: rustc::util::common::panic_hook
   5: std::panicking::rust_panic_with_hook
   6: std::panicking::begin_panic
   7: rustc::util::bug::opt_span_bug_fmt::{{closure}}
   8: rustc::ty::context::tls::with_opt::{{closure}}
   9: rustc::ty::context::tls::with_context_opt
  10: rustc::ty::context::tls::with_opt
  11: rustc::util::bug::opt_span_bug_fmt
  12: rustc::util::bug::bug_fmt
  13: rustc_resolve::build_reduced_graph::<impl rustc_resolve::Resolver<'a>>::populate_module_if_necessary
  14: rustc_resolve::Resolver::lookup_import_candidates_from_module
  15: rustc_resolve::Resolver::resolve_path
  16: rustc_resolve::resolve_imports::ImportResolver::resolve_imports
  17: rustc_resolve::macros::<impl syntax::ext::base::Resolver for rustc_resolve::Resolver<'a>>::resolve_imports
  18: syntax::ext::expand::MacroExpander::expand_fragment
  19: syntax::ext::expand::MacroExpander::expand_crate
  20: rustc_driver::driver::phase_2_configure_and_expand_inner::{{closure}}
  21: rustc::util::common::time
  22: rustc_driver::driver::phase_2_configure_and_expand
  23: rustc_driver::driver::compile_input
  24: rustc_driver::run_compiler_with_pool
  25: <scoped_tls::ScopedKey<T>>::set
  26: rustc_driver::run_compiler
  27: <scoped_tls::ScopedKey<T>>::set
  28: syntax::with_globals
  29: __rust_maybe_catch_panic
  30: rustc_driver::run
  31: rustc_driver::main
  32: std::rt::lang_start::{{closure}}
  33: std::panicking::try::do_call
  34: __rust_maybe_catch_panic
  35: std::rt::lang_start_internal
  36: main
query stack during panic:
end of query stack

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.33.0-nightly (790f4c566 2018-12-19) running on x86_64-apple-darwin

note: compiler flags: -C debuginfo=2 -C incremental

note: some of the compiler flags provided by cargo are hidden

error: Could not compile `rust_nightly_790f4c566_2018-12-19_trait_alias_bug`.

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

Activity

added
I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
on Dec 21, 2018
alexreg

alexreg commented on Dec 22, 2018

@alexreg
Contributor

Thanks for the report. I can confirm this has already been fixed in my PR #55994, which I'm hoping will merge very soon. :-)

error[E0432]: unresolved import `crate::NON_EXISTENT`
 --> src/lib.rs:7:12
  |
7 | use crate::NON_EXISTENT::ANY_GIBERISH_HERE_CAUSES_PANIC;
  |            ^^^^^^^^^^^^ maybe a missing `extern crate NON_EXISTENT;`?

warning: unused import: `crate::NON_EXISTENT::ANY_GIBERISH_HERE_CAUSES_PANIC`
 --> src/lib.rs:7:5
  |
7 | use crate::NON_EXISTENT::ANY_GIBERISH_HERE_CAUSES_PANIC;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: #[warn(unused_imports)] on by default

error: aborting due to previous error

The above is what I got when I tried to build your crate locally, using my PR build of rustc. I presume you expected something like this? If so, please feel free to close.

jgrowl

jgrowl commented on Dec 23, 2018

@jgrowl
Author

@alexreg Great, that is what I would expect! Glad to see you're already ahead of me. I look forward to you landing your change so I can test the original project I was working on. I'll go ahead and close this issue. Thanks again!

added a commit that references this issue on Jan 19, 2019

Rollup merge of rust-lang#57502 - nikomatsakis:fix-trait-alias-1b, r=…

5272be5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-trait-systemArea: Trait systemI-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    Participants

    @alexreg@jgrowl@Centril

    Issue actions

      Nightly Type Alias Compiler panic `unexpected definition: TraitAlias` · Issue #57023 · rust-lang/rust