Skip to content

ICE: inconsistent resolution for an import #128813

Closed
@Naserume

Description

@Naserume

Code

extern crate core;

fn useful_syntax() {
    use ::{{core}, {std}};
}

macro_rules! define_other_core {
    () => {
        extern crate std as core;
    };
}

define_other_core!();

fn main() {}

command: rustc ./file.rs --edition=2021

Meta

rustc --version --verbose:

rustc 1.82.0-nightly (60d146580 2024-08-06)
binary: rustc
commit-hash: 60d146580c10036ce89e019422c6bc2fd9729b65
commit-date: 2024-08-06
host: x86_64-apple-darwin
release: 1.82.0-nightly
LLVM version: 19.1.0

Error output

error[E0259]: the name `core` is defined multiple times
  --> ./12995.rs:9:9
   |
1  | extern crate core;
   | ------------------ previous import of the extern crate `core` here
...
9  |         extern crate std as core;
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^ `core` reimported here
...
13 | define_other_core!();
   | -------------------- in this macro invocation
   |
   = note: `core` must be defined only once in the type namespace of this module
   = note: this error originates in the macro `define_other_core` (in Nightly builds, run with -Z macro-backtrace for more info)
help: you can use `as` to change the binding name of the import
   |
9  |         extern crate std as other_core;
   |

Backtrace

error: internal compiler error: compiler/rustc_resolve/src/imports.rs:1095:33: inconsistent resolution for an import
 --> ./12995.rs:4:13
  |
4 |     use ::{{core}, {std}};
  |             ^^^^

