Add FCW for derive helper attributes that will conflict with built-in attributes#151152
Conversation
|
Some changes occurred in compiler/rustc_attr_parsing |
|
r? @chenyukang rustbot has assigned @chenyukang. Use |
This comment has been minimized.
This comment has been minimized.
54147eb to
c9b7a07
Compare
c9b7a07 to
4dda363
Compare
This comment has been minimized.
This comment has been minimized.
|
@bors r=chenyukang |
|
New deprecation lints go through language team process, and the lint name also doesn't follow naming conventions. |
|
@bors r- |
|
Commit 4dda363 has been unapproved. |
|
@rustbot label +I-lang-nominated I am nominating this for lang-team attention. What name should this lint have? The current name doesn't follow the naming conventions My main idea is |
This comment has been minimized.
This comment has been minimized.
f4eca01 to
846e4ee
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. |
|
@bors r+ |
|
@nik-rev: 🔑 Insufficient privileges: not in review users |
|
@bors r=JonathanBrouwer |
|
@nik-rev: 🔑 Insufficient privileges: not in review users |
|
@rustbot ready |
|
@bors try jobs=test-various |
This comment has been minimized.
This comment has been minimized.
Add FCW for derive helper attributes that will conflict with built-in attributes try-job: test-various
|
@bors r=chenyukang |
…=chenyukang
Add FCW for derive helper attributes that will conflict with built-in attributes
Adds a future-compatibility-warning deny-by-default lint that helps catch invalid derive helper attribute names early.
This issues the lint, saying that `ignore` helper will clash with the built-in `ignore` attribute.
```rust
#![crate_type = "proc-macro"]
#![deny(ambiguous_derive_helpers)]
use proc_macro::TokenStream;
#[proc_macro_derive(Trait, attributes(ignore))]
pub fn example(input: TokenStream) -> TokenStream {
TokenStream::new()
}
```
If you actually tried to use that `ignore` helper attribute, you won't be able to due to the ambiguity:
```rust
#[derive(Trait)]
struct Foo {
#[ignore]
field: (),
}
```
Produces:
```
error[E0659]: `ignore` is ambiguous
--> src/lib.rs:5:7
|
5 | #[ignore]
| ^^^^^^ ambiguous name
|
= note: ambiguous because of a name conflict with a builtin attribute
= note: `ignore` could refer to a built-in attribute
note: `ignore` could also refer to the derive helper attribute defined here
--> src/lib.rs:3:10
|
3 | #[derive(Trait)]
| ^^^^^
```
…=chenyukang
Add FCW for derive helper attributes that will conflict with built-in attributes
Adds a future-compatibility-warning deny-by-default lint that helps catch invalid derive helper attribute names early.
This issues the lint, saying that `ignore` helper will clash with the built-in `ignore` attribute.
```rust
#![crate_type = "proc-macro"]
#![deny(ambiguous_derive_helpers)]
use proc_macro::TokenStream;
#[proc_macro_derive(Trait, attributes(ignore))]
pub fn example(input: TokenStream) -> TokenStream {
TokenStream::new()
}
```
If you actually tried to use that `ignore` helper attribute, you won't be able to due to the ambiguity:
```rust
#[derive(Trait)]
struct Foo {
#[ignore]
field: (),
}
```
Produces:
```
error[E0659]: `ignore` is ambiguous
--> src/lib.rs:5:7
|
5 | #[ignore]
| ^^^^^^ ambiguous name
|
= note: ambiguous because of a name conflict with a builtin attribute
= note: `ignore` could refer to a built-in attribute
note: `ignore` could also refer to the derive helper attribute defined here
--> src/lib.rs:3:10
|
3 | #[derive(Trait)]
| ^^^^^
```
…=chenyukang
Add FCW for derive helper attributes that will conflict with built-in attributes
Adds a future-compatibility-warning deny-by-default lint that helps catch invalid derive helper attribute names early.
This issues the lint, saying that `ignore` helper will clash with the built-in `ignore` attribute.
```rust
#![crate_type = "proc-macro"]
#![deny(ambiguous_derive_helpers)]
use proc_macro::TokenStream;
#[proc_macro_derive(Trait, attributes(ignore))]
pub fn example(input: TokenStream) -> TokenStream {
TokenStream::new()
}
```
If you actually tried to use that `ignore` helper attribute, you won't be able to due to the ambiguity:
```rust
#[derive(Trait)]
struct Foo {
#[ignore]
field: (),
}
```
Produces:
```
error[E0659]: `ignore` is ambiguous
--> src/lib.rs:5:7
|
5 | #[ignore]
| ^^^^^^ ambiguous name
|
= note: ambiguous because of a name conflict with a builtin attribute
= note: `ignore` could refer to a built-in attribute
note: `ignore` could also refer to the derive helper attribute defined here
--> src/lib.rs:3:10
|
3 | #[derive(Trait)]
| ^^^^^
```
Rollup of 17 pull requests Successful merges: - #142415 (Add note when inherent impl for a alias type defined outside of the crate) - #142680 (Fix passing/returning structs with the 64-bit SPARC ABI) - #150768 (Don't compute FnAbi for LLVM intrinsics in backends) - #151152 (Add FCW for derive helper attributes that will conflict with built-in attributes) - #151814 (layout: handle rigid aliases without params) - #151863 (Borrowck: simplify diagnostics for placeholders) - #152159 (Add note for `?Sized` params in int-ptr casts diag) - #152434 (Clarify names of `QueryVTable` functions for "executing" a query) - #152478 (Remove tm_factory field from CodegenContext) - #152498 (Partially revert "resolve: Update `NameBindingData::vis` in place") - #152316 (fix: add continue) - #152394 (Correctly check if a macro call is actually a macro call in rustdoc highlighter) - #152425 (Port #![test_runner] to the attribute parser) - #152481 (Use cg_ssa's produce_final_output_artifacts in cg_clif) - #152485 (fix issue#152482) - #152495 (Clean up some subdiagnostics) - #152502 (Implement `BinaryHeap::from_raw_vec`)
Rollup merge of #151152 - nik-contrib:helper_attr_builtin, r=chenyukang Add FCW for derive helper attributes that will conflict with built-in attributes Adds a future-compatibility-warning deny-by-default lint that helps catch invalid derive helper attribute names early. This issues the lint, saying that `ignore` helper will clash with the built-in `ignore` attribute. ```rust #![crate_type = "proc-macro"] #![deny(ambiguous_derive_helpers)] use proc_macro::TokenStream; #[proc_macro_derive(Trait, attributes(ignore))] pub fn example(input: TokenStream) -> TokenStream { TokenStream::new() } ``` If you actually tried to use that `ignore` helper attribute, you won't be able to due to the ambiguity: ```rust #[derive(Trait)] struct Foo { #[ignore] field: (), } ``` Produces: ``` error[E0659]: `ignore` is ambiguous --> src/lib.rs:5:7 | 5 | #[ignore] | ^^^^^^ ambiguous name | = note: ambiguous because of a name conflict with a builtin attribute = note: `ignore` could refer to a built-in attribute note: `ignore` could also refer to the derive helper attribute defined here --> src/lib.rs:3:10 | 3 | #[derive(Trait)] | ^^^^^ ```
Adds a future-compatibility-warning deny-by-default lint that helps catch invalid derive helper attribute names early.
This issues the lint, saying that
ignorehelper will clash with the built-inignoreattribute.If you actually tried to use that
ignorehelper attribute, you won't be able to due to the ambiguity:Produces: