Skip to content

Reword ?Trait bound diagnostic #136944

@compiler-errors

Description

@compiler-errors
Member

I don't want to block this PR on surface level things like phrasing, so feel free to ignore this and I'll submit this as a follow-up PR. I've never liked how this specific diagnostic is formulated, it's super verbose.

Now with this being a hard error this sentence doesn't quite make sense anymore. I'd rather see a message that's straight to the point like `?` can only be applied to `Sized` (similar to `~const` can only be applied to `#[const_trait]` traits or `async` bound modifier only allowed on `Fn`/`FnMut`/`FnOnce` traits) and defer any further explanations to diagnostic note/help messages if at all (cc error codes).

If we wanted to feel fancy we could provide a structured suggestion for removing the entire bound.

Originally posted by @fmease in #135841 (comment)

Activity

added
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Feb 12, 2025
added
A-diagnosticsArea: Messages for errors, warnings, and lints
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
and removed
needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.
on Feb 12, 2025
changed the title [-]Reword `?Trait` bounds[/-] [+]Reword `?Trait` bound diagnostic[/+] on Feb 12, 2025
added a commit that references this issue on Jun 20, 2025

Auto merge of #142693 - fmease:unbound-bettering, r=<try>

bfa10de
added a commit that references this issue on Jun 28, 2025

Auto merge of #142693 - fmease:unbound-bettering, r=<try>

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

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Participants

    @compiler-errors@fmease@rustbot

    Issue actions

      Reword `?Trait` bound diagnostic · Issue #136944 · rust-lang/rust