Skip to content

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

@jruderman

Description

@jruderman
Contributor

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

Activity

added
C-bugCategory: This is a bug.
I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
on Nov 29, 2022
jruderman

jruderman commented on Nov 29, 2022

@jruderman
ContributorAuthor

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

chenyukang

chenyukang commented on Dec 2, 2022

@chenyukang
Member

@rustbot claim

chenyukang

chenyukang commented on Dec 2, 2022

@chenyukang
Member

@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

cjgillot commented on Dec 2, 2022

@cjgillot
Contributor

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

chenyukang

chenyukang commented on Dec 3, 2022

@chenyukang
Member

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

added a commit that references this issue on Dec 3, 2022
795b2af
added a commit that references this issue on Dec 3, 2022
af8f722
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    Participants

    @chenyukang@jruderman@cjgillot

    Issue actions

      ICE "inconsistent resolution for an import" with two enums · Issue #105069 · rust-lang/rust