Skip to content

[ICE]: no resolution for an import #160512

Description

@mu001999

Code

use my_api::self as alias;

Compiling the above code by rustc --crate-type=lib --edition=2024 -Znamespaced-crates --extern 'my_api::utils' main.rs will lead to the ICE. This happens after #155137, because this PR doesn't handle OpenModule.

Trailing self follows OpenModule should work like normal modules.

Meta

rustc --version --verbose:

rustc 1.99.0-nightly (af3d95584 2026-07-09)
binary: rustc
commit-hash: af3d95584dbddcae597890340995509a7fb47a50
commit-date: 2026-07-09
host: aarch64-apple-darwin
release: 1.99.0-nightly
LLVM version: 22.1.8

Error output

note: no errors encountered even though delayed bugs were created

note: those delayed bugs will now be shown as internal compiler errors

error: internal compiler error: no resolution for an import
 --> main.rs:1:5
  |
1 | use my_api::self as alias;
  |     ^^^^^^^^^^^^
  |
note: delayed at /rustc-dev/af3d95584dbddcae597890340995509a7fb47a50/compiler/rustc_ast_lowering/src/lib.rs:1022:24 - disabled backtrace
 --> main.rs:1:5
  |
1 | use my_api::self as alias;
  |     ^^^^^^^^^^^^

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/mu00/repos/playground/rustc-ice-2026-08-04T14_42_19-94109.txt` to your bug report

note: rustc 1.99.0-nightly (af3d95584 2026-07-09) running on aarch64-apple-darwin

note: compiler flags: --crate-type lib -Z namespaced-crates
Backtrace

note: no errors encountered even though delayed bugs were created

note: those delayed bugs will now be shown as internal compiler errors

error: internal compiler error: no resolution for an import
 --> main.rs:1:5
  |
1 | use my_api::self as alias;
  |     ^^^^^^^^^^^^
  |
note: delayed at /rustc-dev/af3d95584dbddcae597890340995509a7fb47a50/compiler/rustc_ast_lowering/src/lib.rs:1022:24
         0: <std::backtrace::Backtrace>::create
         1: <std::backtrace::Backtrace>::capture
         2: <rustc_errors::DiagCtxtInner>::emit_diagnostic
         3: <rustc_errors::DiagCtxtHandle>::emit_diagnostic
         4: <rustc_span::ErrorGuaranteed as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
         5: <rustc_errors::DiagCtxtHandle>::span_delayed_bug::<rustc_span::span_encoding::Span, &str>
         6: <rustc_ast_lowering::LoweringContext>::lower_import_res
         7: <rustc_ast_lowering::LoweringContext>::lower_use_tree
         8: <rustc_ast_lowering::LoweringContext>::lower_item_kind
         9: rustc_ast_lowering::lower_to_hir
        10: rustc_query_impl::query_impl::lower_to_hir::invoke_provider_fn::__rust_begin_short_backtrace
        11: rustc_query_impl::execution::try_execute_query::<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::ErasedData<[u8; 16]>, rustc_middle::dep_graph::graph::DepNodeIndex>, false>
        12: rustc_query_impl::query_impl::lower_to_hir::execute_query_non_incr::__rust_end_short_backtrace
        13: <rustc_middle::hir::provide::{closure#1} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_span::def_id::LocalDefId)>>::call_once
        14: rustc_query_impl::query_impl::hir_owner::invoke_provider_fn::__rust_begin_short_backtrace
        15: rustc_query_impl::execution::try_execute_query::<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::ErasedData<[u8; 32]>, rustc_middle::dep_graph::graph::DepNodeIndex>, false>
        16: rustc_query_impl::query_impl::hir_owner::execute_query_non_incr::__rust_end_short_backtrace
        17: <rustc_middle::ty::context::TyCtxt>::expect_hir_owner_nodes
        18: rustc_middle::hir::map::hir_crate_items
        19: rustc_query_impl::query_impl::hir_crate_items::invoke_provider_fn::__rust_begin_short_backtrace
        20: rustc_query_impl::execution::try_execute_query::<rustc_middle::query::caches::SingleCache<rustc_middle::query::erase::ErasedData<[u8; 8]>>, false>
        21: rustc_query_impl::query_impl::hir_crate_items::execute_query_non_incr::__rust_end_short_backtrace
        22: rustc_interface::passes::analysis
        23: rustc_query_impl::execution::try_execute_query::<rustc_middle::query::caches::SingleCache<rustc_middle::query::erase::ErasedData<[u8; 0]>>, false>
        24: rustc_query_impl::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
        25: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>
        26: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
        27: std::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
        28: <std::thread::lifecycle::spawn_unchecked<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
        29: <std::sys::thread::unix::Thread>::new::thread_start
        30: __pthread_cond_wait

 --> main.rs:1:5
  |
1 | use my_api::self as alias;
  |     ^^^^^^^^^^^^

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/mu00/repos/playground/rustc-ice-2026-08-04T14_43_13-94136.txt` to your bug report

note: rustc 1.99.0-nightly (af3d95584 2026-07-09) running on aarch64-apple-darwin

note: compiler flags: --crate-type lib -Z namespaced-crates

query stack during panic:
end of query stack

Metadata

Metadata

Assignees

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.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions