rust-lang / rust-lang/rust

When encountering duplicated item names, register error resolution to avoid further errors

Open
#151,421 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-diagnostics A-resolve D-verbose T-compiler
Dominant language
Rust
Stars
119k
Forks
16.2k
PR merge metrics
PR metrics pending

Description

As one example from our test suite, the following test has a duplicated name error, where the latter resolution is registered, which causes any use of the item when expecting the first causes subsequent errors:

https://github.com/rust-lang/rust/blob/fffc4fcf96b30bc838551de5104d74f82400b35b/tests/ui/traits/issue-106072.stderr#L1-L23

Ideally when encountering duplicated names we should register that name as an error Res so that subsequent uses do not emit any errors. Fixing the duplicated names might cause subsequent errors to happen from any case where we were expecting the latter item, but it's just a coin toss in the end (and when adding a new item shadowing an existing one, the existing one is likely to have many more usages than the new one). Doing this trades less verbosity when encountering this for at least one additional compile cycle to get the errors of incorrect uses. An alternative would be to collect all access to duplicated items and emit a single error for them, but that might need additional complicated Resolver logic.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with tests/ui/traits/issue-106072.stderr and trace the compiler resolver's handling of duplicated names and the Resolver logic mentioned in the issue. Confirm the current diagnostics and identify the relevant duplicate-name resolution path. Done means duplicated names register an error Res so later uses do not produce follow-on errors, with UI expectations updated accordingly.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.