-
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.
Auto merge of #11560 - y21:ui-toml-tests, r=Alexendoo
Add missing tests for configuration options I noticed that a lot of lints didn't have test(s) for their configuration. This leads to issues like #11481 where the lint just does nothing with it. This PR adds tests for *almost*[^1] all of the lints with a configuration that didn't have a test in ui-toml. The tests that I wrote here are usually two cases: one for where it's right above or under the limit set by the config where it shouldn't lint and another one for right above where it should. changelog: none [^1]: allow-one-hash-in-raw-strings is ignored by needless_raw_string_hashes
- Loading branch information
Showing
61 changed files
with
501 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
literal-representation-threshold = 0xFFFFFF |
6 changes: 6 additions & 0 deletions
6
tests/ui-toml/decimal_literal_representation/decimal_literal_representation.fixed
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,6 @@ | ||
#![warn(clippy::decimal_literal_representation)] | ||
fn main() { | ||
let _ = 8388608; | ||
let _ = 0x00FF_FFFF; | ||
//~^ ERROR: integer literal has a better hexadecimal representation | ||
} |
6 changes: 6 additions & 0 deletions
6
tests/ui-toml/decimal_literal_representation/decimal_literal_representation.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,6 @@ | ||
#![warn(clippy::decimal_literal_representation)] | ||
fn main() { | ||
let _ = 8388608; | ||
let _ = 16777215; | ||
//~^ ERROR: integer literal has a better hexadecimal representation | ||
} |
11 changes: 11 additions & 0 deletions
11
tests/ui-toml/decimal_literal_representation/decimal_literal_representation.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,11 @@ | ||
error: integer literal has a better hexadecimal representation | ||
--> $DIR/decimal_literal_representation.rs:4:13 | ||
| | ||
LL | let _ = 16777215; | ||
| ^^^^^^^^ help: consider: `0x00FF_FFFF` | ||
| | ||
= note: `-D clippy::decimal-literal-representation` implied by `-D warnings` | ||
= help: to override `-D warnings` add `#[allow(clippy::decimal_literal_representation)]` | ||
|
||
error: aborting due to previous error | ||
|
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 @@ | ||
allowed-scripts = ["Cyrillic"] |
6 changes: 6 additions & 0 deletions
6
tests/ui-toml/disallowed_script_idents/disallowed_script_idents.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,6 @@ | ||
#![warn(clippy::disallowed_script_idents)] | ||
fn main() { | ||
let счётчик = 10; | ||
let カウンタ = 10; | ||
//~^ ERROR: identifier `カウンタ` has a Unicode script that is not allowed by configuration | ||
} |
11 changes: 11 additions & 0 deletions
11
tests/ui-toml/disallowed_script_idents/disallowed_script_idents.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,11 @@ | ||
error: identifier `カウンタ` has a Unicode script that is not allowed by configuration: Katakana | ||
--> $DIR/disallowed_script_idents.rs:4:9 | ||
| | ||
LL | let カウンタ = 10; | ||
| ^^^^^^^^ | ||
| | ||
= note: `-D clippy::disallowed-script-idents` implied by `-D warnings` | ||
= help: to override `-D warnings` add `#[allow(clippy::disallowed_script_idents)]` | ||
|
||
error: aborting due to previous error | ||
|
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 @@ | ||
enum-variant-name-threshold = 5 |
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,16 @@ | ||
enum Foo { | ||
AFoo, | ||
BFoo, | ||
CFoo, | ||
DFoo, | ||
} | ||
enum Foo2 { | ||
//~^ ERROR: all variants have the same postfix | ||
AFoo, | ||
BFoo, | ||
CFoo, | ||
DFoo, | ||
EFoo, | ||
} | ||
|
||
fn main() {} |
18 changes: 18 additions & 0 deletions
18
tests/ui-toml/enum_variant_names/enum_variant_names.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,18 @@ | ||
error: all variants have the same postfix: `Foo` | ||
--> $DIR/enum_variant_names.rs:7:1 | ||
| | ||
LL | / enum Foo2 { | ||
LL | | | ||
LL | | AFoo, | ||
LL | | BFoo, | ||
... | | ||
LL | | EFoo, | ||
LL | | } | ||
| |_^ | ||
| | ||
= help: remove the postfixes and use full paths to the variants instead of glob imports | ||
= note: `-D clippy::enum-variant-names` implied by `-D warnings` | ||
= help: to override `-D warnings` add `#[allow(clippy::enum_variant_names)]` | ||
|
||
error: aborting due to previous error | ||
|
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 @@ | ||
enum-variant-size-threshold = 500 |
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,11 @@ | ||
enum Fine { | ||
A(()), | ||
B([u8; 500]), | ||
} | ||
enum Bad { | ||
//~^ ERROR: large size difference between variants | ||
A(()), | ||
B(Box<[u8; 501]>), | ||
} | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
enum Fine { | ||
A(()), | ||
B([u8; 500]), | ||
} | ||
enum Bad { | ||
//~^ ERROR: large size difference between variants | ||
A(()), | ||
B([u8; 501]), | ||
} | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
error: large size difference between variants | ||
--> $DIR/enum_variant_size.rs:5:1 | ||
| | ||
LL | / enum Bad { | ||
LL | | | ||
LL | | A(()), | ||
| | ----- the second-largest variant contains at least 0 bytes | ||
LL | | B([u8; 501]), | ||
| | ------------ the largest variant contains at least 501 bytes | ||
LL | | } | ||
| |_^ the entire enum is at least 502 bytes | ||
| | ||
= note: `-D clippy::large-enum-variant` implied by `-D warnings` | ||
= help: to override `-D warnings` add `#[allow(clippy::large_enum_variant)]` | ||
help: consider boxing the large fields to reduce the total size of the enum | ||
| | ||
LL | B(Box<[u8; 501]>), | ||
| ~~~~~~~~~~~~~~ | ||
|
||
error: aborting due to previous error | ||
|
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 @@ | ||
enforce-iter-loop-reborrow = true |
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,10 @@ | ||
#![warn(clippy::explicit_iter_loop)] | ||
|
||
fn main() { | ||
let mut vec = vec![1, 2, 3]; | ||
let rmvec = &mut vec; | ||
for _ in &*rmvec {} | ||
//~^ ERROR: it is more concise to loop over references to containers | ||
for _ in &mut *rmvec {} | ||
//~^ ERROR: it is more concise to loop over references to containers | ||
} |
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,10 @@ | ||
#![warn(clippy::explicit_iter_loop)] | ||
|
||
fn main() { | ||
let mut vec = vec![1, 2, 3]; | ||
let rmvec = &mut vec; | ||
for _ in rmvec.iter() {} | ||
//~^ ERROR: it is more concise to loop over references to containers | ||
for _ in rmvec.iter_mut() {} | ||
//~^ ERROR: it is more concise to loop over references to containers | ||
} |
17 changes: 17 additions & 0 deletions
17
tests/ui-toml/explicit_iter_loop/explicit_iter_loop.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,17 @@ | ||
error: it is more concise to loop over references to containers instead of using explicit iteration methods | ||
--> $DIR/explicit_iter_loop.rs:6:14 | ||
| | ||
LL | for _ in rmvec.iter() {} | ||
| ^^^^^^^^^^^^ help: to write this more concisely, try: `&*rmvec` | ||
| | ||
= note: `-D clippy::explicit-iter-loop` implied by `-D warnings` | ||
= help: to override `-D warnings` add `#[allow(clippy::explicit_iter_loop)]` | ||
|
||
error: it is more concise to loop over references to containers instead of using explicit iteration methods | ||
--> $DIR/explicit_iter_loop.rs:8:14 | ||
| | ||
LL | for _ in rmvec.iter_mut() {} | ||
| ^^^^^^^^^^^^^^^^ help: to write this more concisely, try: `&mut *rmvec` | ||
|
||
error: aborting due to 2 previous errors | ||
|
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 @@ | ||
stack-size-threshold = 1000 |
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,17 @@ | ||
#![warn(clippy::large_stack_frames)] | ||
|
||
// We use this helper function instead of writing [0; 4294967297] directly to represent a | ||
// case that large_stack_arrays can't catch | ||
fn create_array<const N: usize>() -> [u8; N] { | ||
[0; N] | ||
} | ||
|
||
fn f() { | ||
let _x = create_array::<1000>(); | ||
} | ||
fn f2() { | ||
//~^ ERROR: this function allocates a large amount of stack space | ||
let _x = create_array::<1001>(); | ||
} | ||
|
||
fn main() {} |
15 changes: 15 additions & 0 deletions
15
tests/ui-toml/large_stack_frames/large_stack_frames.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,15 @@ | ||
error: this function allocates a large amount of stack space | ||
--> $DIR/large_stack_frames.rs:12:1 | ||
| | ||
LL | / fn f2() { | ||
LL | | | ||
LL | | let _x = create_array::<1001>(); | ||
LL | | } | ||
| |_^ | ||
| | ||
= note: allocating large amounts of stack space can overflow the stack | ||
= note: `-D clippy::large-stack-frames` implied by `-D warnings` | ||
= help: to override `-D warnings` add `#[allow(clippy::large_stack_frames)]` | ||
|
||
error: aborting due to previous error | ||
|
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 @@ | ||
pass-by-value-size-limit = 512 |
7 changes: 7 additions & 0 deletions
7
tests/ui-toml/large_types_passed_by_value/large_types_passed_by_value.fixed
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,7 @@ | ||
#![warn(clippy::large_types_passed_by_value)] | ||
|
||
fn f(_v: [u8; 512]) {} | ||
fn f2(_v: &[u8; 513]) {} | ||
//~^ ERROR: this argument (513 byte) is passed by value | ||
|
||
fn main() {} |
7 changes: 7 additions & 0 deletions
7
tests/ui-toml/large_types_passed_by_value/large_types_passed_by_value.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,7 @@ | ||
#![warn(clippy::large_types_passed_by_value)] | ||
|
||
fn f(_v: [u8; 512]) {} | ||
fn f2(_v: [u8; 513]) {} | ||
//~^ ERROR: this argument (513 byte) is passed by value | ||
|
||
fn main() {} |
11 changes: 11 additions & 0 deletions
11
tests/ui-toml/large_types_passed_by_value/large_types_passed_by_value.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,11 @@ | ||
error: this argument (513 byte) is passed by value, but might be more efficient if passed by reference (limit: 512 byte) | ||
--> $DIR/large_types_passed_by_value.rs:4:11 | ||
| | ||
LL | fn f2(_v: [u8; 513]) {} | ||
| ^^^^^^^^^ help: consider passing by reference instead: `&[u8; 513]` | ||
| | ||
= note: `-D clippy::large-types-passed-by-value` implied by `-D warnings` | ||
= help: to override `-D warnings` add `#[allow(clippy::large_types_passed_by_value)]` | ||
|
||
error: aborting due to previous error | ||
|
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 @@ | ||
matches-for-let-else = "AllTypes" |
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,10 @@ | ||
#![warn(clippy::manual_let_else)] | ||
|
||
enum Foo { | ||
A(u8), | ||
B, | ||
} | ||
|
||
fn main() { | ||
let Foo::A(x) = Foo::A(1) else { return }; | ||
} |
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 @@ | ||
#![warn(clippy::manual_let_else)] | ||
|
||
enum Foo { | ||
A(u8), | ||
B, | ||
} | ||
|
||
fn main() { | ||
let x = match Foo::A(1) { | ||
//~^ ERROR: this could be rewritten as `let...else` | ||
Foo::A(x) => x, | ||
Foo::B => return, | ||
}; | ||
} |
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,15 @@ | ||
error: this could be rewritten as `let...else` | ||
--> $DIR/manual_let_else.rs:9:5 | ||
| | ||
LL | / let x = match Foo::A(1) { | ||
LL | | | ||
LL | | Foo::A(x) => x, | ||
LL | | Foo::B => return, | ||
LL | | }; | ||
| |______^ help: consider writing: `let Foo::A(x) = Foo::A(1) else { return };` | ||
| | ||
= note: `-D clippy::manual-let-else` implied by `-D warnings` | ||
= help: to override `-D warnings` add `#[allow(clippy::manual_let_else)]` | ||
|
||
error: aborting due to previous error | ||
|
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 @@ | ||
allowed-dotfiles = ["dot"] |
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,9 @@ | ||
#![warn(clippy::path_ends_with_ext)] | ||
|
||
use std::path::Path; | ||
|
||
fn f(p: &Path) { | ||
p.ends_with(".dot"); | ||
} | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
large-error-threshold = 512 |
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,10 @@ | ||
#![warn(clippy::result_large_err)] | ||
|
||
fn f() -> Result<(), [u8; 511]> { | ||
todo!() | ||
} | ||
fn f2() -> Result<(), [u8; 512]> { | ||
//~^ ERROR: the `Err`-variant returned from this function is very large | ||
todo!() | ||
} | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
error: the `Err`-variant returned from this function is very large | ||
--> $DIR/result_large_err.rs:6:12 | ||
| | ||
LL | fn f2() -> Result<(), [u8; 512]> { | ||
| ^^^^^^^^^^^^^^^^^^^^^ the `Err`-variant is at least 512 bytes | ||
| | ||
= help: try reducing the size of `[u8; 512]`, for example by boxing large elements or replacing it with `Box<[u8; 512]>` | ||
= note: `-D clippy::result-large-err` implied by `-D warnings` | ||
= help: to override `-D warnings` add `#[allow(clippy::result_large_err)]` | ||
|
||
error: aborting due to previous error | ||
|
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,5 @@ | ||
fn f(x: Box<[u8; 500]>) {} | ||
//~^ ERROR: local variable doesn't need to be boxed here | ||
fn f2(x: Box<[u8; 501]>) {} | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
error: local variable doesn't need to be boxed here | ||
--> $DIR/boxed_local.rs:1:6 | ||
| | ||
LL | fn f(x: Box<[u8; 500]>) {} | ||
| ^ | ||
| | ||
= note: `-D clippy::boxed-local` implied by `-D warnings` | ||
= help: to override `-D warnings` add `#[allow(clippy::boxed_local)]` | ||
|
||
error: aborting due to previous error | ||
|
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 @@ | ||
too-large-for-stack = 500 |
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,9 @@ | ||
#![warn(clippy::useless_vec)] | ||
|
||
fn main() { | ||
let x = [0u8; 500]; | ||
//~^ ERROR: useless use of `vec!` | ||
x.contains(&1); | ||
let y = vec![0u8; 501]; | ||
y.contains(&1); | ||
} |
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,9 @@ | ||
#![warn(clippy::useless_vec)] | ||
|
||
fn main() { | ||
let x = vec![0u8; 500]; | ||
//~^ ERROR: useless use of `vec!` | ||
x.contains(&1); | ||
let y = vec![0u8; 501]; | ||
y.contains(&1); | ||
} |
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,11 @@ | ||
error: useless use of `vec!` | ||
--> $DIR/useless_vec.rs:4:13 | ||
| | ||
LL | let x = vec![0u8; 500]; | ||
| ^^^^^^^^^^^^^^ help: you can use an array directly: `[0u8; 500]` | ||
| | ||
= note: `-D clippy::useless-vec` implied by `-D warnings` | ||
= help: to override `-D warnings` add `#[allow(clippy::useless_vec)]` | ||
|
||
error: aborting due to previous error | ||
|
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 @@ | ||
too-many-arguments-threshold = 10 |
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,7 @@ | ||
#![warn(clippy::too_many_arguments)] | ||
|
||
fn not_too_many(p1: u8, p2: u8, p3: u8, p4: u8, p5: u8, p6: u8, p7: u8, p8: u8, p9: u8, p10: u8) {} | ||
fn too_many(p1: u8, p2: u8, p3: u8, p4: u8, p5: u8, p6: u8, p7: u8, p8: u8, p9: u8, p10: u8, p11: u8) {} | ||
//~^ ERROR: this function has too many arguments | ||
|
||
fn main() {} |
11 changes: 11 additions & 0 deletions
11
tests/ui-toml/too_many_arguments/too_many_arguments.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,11 @@ | ||
error: this function has too many arguments (11/10) | ||
--> $DIR/too_many_arguments.rs:4:1 | ||
| | ||
LL | fn too_many(p1: u8, p2: u8, p3: u8, p4: u8, p5: u8, p6: u8, p7: u8, p8: u8, p9: u8, p10: u8, p11: u8) {} | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: `-D clippy::too-many-arguments` implied by `-D warnings` | ||
= help: to override `-D warnings` add `#[allow(clippy::too_many_arguments)]` | ||
|
||
error: aborting due to previous error | ||
|
Oops, something went wrong.