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

"inconsistent resolution for an import" with Rust 2018 #56596

Closed
Thinkofname opened this issue Dec 7, 2018 · 6 comments
Closed

"inconsistent resolution for an import" with Rust 2018 #56596

Thinkofname opened this issue Dec 7, 2018 · 6 comments
Assignees
Labels
A-resolve Area: Name resolution I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@Thinkofname
Copy link

I was trying to use the 2018 edition with my game and after running cargo fix and then trying to cargo check the result I got the following panic. This only happens if edition = "2018" is set in my Cargo.toml, if its not set it compiles fine. I'm not sure where its crashing so I can't provide a test case yet.

Rustc version: rustc 1.31.0 (abe02cefd 2018-12-04)

Backtrace:

thread 'main' panicked at 'librustc_resolve/resolve_imports.rs:840: inconsistent resolution for an import', librustc/util/bug.rs:47:26
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
             at libstd/sys_common/backtrace.rs:59
   2: std::panicking::default_hook::{{closure}}
             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::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::span_bug_fmt
  13: rustc_resolve::resolve_imports::ImportResolver::finalize_imports
  14: rustc_resolve::Resolver::resolve_crate
  15: rustc::util::common::time
  16: rustc_driver::driver::phase_2_configure_and_expand
  17: rustc_driver::driver::compile_input
  18: rustc_driver::run_compiler_with_pool
  19: rustc_driver::driver::spawn_thread_pool
  20: rustc_driver::run_compiler
  21: <scoped_tls::ScopedKey<T>>::set
  22: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
  23: __rust_maybe_catch_panic
             at libpanic_unwind/lib.rs:102
  24: rustc_driver::run
  25: rustc_driver::main
  26: std::rt::lang_start::{{closure}}
  27: std::panicking::try::do_call
             at libstd/rt.rs:59
             at libstd/panicking.rs:310
  28: __rust_maybe_catch_panic
             at libpanic_unwind/lib.rs:102
  29: std::rt::lang_start_internal
             at libstd/panicking.rs:289
             at libstd/panic.rs:392
             at libstd/rt.rs:58
  30: main
  31: __libc_start_main
  32: <unknown>
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.31.0 (abe02cefd 2018-12-04) running on x86_64-unknown-linux-gnu

note: compiler flags: -C opt-level=1 -C debuginfo=2 -C debug-assertions=on -C incremental -C linker=clang -C link-arg=-fuse-ld=lld --crate-type bin

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

error: Could not compile `univercity`.
@petrochenkov petrochenkov self-assigned this Dec 7, 2018
@petrochenkov petrochenkov added A-resolve Area: Name resolution I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ labels Dec 7, 2018
@petrochenkov
Copy link
Contributor

@Thinkofname
The assert at resolve_imports.rs:840 was inserted because I didn't know how that situation could happen and assumed it was impossible, so I can't reproduce this without your help.

Minimizing reproduction is not necessary, the whole crate causing the error would work too.

@Thinkofname
Copy link
Author

Thinkofname commented Dec 7, 2018

The code is from a private project that isn't the easiest to build.

I managed to reduce it down to a small-ish test case without all the dependencies though.
bug.zip

@petrochenkov
Copy link
Contributor

Thanks!
I'll look at it.

@ennis
Copy link

ennis commented Dec 25, 2018

I ran into a similar ICE with the same message (but possibly unrelated) with the latest nightly:

   Compiling inconsistent_import v0.1.0 (C:\Users\Alexandre\Developpement\rust_bugs\inconsistent_import)
thread 'rustc' panicked at 'src\librustc_resolve\resolve_imports.rs:970: inconsistent resolution for an import', src\librustc\util\bug.rs:47:26
stack backtrace:
   0: std::sys_common::alloc::realloc_fallback
   1: std::panicking::take_hook
   2: std::panicking::take_hook
   3: <rustc::ty::sty::Binder<rustc::ty::ProjectionPredicate<'tcx>> as rustc::ty::ToPredicate<'tcx>>::to_predicate
   4: std::panicking::rust_panic_with_hook
   5: <rustc_resolve::CrateLint as core::fmt::Debug>::fmt
   6: rustc_resolve::build_reduced_graph::<impl rustc_resolve::ToNameBinding<'a> for (rustc::hir::def::Def, rustc::ty::Visibility, syntax_pos::span_encoding::Span, syntax_pos::hygiene::Mark, rustc_resolve::build_reduced_graph::IsMacroExport)>::to_name_binding
   7: rustc_resolve::build_reduced_graph::<impl rustc_resolve::ToNameBinding<'a> for (rustc::hir::def::Def, rustc::ty::Visibility, syntax_pos::span_encoding::Span, syntax_pos::hygiene::Mark, rustc_resolve::build_reduced_graph::IsMacroExport)>::to_name_binding
   8: rustc_resolve::build_reduced_graph::<impl rustc_resolve::ToNameBinding<'a> for (rustc::hir::def::Def, rustc::ty::Visibility, syntax_pos::span_encoding::Span, syntax_pos::hygiene::Mark, rustc_resolve::build_reduced_graph::IsMacroExport)>::to_name_binding
   9: rustc_resolve::build_reduced_graph::<impl rustc_resolve::ToNameBinding<'a> for (rustc::hir::def::Def, rustc::ty::Visibility, syntax_pos::span_encoding::Span, syntax_pos::hygiene::Mark, rustc_resolve::build_reduced_graph::IsMacroExport)>::to_name_binding
  10: rustc_resolve::build_reduced_graph::<impl rustc_resolve::ToNameBinding<'a> for (rustc::hir::def::Def, rustc::ty::Visibility, syntax_pos::span_encoding::Span, syntax_pos::hygiene::Mark, rustc_resolve::build_reduced_graph::IsMacroExport)>::to_name_binding
  11: rustc_resolve::build_reduced_graph::<impl rustc_resolve::ToNameBinding<'a> for (rustc::hir::def::Def, rustc::ty::Visibility, syntax_pos::span_encoding::Span, syntax_pos::hygiene::Mark, rustc_resolve::build_reduced_graph::IsMacroExport)>::to_name_binding
  12: rustc_resolve::resolve_imports::<impl rustc_resolve::Resolver<'a>>::try_define
  13: rustc_resolve::resolve_imports::ImportResolver::finalize_imports
  14: rustc_resolve::Resolver::resolve_crate
  15: rustc_driver::driver::count_nodes
  16: rustc_driver::driver::compile_input
  17: rustc_driver::run_compiler
  18: <rustc_driver::CompilationFailure as core::fmt::Debug>::fmt
  19: rustc_driver::run_compiler
  20: <rustc_driver::CompilationFailure as core::fmt::Debug>::fmt
  21: <humantime::duration::Error as std::error::Error>::cause
  22: _rust_maybe_catch_panic
  23: <humantime::duration::Error as std::error::Error>::cause
  24: std::sys::windows::thread::Thread::new
  25: BaseThreadInitThunk
  26: RtlUserThreadStart
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 (f960f377f 2018-12-24) running on x86_64-pc-windows-msvc

note: compiler flags: -C debuginfo=2 -C incremental --crate-type bin

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

error: Could not compile `inconsistent_import`.

Project triggering the ICE: https://github.com/ennis/inconsistent_import
Code triggering the ICE: https://github.com/ennis/inconsistent_import/blob/master/examples/sample.rs

Output of rustc --version --verbose

rustc 1.33.0-nightly (f960f377f 2018-12-24)
binary: rustc
commit-hash: f960f377fde2a01f64ec6f747725ce41147f46de
commit-date: 2018-12-24
host: x86_64-pc-windows-msvc
release: 1.33.0-nightly
LLVM version: 8.0

Steps to reproduce:
build example with cargo build --example sample

@petrochenkov
Copy link
Contributor

The issue described in the comment above (#56596 (comment)) is fixed in #57160.
I haven't looked at the primary issue yet.

@petrochenkov
Copy link
Contributor

Fixed in #57181

bors added a commit that referenced this issue Dec 29, 2018
resolve: Fix an ICE in import validation

Fixes ICE reported in the comment #56596 (comment)
bors added a commit that referenced this issue Dec 29, 2018
resolve: Fix an ICE in import validation

Fixes ICE reported in the comment #56596 (comment)
bors added a commit that referenced this issue Dec 29, 2018
resolve: Fix another ICE in import validation

Imports are allowed to have ambiguous resolutions as long as all of them have same `Def`.
As it turned out, it's possible for different `Module`s to have same `Def` when `extern crate` items are involved.

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

No branches or pull requests

3 participants