thread 'rustc' panicked at compiler/rustc_resolve/src/imports.rs:1095:33:
Box<dyn Any>
stack backtrace:
   0:        0x102a0a7f9 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hde541634c76c8424
   1:        0x102a5658b - core::fmt::write::h0a6995bfd5310686
   2:        0x1029ffa32 - std::io::Write::write_fmt::ha44463c63b65871a
   3:        0x102a0d0a8 - std::panicking::default_hook::{{closure}}::h8629ee341b692758
   4:        0x102a0ccee - std::panicking::default_hook::h8703f8d1cc197d13
   5:        0x10c06f0fd - std[513de39480af1bab]::panicking::update_hook::<alloc[88fbee91b568d05e]::boxed::Box<rustc_driver_impl[1a7a7dac5035a0ee]::install_ice_hook::{closure#0}>>::{closure#0}
   6:        0x102a0ded0 - std::panicking::rust_panic_with_hook::h68d7251319b974a6
   7:        0x10c0e28f7 - std[513de39480af1bab]::panicking::begin_panic::<rustc_errors[77d550dff4600411]::ExplicitBug>::{closure#0}
   8:        0x10c0ce7f9 - std[513de39480af1bab]::sys::backtrace::__rust_end_short_backtrace::<std[513de39480af1bab]::panicking::begin_panic<rustc_errors[77d550dff4600411]::ExplicitBug>::{closure#0}, !>
   9:        0x110ca0589 - std[513de39480af1bab]::panicking::begin_panic::<rustc_errors[77d550dff4600411]::ExplicitBug>
  10:        0x10c0f5466 - <rustc_errors[77d550dff4600411]::diagnostic::BugAbort as rustc_errors[77d550dff4600411]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  11:        0x10d7ced41 - <rustc_errors[77d550dff4600411]::DiagCtxtHandle>::span_bug::<rustc_span[af5dc13a57d4458]::span_encoding::Span, alloc[88fbee91b568d05e]::string::String>
  12:        0x10d823f78 - rustc_middle[ef4ebef1f35b9a45]::util::bug::opt_span_bug_fmt::<rustc_span[af5dc13a57d4458]::span_encoding::Span>::{closure#0}
  13:        0x10d823fb7 - rustc_middle[ef4ebef1f35b9a45]::ty::context::tls::with_opt::<rustc_middle[ef4ebef1f35b9a45]::util::bug::opt_span_bug_fmt<rustc_span[af5dc13a57d4458]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  14:        0x10d806895 - rustc_middle[ef4ebef1f35b9a45]::ty::context::tls::with_context_opt::<rustc_middle[ef4ebef1f35b9a45]::ty::context::tls::with_opt<rustc_middle[ef4ebef1f35b9a45]::util::bug::opt_span_bug_fmt<rustc_span[af5dc13a57d4458]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  15:        0x110e2de12 - rustc_middle[ef4ebef1f35b9a45]::util::bug::span_bug_fmt::<rustc_span[af5dc13a57d4458]::span_encoding::Span>
  16:        0x10d8912a5 - <rustc_resolve[45692f5fb0b81a0]::Resolver>::finalize_import::{closure#2}
  17:        0x10d88c7e2 - <rustc_resolve[45692f5fb0b81a0]::Resolver>::finalize_import
  18:        0x10d90b9bd - <rustc_resolve[45692f5fb0b81a0]::Resolver>::resolve_crate::{closure#0}
  19:        0x10d90a9de - <rustc_resolve[45692f5fb0b81a0]::Resolver>::resolve_crate
  20:        0x10c9a9e24 - rustc_interface[55f0bb586236ba3f]::passes::resolver_for_lowering_raw
  21:        0x10d718c66 - rustc_query_impl[db7d5818ebb544c0]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[db7d5818ebb544c0]::query_impl::resolver_for_lowering_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[ef4ebef1f35b9a45]::query::erase::Erased<[u8; 16usize]>>
  22:        0x10d6dbb3e - <rustc_query_impl[db7d5818ebb544c0]::query_impl::resolver_for_lowering_raw::dynamic_query::{closure#2} as core[31c80208252ed77d]::ops::function::FnOnce<(rustc_middle[ef4ebef1f35b9a45]::ty::context::TyCtxt, ())>>::call_once
  23:        0x10d4f4ae8 - rustc_query_system[9c8bd583e072577f]::query::plumbing::try_execute_query::<rustc_query_impl[db7d5818ebb544c0]::DynamicConfig<rustc_query_system[9c8bd583e072577f]::query::caches::SingleCache<rustc_middle[ef4ebef1f35b9a45]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[db7d5818ebb544c0]::plumbing::QueryCtxt, false>
  24:        0x10d7207bc - rustc_query_impl[db7d5818ebb544c0]::query_impl::resolver_for_lowering_raw::get_query_non_incr::__rust_end_short_backtrace
  25:        0x10c019ebe - <rustc_interface[55f0bb586236ba3f]::queries::QueryResult<&rustc_middle[ef4ebef1f35b9a45]::ty::context::GlobalCtxt>>::enter::<&rustc_data_structures[1d7d5eef2915edc]::steal::Steal<(rustc_middle[ef4ebef1f35b9a45]::ty::ResolverAstLowering, alloc[88fbee91b568d05e]::sync::Arc<rustc_ast[6e61105b9f75d832]::ast::Crate>)>, rustc_driver_impl[1a7a7dac5035a0ee]::run_compiler::{closure#0}::{closure#1}::{closure#3}>
  26:        0x10c07559d - rustc_interface[55f0bb586236ba3f]::interface::run_compiler::<core[31c80208252ed77d]::result::Result<(), rustc_span[af5dc13a57d4458]::ErrorGuaranteed>, rustc_driver_impl[1a7a7dac5035a0ee]::run_compiler::{closure#0}>::{closure#1}
  27:        0x10c0619c1 - std[513de39480af1bab]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[55f0bb586236ba3f]::util::run_in_thread_with_globals<rustc_interface[55f0bb586236ba3f]::util::run_in_thread_pool_with_globals<rustc_interface[55f0bb586236ba3f]::interface::run_compiler<core[31c80208252ed77d]::result::Result<(), rustc_span[af5dc13a57d4458]::ErrorGuaranteed>, rustc_driver_impl[1a7a7dac5035a0ee]::run_compiler::{closure#0}>::{closure#1}, core[31c80208252ed77d]::result::Result<(), rustc_span[af5dc13a57d4458]::ErrorGuaranteed>>::{closure#0}, core[31c80208252ed77d]::result::Result<(), rustc_span[af5dc13a57d4458]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[31c80208252ed77d]::result::Result<(), rustc_span[af5dc13a57d4458]::ErrorGuaranteed>>
  28:        0x10c078a06 - <<std[513de39480af1bab]::thread::Builder>::spawn_unchecked_<rustc_interface[55f0bb586236ba3f]::util::run_in_thread_with_globals<rustc_interface[55f0bb586236ba3f]::util::run_in_thread_pool_with_globals<rustc_interface[55f0bb586236ba3f]::interface::run_compiler<core[31c80208252ed77d]::result::Result<(), rustc_span[af5dc13a57d4458]::ErrorGuaranteed>, rustc_driver_impl[1a7a7dac5035a0ee]::run_compiler::{closure#0}>::{closure#1}, core[31c80208252ed77d]::result::Result<(), rustc_span[af5dc13a57d4458]::ErrorGuaranteed>>::{closure#0}, core[31c80208252ed77d]::result::Result<(), rustc_span[af5dc13a57d4458]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[31c80208252ed77d]::result::Result<(), rustc_span[af5dc13a57d4458]::ErrorGuaranteed>>::{closure#1} as core[31c80208252ed77d]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  29:        0x102a16afb - std::sys::pal::unix::thread::Thread::new::thread_start::h38612934f7248e43
  30:     0x7ff801f5318b - __pthread_start

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: please make sure that you have updated to the latest nightly

note: please attach the file at `/Users/rustc-ice-2024-08-08T08_02_16-90700.txt` to your bug report

query stack during panic:
#0 [resolver_for_lowering_raw] getting the resolver for lowering
end of query stack
error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0259`.

Note

ICE location:

let res = binding.res();
let has_ambiguity_error =
this.ambiguity_errors.iter().any(|error| !error.warning);
if res == Res::Err || has_ambiguity_error {
this.dcx()
.span_delayed_bug(import.span, "some error happened for an import");
return;
}
if let Ok(initial_res) = initial_res {
if res != initial_res {
span_bug!(import.span, "inconsistent resolution for an import");
}
} else if this.privacy_errors.is_empty() {
this.dcx()
.create_err(CannotDetermineImportResolution { span: import.span })
.emit();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyC-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

    No branches or pull requests

    Issue actions