Fix and bless clippy tests

This commit is contained in:
Gary Guo 2024-04-19 17:01:35 +01:00
parent cfee72aa24
commit 9d16364198
14 changed files with 74 additions and 79 deletions

View File

@ -1,4 +1,3 @@
#![feature(inline_const)]
#![warn(clippy::indexing_slicing)]
// We also check the out_of_bounds_indexing lint here, because it lints similar things and
// we want to avoid false positives.

View File

@ -1,5 +1,5 @@
error: indexing may panic
--> tests/ui-toml/suppress_lint_in_const/test.rs:27:5
--> tests/ui-toml/suppress_lint_in_const/test.rs:26:5
|
LL | x[index];
| ^^^^^^^^
@ -9,7 +9,7 @@ LL | x[index];
= help: to override `-D warnings` add `#[allow(clippy::indexing_slicing)]`
error: indexing may panic
--> tests/ui-toml/suppress_lint_in_const/test.rs:42:5
--> tests/ui-toml/suppress_lint_in_const/test.rs:41:5
|
LL | v[0];
| ^^^^
@ -17,7 +17,7 @@ LL | v[0];
= help: consider using `.get(n)` or `.get_mut(n)` instead
error: indexing may panic
--> tests/ui-toml/suppress_lint_in_const/test.rs:43:5
--> tests/ui-toml/suppress_lint_in_const/test.rs:42:5
|
LL | v[10];
| ^^^^^
@ -25,7 +25,7 @@ LL | v[10];
= help: consider using `.get(n)` or `.get_mut(n)` instead
error: indexing may panic
--> tests/ui-toml/suppress_lint_in_const/test.rs:44:5
--> tests/ui-toml/suppress_lint_in_const/test.rs:43:5
|
LL | v[1 << 3];
| ^^^^^^^^^
@ -33,7 +33,7 @@ LL | v[1 << 3];
= help: consider using `.get(n)` or `.get_mut(n)` instead
error: indexing may panic
--> tests/ui-toml/suppress_lint_in_const/test.rs:50:5
--> tests/ui-toml/suppress_lint_in_const/test.rs:49:5
|
LL | v[N];
| ^^^^
@ -41,7 +41,7 @@ LL | v[N];
= help: consider using `.get(n)` or `.get_mut(n)` instead
error: indexing may panic
--> tests/ui-toml/suppress_lint_in_const/test.rs:51:5
--> tests/ui-toml/suppress_lint_in_const/test.rs:50:5
|
LL | v[M];
| ^^^^

View File

@ -10,7 +10,7 @@
arithmetic_overflow,
unconditional_panic
)]
#![feature(const_mut_refs, inline_const)]
#![feature(const_mut_refs)]
#![warn(clippy::arithmetic_side_effects)]
extern crate proc_macro_derive;

View File

@ -1,4 +1,4 @@
#![feature(let_chains, inline_const)]
#![feature(let_chains)]
#![warn(clippy::bool_to_int_with_if)]
#![allow(unused, dead_code, clippy::unnecessary_operation, clippy::no_effect)]

View File

@ -1,4 +1,4 @@
#![feature(let_chains, inline_const)]
#![feature(let_chains)]
#![warn(clippy::bool_to_int_with_if)]
#![allow(unused, dead_code, clippy::unnecessary_operation, clippy::no_effect)]

View File

@ -1,4 +1,3 @@
#![feature(inline_const)]
#![warn(clippy::const_is_empty)]
#![allow(clippy::needless_late_init, unused_must_use)]

View File

