Skip to content

diagnostic::do_not_recommend can emit an error if it encounters a keyword #151996

Description

@mejrs

I tried this code:

#![crate_type = "lib"]

pub trait X{}
pub struct Y;

#[diagnostic::do_not_recommend(if)]
impl X for Y {}

I expected to see this happen: a warning

Instead, this happened: an error

Meta

current nightly

this attribute is never allowed to error, this is a corner case I missed in #151516

cc @JonathanBrouwer @jdonszelmann

@rustbot claim

Activity

  1. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Feb 2, 2026
  2. added
    A-attributesArea: Attributes (`#[…]`, `#![…]`)
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    and removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Feb 2, 2026
  3. Krishna-js45 commented on Feb 2, 2026

    @Krishna-js45
  4. added a commit that references this issue on Feb 2, 2026
  5. added a commit that references this issue on Feb 3, 2026
  6. added a commit that references this issue on Feb 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-attributesArea: Attributes (`#[…]`, `#![…]`)C-bugCategory: This is a bug.T-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