Skip to content

ICE: path resolved multiple times  #141265

@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

fn foo(n: i32) -> i32 {
    for else if n < 30 {
          return 3;
        } else if n <   
}

fn main() {}

original:

fn foo(n: i32) -> i32 {
    for else if n < 30 {
          return 3;
        } else if n < 40 {
          return 4;
        } else {
          return 5;
        } in 0..0 { //~ ERROR mismatched types [E0308]
       if n < 0 {
        return i;
        } else if n < 10 {
          return 1;
        } else if n < 30 {
          return 2;
        } else if n < 3 {
          return 30;
        } else if i < 40 {
          return 4;
        } else {
          return 5;
        }

    } //~ HELP consider returning a value here
}

fn main() {}

Version information

rustc 1.89.0-nightly (59372f2c8 2025-05-19)
binary: rustc
commit-hash: 59372f2c81ba74554d9a71b12a4ed7f29adb33a2
commit-date: 2025-05-19
host: x86_64-unknown-linux-gnu
release: 1.89.0-nightly
LLVM version: 20.1.5

Possibly related line of code:

module
}
fn record_partial_res(&mut self, node_id: NodeId, resolution: PartialRes) {
debug!("(recording res) recording {:?} for {}", resolution, node_id);
if let Some(prev_res) = self.partial_res_map.insert(node_id, resolution) {
panic!("path resolved multiple times ({prev_res:?} before, {resolution:?} now)");
}
}
fn record_pat_span(&mut self, node: NodeId, span: Span) {
debug!("(recording pat) recording {:?} for {:?}", node, span);
self.pat_span_map.insert(node, span);

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

Program output

error: expected identifier, found keyword `else`
 --> /tmp/icemaker_global_tempdir.ZYQklpQgWWWg/rustc_testrunner_tmpdir_reporting.HxFtsJMYfXBy/mvce.rs:2:9
  |
2 |     for else if n < 30 {
  |         ^^^^ expected identifier, found keyword

error: missing `in` in `for` loop
 --> /tmp/icemaker_global_tempdir.ZYQklpQgWWWg/rustc_testrunner_tmpdir_reporting.HxFtsJMYfXBy/mvce.rs:2:23
  |
2 |     for else if n < 30 {
  |                       ^
  |
help: try adding `in` here
  |
2 |     for else if n < 30 in {
  |                        ++

error: missing expression to iterate on in `for` loop
 --> /tmp/icemaker_global_tempdir.ZYQklpQgWWWg/rustc_testrunner_tmpdir_reporting.HxFtsJMYfXBy/mvce.rs:2:24
  |
2 |     for else if n < 30 {
  |                        ^
  |
help: try adding an expression to the `for` loop
  |
2 |     for else if n < 30 /* expression */ {
  |                        ++++++++++++++++

error: expected expression, found keyword `else`
 --> /tmp/icemaker_global_tempdir.ZYQklpQgWWWg/rustc_testrunner_tmpdir_reporting.HxFtsJMYfXBy/mvce.rs:4:11
  |
4 |         } else if n <   
  |           ^^^^ expected expression


thread 'rustc' panicked at compiler/rustc_resolve/src/lib.rs:2063:13:
path resolved multiple times (PartialRes { base_res: Local(NodeId(11)), unresolved_segments: 0 } before, PartialRes { base_res: Local(NodeId(11)), unresolved_segments: 0 } now)
stack backtrace:
   0:     0x7ca4b116e023 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hb733e9efaf3b1f11
   1:     0x7ca4b18057f7 - core::fmt::write::h82b110e81b344036
   2:     0x7ca4b28d7e11 - std::io::Write::write_fmt::hd49d25d684d23c2d
   3:     0x7ca4b116de82 - std::sys::backtrace::BacktraceLock::print::hbfba2ef59f2b2801
   4:     0x7ca4b1171a7a - std::panicking::default_hook::{{closure}}::h396d1a8f0249ebe8
   5:     0x7ca4b11715ff - std::panicking::default_hook::h6c17c4754142377e
   6:     0x7ca4b019cff3 - std[968b93fd6ebeb4b5]::panicking::update_hook::<alloc[bc06130c28a49d30]::boxed::Box<rustc_driver_impl[e6bc7aa567003b68]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x7ca4b11722f3 - std::panicking::rust_panic_with_hook::h48352e2ca75f781b
   8:     0x7ca4b1171fea - std::panicking::begin_panic_handler::{{closure}}::h503425dfec26aebe
   9:     0x7ca4b116e4f9 - std::sys::backtrace::__rust_end_short_backtrace::ha2d4adb75cb99627
  10:     0x7ca4b1171cad - __rustc[f9c36fba5a9aea26]::rust_begin_unwind
  11:     0x7ca4ada88520 - core::panicking::panic_fmt::h3fab37719e87c850
  12:     0x7ca4b2976f89 - <rustc_resolve[7ba995a0bb498022]::late::LateResolutionVisitor>::smart_resolve_path_fragment
  13:     0x7ca4b2368ba3 - <rustc_resolve[7ba995a0bb498022]::late::LateResolutionVisitor>::resolve_expr
  14:     0x7ca4b236a4e2 - <rustc_resolve[7ba995a0bb498022]::late::LateResolutionVisitor>::resolve_expr
  15:     0x7ca4ae3bef29 - <rustc_resolve[7ba995a0bb498022]::late::LateResolutionVisitor>::resolve_pattern_inner::{closure#0}
  16:     0x7ca4b2360063 - <rustc_ast[1ff731b08f9d714a]::ast::Pat>::walk::<<rustc_resolve[7ba995a0bb498022]::late::LateResolutionVisitor>::resolve_pattern_inner::{closure#0}>
  17:     0x7ca4b235fb79 - <rustc_resolve[7ba995a0bb498022]::late::LateResolutionVisitor>::resolve_pattern_top
  18:     0x7ca4b2369e09 - <rustc_resolve[7ba995a0bb498022]::late::LateResolutionVisitor>::resolve_expr
  19:     0x7ca4b23681d3 - <rustc_resolve[7ba995a0bb498022]::late::LateResolutionVisitor>::resolve_block
  20:     0x7ca4b2362268 - <rustc_resolve[7ba995a0bb498022]::late::LateResolutionVisitor as rustc_ast[1ff731b08f9d714a]::visit::Visitor>::visit_fn
  21:     0x7ca4b242da2f - rustc_ast[1ff731b08f9d714a]::visit::walk_item_ctxt::<rustc_resolve[7ba995a0bb498022]::late::LateResolutionVisitor, rustc_ast[1ff731b08f9d714a]::ast::ItemKind>
  22:     0x7ca4b24375d5 - <rustc_resolve[7ba995a0bb498022]::late::LateResolutionVisitor as rustc_ast[1ff731b08f9d714a]::visit::Visitor>::visit_item
  23:     0x7ca4b2409ce3 - <rustc_resolve[7ba995a0bb498022]::Resolver>::resolve_crate::{closure#0}
  24:     0x7ca4b2411b3f - <rustc_resolve[7ba995a0bb498022]::Resolver>::resolve_crate
  25:     0x7ca4b1ff2a2d - rustc_interface[19b65b2206430f98]::passes::resolver_for_lowering_raw
  26:     0x7ca4b1ff198d - rustc_query_impl[1c6786156c11e9e4]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[1c6786156c11e9e4]::query_impl::resolver_for_lowering_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[6f6b1c72c5137cad]::query::erase::Erased<[u8; 16usize]>>
  27:     0x7ca4b1ff1979 - <rustc_query_impl[1c6786156c11e9e4]::query_impl::resolver_for_lowering_raw::dynamic_query::{closure#2} as core[b511c5479c35ab71]::ops::function::FnOnce<(rustc_middle[6f6b1c72c5137cad]::ty::context::TyCtxt, ())>>::call_once
  28:     0x7ca4b276ed07 - rustc_query_system[e8736666912a07d4]::query::plumbing::try_execute_query::<rustc_query_impl[1c6786156c11e9e4]::DynamicConfig<rustc_query_system[e8736666912a07d4]::query::caches::SingleCache<rustc_middle[6f6b1c72c5137cad]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[1c6786156c11e9e4]::plumbing::QueryCtxt, false>
  29:     0x7ca4b276e8a5 - rustc_query_impl[1c6786156c11e9e4]::query_impl::resolver_for_lowering_raw::get_query_non_incr::__rust_end_short_backtrace
  30:     0x7ca4b287c671 - rustc_interface[19b65b2206430f98]::passes::create_and_enter_global_ctxt::<core[b511c5479c35ab71]::option::Option<rustc_interface[19b65b2206430f98]::queries::Linker>, rustc_driver_impl[e6bc7aa567003b68]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  31:     0x7ca4b29249e6 - rustc_interface[19b65b2206430f98]::interface::run_compiler::<(), rustc_driver_impl[e6bc7aa567003b68]::run_compiler::{closure#0}>::{closure#1}
  32:     0x7ca4b28d1ac6 - std[968b93fd6ebeb4b5]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[19b65b2206430f98]::util::run_in_thread_with_globals<rustc_interface[19b65b2206430f98]::util::run_in_thread_pool_with_globals<rustc_interface[19b65b2206430f98]::interface::run_compiler<(), rustc_driver_impl[e6bc7aa567003b68]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  33:     0x7ca4b28d176b - <<std[968b93fd6ebeb4b5]::thread::Builder>::spawn_unchecked_<rustc_interface[19b65b2206430f98]::util::run_in_thread_with_globals<rustc_interface[19b65b2206430f98]::util::run_in_thread_pool_with_globals<rustc_interface[19b65b2206430f98]::interface::run_compiler<(), rustc_driver_impl[e6bc7aa567003b68]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[b511c5479c35ab71]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  34:     0x7ca4b28d327d - std::sys::pal::unix::thread::Thread::new::thread_start::hfb82a117727f37ef
  35:     0x7ca4ac6a57eb - <unknown>
  36:     0x7ca4ac72918c - <unknown>
  37:                0x0 - <unknown>

error: the compiler unexpectedly panicked. this is a bug.

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.89.0-nightly (59372f2c8 2025-05-19) 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 4 previous errors


Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-has-bisectionStatus: A bisection has been found for this issueS-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-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