Skip to content

ICE: inconsistent resolution for an import #126389

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
matthiaskrgr opened this issue Jun 13, 2024 · 3 comments · Fixed by #126568
Closed

ICE: inconsistent resolution for an import #126389

matthiaskrgr opened this issue Jun 13, 2024 · 3 comments · Fixed by #126568
Labels
A-resolve Area: Name/path resolution done by `rustc_resolve` specifically C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

auto-reduced (treereduce-rust):

mod a {
    pub mod b {
        pub mod c {}
    }
}

use a::*;

use b::c;

use c as b;

fn c() {}

original:

mod a {
    pub mod b {
        pub mod c {}
    }
}

use a::*;

use b::c;
//~^ ERROR: cannot determine resolution for the import
//~| ERROR: cannot determine resolution for the import
//~| ERROR: unresolved import `b::c`
use c as b;

fn c() {}

Version information

rustc 1.81.0-nightly (c25ac9d6c 2024-06-12)
binary: rustc
commit-hash: c25ac9d6cc285e57e1176dc2da6848b9d0163810
commit-date: 2024-06-12
host: x86_64-unknown-linux-gnu
release: 1.81.0-nightly
LLVM version: 18.1.7

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

error: internal compiler error: compiler/rustc_resolve/src/imports.rs:896:25: inconsistent resolution for an import
 --> /tmp/icemaker_global_tempdir.HTYQOidXpdqD/rustc_testrunner_tmpdir_reporting.saIM6oGr9vhO/mvce.rs:9:5
  |
9 | use b::c;
  |     ^^^^

