Skip to content

Conversation

@mejrs
Copy link
Contributor

@mejrs mejrs commented Jan 13, 2026

@rustbot
Copy link
Collaborator

rustbot commented Jan 13, 2026

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

cc @jdonszelmann, @JonathanBrouwer

Some changes occurred to the core trait solver

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

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann, @JonathanBrouwer

Some changes occurred in compiler/rustc_hir/src/attrs

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. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Jan 13, 2026
@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 13, 2026

☔ The latest upstream changes (presumably #151051) made this pull request unmergeable. Please resolve the merge conflicts.

@rustbot
Copy link
Collaborator

rustbot commented Jan 13, 2026

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.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

if parts == &[sym::rustc_dummy] {
// The arguments of rustc_dummy and diagnostic attributes are not validated
// if the arguments are delimited
if parts == &[sym::rustc_dummy] || parts[0] == sym::diagnostic {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm the special casting of this attribute is a little ugly here. Especially since this will affect all diagnostic attributes, and we're introducing a new one soon (#150935) which should not suffer the mistakes from the past

Copy link
Contributor

@JonathanBrouwer JonathanBrouwer Jan 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we perhaps do a crater run and see how bad making a breaking change is for this? Since these attributes are so niche I expect making the breaking change will be fine

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which should not suffer the mistakes from the past

There were no mistakes, this is the intended behavior. That is, any syntactically valid input is allowed, similar to attribute macros. I do not want to shut the door on being able to use non-metaitem syntax going forward. For example in the future I'd like to expand these attributes to reference types and traits, and something like From<i32> is not valid metaitem syntax.

Copy link
Contributor

@JonathanBrouwer JonathanBrouwer Jan 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to do this in the future, we would need to add support for parsing types and traits to the attribute parser. As I see it, that is even more an argument for removing this special case now, since this special case skips the attribute parser for this attribute.

I.e. If this attribute skips the attribute parser now, we can not use the attribute parser to parse any arguments in the future

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to do this in the future, we would need to add support for parsing types and traits to the attribute parser.

Yes, we would need to add some kind of support for that. But the semantics of the diagnostic namespace are that any such future extensions are ignored by older compilers and do not raise errors.

In other words: to extend the attribute in the future, we must be maximally permissive now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, that makes sense, thanks for explaining!
Could you add a comment to https://doc.rust-lang.org/reference/attributes/diagnostics.html#r-attributes.diagnostic.namespace.unknown-invalid-syntax on this check then?

This still doesn't really solve the usecase for diagnostic attributes that do need to have arguments parsed. Ideally the attribute parser would run, but any errors should be warnings instead. Not sure if we should solve this problem in this PR or when it comes up tho

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if we should solve this problem in this PR or when it comes up tho

This will be an issue with the other diagnostic attributes, so I'll see if I can figure something out.

Copy link
Contributor

@JonathanBrouwer JonathanBrouwer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job! Some minor comments :)

View changes since this review

@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 Jan 13, 2026
@rustbot
Copy link
Collaborator

rustbot commented Jan 13, 2026

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

@JonathanBrouwer
Copy link
Contributor

(Jana feel free to steal the assign back, since I think you two might know eachother?)

@mejrs
Copy link
Contributor Author

mejrs commented Jan 13, 2026

I've pushed the link , I'll need to think more about a proper fix for the other diagnostic attributes. But that doesn't matter today.

@rustbot ready

@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 Jan 13, 2026
@JonathanBrouwer
Copy link
Contributor

Don't expect this to have a significant performance impact, but attr parsing has been surprisingly perf sensitive so let's see
@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors bot pushed a commit that referenced this pull request Jan 14, 2026
Port `diagnostic::do_not_recommend` to new attr parsing
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jan 14, 2026
@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 14, 2026

☀️ Try build successful (CI)
Build commit: f1840ed (f1840edf4b3cea3df43ffa5d38ac815208afedae, parent: 4931e09e3ac3182d2a00f38cccfdf68e8e385e1c)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (f1840ed): comparison URL.

Overall result: ❌✅ regressions and improvements - no action needed

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

@bors rollup=never
@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.5% [0.5%, 0.5%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.1% [-0.1%, -0.1%] 1
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (primary -0.8%, secondary -3.8%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.8% [-0.8%, -0.8%] 1
Improvements ✅
(secondary)
-3.8% [-3.8%, -3.8%] 1
All ❌✅ (primary) -0.8% [-0.8%, -0.8%] 1

Cycles

Results (primary -2.7%, secondary 3.7%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
3.7% [3.7%, 3.7%] 1
Improvements ✅
(primary)
-2.7% [-2.7%, -2.7%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -2.7% [-2.7%, -2.7%] 1

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 474.176s -> 474.127s (-0.01%)
Artifact size: 383.16 MiB -> 383.18 MiB (0.00%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jan 14, 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. 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.

6 participants