-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Open
Labels
A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyArea: Name/path resolution done by `rustc_resolve` specificallyC-bugCategory: This is a bug.Category: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.This issue may need triage. Remove it if it has been sufficiently triaged.
Description
Code
This error appears when I add a new line in a macro with a unknown type:
"subcommand" => subcommand::Builder,
This is expanded as:
subcommands.insert("subcommand", <subcommand::Builder as crate::command::Builder>::new("subcommand") as Box<dyn crate::command::Builder>);
The rust-analyzer error:
Cannot find type `Builder` in module `subcommand` not found in `subcommand`.
I made this many times (it’s a early stage development software), but this new one (~270nth) this error appears.
Meta
rustc --version --verbose
:
rustc 1.89.0 (29483883e 2025-08-04)
binary: rustc
commit-hash: 29483883eed69d5fb4db01964cdf2af4d86e9cb2
commit-date: 2025-08-04
host: x86_64-unknown-linux-gnu
release: 1.89.0
LLVM version: 20.1.7
This bug also exists in nightly (1.91.0-nightly (7ad23f43a 2025-09-09)
) and without cargo configuration file.
Error output
$ RUST_BACKTRACE=1 cargo build
Compiling postkey v0.1.0 (/home/sanpi/projects/rust/postkey)
thread 'rustc' panicked at /rustc-dev/29483883eed69d5fb4db01964cdf2af4d86e9cb2/library/alloc/src/vec/mod.rs:2678:36:
slice index starts at 5 but ends at 4
stack backtrace:
0: __rustc::rust_begin_unwind
1: core::panicking::panic_fmt
2: core::slice::index::slice_index_order_fail::do_panic::runtime
3: core::slice::index::slice_index_order_fail
4: <rustc_errors::styled_buffer::StyledBuffer>::replace
5: <rustc_errors::emitter::HumanEmitter>::emit_messages_default_inner::{closure#0}
6: <rustc_errors::emitter::HumanEmitter as rustc_errors::emitter::Emitter>::emit_diagnostic
7: <rustc_errors::json::Diagnostic>::from_errors_diagnostic
8: <rustc_errors::json::JsonEmitter as rustc_errors::emitter::Emitter>::emit_diagnostic
9: <rustc_errors::DiagCtxtInner>::emit_diagnostic::{closure#3}
10: rustc_interface::callbacks::track_diagnostic::<core::option::Option<rustc_span::ErrorGuaranteed>>::{closure#0}
11: rustc_interface::callbacks::track_diagnostic::<core::option::Option<rustc_span::ErrorGuaranteed>>
12: <rustc_errors::DiagCtxtInner>::emit_diagnostic
13: <rustc_errors::DiagCtxtHandle>::emit_diagnostic
14: <rustc_span::ErrorGuaranteed as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
15: <rustc_resolve::Resolver>::resolve_crate::{closure#0}
16: <rustc_resolve::Resolver>::resolve_crate
17: rustc_interface::passes::configure_and_expand
18: rustc_interface::passes::resolver_for_lowering_raw
[... omitted 2 frames ...]
19: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
20: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
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: rustc 1.89.0 (29483883e 2025-08-04) running on x86_64-unknown-linux-gnu
note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED] -C link-arg=-fuse-ld=lld
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
#0 [resolver_for_lowering_raw] getting the resolver for lowering
end of query stack
For more information about this error, try `rustc --explain E0412`.
error: could not compile `postkey` (bin "postkey")
Caused by:
process didn't exit successfully: `/home/sanpi/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rustc --crate-name postkey --edition=2024 src/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=167 --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 --check-cfg 'cfg(docsrs,test)' --check-cfg 'cfg(feature, values())' -C metadata=cbd9df087f182685 -C extra-filename=-37c29d03d7b94f0c --out-dir /home/sanpi/projects/rust/postkey/target/debug/deps -C incremental=/home/sanpi/projects/rust/postkey/target/debug/incremental -L dependency=/home/sanpi/projects/rust/postkey/target/debug/deps --extern derive_more=/home/sanpi/projects/rust/postkey/target/debug/deps/libderive_more-99848350edde0a49.rlib --extern dyn_clone=/home/sanpi/projects/rust/postkey/target/debug/deps/libdyn_clone-e8110d5f11504192.rlib --extern elephantry=/home/sanpi/projects/rust/postkey/target/debug/deps/libelephantry-d92bcff8301c1786.rlib --extern envir=/home/sanpi/projects/rust/postkey/target/debug/deps/libenvir-4e1e0ceeafee9aa3.rlib --extern log=/home/sanpi/projects/rust/postkey/target/debug/deps/liblog-76cf59219504c6cb.rlib --extern thiserror=/home/sanpi/projects/rust/postkey/target/debug/deps/libthiserror-3e46ed291a111f91.rlib -C link-arg=-fuse-ld=lld -L native=/usr/lib` (exit status: 101)
Metadata
Metadata
Assignees
Labels
A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyArea: Name/path resolution done by `rustc_resolve` specificallyC-bugCategory: This is a bug.Category: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.This issue may need triage. Remove it if it has been sufficiently triaged.