thread 'rustc' panicked at compiler/rustc_resolve/src/imports.rs:896:25:
Box<dyn Any>
stack backtrace:
   0:     0x7330e58f5ae5 - std::backtrace_rs::backtrace::libunwind::trace::h6be50cef0e090531
                               at /rustc/c25ac9d6cc285e57e1176dc2da6848b9d0163810/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5
   1:     0x7330e58f5ae5 - std::backtrace_rs::backtrace::trace_unsynchronized::h84167074cb4f1713
                               at /rustc/c25ac9d6cc285e57e1176dc2da6848b9d0163810/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7330e58f5ae5 - std::sys_common::backtrace::_print_fmt::hb5cf039fd1f30b07
                               at /rustc/c25ac9d6cc285e57e1176dc2da6848b9d0163810/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7330e58f5ae5 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h01adaba1565f117f
                               at /rustc/c25ac9d6cc285e57e1176dc2da6848b9d0163810/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7330e594677b - core::fmt::rt::Argument::fmt::h2910e36f4e21d32d
                               at /rustc/c25ac9d6cc285e57e1176dc2da6848b9d0163810/library/core/src/fmt/rt.rs:165:63
   5:     0x7330e594677b - core::fmt::write::h6d9d2f7ff8571b34
                               at /rustc/c25ac9d6cc285e57e1176dc2da6848b9d0163810/library/core/src/fmt/mod.rs:1168:21
   6:     0x7330e58ea6bf - std::io::Write::write_fmt::hd882c0f914f56bf0
                               at /rustc/c25ac9d6cc285e57e1176dc2da6848b9d0163810/library/std/src/io/mod.rs:1835:15
   7:     0x7330e58f58be - std::sys_common::backtrace::_print::hcc6c907dafd9aacb
                               at /rustc/c25ac9d6cc285e57e1176dc2da6848b9d0163810/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7330e58f58be - std::sys_common::backtrace::print::h2c716a051c9b24be
                               at /rustc/c25ac9d6cc285e57e1176dc2da6848b9d0163810/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7330e58f82f9 - std::panicking::default_hook::{{closure}}::he8ad829f77bd4e23
  10:     0x7330e58f809c - std::panicking::default_hook::heb22a1402d2cff23
                               at /rustc/c25ac9d6cc285e57e1176dc2da6848b9d0163810/library/std/src/panicking.rs:292:9
  11:     0x7330e20b2c9f - std[5c07af62f3786d14]::panicking::update_hook::<alloc[eebcfc85002bd7db]::boxed::Box<rustc_driver_impl[2b4723ede88f52b1]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7330e58f8bff - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::hd8f0fcaec26c179e
                               at /rustc/c25ac9d6cc285e57e1176dc2da6848b9d0163810/library/alloc/src/boxed.rs:2076:9
  13:     0x7330e58f8bff - std::panicking::rust_panic_with_hook::hc9dbad8884217847
                               at /rustc/c25ac9d6cc285e57e1176dc2da6848b9d0163810/library/std/src/panicking.rs:801:13
  14:     0x7330e20e3621 - std[5c07af62f3786d14]::panicking::begin_panic::<rustc_errors[d9dad43edaa48690]::ExplicitBug>::{closure#0}
  15:     0x7330e20e03d6 - std[5c07af62f3786d14]::sys_common::backtrace::__rust_end_short_backtrace::<std[5c07af62f3786d14]::panicking::begin_panic<rustc_errors[d9dad43edaa48690]::ExplicitBug>::{closure#0}, !>
  16:     0x7330e20e00b6 - std[5c07af62f3786d14]::panicking::begin_panic::<rustc_errors[d9dad43edaa48690]::ExplicitBug>
  17:     0x7330e20ecb71 - <rustc_errors[d9dad43edaa48690]::diagnostic::BugAbort as rustc_errors[d9dad43edaa48690]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  18:     0x7330e29ca318 - <rustc_errors[d9dad43edaa48690]::DiagCtxt>::span_bug::<rustc_span[9012e0e35e67507c]::span_encoding::Span, alloc[eebcfc85002bd7db]::string::String>
  19:     0x7330e29e697d - rustc_middle[f645b954b6a941ee]::util::bug::opt_span_bug_fmt::<rustc_span[9012e0e35e67507c]::span_encoding::Span>::{closure#0}
  20:     0x7330e29e69aa - rustc_middle[f645b954b6a941ee]::ty::context::tls::with_opt::<rustc_middle[f645b954b6a941ee]::util::bug::opt_span_bug_fmt<rustc_span[9012e0e35e67507c]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  21:     0x7330e29e0b6b - rustc_middle[f645b954b6a941ee]::ty::context::tls::with_context_opt::<rustc_middle[f645b954b6a941ee]::ty::context::tls::with_opt<rustc_middle[f645b954b6a941ee]::util::bug::opt_span_bug_fmt<rustc_span[9012e0e35e67507c]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  22:     0x7330e0f05ea7 - rustc_middle[f645b954b6a941ee]::util::bug::span_bug_fmt::<rustc_span[9012e0e35e67507c]::span_encoding::Span>
  23:     0x7330e451bf75 - <rustc_resolve[b14fb066e2167f99]::Resolver>::resolve_crate::{closure#0}
  24:     0x7330e4512cc0 - <rustc_resolve[b14fb066e2167f99]::Resolver>::resolve_crate
  25:     0x7330e38f555a - rustc_interface[8465b2f8b714accd]::passes::resolver_for_lowering_raw
  26:     0x7330e38f47cd - rustc_query_impl[860f4585269295fe]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[860f4585269295fe]::query_impl::resolver_for_lowering_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[f645b954b6a941ee]::query::erase::Erased<[u8; 16usize]>>
  27:     0x7330e38f47b1 - <rustc_query_impl[860f4585269295fe]::query_impl::resolver_for_lowering_raw::dynamic_query::{closure#2} as core[207868f0da9fe1eb]::ops::function::FnOnce<(rustc_middle[f645b954b6a941ee]::ty::context::TyCtxt, ())>>::call_once
  28:     0x7330e41f4e1d - rustc_query_system[88bb5c8529314a04]::query::plumbing::try_execute_query::<rustc_query_impl[860f4585269295fe]::DynamicConfig<rustc_query_system[88bb5c8529314a04]::query::caches::SingleCache<rustc_middle[f645b954b6a941ee]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[860f4585269295fe]::plumbing::QueryCtxt, false>
  29:     0x7330e41f4abd - rustc_query_impl[860f4585269295fe]::query_impl::resolver_for_lowering_raw::get_query_non_incr::__rust_end_short_backtrace
  30:     0x7330e40d0782 - rustc_interface[8465b2f8b714accd]::interface::run_compiler::<core[207868f0da9fe1eb]::result::Result<(), rustc_span[9012e0e35e67507c]::ErrorGuaranteed>, rustc_driver_impl[2b4723ede88f52b1]::run_compiler::{closure#0}>::{closure#1}
  31:     0x7330e40ef649 - std[5c07af62f3786d14]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[8465b2f8b714accd]::util::run_in_thread_with_globals<rustc_interface[8465b2f8b714accd]::util::run_in_thread_pool_with_globals<rustc_interface[8465b2f8b714accd]::interface::run_compiler<core[207868f0da9fe1eb]::result::Result<(), rustc_span[9012e0e35e67507c]::ErrorGuaranteed>, rustc_driver_impl[2b4723ede88f52b1]::run_compiler::{closure#0}>::{closure#1}, core[207868f0da9fe1eb]::result::Result<(), rustc_span[9012e0e35e67507c]::ErrorGuaranteed>>::{closure#0}, core[207868f0da9fe1eb]::result::Result<(), rustc_span[9012e0e35e67507c]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[207868f0da9fe1eb]::result::Result<(), rustc_span[9012e0e35e67507c]::ErrorGuaranteed>>
  32:     0x7330e40ef3fa - <<std[5c07af62f3786d14]::thread::Builder>::spawn_unchecked_<rustc_interface[8465b2f8b714accd]::util::run_in_thread_with_globals<rustc_interface[8465b2f8b714accd]::util::run_in_thread_pool_with_globals<rustc_interface[8465b2f8b714accd]::interface::run_compiler<core[207868f0da9fe1eb]::result::Result<(), rustc_span[9012e0e35e67507c]::ErrorGuaranteed>, rustc_driver_impl[2b4723ede88f52b1]::run_compiler::{closure#0}>::{closure#1}, core[207868f0da9fe1eb]::result::Result<(), rustc_span[9012e0e35e67507c]::ErrorGuaranteed>>::{closure#0}, core[207868f0da9fe1eb]::result::Result<(), rustc_span[9012e0e35e67507c]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[207868f0da9fe1eb]::result::Result<(), rustc_span[9012e0e35e67507c]::ErrorGuaranteed>>::{closure#2} as core[207868f0da9fe1eb]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  33:     0x7330e5902a7b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hd64233370b4bbb13
                               at /rustc/c25ac9d6cc285e57e1176dc2da6848b9d0163810/library/alloc/src/boxed.rs:2062:9
  34:     0x7330e5902a7b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h8b9a0bf226b4eb10
                               at /rustc/c25ac9d6cc285e57e1176dc2da6848b9d0163810/library/alloc/src/boxed.rs:2062:9
  35:     0x7330e5902a7b - std::sys::pal::unix::thread::Thread::new::thread_start::h25e4cee516ffa27e
                               at /rustc/c25ac9d6cc285e57e1176dc2da6848b9d0163810/library/std/src/sys/pal/unix/thread.rs:108:17
  36:     0x7330deca6ded - <unknown>
  37:     0x7330ded2a0dc - <unknown>
  38:                0x0 - <unknown>

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: rustc 1.81.0-nightly (c25ac9d6c 2024-06-12) running on x86_64-unknown-linux-gnu

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


@matthiaskrgr matthiaskrgr added 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. C-bug Category: This is a bug. labels Jun 13, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jun 13, 2024
@jieyouxu
Copy link
Member

jieyouxu commented Jun 13, 2024

Isn't this example identical to #124490 (comment)?

EDIT: oh I see, the PR that closes #124490 doesn't actually have this test, so it's possible this is a different ICE.

@jieyouxu jieyouxu added A-resolve Area: Name/path resolution done by `rustc_resolve` specifically S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Jun 13, 2024
@matthiaskrgr
Copy link
Member Author

This one has an additional fn c() {} which indeed causes the ICE to trigger again 😆

@matthiaskrgr
Copy link
Member Author

Regression in nightly-2020-11-09
commit[0] 2020-11-07: Auto merge of #75199 - Mark-Simulacrum:debug-asserts, r=pietroalbini
commit[1] 2020-11-07: Auto merge of #78784 - Mark-Simulacrum:revert-77421, r=petrochenkov
commit[2] 2020-11-08: Auto merge of #77729 - petrochenkov:mergetarg, r=Mark-Simulacrum
commit[3] 2020-11-08: Auto merge of #78410 - lcnr:revert75443, r=nikomatsakis
commit[4] 2020-11-08: Auto merge of #78874 - m-ou-se:rollup-3jp1ijj, r=m-ou-se
commit[5] 2020-11-08: Auto merge of #78712 - petrochenkov:visitok, r=Aaron1011

@matthiaskrgr matthiaskrgr added the S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. label Jun 17, 2024
@bors bors closed this as completed in ba26af3 Jun 17, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jun 17, 2024
Rollup merge of rust-lang#126568 - bvanjoi:fix-126376, r=petrochenkov

mark undetermined if target binding in current ns is not got

Fixes rust-lang#126376
Fixes rust-lang#126389

Add a branch to handle more cases...

r? `@petrochenkov`
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-resolve Area: Name/path resolution done by `rustc_resolve` specifically C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue 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