Skip to content

Do not continue past rustc_resolve when encountering duplicated items - #162831

Open
estebank wants to merge 3 commits into
rust-lang:mainfrom
estebank:duplicated-items
Open

estebank wants to merge 3 commits into
rust-lang:mainfrom
estebank:duplicated-items

Conversation

@estebank

@estebank estebank commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Duplicated items cause lots of confusing knock down errors. This change side-steps some known ICEs, and reduces the verbosity of crates with duplicated items at the cost of not emitting every error that we could.

Noticed just how problematic these can be while looking at #160695, as #[derive]s are particularly prone to the kind of confusion these duplicates cause.

Fix #120873, fix #123690.

r? @petrochenkov

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Sep 15, 2026
@rust-log-analyzer

This comment has been minimized.

@rustbot

rustbot commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator

This PR changes a file inside tests/crashes. If a crash was fixed, please move into the corresponding ui subdir and add 'Fixes #' to the PR description to autoclose the issue upon merge.

@rust-log-analyzer

This comment has been minimized.

@rust-bors

This comment has been minimized.

Duplicated items cause lots of confusing knock down errors. This change side-steps some known ICEs, and reduces the verbosity of crates with duplicated items at the cost of not emitting every error that we could.
120873 -> `tests/ui/resolve/multiple_definitions_attribute_merging.rs`
          (already existing)
123690 -> `tests/ui/resolve/duplicated-enum-variant.rs`
155482 -> `tests/ui/resolve/duplicated-item-in-const-generics.rs`
	  Added two cases from the report that still ICE.
@rustbot

rustbot commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@rust-log-analyzer

This comment has been minimized.

@estebank

Copy link
Copy Markdown
Contributor Author

CC @oli-obk as we spent a lot of time some years back removing Fatal.raise() as much as possible, and this is a partial walk-back.

@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

The job test-aarch64-gnu-llvm-21-2 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)

error[E0428]: the name `bar` is defined multiple times
##[error] --> lint_example.rs:8:1
  |
5 | pub fn bar<'a: 'static>() {}
  | ------------------------- previous definition of the value `bar` here
...
8 | pub fn bar<'a: 'b, 'b: 'a>() {}
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `bar` redefined here
  |
  = note: `bar` must be defined only once in the value namespace of this block


error: aborting due to 1 previous error
---
     |
1894 | type Foo<T> = u32; // error: type parameter `T` is never used
     | ------------------ previous definition of the type `Foo` here
1895 | // or:
1896 | type Foo<A, B> = Box<A>;
     | ^^^^^^^^^^^^^^^^^^^^^^^^ `Foo` redefined here
     |
     = note: `Foo` must be defined only once in the type namespace of this block

error: aborting due to 1 previous error

---
    /checkout/obj/build/aarch64-unknown-linux-gnu/test/error-index.md - Rust_Compiler_Error_Index::E0091 (line 1893)

test result: FAILED. 1036 passed; 1 failed; 81 ignored; 0 measured; 0 filtered out; finished in 23.82s

Command `/checkout/obj/build/bootstrap/debug/rustdoc -Wrustdoc::invalid_codeblock_attributes -Dwarnings -Znormalize-docs -Znext-solver=coherence -Z unstable-options --test /checkout/obj/build/aarch64-unknown-linux-gnu/test/error-index.md --test-args ` failed with exit code 101
Created at: src/bootstrap/src/core/builder/mod.rs:1518:23
Executed at: src/bootstrap/src/core/build_steps/test.rs:3320:13

Command has failed. Rerun with -v to see more details.
Bootstrap failed while executing `--stage 2 test --skip tidy --skip intrinsic-test --skip src/tools/rust-analyzer --skip tests --skip library --skip tidyselftest`
Currently active steps:
test::ErrorIndex { compilers: RustcPrivateCompilers { build_compiler: Compiler { stage: 1, host: aarch64-unknown-linux-gnu, forced_compiler: false }, target_compiler: Compiler { stage: 2, host: aarch64-unknown-linux-gnu, forced_compiler: false } } } at src/bootstrap/src/core/build_steps/test.rs:3262
Build completed unsuccessfully in 0:40:04
  local time: Wed Sep 16 21:59:13 UTC 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ICE: Unsigned value 0x100 does not fit in 8 bits ICE: builtin derive created an unaligned reference

4 participants