@ -1,5 +1,5 @@
error: this expression always evaluates to true
--> tests/ui/const_is_empty.rs:6:8
--> tests/ui/const_is_empty.rs:5:8
|
LL | if "".is_empty() {
| ^^^^^^^^^^^^^
@ -8,151 +8,151 @@ LL | if "".is_empty() {
= help: to override `-D warnings` add `#[allow(clippy::const_is_empty)]`
error: this expression always evaluates to false
--> tests/ui/const_is_empty.rs:9:8
--> tests/ui/const_is_empty.rs:8:8
|
LL | if "foobar".is_empty() {
| ^^^^^^^^^^^^^^^^^^^
error: this expression always evaluates to true
--> tests/ui/const_is_empty.rs:15:8
--> tests/ui/const_is_empty.rs:14:8
|
LL | if b"".is_empty() {
| ^^^^^^^^^^^^^^
error: this expression always evaluates to false
--> tests/ui/const_is_empty.rs:18:8
--> tests/ui/const_is_empty.rs:17:8
|
LL | if b"foobar".is_empty() {
| ^^^^^^^^^^^^^^^^^^^^
error: this expression always evaluates to true
--> tests/ui/const_is_empty.rs:35:8
--> tests/ui/const_is_empty.rs:34:8
|
LL | if empty2.is_empty() {
| ^^^^^^^^^^^^^^^^^
error: this expression always evaluates to false
--> tests/ui/const_is_empty.rs:38:8
--> tests/ui/const_is_empty.rs:37:8
|
LL | if non_empty2.is_empty() {
| ^^^^^^^^^^^^^^^^^^^^^
error: this expression always evaluates to true
--> tests/ui/const_is_empty.rs:60:13
--> tests/ui/const_is_empty.rs:59:13
|
LL | let _ = EMPTY_STR.is_empty();
| ^^^^^^^^^^^^^^^^^^^^
error: this expression always evaluates to false
--> tests/ui/const_is_empty.rs:62:13
--> tests/ui/const_is_empty.rs:61:13
|
LL | let _ = NON_EMPTY_STR.is_empty();
| ^^^^^^^^^^^^^^^^^^^^^^^^
error: this expression always evaluates to true
--> tests/ui/const_is_empty.rs:64:13
--> tests/ui/const_is_empty.rs:63:13
|
LL | let _ = EMPTY_BSTR.is_empty();
| ^^^^^^^^^^^^^^^^^^^^^
error: this expression always evaluates to false
--> tests/ui/const_is_empty.rs:66:13
--> tests/ui/const_is_empty.rs:65:13
|
LL | let _ = NON_EMPTY_BSTR.is_empty();
| ^^^^^^^^^^^^^^^^^^^^^^^^^
error: this expression always evaluates to true
--> tests/ui/const_is_empty.rs:68:13
--> tests/ui/const_is_empty.rs:67:13
|
LL | let _ = EMPTY_ARRAY.is_empty();
| ^^^^^^^^^^^^^^^^^^^^^^
error: this expression always evaluates to true
--> tests/ui/const_is_empty.rs:70:13
--> tests/ui/const_is_empty.rs:69:13
|
LL | let _ = EMPTY_ARRAY_REPEAT.is_empty();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: this expression always evaluates to true
--> tests/ui/const_is_empty.rs:72:13
--> tests/ui/const_is_empty.rs:71:13
|
LL | let _ = EMPTY_U8_SLICE.is_empty();
| ^^^^^^^^^^^^^^^^^^^^^^^^^
error: this expression always evaluates to false
--> tests/ui/const_is_empty.rs:74:13
--> tests/ui/const_is_empty.rs:73:13
|
LL | let _ = NON_EMPTY_U8_SLICE.is_empty();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: this expression always evaluates to false
--> tests/ui/const_is_empty.rs:76:13
--> tests/ui/const_is_empty.rs:75:13
|
LL | let _ = NON_EMPTY_ARRAY.is_empty();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
error: this expression always evaluates to false
--> tests/ui/const_is_empty.rs:78:13
--> tests/ui/const_is_empty.rs:77:13
|
LL | let _ = NON_EMPTY_ARRAY_REPEAT.is_empty();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: this expression always evaluates to true
--> tests/ui/const_is_empty.rs:80:13
--> tests/ui/const_is_empty.rs:79:13
|
LL | let _ = EMPTY_REF_ARRAY.is_empty();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
error: this expression always evaluates to false
--> tests/ui/const_is_empty.rs:82:13
--> tests/ui/const_is_empty.rs:81:13
|
LL | let _ = NON_EMPTY_REF_ARRAY.is_empty();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: this expression always evaluates to true
--> tests/ui/const_is_empty.rs:84:13
--> tests/ui/const_is_empty.rs:83:13
|
LL | let _ = EMPTY_SLICE.is_empty();
| ^^^^^^^^^^^^^^^^^^^^^^
error: this expression always evaluates to false
--> tests/ui/const_is_empty.rs:86:13
--> tests/ui/const_is_empty.rs:85:13
|
LL | let _ = NON_EMPTY_SLICE.is_empty();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
error: this expression always evaluates to false
--> tests/ui/const_is_empty.rs:88:13
--> tests/ui/const_is_empty.rs:87:13
|
LL | let _ = NON_EMPTY_SLICE_REPEAT.is_empty();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: this expression always evaluates to false
--> tests/ui/const_is_empty.rs:94:13
--> tests/ui/const_is_empty.rs:93:13
|
LL | let _ = value.is_empty();
| ^^^^^^^^^^^^^^^^
error: this expression always evaluates to false
--> tests/ui/const_is_empty.rs:97:13
--> tests/ui/const_is_empty.rs:96:13
|
LL | let _ = x.is_empty();
| ^^^^^^^^^^^^
error: this expression always evaluates to true
--> tests/ui/const_is_empty.rs:99:13
--> tests/ui/const_is_empty.rs:98:13
|
LL | let _ = "".is_empty();
| ^^^^^^^^^^^^^
error: this expression always evaluates to true
--> tests/ui/const_is_empty.rs:101:13
--> tests/ui/const_is_empty.rs:100:13
|
LL | let _ = b"".is_empty();
| ^^^^^^^^^^^^^^
error: this expression always evaluates to true
--> tests/ui/const_is_empty.rs:155:13
--> tests/ui/const_is_empty.rs:154:13
|
LL | let _ = val.is_empty();
| ^^^^^^^^^^^^^^

View File

@ -1,6 +1,5 @@
//@compile-flags: -Zdeduplicate-diagnostics=yes
#![feature(inline_const)]
#![warn(clippy::indexing_slicing)]
// We also check the out_of_bounds_indexing lint here, because it lints similar things and
// we want to avoid false positives.

View File

@ -1,5 +1,5 @@
error: indexing may panic
--> tests/ui/indexing_slicing_index.rs:16:20
--> tests/ui/indexing_slicing_index.rs:15:20
|
LL | const REF: &i32 = &ARR[idx()]; // This should be linted, since `suppress-restriction-lint-in-const` default is false.
| ^^^^^^^^^^
@ -10,19 +10,19 @@ LL | const REF: &i32 = &ARR[idx()]; // This should be linted, since `suppress-re
= help: to override `-D warnings` add `#[allow(clippy::indexing_slicing)]`
error[E0080]: evaluation of `main::{constant#3}` failed
--> tests/ui/indexing_slicing_index.rs:48:14
--> tests/ui/indexing_slicing_index.rs:47:14
|
LL | const { &ARR[idx4()] };
| ^^^^^^^^^^^ index out of bounds: the length is 2 but the index is 4
note: erroneous constant encountered
--> tests/ui/indexing_slicing_index.rs:48:5
--> tests/ui/indexing_slicing_index.rs:47:5
|
LL | const { &ARR[idx4()] };
| ^^^^^^^^^^^^^^^^^^^^^^
error: indexing may panic
--> tests/ui/indexing_slicing_index.rs:29:5
--> tests/ui/indexing_slicing_index.rs:28:5
|
LL | x[index];
| ^^^^^^^^
@ -30,7 +30,7 @@ LL | x[index];
= help: consider using `.get(n)` or `.get_mut(n)` instead
error: index is out of bounds
--> tests/ui/indexing_slicing_index.rs:32:5
--> tests/ui/indexing_slicing_index.rs:31:5
|
LL | x[4];
| ^^^^
@ -39,13 +39,13 @@ LL | x[4];
= help: to override `-D warnings` add `#[allow(clippy::out_of_bounds_indexing)]`
error: index is out of bounds
--> tests/ui/indexing_slicing_index.rs:34:5
--> tests/ui/indexing_slicing_index.rs:33:5
|
LL | x[1 << 3];
| ^^^^^^^^^
error: indexing may panic
--> tests/ui/indexing_slicing_index.rs:45:14
--> tests/ui/indexing_slicing_index.rs:44:14
|
LL | const { &ARR[idx()] };
| ^^^^^^^^^^
@ -54,7 +54,7 @@ LL | const { &ARR[idx()] };
= note: the suggestion might not be applicable in constant blocks
error: indexing may panic
--> tests/ui/indexing_slicing_index.rs:48:14
--> tests/ui/indexing_slicing_index.rs:47:14
|
LL | const { &ARR[idx4()] };
| ^^^^^^^^^^^
@ -63,13 +63,13 @@ LL | const { &ARR[idx4()] };
= note: the suggestion might not be applicable in constant blocks
error: index is out of bounds
--> tests/ui/indexing_slicing_index.rs:55:5
--> tests/ui/indexing_slicing_index.rs:54:5
|
LL | y[4];
| ^^^^
error: indexing may panic
--> tests/ui/indexing_slicing_index.rs:58:5
--> tests/ui/indexing_slicing_index.rs:57:5
|
LL | v[0];
| ^^^^
@ -77,7 +77,7 @@ LL | v[0];
= help: consider using `.get(n)` or `.get_mut(n)` instead
error: indexing may panic
--> tests/ui/indexing_slicing_index.rs:60:5
--> tests/ui/indexing_slicing_index.rs:59:5
|
LL | v[10];
| ^^^^^
@ -85,7 +85,7 @@ LL | v[10];
= help: consider using `.get(n)` or `.get_mut(n)` instead
error: indexing may panic
--> tests/ui/indexing_slicing_index.rs:62:5
--> tests/ui/indexing_slicing_index.rs:61:5
|
LL | v[1 << 3];
| ^^^^^^^^^
@ -93,13 +93,13 @@ LL | v[1 << 3];
= help: consider using `.get(n)` or `.get_mut(n)` instead
error: index is out of bounds
--> tests/ui/indexing_slicing_index.rs:70:5
--> tests/ui/indexing_slicing_index.rs:69:5
|
LL | x[N];
| ^^^^
error: indexing may panic
--> tests/ui/indexing_slicing_index.rs:73:5
--> tests/ui/indexing_slicing_index.rs:72:5
|
LL | v[N];
| ^^^^
@ -107,7 +107,7 @@ LL | v[N];
= help: consider using `.get(n)` or `.get_mut(n)` instead
error: indexing may panic
--> tests/ui/indexing_slicing_index.rs:75:5
--> tests/ui/indexing_slicing_index.rs:74:5
|
LL | v[M];
| ^^^^
@ -115,7 +115,7 @@ LL | v[M];
= help: consider using `.get(n)` or `.get_mut(n)` instead
error: index is out of bounds
--> tests/ui/indexing_slicing_index.rs:79:13
--> tests/ui/indexing_slicing_index.rs:78:13
|
LL | let _ = x[4];
| ^^^^

View File

@ -2,7 +2,6 @@
//@aux-build:proc_macros.rs
#![allow(clippy::needless_if, unused)]
#![warn(clippy::manual_is_infinite, clippy::manual_is_finite)]
#![feature(inline_const)]
#[macro_use]
extern crate proc_macros;

View File

@ -1,5 +1,5 @@
error: manually checking if a float is infinite
--> tests/ui/manual_float_methods.rs:23:8
--> tests/ui/manual_float_methods.rs:22:8
|
LL | if x == f32::INFINITY || x == f32::NEG_INFINITY {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the dedicated method instead: `x.is_infinite()`
@ -8,7 +8,7 @@ LL | if x == f32::INFINITY || x == f32::NEG_INFINITY {}
= help: to override `-D warnings` add `#[allow(clippy::manual_is_infinite)]`
error: manually checking if a float is finite
--> tests/ui/manual_float_methods.rs:24:8
--> tests/ui/manual_float_methods.rs:23:8
|
LL | if x != f32::INFINITY && x != f32::NEG_INFINITY {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -29,13 +29,13 @@ LL | if !x.is_infinite() {}
| ~~~~~~~~~~~~~~~~
error: manually checking if a float is infinite
--> tests/ui/manual_float_methods.rs:25:8
--> tests/ui/manual_float_methods.rs:24:8
|
LL | if x == INFINITE || x == NEG_INFINITE {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the dedicated method instead: `x.is_infinite()`
error: manually checking if a float is finite
--> tests/ui/manual_float_methods.rs:26:8
--> tests/ui/manual_float_methods.rs:25:8
|
LL | if x != INFINITE && x != NEG_INFINITE {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -54,13 +54,13 @@ LL | if !x.is_infinite() {}
| ~~~~~~~~~~~~~~~~
error: manually checking if a float is infinite
--> tests/ui/manual_float_methods.rs:28:8
--> tests/ui/manual_float_methods.rs:27:8
|
LL | if x == f64::INFINITY || x == f64::NEG_INFINITY {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the dedicated method instead: `x.is_infinite()`
error: manually checking if a float is finite
--> tests/ui/manual_float_methods.rs:29:8
--> tests/ui/manual_float_methods.rs:28:8
|
LL | if x != f64::INFINITY && x != f64::NEG_INFINITY {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -1,4 +1,4 @@
#![feature(inline_const, try_blocks)]
#![feature(try_blocks)]
#![allow(
clippy::eq_op,
clippy::single_match,

View File

@ -1,5 +1,4 @@
#![allow(clippy::assertions_on_constants, clippy::eq_op, clippy::let_unit_value)]
#![feature(inline_const)]
#![warn(clippy::unimplemented, clippy::unreachable, clippy::todo, clippy::panic)]
extern crate core;

View File

@ -1,5 +1,5 @@
error: `panic` should not be present in production code
--> tests/ui/panicking_macros.rs:23:5
--> tests/ui/panicking_macros.rs:22:5
|
LL | panic!();
| ^^^^^^^^
@ -8,19 +8,19 @@ LL | panic!();
= help: to override `-D warnings` add `#[allow(clippy::panic)]`
error: `panic` should not be present in production code
--> tests/ui/panicking_macros.rs:26:5
--> tests/ui/panicking_macros.rs:25:5
|
LL | panic!("message");
| ^^^^^^^^^^^^^^^^^
error: `panic` should not be present in production code
--> tests/ui/panicking_macros.rs:28:5
--> tests/ui/panicking_macros.rs:27:5
|
LL | panic!("{} {}", "panic with", "multiple arguments");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: `todo` should not be present in production code
--> tests/ui/panicking_macros.rs:35:5
--> tests/ui/panicking_macros.rs:34:5
|
LL | todo!();
| ^^^^^^^
@ -29,19 +29,19 @@ LL | todo!();
= help: to override `-D warnings` add `#[allow(clippy::todo)]`
error: `todo` should not be present in production code
--> tests/ui/panicking_macros.rs:38:5
--> tests/ui/panicking_macros.rs:37:5
|
LL | todo!("message");
| ^^^^^^^^^^^^^^^^
error: `todo` should not be present in production code
--> tests/ui/panicking_macros.rs:40:5
--> tests/ui/panicking_macros.rs:39:5
|
LL | todo!("{} {}", "panic with", "multiple arguments");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: `unimplemented` should not be present in production code
--> tests/ui/panicking_macros.rs:47:5
--> tests/ui/panicking_macros.rs:46:5
|
LL | unimplemented!();
| ^^^^^^^^^^^^^^^^
@ -50,19 +50,19 @@ LL | unimplemented!();
= help: to override `-D warnings` add `#[allow(clippy::unimplemented)]`
error: `unimplemented` should not be present in production code
--> tests/ui/panicking_macros.rs:50:5
--> tests/ui/panicking_macros.rs:49:5
|
LL | unimplemented!("message");
| ^^^^^^^^^^^^^^^^^^^^^^^^^
error: `unimplemented` should not be present in production code
--> tests/ui/panicking_macros.rs:52:5
--> tests/ui/panicking_macros.rs:51:5
|
LL | unimplemented!("{} {}", "panic with", "multiple arguments");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: usage of the `unreachable!` macro
--> tests/ui/panicking_macros.rs:59:5
--> tests/ui/panicking_macros.rs:58:5
|
LL | unreachable!();
| ^^^^^^^^^^^^^^
@ -71,37 +71,37 @@ LL | unreachable!();
= help: to override `-D warnings` add `#[allow(clippy::unreachable)]`
error: usage of the `unreachable!` macro
--> tests/ui/panicking_macros.rs:62:5
--> tests/ui/panicking_macros.rs:61:5
|
LL | unreachable!("message");
| ^^^^^^^^^^^^^^^^^^^^^^^
error: usage of the `unreachable!` macro
--> tests/ui/panicking_macros.rs:64:5
--> tests/ui/panicking_macros.rs:63:5
|
LL | unreachable!("{} {}", "panic with", "multiple arguments");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: `panic` should not be present in production code
--> tests/ui/panicking_macros.rs:71:5
--> tests/ui/panicking_macros.rs:70:5
|
LL | panic!();
| ^^^^^^^^
error: `todo` should not be present in production code
--> tests/ui/panicking_macros.rs:73:5
--> tests/ui/panicking_macros.rs:72:5
|
LL | todo!();
| ^^^^^^^
error: `unimplemented` should not be present in production code
--> tests/ui/panicking_macros.rs:75:5
--> tests/ui/panicking_macros.rs:74:5
|
LL | unimplemented!();
| ^^^^^^^^^^^^^^^^
error: usage of the `unreachable!` macro
--> tests/ui/panicking_macros.rs:77:5
--> tests/ui/panicking_macros.rs:76:5
|
LL | unreachable!();
| ^^^^^^^^^^^^^^