Skip to content

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

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

estebank wants to merge 5 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

This comment has been minimized.

// Duplicated types wreak havoc on other errors, like impls selecting the wrong
// type causing wrong number of generic params and other assorted number of
// irrelevant nonsense, so avoid advancing to the next compiler stage.
self.raise_fatal_after_resolve = true;

@petrochenkov petrochenkov Sep 18, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the flag set conditionally, depending on whether the old or new declaration is an import or not?
I'd expect no such condition, anything that can be defined can be imported as well.

Or if the problem is with types specifically, the condition could be ns == TypeNS or more specific based on old_binding.res().

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed. We silence fewer errors now by checking ns == TypeNS. The only knock down error in the suite that I'd like to get rid off caused by dupes is "missing method in impl" caused when the impl has a single method but the trait has two with the same name, but that is minor.

@petrochenkov petrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 18, 2026
@rust-log-analyzer

This comment has been minimized.

@estebank estebank added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 18, 2026
@rust-bors

rust-bors Bot commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #163002) made this pull request unmergeable. Please resolve the merge conflicts by rebasing.

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