-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Split up the unknown_or_malformed_diagnostic_attributes
lint
#140717
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Some changes occurred in compiler/rustc_passes/src/check_attr.rs |
I know creating a new lint requires lang team approval, but I'm unsure if splitting a lint needs it. @rustbot labels +I-lang-nominated |
This comment has been minimized.
This comment has been minimized.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as off-topic.
This comment was marked as off-topic.
This seems consistent with how @rfcbot merge |
Team member @joshtriplett has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
@rfcbot reviewed |
Just to add the context why this was implemented as a single lint: #114452 (comment) Which means @petrochenkov might still have opinions about this. |
@rfcbot reviewed I think we definitely want to split out the "unknown" case for the reason given in the description. I feel less strongly about the other cases, but I can imagine wanting to allow those because of version skew, e.g. when a lint doesn't apply to certain item kinds in older versions of the compiler but does in newer versions. |
Responding to the earlier ping, I'm always in favor of more targeted lints, so I'm in favor of turning this into a group. |
@rfcbot reviewed Trying again. |
@rfcbot ping |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks OK to me.
☔ The latest upstream changes (presumably #142432) made this pull request unmergeable. Please resolve the merge conflicts. |
@oli-obk are you available to review the implementation? I can reroll otherwise. |
@bors r+ |
Split up the `unknown_or_malformed_diagnostic_attributes` lint This splits up the lint into the following lint group: - `unknown_diagnostic_attributes` - triggers if the attribute is unknown to the current compiler - `misplaced_diagnostic_attributes` - triggers if the attribute exists but it is not placed on the item kind it's meant for - `malformed_diagnostic_attributes` - triggers if the attribute's syntax or options are invalid - `malformed_diagnostic_format_literals` - triggers if the format string literal is invalid, for example if it has unpaired curly braces or invalid parameters - this pr doesn't create it, but future lints for things like deprecations can also go here. This PR does not start emitting lints in places that previously did not. ## Motivation I want to have finer control over what `unknown_or_malformed_diagnostic_attributes` does I have a project with fairly low msrv that is/will have a lower msrv than future diagnostic attributes. So lints will be emitted when I or others compile it on a lower msrv. At this time, there are two options to silence these lints: - `#[allow(unknown_or_malformed_diagnostic_attributes)]` - this risks diagnostic regressions if I (or others) mess up using the attribute, or if the attribute's syntax ever changes. - write a build script to detect the compiler version and emit cfgs, and then conditionally enable the attribute: ```rust #[cfg_attr(rust_version_99, diagnostic::new_attr_in_rust_99(thing = ..))]` struct Foo; ``` or conditionally `allow` the lint: ```rust // lib.rs #![cfg_attr(not(current_rust), allow(unknown_or_malformed_diagnostic_attributes))] ``` I like to avoid using build scripts if I can, so the following works much better for me. That is what this PR will let me do in the future: ```rust #[allow(unknown_diagnostic_attribute, reason = "attribute came out in rust 1.99 but msrv is 1.70")] #[diagnostic::new_attr_in_rust_99(thing = ..)]` struct Foo;
This comment has been minimized.
This comment has been minimized.
💔 Test failed - checks-actions |
@bors r+ |
☀️ Test successful - checks-actions |
What is this?This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.Comparing 288e94c (parent) -> b1d2f2c (this PR) Test differencesShow 277 test diffs277 doctest diffs were found. These are ignored, as they are noisy. Test dashboardRun cargo run --manifest-path src/ci/citool/Cargo.toml -- \
test-dashboard b1d2f2c64c6254b2a935d6a2d29b68f4511cf500 --output-dir test-dashboard And then open Job duration changes
How to interpret the job duration changes?Job durations can vary a lot, based on the actual runner instance |
Finished benchmarking commit (b1d2f2c): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)Results (primary 1.6%, secondary -0.6%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary 2.4%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 468.578s -> 466.487s (-0.45%) |
This splits up the lint into the following lint group:
unknown_diagnostic_attributes
- triggers if the attribute is unknown to the current compilermisplaced_diagnostic_attributes
- triggers if the attribute exists but it is not placed on the item kind it's meant formalformed_diagnostic_attributes
- triggers if the attribute's syntax or options are invalidmalformed_diagnostic_format_literals
- triggers if the format string literal is invalid, for example if it has unpaired curly braces or invalid parametersThis PR does not start emitting lints in places that previously did not.
Motivation
I want to have finer control over what
unknown_or_malformed_diagnostic_attributes
doesI have a project with fairly low msrv that is/will have a lower msrv than future diagnostic attributes. So lints will be emitted when I or others compile it on a lower msrv.
At this time, there are two options to silence these lints:
#[allow(unknown_or_malformed_diagnostic_attributes)]
- this risks diagnostic regressions if I (or others) mess up using the attribute, or if the attribute's syntax ever changes.allow
the lint:I like to avoid using build scripts if I can, so the following works much better for me. That is what this PR will let me do in the future: