-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check
#[diagnostic::do_not_recommend]
for arguments
This commit adds a check that verifies that no arguments are passed to `#[diagnostic::do_not_recommend]`. If we detect arguments we emit a warning.
- Loading branch information
Showing
6 changed files
with
91 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
tests/ui/diagnostic_namespace/do_not_recommend/does_not_acccept_args.current.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
warning: `#[diagnostic::do_not_recommend]` does not expect any arguments | ||
--> $DIR/does_not_acccept_args.rs:12:1 | ||
| | ||
LL | #[diagnostic::do_not_recommend(not_accepted)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: `#[warn(unknown_or_malformed_diagnostic_attributes)]` on by default | ||
|
||
warning: `#[diagnostic::do_not_recommend]` does not expect any arguments | ||
--> $DIR/does_not_acccept_args.rs:16:1 | ||
| | ||
LL | #[diagnostic::do_not_recommend(not_accepted = "foo")] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
warning: `#[diagnostic::do_not_recommend]` does not expect any arguments | ||
--> $DIR/does_not_acccept_args.rs:20:1 | ||
| | ||
LL | #[diagnostic::do_not_recommend(not_accepted(42))] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
warning: 3 warnings emitted | ||
|
22 changes: 22 additions & 0 deletions
22
tests/ui/diagnostic_namespace/do_not_recommend/does_not_acccept_args.next.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
warning: `#[diagnostic::do_not_recommend]` does not expect any arguments | ||
--> $DIR/does_not_acccept_args.rs:12:1 | ||
| | ||
LL | #[diagnostic::do_not_recommend(not_accepted)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: `#[warn(unknown_or_malformed_diagnostic_attributes)]` on by default | ||
|
||
warning: `#[diagnostic::do_not_recommend]` does not expect any arguments | ||
--> $DIR/does_not_acccept_args.rs:16:1 | ||
| | ||
LL | #[diagnostic::do_not_recommend(not_accepted = "foo")] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
warning: `#[diagnostic::do_not_recommend]` does not expect any arguments | ||
--> $DIR/does_not_acccept_args.rs:20:1 | ||
| | ||
LL | #[diagnostic::do_not_recommend(not_accepted(42))] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
warning: 3 warnings emitted | ||
|
24 changes: 24 additions & 0 deletions
24
tests/ui/diagnostic_namespace/do_not_recommend/does_not_acccept_args.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
//@ check-pass | ||
//@ revisions: current next | ||
//@ ignore-compare-mode-next-solver (explicit revisions) | ||
//@[next] compile-flags: -Znext-solver | ||
|
||
#![feature(do_not_recommend)] | ||
|
||
trait Foo {} | ||
trait Bar {} | ||
trait Baz {} | ||
|
||
#[diagnostic::do_not_recommend(not_accepted)] | ||
//~^ WARNING `#[diagnostic::do_not_recommend]` does not expect any arguments | ||
impl<T> Foo for T where T: Send {} | ||
|
||
#[diagnostic::do_not_recommend(not_accepted = "foo")] | ||
//~^ WARNING `#[diagnostic::do_not_recommend]` does not expect any arguments | ||
impl<T> Bar for T where T: Send {} | ||
|
||
#[diagnostic::do_not_recommend(not_accepted(42))] | ||
//~^ WARNING `#[diagnostic::do_not_recommend]` does not expect any arguments | ||
impl<T> Baz for T where T: Send {} | ||
|
||
fn main() {} |