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 Type Alias Compiler panic unexpected definition: TraitAlias #57023

Closed
jgrowl opened this issue Dec 21, 2018 · 2 comments
Closed

Nightly Type Alias Compiler panic unexpected definition: TraitAlias #57023

jgrowl opened this issue Dec 21, 2018 · 2 comments
Assignees
Labels
A-traits Area: Trait system I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@jgrowl
Copy link

jgrowl commented Dec 21, 2018

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.
@Centril Centril added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Dec 21, 2018
@Centril Centril added the A-traits Area: Trait system label Dec 21, 2018
@alexreg
Copy link
Contributor

alexreg commented Dec 22, 2018

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
Copy link
Author

jgrowl commented Dec 23, 2018

@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!

@jgrowl jgrowl closed this as completed Dec 23, 2018
Centril added a commit to Centril/rust that referenced this issue Jan 19, 2019
…nikomatsakis

make trait-aliases work across crates

This is rebase of a small part of @alexreg's PR rust-lang#55994. It focuses just on the changes that integrate trait aliases properly into crate metadata, excluding the stylistic edits and the trait objects.

The stylistic edits I also rebased and can open a separate PR.

The trait object stuff I found challenging and decided it basically needed to be reimplemented. For now I've excluded it.

Since this is really @alexreg's work (I really just rebased) I am going to make it r=me once it is working.

Fixes rust-lang#56488.
Fixes rust-lang#57023.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-traits Area: Trait system I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants