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

ICE "inconsistent resolution for an import" with two enums #105069

Closed
jruderman opened this issue Nov 29, 2022 · 5 comments · Fixed by #105208
Closed

ICE "inconsistent resolution for an import" with two enums #105069

jruderman opened this issue Nov 29, 2022 · 5 comments · Fixed by #105208
Assignees
Labels
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

@jruderman
Copy link
Contributor

jruderman commented Nov 29, 2022

Code

use self::A::*;
use V;
use self::B::*;
enum A {
    V
}
enum B {
    V
}
fn main() {}

Error output

thread 'rustc' panicked at 'compiler/rustc_resolve/src/imports.rs:818: inconsistent resolution for an import', compiler/rustc_middle/src/util/bug.rs:36

Backtrace
stack backtrace:
   0:        0x1028302a6 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h1901ec5c10c2d477
   1:        0x10288ee2a - core::fmt::write::h453ba3b763f16dfb
   2:        0x10282264c - std::io::Write::write_fmt::h35935f9cf41659e0
   3:        0x10283008a - std::sys_common::backtrace::print::h48cb2ddd4d16ad05
   4:        0x1028333d3 - std::panicking::default_hook::{{closure}}::hf85401495f021b7c
   5:        0x102833128 - std::panicking::default_hook::hcc698ed67aaec0db
   6:        0x10e2de5fd - rustc_driver[c6bc39476a4ff69]::DEFAULT_HOOK::{closure#0}::{closure#0}
   7:        0x102833bb7 - std::panicking::rust_panic_with_hook::h4686e220b4123e59
   8:        0x11133abec - std[e853a6d0ec043b70]::panicking::begin_panic::<alloc[374a688e4a400e73]::string::String>::{closure#0}
   9:        0x11133a6e0 - std[e853a6d0ec043b70]::sys_common::backtrace::__rust_end_short_backtrace::<std[e853a6d0ec043b70]::panicking::begin_panic<alloc[374a688e4a400e73]::string::String>::{closure#0}, !>
  10:        0x11305dcec - std[e853a6d0ec043b70]::panicking::begin_panic::<alloc[374a688e4a400e73]::string::String>
  11:        0x11124d51f - std[e853a6d0ec043b70]::panic::panic_any::<alloc[374a688e4a400e73]::string::String>
  12:        0x11124d704 - rustc_middle[d5319f07d231351a]::ty::context::tls::with_context_opt::<rustc_middle[d5319f07d231351a]::ty::context::tls::with_opt<rustc_middle[d5319f07d231351a]::util::bug::opt_span_bug_fmt<rustc_span[db835ecaf6c42563]::span_encoding::Span>::{closure#0}, ()>::{closure#0}, ()>
  13:        0x11124d641 - rustc_middle[d5319f07d231351a]::util::bug::opt_span_bug_fmt::<rustc_span[db835ecaf6c42563]::span_encoding::Span>
  14:        0x11305c3cf - rustc_middle[d5319f07d231351a]::util::bug::span_bug_fmt::<rustc_span[db835ecaf6c42563]::span_encoding::Span>
  15:        0x1112c1754 - <rustc_resolve[90772e7bddb5c4fb]::imports::ImportResolver>::finalize_import::{closure#0}
  16:        0x111322f27 - <rustc_resolve[90772e7bddb5c4fb]::imports::ImportResolver>::finalize_import
  17:        0x111321161 - <rustc_resolve[90772e7bddb5c4fb]::imports::ImportResolver>::finalize_imports
  18:        0x1113303df - <rustc_session[bf9d936332845243]::session::Session>::time::<(), <rustc_resolve[90772e7bddb5c4fb]::Resolver>::resolve_crate::{closure#0}>
  19:        0x10e3a3a17 - rustc_interface[6b0baa6f0acee236]::passes::configure_and_expand
  20:        0x10e3ab3f6 - <rustc_interface[6b0baa6f0acee236]::queries::Queries>::expansion
  21:        0x10e2b6a67 - <rustc_interface[6b0baa6f0acee236]::interface::Compiler>::enter::<rustc_driver[c6bc39476a4ff69]::run_compiler::{closure#1}::{closure#2}, core[e7c8723dd1d9fd02]::result::Result<core[e7c8723dd1d9fd02]::option::Option<rustc_interface[6b0baa6f0acee236]::queries::Linker>, rustc_errors[5974999511236221]::ErrorGuaranteed>>
  22:        0x10e252d5d - rustc_span[db835ecaf6c42563]::with_source_map::<core[e7c8723dd1d9fd02]::result::Result<(), rustc_errors[5974999511236221]::ErrorGuaranteed>, rustc_interface[6b0baa6f0acee236]::interface::run_compiler<core[e7c8723dd1d9fd02]::result::Result<(), rustc_errors[5974999511236221]::ErrorGuaranteed>, rustc_driver[c6bc39476a4ff69]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  23:        0x10e2a9a9d - <scoped_tls[9dceb67bf45baec5]::ScopedKey<rustc_span[db835ecaf6c42563]::SessionGlobals>>::set::<rustc_interface[6b0baa6f0acee236]::interface::run_compiler<core[e7c8723dd1d9fd02]::result::Result<(), rustc_errors[5974999511236221]::ErrorGuaranteed>, rustc_driver[c6bc39476a4ff69]::run_compiler::{closure#1}>::{closure#0}, core[e7c8723dd1d9fd02]::result::Result<(), rustc_errors[5974999511236221]::ErrorGuaranteed>>
  24:        0x10e278ffa - std[e853a6d0ec043b70]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[6b0baa6f0acee236]::util::run_in_thread_pool_with_globals<rustc_interface[6b0baa6f0acee236]::interface::run_compiler<core[e7c8723dd1d9fd02]::result::Result<(), rustc_errors[5974999511236221]::ErrorGuaranteed>, rustc_driver[c6bc39476a4ff69]::run_compiler::{closure#1}>::{closure#0}, core[e7c8723dd1d9fd02]::result::Result<(), rustc_errors[5974999511236221]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[e7c8723dd1d9fd02]::result::Result<(), rustc_errors[5974999511236221]::ErrorGuaranteed>>
  25:        0x10e2592a5 - <<std[e853a6d0ec043b70]::thread::Builder>::spawn_unchecked_<rustc_interface[6b0baa6f0acee236]::util::run_in_thread_pool_with_globals<rustc_interface[6b0baa6f0acee236]::interface::run_compiler<core[e7c8723dd1d9fd02]::result::Result<(), rustc_errors[5974999511236221]::ErrorGuaranteed>, rustc_driver[c6bc39476a4ff69]::run_compiler::{closure#1}>::{closure#0}, core[e7c8723dd1d9fd02]::result::Result<(), rustc_errors[5974999511236221]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[e7c8723dd1d9fd02]::result::Result<(), rustc_errors[5974999511236221]::ErrorGuaranteed>>::{closure#1} as core[e7c8723dd1d9fd02]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  26:        0x10283ce87 - std::sys::unix::thread::Thread::new::thread_start::hb253bfeab5e611e1
  27:     0x7ff807a764e1 - __pthread_start

Regression

Regression in nightly-2018-12-30

Version

rustc 1.67.0-nightly (1eb62b123 2022-11-27)
binary: rustc
commit-hash: 1eb62b1235fd77200e6bd967d70e83c0f2497233
commit-date: 2022-11-27
host: x86_64-apple-darwin
release: 1.67.0-nightly
LLVM version: 15.0.4
@jruderman jruderman added 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. labels Nov 29, 2022
@jruderman
Copy link
Contributor Author

Same error message as #83950, but this one is self-contained and might be a separate bug.

@chenyukang
Copy link
Member

@rustbot claim

@chenyukang
Copy link
Member

chenyukang commented Dec 2, 2022

@compiler-errors
how about make this bug to an error with diagonostic?

span_bug!(import.span, "inconsistent resolution for an import");

Seems we don't have a chance to insert ambiguity_errors, because the use V is before the later use self::B::*;.

If we change code to this:

use self::A::*;
use self::B::*;
use V;

enum A {
    V
}
enum B {
    V
}
fn main() {}

It will be:

error[E0659]: `V` is ambiguous

if let Some((b2, kind)) = used_binding.ambiguity {

@cjgillot
Copy link
Contributor

cjgillot commented Dec 2, 2022

Could we register an AmbiguityError exactly in the place we ICE?

@chenyukang
Copy link
Member

Yes, this is also a solution, and then we can report error in the same function report_errors.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Dec 3, 2022
…gillot

Add AmbiguityError for inconsistent resolution for an import

Fixes rust-lang#105069
Fixes rust-lang#83950
@bors bors closed this as completed in 795b2af Dec 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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

Successfully merging a pull request may close this issue.

3 participants