Skip to content

Use attribute parser for deprecated attribute checking - #160459

Open
obeis wants to merge 1 commit into
rust-lang:mainfrom
obeis:check_deprecated
Open

Use attribute parser for deprecated attribute checking#160459
obeis wants to merge 1 commit into
rust-lang:mainfrom
obeis:check_deprecated

Conversation

@obeis

@obeis obeis commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

@rustbot

rustbot commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann, @JonathanBrouwer

Some changes occurred in compiler/rustc_passes/src/check_attr.rs

cc @jdonszelmann, @JonathanBrouwer

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) 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. labels Aug 3, 2026
@obeis obeis changed the title Use attribute parser for deprecated attribute checking Use attribute parser for deprecated attribute checking Aug 3, 2026
@obeis
obeis force-pushed the check_deprecated branch from db4cd0d to 309ea35 Compare August 3, 2026 19:10
@rust-log-analyzer

This comment has been minimized.

@obeis
obeis force-pushed the check_deprecated branch from 309ea35 to aaa1340 Compare August 3, 2026 20:36
@rust-log-analyzer

This comment has been minimized.

Comment thread compiler/rustc_hir/src/target.rs Outdated

/// Context of an associated const or associated type (not methods; see [`MethodKind`]).
#[derive(Copy, Clone, PartialEq, Debug, Eq, StableHash)]
pub enum AssocKind {

@JonathanBrouwer JonathanBrouwer Aug 7, 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.

Can we reuse the existing AssocCtxt type rather than introducing a new one?

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.

I reused the existing type.

let attr_span = cx.attr_span;
cx.emit_lint(
UNUSED_ATTRIBUTES,
DeprecatedAnnotationHasNoEffect { span: attr_span },

@JonathanBrouwer JonathanBrouwer Aug 7, 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.

Does this need to be its own diagnostic rather than just the default Policy::Warn diagnostic?

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.

I think using UNUSED_ATTRIBUTES is better here because it's indicates that the attribute "has no effect" rather than saying it has a "wrong target" which is a better fit for unused attributes and unused lint group.

let attr_span = cx.attr_span;
cx.emit_lint(
UNUSED_ATTRIBUTES,
DeprecatedAnnotationHasNoEffect { span: attr_span },

@JonathanBrouwer JonathanBrouwer Aug 7, 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.

Is this path covered by any tests?

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.

here in tests/ui/deprecation/deprecation-sanity.rs:

#[deprecated = "hello"] //~ ERROR attribute cannot be used on
//~| WARN previously accepted
impl Default for X {
    fn default() -> Self {
        X
    }
}

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

rustbot commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@rust-bors

This comment has been minimized.

@obeis
obeis force-pushed the check_deprecated branch from aaa1340 to 111bef3 Compare August 15, 2026 13:29
@rustbot

rustbot commented Aug 15, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in compiler/rustc_attr_ir

cc @jdonszelmann, @JonathanBrouwer

@rustbot

rustbot commented Aug 15, 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.

@obeis
obeis requested a review from JonathanBrouwer August 15, 2026 13:31
@rustbot rustbot 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 Aug 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants