Repository navigation
Conversation
|
Some changes occurred in compiler/rustc_attr_parsing |
|
r? @oli-obk rustbot has assigned @oli-obk. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
f3ab317 to
1aed523
Compare
| Allow(Target::While), | ||
| Allow(Target::Break), | ||
| Warn(Target::MacroCall), | ||
| Allow(Target::MacroCall), |
There was a problem hiding this comment.
I think it makes sense to emit the warning iff none of the lints that are configured are pre-expansion lints. I'm not sure how easy that would be to implement tho...
There was a problem hiding this comment.
We do have some cases where this is linted against based on the lint, like non_exhaustive_omitted_patterns on match arms for example.
|
(It would be nice to get this in before the beta cutoff, otherwise it will require backporting) |
|
I think since this is a change to when a lint is emitted, the lang team needs to approve this. |
It was added in #87296, without lang involvement. The FCW was added to it after I ported the lint attributes, again without lang involvement. Both were probably mistakes. and the correct process would be to revert both and then (if desired) land it again with t-lang approval. |
|
Since the lint has already been on stable for 5 years, and it is useful in most cases, I don't like removing it entirely, especially not without T-lang approval. For example, the lint helps identify that lint attributes are not applied to the expanded code of a macro: macro_rules! nice {
() => {
// mhuahuahua :D
unsafe { *std::ptr::null::<()>() } //~ OK
};
}
fn main(){
#[deny(unsafe_code)]
nice!();
}(I'm still happy to revert the FCW part) |
|
Sounds good, I'll do that. |
|
I think it would generally be a good idea to do a future PR to emit a lint for "this particular lint on this target doesn't make sense" |
Sounds like a good idea! |
1aed523 to
6c7f841
Compare
|
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. |
…anBrouwer
Revert FCW on lint attributes on macro calls
In porting the lint attributes, it also added a fcw if they're used on a macro invocation. However t is something that has meaning, so revert the FCW.
```rust
// edition ..2021
macro_rules! wat {
($($tt:tt)*) => {}
}
fn main(){
#[deny(keyword_idents_2024)]
wat!(gen);
//~^ ERROR `gen` is a keyword in the 2024 edition
//~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024!
}
```
So I don't think this should be a fcw.
Similarly, clippy currently does this:
```rust
fn main() {
#[deny(clippy::nonstandard_macro_braces)]
println! {};
}
```
```rust
error: use of irregular braces for `println!` macro
--> src/main.rs:3:5
|
3 | println! {};
| ^^^^^^^^^^^ help: consider writing: `println!()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/main/index.html#nonstandard_macro_braces
note: the lint level is defined here
--> src/main.rs:2:12
|
2 | #[deny(clippy::nonstandard_macro_braces)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: the `deny` attribute cannot be used on macro calls
--> src/main.rs:2:7
|
2 | #[deny(clippy::nonstandard_macro_braces)]
| ^^^^
3 | println! {};
|
= help: the `deny` attribute can be applied to associated consts, associated types, break expressions, const parameters, constants, crates, data types, enum variants, extern crates, for loops, foreign modules, foreign statics, function params, functions, global asms, impl blocks, lifetime parameters, loops, macro defs, match arms, modules, pattern fields, statics, struct fields, trait aliases, traits, type aliases, type parameters, use statements, and while loops
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: placing this attribute on a macro invocation does nothing even if the macro expands to what would be a valid target for the attribute
= note: `#[warn(unused_attributes)]` (part of `#[warn(unused)]`) on by default
```
…anBrouwer
Revert FCW on lint attributes on macro calls
In porting the lint attributes, it also added a fcw if they're used on a macro invocation. However t is something that has meaning, so revert the FCW.
```rust
// edition ..2021
macro_rules! wat {
($($tt:tt)*) => {}
}
fn main(){
#[deny(keyword_idents_2024)]
wat!(gen);
//~^ ERROR `gen` is a keyword in the 2024 edition
//~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024!
}
```
So I don't think this should be a fcw.
Similarly, clippy currently does this:
```rust
fn main() {
#[deny(clippy::nonstandard_macro_braces)]
println! {};
}
```
```rust
error: use of irregular braces for `println!` macro
--> src/main.rs:3:5
|
3 | println! {};
| ^^^^^^^^^^^ help: consider writing: `println!()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/main/index.html#nonstandard_macro_braces
note: the lint level is defined here
--> src/main.rs:2:12
|
2 | #[deny(clippy::nonstandard_macro_braces)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: the `deny` attribute cannot be used on macro calls
--> src/main.rs:2:7
|
2 | #[deny(clippy::nonstandard_macro_braces)]
| ^^^^
3 | println! {};
|
= help: the `deny` attribute can be applied to associated consts, associated types, break expressions, const parameters, constants, crates, data types, enum variants, extern crates, for loops, foreign modules, foreign statics, function params, functions, global asms, impl blocks, lifetime parameters, loops, macro defs, match arms, modules, pattern fields, statics, struct fields, trait aliases, traits, type aliases, type parameters, use statements, and while loops
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: placing this attribute on a macro invocation does nothing even if the macro expands to what would be a valid target for the attribute
= note: `#[warn(unused_attributes)]` (part of `#[warn(unused)]`) on by default
```
…uwer Rollup of 7 pull requests Successful merges: - #164752 (Apply the Cortex-A53 843419 CC mitigation to aarch64 targets ) - #165376 (Add `Forget` trait feature gate) - #165257 (Revert FCW on lint attributes on macro calls) - #165364 (Update books) - #165424 (Update amdgpu datalayout for LLVM 24) - #165443 (Add `Discriminant::ord`) - #165445 (Add an unstable option to increase the chain depth of the next solver overflow FCW)
…anBrouwer
Revert FCW on lint attributes on macro calls
In porting the lint attributes, it also added a fcw if they're used on a macro invocation. However t is something that has meaning, so revert the FCW.
```rust
// edition ..2021
macro_rules! wat {
($($tt:tt)*) => {}
}
fn main(){
#[deny(keyword_idents_2024)]
wat!(gen);
//~^ ERROR `gen` is a keyword in the 2024 edition
//~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024!
}
```
So I don't think this should be a fcw.
Similarly, clippy currently does this:
```rust
fn main() {
#[deny(clippy::nonstandard_macro_braces)]
println! {};
}
```
```rust
error: use of irregular braces for `println!` macro
--> src/main.rs:3:5
|
3 | println! {};
| ^^^^^^^^^^^ help: consider writing: `println!()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/main/index.html#nonstandard_macro_braces
note: the lint level is defined here
--> src/main.rs:2:12
|
2 | #[deny(clippy::nonstandard_macro_braces)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: the `deny` attribute cannot be used on macro calls
--> src/main.rs:2:7
|
2 | #[deny(clippy::nonstandard_macro_braces)]
| ^^^^
3 | println! {};
|
= help: the `deny` attribute can be applied to associated consts, associated types, break expressions, const parameters, constants, crates, data types, enum variants, extern crates, for loops, foreign modules, foreign statics, function params, functions, global asms, impl blocks, lifetime parameters, loops, macro defs, match arms, modules, pattern fields, statics, struct fields, trait aliases, traits, type aliases, type parameters, use statements, and while loops
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: placing this attribute on a macro invocation does nothing even if the macro expands to what would be a valid target for the attribute
= note: `#[warn(unused_attributes)]` (part of `#[warn(unused)]`) on by default
```
…uwer Rollup of 17 pull requests Successful merges: - #164752 (Apply the Cortex-A53 843419 CC mitigation to aarch64 targets ) - #165011 (std: Clean up and improve errors for `is_*_feature_detected` macros) - #165376 (Add `Forget` trait feature gate) - #164482 (Remove the label starting with 0 in the test binary_asm_labels_allowed.rs) - #165201 (Move a bunch of methods out of `AttributeExt`) - #165268 (Fix constant-pattern equality suggestion spans in macros) - #165318 (Fix explicit destructor-call suggestion spans in macros) - #164440 ([Outreachy] alloc: Add test coverage for try_clone_from_ref_in (Box, Arc, Rc)) - #165001 (Document allocator swap in BinaryHeap::append) - #165257 (Revert FCW on lint attributes on macro calls) - #165330 (Impl read_le/read_be for f16 and f128) - #165364 (Update books) - #165414 (Remove unusued query key impl) - #165424 (Update amdgpu datalayout for LLVM 24) - #165440 (docker: bump node to v24.22.2 in shared script) - #165443 (Add `Discriminant::ord`) - #165445 (Add an unstable option to increase the chain depth of the next solver overflow FCW)
…uwer Rollup of 17 pull requests Successful merges: - #164752 (Apply the Cortex-A53 843419 CC mitigation to aarch64 targets ) - #165011 (std: Clean up and improve errors for `is_*_feature_detected` macros) - #165376 (Add `Forget` trait feature gate) - #164482 (Remove the label starting with 0 in the test binary_asm_labels_allowed.rs) - #165201 (Move a bunch of methods out of `AttributeExt`) - #165268 (Fix constant-pattern equality suggestion spans in macros) - #165318 (Fix explicit destructor-call suggestion spans in macros) - #164440 ([Outreachy] alloc: Add test coverage for try_clone_from_ref_in (Box, Arc, Rc)) - #165001 (Document allocator swap in BinaryHeap::append) - #165257 (Revert FCW on lint attributes on macro calls) - #165330 (Impl read_le/read_be for f16 and f128) - #165364 (Update books) - #165414 (Remove unusued query key impl) - #165424 (Update amdgpu datalayout for LLVM 24) - #165440 (docker: bump node to v24.22.2 in shared script) - #165443 (Add `Discriminant::ord`) - #165445 (Add an unstable option to increase the chain depth of the next solver overflow FCW)
…uwer Rollup of 17 pull requests Successful merges: - #164752 (Apply the Cortex-A53 843419 CC mitigation to aarch64 targets ) - #165011 (std: Clean up and improve errors for `is_*_feature_detected` macros) - #165376 (Add `Forget` trait feature gate) - #164482 (Remove the label starting with 0 in the test binary_asm_labels_allowed.rs) - #165201 (Move a bunch of methods out of `AttributeExt`) - #165268 (Fix constant-pattern equality suggestion spans in macros) - #165318 (Fix explicit destructor-call suggestion spans in macros) - #164440 ([Outreachy] alloc: Add test coverage for try_clone_from_ref_in (Box, Arc, Rc)) - #165001 (Document allocator swap in BinaryHeap::append) - #165257 (Revert FCW on lint attributes on macro calls) - #165330 (Impl read_le/read_be for f16 and f128) - #165364 (Update books) - #165414 (Remove unusued query key impl) - #165424 (Update amdgpu datalayout for LLVM 24) - #165440 (docker: bump node to v24.22.2 in shared script) - #165443 (Add `Discriminant::ord`) - #165445 (Add an unstable option to increase the chain depth of the next solver overflow FCW)
In porting the lint attributes, it also added a fcw if they're used on a macro invocation. However t is something that has meaning, so revert the FCW.
So I don't think this should be a fcw.
Similarly, clippy currently does this: