From 6ce61d543acd54edfbd3dde5861e3a0bee752cd6 Mon Sep 17 00:00:00 2001 From: y21 <30553356+y21@users.noreply.github.com> Date: Sun, 24 Sep 2023 14:56:40 +0200 Subject: [PATCH 1/2] add missing configuration tests --- .../clippy.toml | 1 + .../decimal_literal_representation.fixed | 6 ++++++ .../decimal_literal_representation.rs | 6 ++++++ .../decimal_literal_representation.stderr | 11 ++++++++++ .../disallowed_script_idents/clippy.toml | 1 + .../disallowed_script_idents.rs | 6 ++++++ .../disallowed_script_idents.stderr | 11 ++++++++++ tests/ui-toml/enum_variant_names/clippy.toml | 1 + .../enum_variant_names/enum_variant_names.rs | 16 ++++++++++++++ .../enum_variant_names.stderr | 18 ++++++++++++++++ tests/ui-toml/enum_variant_size/clippy.toml | 1 + .../enum_variant_size/enum_variant_size.fixed | 11 ++++++++++ .../enum_variant_size/enum_variant_size.rs | 11 ++++++++++ .../enum_variant_size.stderr | 21 +++++++++++++++++++ tests/ui-toml/explicit_iter_loop/clippy.toml | 1 + .../explicit_iter_loop.fixed | 10 +++++++++ .../explicit_iter_loop/explicit_iter_loop.rs | 10 +++++++++ .../explicit_iter_loop.stderr | 17 +++++++++++++++ tests/ui-toml/large_stack_frames/clippy.toml | 1 + .../large_stack_frames/large_stack_frames.rs | 17 +++++++++++++++ .../large_stack_frames.stderr | 15 +++++++++++++ .../large_types_passed_by_value/clippy.toml | 1 + .../large_types_passed_by_value.fixed | 7 +++++++ .../large_types_passed_by_value.rs | 7 +++++++ .../large_types_passed_by_value.stderr | 11 ++++++++++ tests/ui-toml/manual_let_else/clippy.toml | 1 + .../manual_let_else/manual_let_else.fixed | 10 +++++++++ .../manual_let_else/manual_let_else.rs | 14 +++++++++++++ .../manual_let_else/manual_let_else.stderr | 15 +++++++++++++ tests/ui-toml/path_ends_with_ext/clippy.toml | 1 + .../path_ends_with_ext/path_ends_with_ext.rs | 9 ++++++++ tests/ui-toml/result_large_err/clippy.toml | 1 + .../result_large_err/result_large_err.rs | 10 +++++++++ .../result_large_err/result_large_err.stderr | 12 +++++++++++ .../too_large_for_stack/boxed_local.rs | 5 +++++ .../too_large_for_stack/boxed_local.stderr | 11 ++++++++++ tests/ui-toml/too_large_for_stack/clippy.toml | 1 + .../too_large_for_stack/useless_vec.fixed | 9 ++++++++ .../too_large_for_stack/useless_vec.rs | 9 ++++++++ .../too_large_for_stack/useless_vec.stderr | 11 ++++++++++ tests/ui-toml/too_many_arguments/clippy.toml | 1 + .../too_many_arguments/too_many_arguments.rs | 7 +++++++ .../too_many_arguments.stderr | 11 ++++++++++ tests/ui-toml/type_complexity/clippy.toml | 1 + .../type_complexity/type_complexity.rs | 7 +++++++ .../type_complexity/type_complexity.stderr | 11 ++++++++++ .../type_repetition_in_bounds/clippy.toml | 1 + .../ui-toml/type_repetition_in_bounds/main.rs | 18 ++++++++++++++++ .../type_repetition_in_bounds/main.stderr | 12 +++++++++++ .../unnecessary_box_returns/clippy.toml | 1 + .../unnecessary_box_returns.fixed | 11 ++++++++++ .../unnecessary_box_returns.rs | 11 ++++++++++ .../unnecessary_box_returns.stderr | 12 +++++++++++ tests/ui-toml/verbose_bit_mask/clippy.toml | 1 + .../verbose_bit_mask/verbose_bit_mask.fixed | 7 +++++++ .../verbose_bit_mask/verbose_bit_mask.rs | 7 +++++++ .../verbose_bit_mask/verbose_bit_mask.stderr | 11 ++++++++++ tests/ui-toml/wildcard_imports/clippy.toml | 1 + .../wildcard_imports/wildcard_imports.fixed | 11 ++++++++++ .../wildcard_imports/wildcard_imports.rs | 11 ++++++++++ .../wildcard_imports/wildcard_imports.stderr | 11 ++++++++++ 61 files changed, 501 insertions(+) create mode 100644 tests/ui-toml/decimal_literal_representation/clippy.toml create mode 100644 tests/ui-toml/decimal_literal_representation/decimal_literal_representation.fixed create mode 100644 tests/ui-toml/decimal_literal_representation/decimal_literal_representation.rs create mode 100644 tests/ui-toml/decimal_literal_representation/decimal_literal_representation.stderr create mode 100644 tests/ui-toml/disallowed_script_idents/clippy.toml create mode 100644 tests/ui-toml/disallowed_script_idents/disallowed_script_idents.rs create mode 100644 tests/ui-toml/disallowed_script_idents/disallowed_script_idents.stderr create mode 100644 tests/ui-toml/enum_variant_names/clippy.toml create mode 100644 tests/ui-toml/enum_variant_names/enum_variant_names.rs create mode 100644 tests/ui-toml/enum_variant_names/enum_variant_names.stderr create mode 100644 tests/ui-toml/enum_variant_size/clippy.toml create mode 100644 tests/ui-toml/enum_variant_size/enum_variant_size.fixed create mode 100644 tests/ui-toml/enum_variant_size/enum_variant_size.rs create mode 100644 tests/ui-toml/enum_variant_size/enum_variant_size.stderr create mode 100644 tests/ui-toml/explicit_iter_loop/clippy.toml create mode 100644 tests/ui-toml/explicit_iter_loop/explicit_iter_loop.fixed create mode 100644 tests/ui-toml/explicit_iter_loop/explicit_iter_loop.rs create mode 100644 tests/ui-toml/explicit_iter_loop/explicit_iter_loop.stderr create mode 100644 tests/ui-toml/large_stack_frames/clippy.toml create mode 100644 tests/ui-toml/large_stack_frames/large_stack_frames.rs create mode 100644 tests/ui-toml/large_stack_frames/large_stack_frames.stderr create mode 100644 tests/ui-toml/large_types_passed_by_value/clippy.toml create mode 100644 tests/ui-toml/large_types_passed_by_value/large_types_passed_by_value.fixed create mode 100644 tests/ui-toml/large_types_passed_by_value/large_types_passed_by_value.rs create mode 100644 tests/ui-toml/large_types_passed_by_value/large_types_passed_by_value.stderr create mode 100644 tests/ui-toml/manual_let_else/clippy.toml create mode 100644 tests/ui-toml/manual_let_else/manual_let_else.fixed create mode 100644 tests/ui-toml/manual_let_else/manual_let_else.rs create mode 100644 tests/ui-toml/manual_let_else/manual_let_else.stderr create mode 100644 tests/ui-toml/path_ends_with_ext/clippy.toml create mode 100644 tests/ui-toml/path_ends_with_ext/path_ends_with_ext.rs create mode 100644 tests/ui-toml/result_large_err/clippy.toml create mode 100644 tests/ui-toml/result_large_err/result_large_err.rs create mode 100644 tests/ui-toml/result_large_err/result_large_err.stderr create mode 100644 tests/ui-toml/too_large_for_stack/boxed_local.rs create mode 100644 tests/ui-toml/too_large_for_stack/boxed_local.stderr create mode 100644 tests/ui-toml/too_large_for_stack/clippy.toml create mode 100644 tests/ui-toml/too_large_for_stack/useless_vec.fixed create mode 100644 tests/ui-toml/too_large_for_stack/useless_vec.rs create mode 100644 tests/ui-toml/too_large_for_stack/useless_vec.stderr create mode 100644 tests/ui-toml/too_many_arguments/clippy.toml create mode 100644 tests/ui-toml/too_many_arguments/too_many_arguments.rs create mode 100644 tests/ui-toml/too_many_arguments/too_many_arguments.stderr create mode 100644 tests/ui-toml/type_complexity/clippy.toml create mode 100644 tests/ui-toml/type_complexity/type_complexity.rs create mode 100644 tests/ui-toml/type_complexity/type_complexity.stderr create mode 100644 tests/ui-toml/type_repetition_in_bounds/clippy.toml create mode 100644 tests/ui-toml/type_repetition_in_bounds/main.rs create mode 100644 tests/ui-toml/type_repetition_in_bounds/main.stderr create mode 100644 tests/ui-toml/unnecessary_box_returns/clippy.toml create mode 100644 tests/ui-toml/unnecessary_box_returns/unnecessary_box_returns.fixed create mode 100644 tests/ui-toml/unnecessary_box_returns/unnecessary_box_returns.rs create mode 100644 tests/ui-toml/unnecessary_box_returns/unnecessary_box_returns.stderr create mode 100644 tests/ui-toml/verbose_bit_mask/clippy.toml create mode 100644 tests/ui-toml/verbose_bit_mask/verbose_bit_mask.fixed create mode 100644 tests/ui-toml/verbose_bit_mask/verbose_bit_mask.rs create mode 100644 tests/ui-toml/verbose_bit_mask/verbose_bit_mask.stderr create mode 100644 tests/ui-toml/wildcard_imports/clippy.toml create mode 100644 tests/ui-toml/wildcard_imports/wildcard_imports.fixed create mode 100644 tests/ui-toml/wildcard_imports/wildcard_imports.rs create mode 100644 tests/ui-toml/wildcard_imports/wildcard_imports.stderr diff --git a/tests/ui-toml/decimal_literal_representation/clippy.toml b/tests/ui-toml/decimal_literal_representation/clippy.toml new file mode 100644 index 00000000000..74fc5d249d0 --- /dev/null +++ b/tests/ui-toml/decimal_literal_representation/clippy.toml @@ -0,0 +1 @@ +literal-representation-threshold = 0xFFFFFF diff --git a/tests/ui-toml/decimal_literal_representation/decimal_literal_representation.fixed b/tests/ui-toml/decimal_literal_representation/decimal_literal_representation.fixed new file mode 100644 index 00000000000..750f3be84c0 --- /dev/null +++ b/tests/ui-toml/decimal_literal_representation/decimal_literal_representation.fixed @@ -0,0 +1,6 @@ +#![warn(clippy::decimal_literal_representation)] +fn main() { + let _ = 8388608; + let _ = 0x00FF_FFFF; + //~^ ERROR: integer literal has a better hexadecimal representation +} diff --git a/tests/ui-toml/decimal_literal_representation/decimal_literal_representation.rs b/tests/ui-toml/decimal_literal_representation/decimal_literal_representation.rs new file mode 100644 index 00000000000..26b3354d159 --- /dev/null +++ b/tests/ui-toml/decimal_literal_representation/decimal_literal_representation.rs @@ -0,0 +1,6 @@ +#![warn(clippy::decimal_literal_representation)] +fn main() { + let _ = 8388608; + let _ = 16777215; + //~^ ERROR: integer literal has a better hexadecimal representation +} diff --git a/tests/ui-toml/decimal_literal_representation/decimal_literal_representation.stderr b/tests/ui-toml/decimal_literal_representation/decimal_literal_representation.stderr new file mode 100644 index 00000000000..6f817a3fdde --- /dev/null +++ b/tests/ui-toml/decimal_literal_representation/decimal_literal_representation.stderr @@ -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 + diff --git a/tests/ui-toml/disallowed_script_idents/clippy.toml b/tests/ui-toml/disallowed_script_idents/clippy.toml new file mode 100644 index 00000000000..26cb2d77bfd --- /dev/null +++ b/tests/ui-toml/disallowed_script_idents/clippy.toml @@ -0,0 +1 @@ +allowed-scripts = ["Cyrillic"] diff --git a/tests/ui-toml/disallowed_script_idents/disallowed_script_idents.rs b/tests/ui-toml/disallowed_script_idents/disallowed_script_idents.rs new file mode 100644 index 00000000000..9df1ec6fab0 --- /dev/null +++ b/tests/ui-toml/disallowed_script_idents/disallowed_script_idents.rs @@ -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 +} diff --git a/tests/ui-toml/disallowed_script_idents/disallowed_script_idents.stderr b/tests/ui-toml/disallowed_script_idents/disallowed_script_idents.stderr new file mode 100644 index 00000000000..31bb5ee3514 --- /dev/null +++ b/tests/ui-toml/disallowed_script_idents/disallowed_script_idents.stderr @@ -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 + diff --git a/tests/ui-toml/enum_variant_names/clippy.toml b/tests/ui-toml/enum_variant_names/clippy.toml new file mode 100644 index 00000000000..0ad7a979948 --- /dev/null +++ b/tests/ui-toml/enum_variant_names/clippy.toml @@ -0,0 +1 @@ +enum-variant-name-threshold = 5 diff --git a/tests/ui-toml/enum_variant_names/enum_variant_names.rs b/tests/ui-toml/enum_variant_names/enum_variant_names.rs new file mode 100644 index 00000000000..8f4e178ccfe --- /dev/null +++ b/tests/ui-toml/enum_variant_names/enum_variant_names.rs @@ -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() {} diff --git a/tests/ui-toml/enum_variant_names/enum_variant_names.stderr b/tests/ui-toml/enum_variant_names/enum_variant_names.stderr new file mode 100644 index 00000000000..11039b1db48 --- /dev/null +++ b/tests/ui-toml/enum_variant_names/enum_variant_names.stderr @@ -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 + diff --git a/tests/ui-toml/enum_variant_size/clippy.toml b/tests/ui-toml/enum_variant_size/clippy.toml new file mode 100644 index 00000000000..64a8017fe02 --- /dev/null +++ b/tests/ui-toml/enum_variant_size/clippy.toml @@ -0,0 +1 @@ +enum-variant-size-threshold = 500 diff --git a/tests/ui-toml/enum_variant_size/enum_variant_size.fixed b/tests/ui-toml/enum_variant_size/enum_variant_size.fixed new file mode 100644 index 00000000000..9ae760ae41a --- /dev/null +++ b/tests/ui-toml/enum_variant_size/enum_variant_size.fixed @@ -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() {} diff --git a/tests/ui-toml/enum_variant_size/enum_variant_size.rs b/tests/ui-toml/enum_variant_size/enum_variant_size.rs new file mode 100644 index 00000000000..cf7f432bf0b --- /dev/null +++ b/tests/ui-toml/enum_variant_size/enum_variant_size.rs @@ -0,0 +1,11 @@ +enum Fine { + A(()), + B([u8; 500]), +} +enum Bad { + //~^ ERROR: large size difference between variants + A(()), + B([u8; 501]), +} + +fn main() {} diff --git a/tests/ui-toml/enum_variant_size/enum_variant_size.stderr b/tests/ui-toml/enum_variant_size/enum_variant_size.stderr new file mode 100644 index 00000000000..4d9bc9d48e4 --- /dev/null +++ b/tests/ui-toml/enum_variant_size/enum_variant_size.stderr @@ -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 + diff --git a/tests/ui-toml/explicit_iter_loop/clippy.toml b/tests/ui-toml/explicit_iter_loop/clippy.toml new file mode 100644 index 00000000000..15d175ef147 --- /dev/null +++ b/tests/ui-toml/explicit_iter_loop/clippy.toml @@ -0,0 +1 @@ +enforce-iter-loop-reborrow = true diff --git a/tests/ui-toml/explicit_iter_loop/explicit_iter_loop.fixed b/tests/ui-toml/explicit_iter_loop/explicit_iter_loop.fixed new file mode 100644 index 00000000000..468da22a926 --- /dev/null +++ b/tests/ui-toml/explicit_iter_loop/explicit_iter_loop.fixed @@ -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 +} diff --git a/tests/ui-toml/explicit_iter_loop/explicit_iter_loop.rs b/tests/ui-toml/explicit_iter_loop/explicit_iter_loop.rs new file mode 100644 index 00000000000..a934648608c --- /dev/null +++ b/tests/ui-toml/explicit_iter_loop/explicit_iter_loop.rs @@ -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 +} diff --git a/tests/ui-toml/explicit_iter_loop/explicit_iter_loop.stderr b/tests/ui-toml/explicit_iter_loop/explicit_iter_loop.stderr new file mode 100644 index 00000000000..587d4f9b3f0 --- /dev/null +++ b/tests/ui-toml/explicit_iter_loop/explicit_iter_loop.stderr @@ -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 + diff --git a/tests/ui-toml/large_stack_frames/clippy.toml b/tests/ui-toml/large_stack_frames/clippy.toml new file mode 100644 index 00000000000..1b68801b970 --- /dev/null +++ b/tests/ui-toml/large_stack_frames/clippy.toml @@ -0,0 +1 @@ +stack-size-threshold = 4294967296 diff --git a/tests/ui-toml/large_stack_frames/large_stack_frames.rs b/tests/ui-toml/large_stack_frames/large_stack_frames.rs new file mode 100644 index 00000000000..39b3c571c5c --- /dev/null +++ b/tests/ui-toml/large_stack_frames/large_stack_frames.rs @@ -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() -> [u8; N] { + [0; N] +} + +fn f() { + let _x = create_array::<4294967296>(); +} +fn f2() { + //~^ ERROR: this function allocates a large amount of stack space + let _x = create_array::<4294967297>(); +} + +fn main() {} diff --git a/tests/ui-toml/large_stack_frames/large_stack_frames.stderr b/tests/ui-toml/large_stack_frames/large_stack_frames.stderr new file mode 100644 index 00000000000..ef7d15a3739 --- /dev/null +++ b/tests/ui-toml/large_stack_frames/large_stack_frames.stderr @@ -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::<4294967297>(); +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 + diff --git a/tests/ui-toml/large_types_passed_by_value/clippy.toml b/tests/ui-toml/large_types_passed_by_value/clippy.toml new file mode 100644 index 00000000000..45bcbce1e3c --- /dev/null +++ b/tests/ui-toml/large_types_passed_by_value/clippy.toml @@ -0,0 +1 @@ +pass-by-value-size-limit = 512 diff --git a/tests/ui-toml/large_types_passed_by_value/large_types_passed_by_value.fixed b/tests/ui-toml/large_types_passed_by_value/large_types_passed_by_value.fixed new file mode 100644 index 00000000000..3c87c79cf2f --- /dev/null +++ b/tests/ui-toml/large_types_passed_by_value/large_types_passed_by_value.fixed @@ -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() {} diff --git a/tests/ui-toml/large_types_passed_by_value/large_types_passed_by_value.rs b/tests/ui-toml/large_types_passed_by_value/large_types_passed_by_value.rs new file mode 100644 index 00000000000..0572373a611 --- /dev/null +++ b/tests/ui-toml/large_types_passed_by_value/large_types_passed_by_value.rs @@ -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() {} diff --git a/tests/ui-toml/large_types_passed_by_value/large_types_passed_by_value.stderr b/tests/ui-toml/large_types_passed_by_value/large_types_passed_by_value.stderr new file mode 100644 index 00000000000..6678a2b4721 --- /dev/null +++ b/tests/ui-toml/large_types_passed_by_value/large_types_passed_by_value.stderr @@ -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 + diff --git a/tests/ui-toml/manual_let_else/clippy.toml b/tests/ui-toml/manual_let_else/clippy.toml new file mode 100644 index 00000000000..cdae1da011b --- /dev/null +++ b/tests/ui-toml/manual_let_else/clippy.toml @@ -0,0 +1 @@ +matches-for-let-else = "AllTypes" diff --git a/tests/ui-toml/manual_let_else/manual_let_else.fixed b/tests/ui-toml/manual_let_else/manual_let_else.fixed new file mode 100644 index 00000000000..972f6aa4030 --- /dev/null +++ b/tests/ui-toml/manual_let_else/manual_let_else.fixed @@ -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 }; +} diff --git a/tests/ui-toml/manual_let_else/manual_let_else.rs b/tests/ui-toml/manual_let_else/manual_let_else.rs new file mode 100644 index 00000000000..fdaba4ad2a6 --- /dev/null +++ b/tests/ui-toml/manual_let_else/manual_let_else.rs @@ -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, + }; +} diff --git a/tests/ui-toml/manual_let_else/manual_let_else.stderr b/tests/ui-toml/manual_let_else/manual_let_else.stderr new file mode 100644 index 00000000000..5c2c86c3731 --- /dev/null +++ b/tests/ui-toml/manual_let_else/manual_let_else.stderr @@ -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 + diff --git a/tests/ui-toml/path_ends_with_ext/clippy.toml b/tests/ui-toml/path_ends_with_ext/clippy.toml new file mode 100644 index 00000000000..40d7dfd938c --- /dev/null +++ b/tests/ui-toml/path_ends_with_ext/clippy.toml @@ -0,0 +1 @@ +allowed-dotfiles = ["dot"] diff --git a/tests/ui-toml/path_ends_with_ext/path_ends_with_ext.rs b/tests/ui-toml/path_ends_with_ext/path_ends_with_ext.rs new file mode 100644 index 00000000000..a34b15f4ac9 --- /dev/null +++ b/tests/ui-toml/path_ends_with_ext/path_ends_with_ext.rs @@ -0,0 +1,9 @@ +#![warn(clippy::path_ends_with_ext)] + +use std::path::Path; + +fn f(p: &Path) { + p.ends_with(".dot"); +} + +fn main() {} diff --git a/tests/ui-toml/result_large_err/clippy.toml b/tests/ui-toml/result_large_err/clippy.toml new file mode 100644 index 00000000000..df505ed9672 --- /dev/null +++ b/tests/ui-toml/result_large_err/clippy.toml @@ -0,0 +1 @@ +large-error-threshold = 512 diff --git a/tests/ui-toml/result_large_err/result_large_err.rs b/tests/ui-toml/result_large_err/result_large_err.rs new file mode 100644 index 00000000000..dea4d61a96b --- /dev/null +++ b/tests/ui-toml/result_large_err/result_large_err.rs @@ -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() {} diff --git a/tests/ui-toml/result_large_err/result_large_err.stderr b/tests/ui-toml/result_large_err/result_large_err.stderr new file mode 100644 index 00000000000..b0936319d1b --- /dev/null +++ b/tests/ui-toml/result_large_err/result_large_err.stderr @@ -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 + diff --git a/tests/ui-toml/too_large_for_stack/boxed_local.rs b/tests/ui-toml/too_large_for_stack/boxed_local.rs new file mode 100644 index 00000000000..2f023612206 --- /dev/null +++ b/tests/ui-toml/too_large_for_stack/boxed_local.rs @@ -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() {} diff --git a/tests/ui-toml/too_large_for_stack/boxed_local.stderr b/tests/ui-toml/too_large_for_stack/boxed_local.stderr new file mode 100644 index 00000000000..2859a29f1b2 --- /dev/null +++ b/tests/ui-toml/too_large_for_stack/boxed_local.stderr @@ -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 + diff --git a/tests/ui-toml/too_large_for_stack/clippy.toml b/tests/ui-toml/too_large_for_stack/clippy.toml new file mode 100644 index 00000000000..a9c42fca468 --- /dev/null +++ b/tests/ui-toml/too_large_for_stack/clippy.toml @@ -0,0 +1 @@ +too-large-for-stack = 500 diff --git a/tests/ui-toml/too_large_for_stack/useless_vec.fixed b/tests/ui-toml/too_large_for_stack/useless_vec.fixed new file mode 100644 index 00000000000..ebe92d9b599 --- /dev/null +++ b/tests/ui-toml/too_large_for_stack/useless_vec.fixed @@ -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); +} diff --git a/tests/ui-toml/too_large_for_stack/useless_vec.rs b/tests/ui-toml/too_large_for_stack/useless_vec.rs new file mode 100644 index 00000000000..e2886a8ccd1 --- /dev/null +++ b/tests/ui-toml/too_large_for_stack/useless_vec.rs @@ -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); +} diff --git a/tests/ui-toml/too_large_for_stack/useless_vec.stderr b/tests/ui-toml/too_large_for_stack/useless_vec.stderr new file mode 100644 index 00000000000..923cded5eef --- /dev/null +++ b/tests/ui-toml/too_large_for_stack/useless_vec.stderr @@ -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 + diff --git a/tests/ui-toml/too_many_arguments/clippy.toml b/tests/ui-toml/too_many_arguments/clippy.toml new file mode 100644 index 00000000000..15906305c89 --- /dev/null +++ b/tests/ui-toml/too_many_arguments/clippy.toml @@ -0,0 +1 @@ +too-many-arguments-threshold = 10 diff --git a/tests/ui-toml/too_many_arguments/too_many_arguments.rs b/tests/ui-toml/too_many_arguments/too_many_arguments.rs new file mode 100644 index 00000000000..7b2d6897d3c --- /dev/null +++ b/tests/ui-toml/too_many_arguments/too_many_arguments.rs @@ -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() {} diff --git a/tests/ui-toml/too_many_arguments/too_many_arguments.stderr b/tests/ui-toml/too_many_arguments/too_many_arguments.stderr new file mode 100644 index 00000000000..a52e1fcb9e3 --- /dev/null +++ b/tests/ui-toml/too_many_arguments/too_many_arguments.stderr @@ -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 + diff --git a/tests/ui-toml/type_complexity/clippy.toml b/tests/ui-toml/type_complexity/clippy.toml new file mode 100644 index 00000000000..bf2ffdd0e30 --- /dev/null +++ b/tests/ui-toml/type_complexity/clippy.toml @@ -0,0 +1 @@ +type-complexity-threshold = 500 diff --git a/tests/ui-toml/type_complexity/type_complexity.rs b/tests/ui-toml/type_complexity/type_complexity.rs new file mode 100644 index 00000000000..b95f5134347 --- /dev/null +++ b/tests/ui-toml/type_complexity/type_complexity.rs @@ -0,0 +1,7 @@ +// 480 +fn f(_: (u8, (u8, (u8, (u8, (u8, (u8,))))))) {} +// 550 +fn f2(_: (u8, (u8, (u8, (u8, (u8, (u8, u8))))))) {} +//~^ ERROR: very complex type used + +fn main() {} diff --git a/tests/ui-toml/type_complexity/type_complexity.stderr b/tests/ui-toml/type_complexity/type_complexity.stderr new file mode 100644 index 00000000000..8ca637f7222 --- /dev/null +++ b/tests/ui-toml/type_complexity/type_complexity.stderr @@ -0,0 +1,11 @@ +error: very complex type used. Consider factoring parts into `type` definitions + --> $DIR/type_complexity.rs:4:10 + | +LL | fn f2(_: (u8, (u8, (u8, (u8, (u8, (u8, u8))))))) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: `-D clippy::type-complexity` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::type_complexity)]` + +error: aborting due to previous error + diff --git a/tests/ui-toml/type_repetition_in_bounds/clippy.toml b/tests/ui-toml/type_repetition_in_bounds/clippy.toml new file mode 100644 index 00000000000..2f91866aa93 --- /dev/null +++ b/tests/ui-toml/type_repetition_in_bounds/clippy.toml @@ -0,0 +1 @@ +max-trait-bounds = 5 diff --git a/tests/ui-toml/type_repetition_in_bounds/main.rs b/tests/ui-toml/type_repetition_in_bounds/main.rs new file mode 100644 index 00000000000..2454c10382d --- /dev/null +++ b/tests/ui-toml/type_repetition_in_bounds/main.rs @@ -0,0 +1,18 @@ +#![warn(clippy::type_repetition_in_bounds)] + +fn f() +where + T: Copy + Clone + Sync + Send + ?Sized + Unpin, + T: PartialEq, +{ +} + +fn f2() +where + T: Copy + Clone + Sync + Send + ?Sized, + T: Unpin + PartialEq, + //~^ ERROR: this type has already been used as a bound predicate +{ +} + +fn main() {} diff --git a/tests/ui-toml/type_repetition_in_bounds/main.stderr b/tests/ui-toml/type_repetition_in_bounds/main.stderr new file mode 100644 index 00000000000..2ae2984975f --- /dev/null +++ b/tests/ui-toml/type_repetition_in_bounds/main.stderr @@ -0,0 +1,12 @@ +error: this type has already been used as a bound predicate + --> $DIR/main.rs:13:5 + | +LL | T: Unpin + PartialEq, + | ^^^^^^^^^^^^^^^^^^^^ + | + = help: consider combining the bounds: `T: Copy + Clone + Sync + Send + ?Sized + Unpin + PartialEq` + = note: `-D clippy::type-repetition-in-bounds` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::type_repetition_in_bounds)]` + +error: aborting due to previous error + diff --git a/tests/ui-toml/unnecessary_box_returns/clippy.toml b/tests/ui-toml/unnecessary_box_returns/clippy.toml new file mode 100644 index 00000000000..7c3ffc2908f --- /dev/null +++ b/tests/ui-toml/unnecessary_box_returns/clippy.toml @@ -0,0 +1 @@ +unnecessary-box-size = 64 diff --git a/tests/ui-toml/unnecessary_box_returns/unnecessary_box_returns.fixed b/tests/ui-toml/unnecessary_box_returns/unnecessary_box_returns.fixed new file mode 100644 index 00000000000..413bc0bf1e3 --- /dev/null +++ b/tests/ui-toml/unnecessary_box_returns/unnecessary_box_returns.fixed @@ -0,0 +1,11 @@ +#![warn(clippy::unnecessary_box_returns)] + +fn f() -> [u8; 64] { + //~^ ERROR: boxed return of the sized type `[u8; 64]` + todo!() +} +fn f2() -> Box<[u8; 65]> { + todo!() +} + +fn main() {} diff --git a/tests/ui-toml/unnecessary_box_returns/unnecessary_box_returns.rs b/tests/ui-toml/unnecessary_box_returns/unnecessary_box_returns.rs new file mode 100644 index 00000000000..b44fbb55448 --- /dev/null +++ b/tests/ui-toml/unnecessary_box_returns/unnecessary_box_returns.rs @@ -0,0 +1,11 @@ +#![warn(clippy::unnecessary_box_returns)] + +fn f() -> Box<[u8; 64]> { + //~^ ERROR: boxed return of the sized type `[u8; 64]` + todo!() +} +fn f2() -> Box<[u8; 65]> { + todo!() +} + +fn main() {} diff --git a/tests/ui-toml/unnecessary_box_returns/unnecessary_box_returns.stderr b/tests/ui-toml/unnecessary_box_returns/unnecessary_box_returns.stderr new file mode 100644 index 00000000000..df9aa37ac10 --- /dev/null +++ b/tests/ui-toml/unnecessary_box_returns/unnecessary_box_returns.stderr @@ -0,0 +1,12 @@ +error: boxed return of the sized type `[u8; 64]` + --> $DIR/unnecessary_box_returns.rs:3:11 + | +LL | fn f() -> Box<[u8; 64]> { + | ^^^^^^^^^^^^^ help: try: `[u8; 64]` + | + = help: changing this also requires a change to the return expressions in this function + = note: `-D clippy::unnecessary-box-returns` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::unnecessary_box_returns)]` + +error: aborting due to previous error + diff --git a/tests/ui-toml/verbose_bit_mask/clippy.toml b/tests/ui-toml/verbose_bit_mask/clippy.toml new file mode 100644 index 00000000000..55a202eefb9 --- /dev/null +++ b/tests/ui-toml/verbose_bit_mask/clippy.toml @@ -0,0 +1 @@ +verbose-bit-mask-threshold = 31 diff --git a/tests/ui-toml/verbose_bit_mask/verbose_bit_mask.fixed b/tests/ui-toml/verbose_bit_mask/verbose_bit_mask.fixed new file mode 100644 index 00000000000..437692a4d78 --- /dev/null +++ b/tests/ui-toml/verbose_bit_mask/verbose_bit_mask.fixed @@ -0,0 +1,7 @@ +#![warn(clippy::verbose_bit_mask)] +fn main() { + let v: i32 = 0; + let _ = v & 0b11111 == 0; + let _ = v.trailing_zeros() >= 6; + //~^ ERROR: bit mask could be simplified +} diff --git a/tests/ui-toml/verbose_bit_mask/verbose_bit_mask.rs b/tests/ui-toml/verbose_bit_mask/verbose_bit_mask.rs new file mode 100644 index 00000000000..ce102708055 --- /dev/null +++ b/tests/ui-toml/verbose_bit_mask/verbose_bit_mask.rs @@ -0,0 +1,7 @@ +#![warn(clippy::verbose_bit_mask)] +fn main() { + let v: i32 = 0; + let _ = v & 0b11111 == 0; + let _ = v & 0b111111 == 0; + //~^ ERROR: bit mask could be simplified +} diff --git a/tests/ui-toml/verbose_bit_mask/verbose_bit_mask.stderr b/tests/ui-toml/verbose_bit_mask/verbose_bit_mask.stderr new file mode 100644 index 00000000000..7377921b42a --- /dev/null +++ b/tests/ui-toml/verbose_bit_mask/verbose_bit_mask.stderr @@ -0,0 +1,11 @@ +error: bit mask could be simplified with a call to `trailing_zeros` + --> $DIR/verbose_bit_mask.rs:5:13 + | +LL | let _ = v & 0b111111 == 0; + | ^^^^^^^^^^^^^^^^^ help: try: `v.trailing_zeros() >= 6` + | + = note: `-D clippy::verbose-bit-mask` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::verbose_bit_mask)]` + +error: aborting due to previous error + diff --git a/tests/ui-toml/wildcard_imports/clippy.toml b/tests/ui-toml/wildcard_imports/clippy.toml new file mode 100644 index 00000000000..875aaeef6c9 --- /dev/null +++ b/tests/ui-toml/wildcard_imports/clippy.toml @@ -0,0 +1 @@ +warn-on-all-wildcard-imports = true diff --git a/tests/ui-toml/wildcard_imports/wildcard_imports.fixed b/tests/ui-toml/wildcard_imports/wildcard_imports.fixed new file mode 100644 index 00000000000..1752f48856c --- /dev/null +++ b/tests/ui-toml/wildcard_imports/wildcard_imports.fixed @@ -0,0 +1,11 @@ +#![warn(clippy::wildcard_imports)] + +mod prelude { + pub const FOO: u8 = 1; +} +use prelude::FOO; +//~^ ERROR: usage of wildcard import + +fn main() { + let _ = FOO; +} diff --git a/tests/ui-toml/wildcard_imports/wildcard_imports.rs b/tests/ui-toml/wildcard_imports/wildcard_imports.rs new file mode 100644 index 00000000000..331c2c59c22 --- /dev/null +++ b/tests/ui-toml/wildcard_imports/wildcard_imports.rs @@ -0,0 +1,11 @@ +#![warn(clippy::wildcard_imports)] + +mod prelude { + pub const FOO: u8 = 1; +} +use prelude::*; +//~^ ERROR: usage of wildcard import + +fn main() { + let _ = FOO; +} diff --git a/tests/ui-toml/wildcard_imports/wildcard_imports.stderr b/tests/ui-toml/wildcard_imports/wildcard_imports.stderr new file mode 100644 index 00000000000..13ec3a229ce --- /dev/null +++ b/tests/ui-toml/wildcard_imports/wildcard_imports.stderr @@ -0,0 +1,11 @@ +error: usage of wildcard import + --> $DIR/wildcard_imports.rs:6:5 + | +LL | use prelude::*; + | ^^^^^^^^^^ help: try: `prelude::FOO` + | + = note: `-D clippy::wildcard-imports` implied by `-D warnings` + = help: to override `-D warnings` add `#[allow(clippy::wildcard_imports)]` + +error: aborting due to previous error + From 6e80db96ea933676ac9b36714e3af9aaa3eedc00 Mon Sep 17 00:00:00 2001 From: y21 <30553356+y21@users.noreply.github.com> Date: Sun, 24 Sep 2023 16:29:26 +0200 Subject: [PATCH 2/2] use a smaller number in test that fits in usize for 32 bit --- tests/ui-toml/large_stack_frames/clippy.toml | 2 +- tests/ui-toml/large_stack_frames/large_stack_frames.rs | 4 ++-- tests/ui-toml/large_stack_frames/large_stack_frames.stderr | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/ui-toml/large_stack_frames/clippy.toml b/tests/ui-toml/large_stack_frames/clippy.toml index 1b68801b970..584335dc28f 100644 --- a/tests/ui-toml/large_stack_frames/clippy.toml +++ b/tests/ui-toml/large_stack_frames/clippy.toml @@ -1 +1 @@ -stack-size-threshold = 4294967296 +stack-size-threshold = 1000 diff --git a/tests/ui-toml/large_stack_frames/large_stack_frames.rs b/tests/ui-toml/large_stack_frames/large_stack_frames.rs index 39b3c571c5c..39798ffea49 100644 --- a/tests/ui-toml/large_stack_frames/large_stack_frames.rs +++ b/tests/ui-toml/large_stack_frames/large_stack_frames.rs @@ -7,11 +7,11 @@ } fn f() { - let _x = create_array::<4294967296>(); + let _x = create_array::<1000>(); } fn f2() { //~^ ERROR: this function allocates a large amount of stack space - let _x = create_array::<4294967297>(); + let _x = create_array::<1001>(); } fn main() {} diff --git a/tests/ui-toml/large_stack_frames/large_stack_frames.stderr b/tests/ui-toml/large_stack_frames/large_stack_frames.stderr index ef7d15a3739..67ee57ab672 100644 --- a/tests/ui-toml/large_stack_frames/large_stack_frames.stderr +++ b/tests/ui-toml/large_stack_frames/large_stack_frames.stderr @@ -3,7 +3,7 @@ error: this function allocates a large amount of stack space | LL | / fn f2() { LL | | -LL | | let _x = create_array::<4294967297>(); +LL | | let _x = create_array::<1001>(); LL | | } | |_^ |