Description
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.