rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
98.34k stars 12.72k forks source link

ICE: `inconsistent resolution for an import` #124490

Closed matthiaskrgr closed 5 months ago

matthiaskrgr commented 6 months ago

auto-reduced (treereduce-rust):

use io::{self as std};
use std::collections::{self as io};

original:

use std::collections::{self as io};
use io::{self as std};

Version information

rustc 1.80.0-nightly (91d5e4af8 2024-04-28)
binary: rustc
commit-hash: 91d5e4af8674bde06096bac1e7ac04af0e94c691
commit-date: 2024-04-28
host: x86_64-unknown-linux-gnu
release: 1.80.0-nightly
LLVM version: 18.1.4

Command: /home/matthias/.rustup/toolchains/master/bin/rustc -Zunstable-options --edition=2024

Program output

``` error: internal compiler error: compiler/rustc_resolve/src/imports.rs:884:25: inconsistent resolution for an import --> /tmp/icemaker_global_tempdir.7N3g3X1DaYFn/rustc_testrunner_tmpdir_reporting.hyRGLJm0FCJ6/mvce.rs:2:24 | 2 | use std::collections::{self as io}; | ^^^^^^^^^^ thread 'rustc' panicked at compiler/rustc_resolve/src/imports.rs:884:25: Box stack backtrace: 0: 0x7b6b0a636035 - std::backtrace_rs::backtrace::libunwind::trace::ha90ea7a57c64b8ab at /rustc/91d5e4af8674bde06096bac1e7ac04af0e94c691/library/std/src/../../backtrace/src/backtrace/libunwind.rs:105:5 1: 0x7b6b0a636035 - std::backtrace_rs::backtrace::trace_unsynchronized::ha58e55f622939b6e at /rustc/91d5e4af8674bde06096bac1e7ac04af0e94c691/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5 2: 0x7b6b0a636035 - std::sys_common::backtrace::_print_fmt::h687007ed504e7e64 at /rustc/91d5e4af8674bde06096bac1e7ac04af0e94c691/library/std/src/sys_common/backtrace.rs:68:5 3: 0x7b6b0a636035 - ::fmt::hecfae54cdc6fec81 at /rustc/91d5e4af8674bde06096bac1e7ac04af0e94c691/library/std/src/sys_common/backtrace.rs:44:22 4: 0x7b6b0a68529b - core::fmt::rt::Argument::fmt::h1cf6305de42401ed at /rustc/91d5e4af8674bde06096bac1e7ac04af0e94c691/library/core/src/fmt/rt.rs:165:63 5: 0x7b6b0a68529b - core::fmt::write::hb74fc275648248fb at /rustc/91d5e4af8674bde06096bac1e7ac04af0e94c691/library/core/src/fmt/mod.rs:1157:21 6: 0x7b6b0a62abdf - std::io::Write::write_fmt::h5209ffd8e6502f0c at /rustc/91d5e4af8674bde06096bac1e7ac04af0e94c691/library/std/src/io/mod.rs:1832:15 7: 0x7b6b0a635e0e - std::sys_common::backtrace::_print::h168707047d27c84e at /rustc/91d5e4af8674bde06096bac1e7ac04af0e94c691/library/std/src/sys_common/backtrace.rs:47:5 8: 0x7b6b0a635e0e - std::sys_common::backtrace::print::h2942d174d6b0e46d at /rustc/91d5e4af8674bde06096bac1e7ac04af0e94c691/library/std/src/sys_common/backtrace.rs:34:9 9: 0x7b6b0a638779 - std::panicking::default_hook::{{closure}}::h4215c46ca923b014 10: 0x7b6b0a6384bd - std::panicking::default_hook::h887f937d01fa1b64 at /rustc/91d5e4af8674bde06096bac1e7ac04af0e94c691/library/std/src/panicking.rs:298:9 11: 0x7b6b06e40a1c - std[aaff33ccdb7ea7e2]::panicking::update_hook::>::{closure#0} 12: 0x7b6b0a638e76 - as core::ops::function::Fn>::call::hfe27c2dc23f9f057 at /rustc/91d5e4af8674bde06096bac1e7ac04af0e94c691/library/alloc/src/boxed.rs:2036:9 13: 0x7b6b0a638e76 - std::panicking::rust_panic_with_hook::h6ef218c13552449b at /rustc/91d5e4af8674bde06096bac1e7ac04af0e94c691/library/std/src/panicking.rs:799:13 14: 0x7b6b06e70374 - std[aaff33ccdb7ea7e2]::panicking::begin_panic::::{closure#0} 15: 0x7b6b06e6cff6 - std[aaff33ccdb7ea7e2]::sys_common::backtrace::__rust_end_short_backtrace::::{closure#0}, !> 16: 0x7b6b06e6ccd6 - std[aaff33ccdb7ea7e2]::panicking::begin_panic:: 17: 0x7b6b06e79181 - ::emit_producing_guarantee 18: 0x7b6b076ede48 - ::span_bug:: 19: 0x7b6b0770a73d - rustc_middle[783a1d49f02736b7]::util::bug::opt_span_bug_fmt::::{closure#0} 20: 0x7b6b0770a76a - rustc_middle[783a1d49f02736b7]::ty::context::tls::with_opt::::{closure#0}, !>::{closure#0} 21: 0x7b6b07704c8b - rustc_middle[783a1d49f02736b7]::ty::context::tls::with_context_opt::::{closure#0}, !>::{closure#0}, !> 22: 0x7b6b05906ec7 - rustc_middle[783a1d49f02736b7]::util::bug::span_bug_fmt:: 23: 0x7b6b0923d880 - ::resolve_crate::{closure#0} 24: 0x7b6b09234c9c - ::resolve_crate 25: 0x7b6b0881032b - rustc_interface[3360209938edb6a7]::passes::resolver_for_lowering_raw 26: 0x7b6b0880f567 - rustc_query_impl[77a161a94332e7e1]::plumbing::__rust_begin_short_backtrace::> 27: 0x7b6b0880f555 - >::call_once 28: 0x7b6b09002e85 - rustc_query_system[61cd216fcfa07925]::query::plumbing::try_execute_query::>, false, false, false>, rustc_query_impl[77a161a94332e7e1]::plumbing::QueryCtxt, false> 29: 0x7b6b09002a01 - rustc_query_impl[77a161a94332e7e1]::query_impl::resolver_for_lowering_raw::get_query_non_incr::__rust_end_short_backtrace 30: 0x7b6b08ea30be - rustc_interface[3360209938edb6a7]::interface::run_compiler::, rustc_driver_impl[d0a4257edbfecd8c]::run_compiler::{closure#0}>::{closure#1} 31: 0x7b6b08e727c9 - std[aaff33ccdb7ea7e2]::sys_common::backtrace::__rust_begin_short_backtrace::, rustc_driver_impl[d0a4257edbfecd8c]::run_compiler::{closure#0}>::{closure#1}, core[8db7010e98043ac]::result::Result<(), rustc_span[6a84a2dd20c85103]::ErrorGuaranteed>>::{closure#0}, core[8db7010e98043ac]::result::Result<(), rustc_span[6a84a2dd20c85103]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[8db7010e98043ac]::result::Result<(), rustc_span[6a84a2dd20c85103]::ErrorGuaranteed>> 32: 0x7b6b08e72576 - <::spawn_unchecked_, rustc_driver_impl[d0a4257edbfecd8c]::run_compiler::{closure#0}>::{closure#1}, core[8db7010e98043ac]::result::Result<(), rustc_span[6a84a2dd20c85103]::ErrorGuaranteed>>::{closure#0}, core[8db7010e98043ac]::result::Result<(), rustc_span[6a84a2dd20c85103]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[8db7010e98043ac]::result::Result<(), rustc_span[6a84a2dd20c85103]::ErrorGuaranteed>>::{closure#2} as core[8db7010e98043ac]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 33: 0x7b6b0a642cab - as core::ops::function::FnOnce>::call_once::h1c1c6804813d5e77 at /rustc/91d5e4af8674bde06096bac1e7ac04af0e94c691/library/alloc/src/boxed.rs:2022:9 34: 0x7b6b0a642cab - as core::ops::function::FnOnce>::call_once::h3d84aa3b40a67b8f at /rustc/91d5e4af8674bde06096bac1e7ac04af0e94c691/library/alloc/src/boxed.rs:2022:9 35: 0x7b6b0a642cab - std::sys::pal::unix::thread::Thread::new::thread_start::h60cefba2ee6cce64 at /rustc/91d5e4af8674bde06096bac1e7ac04af0e94c691/library/std/src/sys/pal/unix/thread.rs:108:17 36: 0x7b6b0a3e155a - 37: 0x7b6b0a45ea3c - 38: 0x0 - 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.80.0-nightly (91d5e4af8 2024-04-28) running on x86_64-unknown-linux-gnu note: compiler flags: -Z unstable-options -Z dump-mir-dir=dir 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 commented 6 months ago

also crashes with just --edition=2021

matthiaskrgr commented 6 months ago

Regression in nightly-2023-07-01

commit[0] 2023-06-29: Auto merge of #112682 - spastorino:new-rpitit-21, r=compiler-errors commit[1] 2023-06-30: Auto merge of #113116 - nnethercote:codegen-opts, r=oli-obk commit[2] 2023-06-30: Auto merge of #113162 - matthiaskrgr:rollup-fct3wj7, r=matthiaskrgr commit[3] 2023-06-30: Auto merge of #113188 - matthiaskrgr:rollup-j3abaks, r=matthiaskrgr commit[4] 2023-06-30: Auto merge of #106619 - agausmann:avr-object-file, r=nagisa commit[5] 2023-06-30: Auto merge of #109524 - bzEq:aix-embed-llvmbc, r=nagisa commit[6] 2023-06-30: Auto merge of #113200 - ferrocene:pa-fix-mir-opt-bless, r=oli-obk

I suspect this is https://github.com/rust-lang/rust/pull/112086

Noratrieb commented 6 months ago
use std::collections as x;
use x as std;

slightly more minimal (ordering is irrelevant)

bvanjoi commented 6 months ago

more reduced:

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

use a::*;

use b::c;
use c as b;

fn main() {}
matthiaskrgr commented 5 months ago

Again, the original example still crashes.