Skip to content

Improve diagnostics for non-well-formed associated items - #162432

Open
ozankenangungor wants to merge 1 commit into
rust-lang:mainfrom
ozankenangungor:issue-162368
Open

Improve diagnostics for non-well-formed associated items#162432
ozankenangungor wants to merge 1 commit into
rust-lang:mainfrom
ozankenangungor:issue-162368

Conversation

@ozankenangungor

@ozankenangungor ozankenangungor commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Fixes #162368.

With the new solver, this ended up as a projection mismatch instead of reporting the Sized requirement from the associated type.

I changed the diagnostic fallback to also check the associated item's own clauses, so it can recover the Self: Sized obligation and report E0277 instead.

In this case, the diagnostic now points to the impl type parameter instead of i32, keeps the note for the associated type bound, and suggests adding where Self: Sized.

I also added regression tests for the original case, an existing where-clause, the normal implicit Sized case, and a non-impl projection use site.

@rustbot

rustbot commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred to the core trait solver

cc @rust-lang/initiative-trait-system-refactor

@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 7, 2026
@rustbot

rustbot commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

r? @ShoyuVanilla

rustbot has assigned @ShoyuVanilla.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 75 candidates
  • Random selection from 20 candidates

Comment thread compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs Outdated
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.

Missing where Self: Sized in impl gives wrong error message for new solver

4 participants