Skip to content

Also point at item being incorrectly annotated by #[diagnostic::on_const] #149606

@estebank

Description

@estebank

When we encounter a #[diagnostic::on_const] on a non-impl, we currently only point at the attribute:

error: `#[diagnostic::on_const]` can only be applied to trait impls
  --> $DIR/misplaced_attr.rs:4:1
   |
LL | #[diagnostic::on_const(message = "tadaa", note = "boing")]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
note: the lint level is defined here
  --> $DIR/misplaced_attr.rs:2:9
   |
LL | #![deny(misplaced_diagnostic_attributes)]
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

We should add a span_label pointing at the item as well, to provide full context in the lint.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.D-papercutDiagnostics: An error or lint that needs small tweaks.D-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.P-lowLow priorityT-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

    Development

    No branches or pull requests

    Issue actions