-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a4d8766
commit f6ce62a
Showing
16 changed files
with
271 additions
and
32 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
14 changes: 14 additions & 0 deletions
14
tests/ui-toml/test_without_fail_case/auxiliary/test_macro.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,14 @@ | ||
#[macro_export] | ||
macro_rules! fallible_macro { | ||
( $x:expr ) => {{ | ||
let _ = $x; | ||
panic!("a"); | ||
}}; | ||
} | ||
|
||
#[macro_export] | ||
macro_rules! non_fallible_macro { | ||
( $x:expr ) => {{ | ||
let _ = $x; | ||
}}; | ||
} |
Empty file.
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 @@ | ||
test-without-fail-case-fallible-paths = ["test_macro::non_fallible_macro"] |
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 @@ | ||
test-without-fail-case-include-indexing-as-fallible = true |
1 change: 0 additions & 1 deletion
1
tests/ui-toml/test_without_fail_case/indexing_fallible/clippy.toml
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
tests/ui-toml/test_without_fail_case/macro_fallible/clippy.toml
This file was deleted.
Oops, something went wrong.
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 @@ | ||
test-without-fail-case-non-fallible-paths = ["test_macro::fallible_macro"] |
45 changes: 45 additions & 0 deletions
45
tests/ui-toml/test_without_fail_case/test_without_fail_case.default.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,45 @@ | ||
error: this function marked with `#[test]` cannot fail and will always succeed | ||
--> tests/ui-toml/test_without_fail_case/test_without_fail_case.rs:15:1 | ||
| | ||
LL | / fn test_custom_macro_fallible() { | ||
LL | | println!("a") | ||
LL | | } | ||
| |_^ | ||
| | ||
= note: consider adding assertions or panics to test failure cases | ||
= note: `-D clippy::test-without-fail-case` implied by `-D warnings` | ||
= help: to override `-D warnings` add `#[allow(clippy::test_without_fail_case)]` | ||
|
||
error: this function marked with `#[test]` cannot fail and will always succeed | ||
--> tests/ui-toml/test_without_fail_case/test_without_fail_case.rs:21:1 | ||
| | ||
LL | / fn test_indexing_fallible() { | ||
LL | | let a = [1, 2, 3]; | ||
LL | | let _ = a[0]; | ||
LL | | } | ||
| |_^ | ||
| | ||
= note: consider adding assertions or panics to test failure cases | ||
|
||
error: this function marked with `#[test]` cannot fail and will always succeed | ||
--> tests/ui-toml/test_without_fail_case/test_without_fail_case.rs:27:1 | ||
| | ||
LL | / fn func_a() { | ||
LL | | let _ = 1; | ||
LL | | } | ||
| |_^ | ||
| | ||
= note: consider adding assertions or panics to test failure cases | ||
|
||
error: this function marked with `#[test]` cannot fail and will always succeed | ||
--> tests/ui-toml/test_without_fail_case/test_without_fail_case.rs:32:1 | ||
| | ||
LL | / fn should_not_lint_if_defined_as_fallible() { | ||
LL | | non_fallible_macro!(1); | ||
LL | | } | ||
| |_^ | ||
| | ||
= note: consider adding assertions or panics to test failure cases | ||
|
||
error: aborting due to 4 previous errors | ||
|
35 changes: 35 additions & 0 deletions
35
tests/ui-toml/test_without_fail_case/test_without_fail_case.fail_macro.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,35 @@ | ||
error: this function marked with `#[test]` cannot fail and will always succeed | ||
--> tests/ui-toml/test_without_fail_case/test_without_fail_case.rs:15:1 | ||
| | ||
LL | / fn test_custom_macro_fallible() { | ||
LL | | println!("a") | ||
LL | | } | ||
| |_^ | ||
| | ||
= note: consider adding assertions or panics to test failure cases | ||
= note: `-D clippy::test-without-fail-case` implied by `-D warnings` | ||
= help: to override `-D warnings` add `#[allow(clippy::test_without_fail_case)]` | ||
|
||
error: this function marked with `#[test]` cannot fail and will always succeed | ||
--> tests/ui-toml/test_without_fail_case/test_without_fail_case.rs:21:1 | ||
| | ||
LL | / fn test_indexing_fallible() { | ||
LL | | let a = [1, 2, 3]; | ||
LL | | let _ = a[0]; | ||
LL | | } | ||
| |_^ | ||
| | ||
= note: consider adding assertions or panics to test failure cases | ||
|
||
error: this function marked with `#[test]` cannot fail and will always succeed | ||
--> tests/ui-toml/test_without_fail_case/test_without_fail_case.rs:27:1 | ||
| | ||
LL | / fn func_a() { | ||
LL | | let _ = 1; | ||
LL | | } | ||
| |_^ | ||
| | ||
= note: consider adding assertions or panics to test failure cases | ||
|
||
error: aborting due to 3 previous errors | ||
|
34 changes: 34 additions & 0 deletions
34
tests/ui-toml/test_without_fail_case/test_without_fail_case.index_fail.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,34 @@ | ||
error: this function marked with `#[test]` cannot fail and will always succeed | ||
--> tests/ui-toml/test_without_fail_case/test_without_fail_case.rs:15:1 | ||
| | ||
LL | / fn test_custom_macro_fallible() { | ||
LL | | println!("a") | ||
LL | | } | ||
| |_^ | ||
| | ||
= note: consider adding assertions or panics to test failure cases | ||
= note: `-D clippy::test-without-fail-case` implied by `-D warnings` | ||
= help: to override `-D warnings` add `#[allow(clippy::test_without_fail_case)]` | ||
|
||
error: this function marked with `#[test]` cannot fail and will always succeed | ||
--> tests/ui-toml/test_without_fail_case/test_without_fail_case.rs:27:1 | ||
| | ||
LL | / fn func_a() { | ||
LL | | let _ = 1; | ||
LL | | } | ||
| |_^ | ||
| | ||
= note: consider adding assertions or panics to test failure cases | ||
|
||
error: this function marked with `#[test]` cannot fail and will always succeed | ||
--> tests/ui-toml/test_without_fail_case/test_without_fail_case.rs:32:1 | ||
| | ||
LL | / fn should_not_lint_if_defined_as_fallible() { | ||
LL | | non_fallible_macro!(1); | ||
LL | | } | ||
| |_^ | ||
| | ||
= note: consider adding assertions or panics to test failure cases | ||
|
||
error: aborting due to 3 previous errors | ||
|
45 changes: 45 additions & 0 deletions
45
tests/ui-toml/test_without_fail_case/test_without_fail_case.no_fail_macro.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,45 @@ | ||
error: this function marked with `#[test]` cannot fail and will always succeed | ||
--> tests/ui-toml/test_without_fail_case/test_without_fail_case.rs:21:1 | ||
| | ||
LL | / fn test_indexing_fallible() { | ||
LL | | let a = [1, 2, 3]; | ||
LL | | let _ = a[0]; | ||
LL | | } | ||
| |_^ | ||
| | ||
= note: consider adding assertions or panics to test failure cases | ||
= note: `-D clippy::test-without-fail-case` implied by `-D warnings` | ||
= help: to override `-D warnings` add `#[allow(clippy::test_without_fail_case)]` | ||
|
||
error: this function marked with `#[test]` cannot fail and will always succeed | ||
--> tests/ui-toml/test_without_fail_case/test_without_fail_case.rs:27:1 | ||
| | ||
LL | / fn func_a() { | ||
LL | | let _ = 1; | ||
LL | | } | ||
| |_^ | ||
| | ||
= note: consider adding assertions or panics to test failure cases | ||
|
||
error: this function marked with `#[test]` cannot fail and will always succeed | ||
--> tests/ui-toml/test_without_fail_case/test_without_fail_case.rs:32:1 | ||
| | ||
LL | / fn should_not_lint_if_defined_as_fallible() { | ||
LL | | non_fallible_macro!(1); | ||
LL | | } | ||
| |_^ | ||
| | ||
= note: consider adding assertions or panics to test failure cases | ||
|
||
error: this function marked with `#[test]` cannot fail and will always succeed | ||
--> tests/ui-toml/test_without_fail_case/test_without_fail_case.rs:37:1 | ||
| | ||
LL | / fn should_lint_if_defined_as_non_fallible() { | ||
LL | | fallible_macro!(1); | ||
LL | | } | ||
| |_^ | ||
| | ||
= note: consider adding assertions or panics to test failure cases | ||
|
||
error: aborting due to 4 previous errors | ||
|
39 changes: 24 additions & 15 deletions
39
tests/ui-toml/test_without_fail_case/test_without_fail_case.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 |
---|---|---|
@@ -1,32 +1,41 @@ | ||
//@aux-build:test_macro.rs | ||
//@compile-flags: --test | ||
//@revisions: default fail_macro no_fail_macro index_fail | ||
//@[default] rustc-env:CLIPPY_CONF_DIR=tests/ui-toml/test_without_fail_case/default | ||
//@[fail_macro] rustc-env:CLIPPY_CONF_DIR=tests/ui-toml/test_without_fail_case/macro_fallible | ||
//@[no_fail_macro] rustc-env:CLIPPY_CONF_DIR=tests/ui-toml/test_without_fail_case/macro_non_fallible | ||
//@[index_fail] rustc-env:CLIPPY_CONF_DIR=tests/ui-toml/test_without_fail_case/indexing_fallible | ||
|
||
//@[fail_macro] rustc-env:CLIPPY_CONF_DIR=tests/ui-toml/test_without_fail_case/fail_macro | ||
//@[no_fail_macro] rustc-env:CLIPPY_CONF_DIR=tests/ui-toml/test_without_fail_case/no_fail_macro | ||
//@[index_fail] rustc-env:CLIPPY_CONF_DIR=tests/ui-toml/test_without_fail_case/index_fail | ||
#![allow(unused)] | ||
#![allow(clippy::tests_outside_test_module)] | ||
#![allow(clippy::unnecessary_literal_unwrap)] | ||
#![warn(clippy::test_without_fail_case)] | ||
|
||
macro_rules! test { | ||
( $( $x:expr ),* ) => {{ | ||
let _ = $x; | ||
panic!("a"); | ||
}}; | ||
} | ||
use test_macro::{fallible_macro, non_fallible_macro}; | ||
|
||
// Should not lint because of the clippy.toml file that adds `test` as fallible. | ||
#[test] | ||
fn test_custom_macro_fallible() { | ||
test![1]; | ||
println!("a") | ||
} | ||
|
||
// Should lint because of the clippy.toml file makes indexing fallible. | ||
// Should not lint unless the clippy.toml file makes indexing fallible. | ||
#[test] | ||
fn test_indexing_fallible() { | ||
let a = vec![1, 2, 3]; | ||
let a = [1, 2, 3]; | ||
let _ = a[0]; | ||
} | ||
|
||
#[test] | ||
fn func_a() { | ||
let _ = 1; | ||
} | ||
|
||
#[test] | ||
fn should_not_lint_if_defined_as_fallible() { | ||
non_fallible_macro!(1); | ||
} | ||
|
||
#[test] | ||
fn should_lint_if_defined_as_non_fallible() { | ||
fallible_macro!(1); | ||
} | ||
|
||
fn main() {} |
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