Name resolution 2.0 does not handle imports in modules
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 2.9k
- Forks
- 231
- Avg merge
- 19h 55m
- Merged PRs (30d)
- 67
Description
Summary
Imports don't appear to work in modules with name resolution 2.0
Reproducer
I tried this code:
fn f() {}
mod a {
fn g() {
}
use super::f;
use self::g as g1;
use g as g2;
fn h() {
f();
g1();
g2();
}
}
Does the code make use of any (1.49) nightly feature ?
- Nightly
Godbolt link
https://godbolt.org/z/ffYY5qYMG
Actual behavior
The current behavior is...
Internal compiler erros:
crab1: internal compiler error: in value, at rust/util/optional.h:1333
0x29fcec5 diagnostic_context::diagnostic_impl(rich_location*, diagnostic_metadata const*, diagnostic_option_id, char const*, __va_list_tag (*) [1], diagnostic_t)
???:0
0x2a1e116 internal_error(char const*, ...)
???:0
0xb95dd8 fancy_abort(char const*, int, char const*)
???:0
0xef2c8e Rust::Privacy::PrivacyReporter::visit(Rust::HIR::PathInExpression&)
???:0
0xef20aa Rust::Privacy::PrivacyReporter::visit(Rust::HIR::CallExpr&)
???:0
0xef2167 Rust::Privacy::PrivacyReporter::visit(Rust::HIR::BlockExpr&)
???:0
0xef241f Rust::Privacy::PrivacyReporter::visit(Rust::HIR::Module&)
???:0
0xef27e1 Rust::Privacy::PrivacyReporter::go(Rust::HIR::Crate&)
???:0
0xeefe73 Rust::Privacy::Resolver::resolve(Rust::HIR::Crate&)
???:0
0xcfdd03 Rust::Session::compile_crate(char const*)
???:0
Please submit a full bug report, with preprocessed source (by using -freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
Compiler returned: 1
Expected behavior
I expected to see...
No errors, maybe unused code warnings
GCC Version
gccrs (Compiler-Explorer-Build-gcc-7d62c5db3aeef0bc962be1b6d6a8b2ec3b2afd32-binutils-2.44) 16.0.0 20250604 (experimental)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the module import example with name resolution 2.0 and inspect the reported entry points Rust::Privacy::Resolver::resolve and Rust::Privacy::PrivacyReporter::visit, especially the HIR path and call-expression visits. There is no test file named in the issue; done means the example no longer triggers an internal compiler error and produces only the expected diagnostics.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100