-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when appliedIssue: The suggestions provided by this Lint cause an ICE/error when appliedT-macrosType: Issues with macros and macro expansionType: Issues with macros and macro expansion
Description
Using the following flags
--force-warn clippy::nonminimal-bool
this code:
// run-pass
pub fn main() {
assert!(("hello".to_string() < "hellr".to_string()));
!((vec![1, 2, 3] <= vec![1, 2, 3, 3]));
!((vec![1, 2, 3] <= vec![1, 2, 3, 3]));
assert_eq!(vec![1, 2, 3], vec![1, 2, 3]);
assert!((vec![1, 2, 3, 4] > vec![1, 2, 3]));
}caused the following diagnostics:
Checking _0030f10919d42bef8196b76fe37991dc66ccf723 v0.1.0 (/tmp/icemaker_global_tempdir.tMrpGeJ6WWUI/icemaker_clippyfix_tempdir.pDey4bpoivNI/_0030f10919d42bef8196b76fe37991dc66ccf723)
warning: this boolean expression can be simplified
--> src/main.rs:5:4
|
5 | !((vec![1, 2, 3] <= vec![1, 2, 3, 3]));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonminimal_bool
= note: requested on the command line with `--force-warn clippy::nonminimal-bool`
help: try
|
5 ~ (<[_]>::into_vec(
6 + // Using the intrinsic produces a dramatic improvement in stack usage for
7 + // unoptimized programs using this code path to construct large Vecs.
8 + $crate::boxed::box_new([$($x),+])
9 + ) > <[_]>::into_vec(
10+ // Using the intrinsic produces a dramatic improvement in stack usage for
11+ // unoptimized programs using this code path to construct large Vecs.
12+ $crate::boxed::box_new([$($x),+])
13~ ));
|
warning: this boolean expression can be simplified
--> src/main.rs:6:5
|
6 | !((vec![1, 2, 3] <= vec![1, 2, 3, 3]));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonminimal_bool
help: try
|
6 ~ (<[_]>::into_vec(
7 + // Using the intrinsic produces a dramatic improvement in stack usage for
8 + // unoptimized programs using this code path to construct large Vecs.
9 + $crate::boxed::box_new([$($x),+])
10+ ) > <[_]>::into_vec(
11+ // Using the intrinsic produces a dramatic improvement in stack usage for
12+ // unoptimized programs using this code path to construct large Vecs.
13+ $crate::boxed::box_new([$($x),+])
14~ ));
|
warning: `_0030f10919d42bef8196b76fe37991dc66ccf723` (bin "_0030f10919d42bef8196b76fe37991dc66ccf723") generated 2 warnings (run `cargo clippy --fix --bin "_0030f10919d42bef8196b76fe37991dc66ccf723" -p _0030f10919d42bef8196b76fe37991dc66ccf723` to apply 2 suggestions)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.27s
However after applying these diagnostics, the resulting code:
// run-pass
pub fn main() {
assert!(("hello".to_string() < "hellr".to_string()));
(<[_]>::into_vec(
// Using the intrinsic produces a dramatic improvement in stack usage for
// unoptimized programs using this code path to construct large Vecs.
$crate::boxed::box_new([$($x),+])
) > <[_]>::into_vec(
// Using the intrinsic produces a dramatic improvement in stack usage for
// unoptimized programs using this code path to construct large Vecs.
$crate::boxed::box_new([$($x),+])
));
(<[_]>::into_vec(
// Using the intrinsic produces a dramatic improvement in stack usage for
// unoptimized programs using this code path to construct large Vecs.
$crate::boxed::box_new([$($x),+])
) > <[_]>::into_vec(
// Using the intrinsic produces a dramatic improvement in stack usage for
// unoptimized programs using this code path to construct large Vecs.
$crate::boxed::box_new([$($x),+])
));
assert_eq!(vec![1, 2, 3], vec![1, 2, 3]);
assert!((vec![1, 2, 3, 4] > vec![1, 2, 3]));
}no longer compiled:
Checking _0030f10919d42bef8196b76fe37991dc66ccf723 v0.1.0 (/tmp/icemaker_global_tempdir.tMrpGeJ6WWUI/icemaker_clippyfix_tempdir.pDey4bpoivNI/_0030f10919d42bef8196b76fe37991dc66ccf723)
error: expected expression, found `$`
--> src/main.rs:8:13
|
8 | $crate::boxed::box_new([$($x),+])
| ^ expected expression
error: expected expression, found `$`
--> src/main.rs:12:13
|
12 | $crate::boxed::box_new([$($x),+])
| ^ expected expression
error: expected expression, found `$`
--> src/main.rs:17:13
|
17 | $crate::boxed::box_new([$($x),+])
| ^ expected expression
error: expected expression, found `$`
--> src/main.rs:21:13
|
21 | $crate::boxed::box_new([$($x),+])
| ^ expected expression
error: could not compile `_0030f10919d42bef8196b76fe37991dc66ccf723` (bin "_0030f10919d42bef8196b76fe37991dc66ccf723") due to 4 previous errors
warning: build failed, waiting for other jobs to finish...
error: could not compile `_0030f10919d42bef8196b76fe37991dc66ccf723` (bin "_0030f10919d42bef8196b76fe37991dc66ccf723" test) due to 4 previous errors
Version:
rustc 1.93.0-nightly (6a884ad1b 2025-11-02)
binary: rustc
commit-hash: 6a884ad1b502fe48307d363858510702429fc735
commit-date: 2025-11-02
host: x86_64-unknown-linux-gnu
release: 1.93.0-nightly
LLVM version: 21.1.3
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when appliedIssue: The suggestions provided by this Lint cause an ICE/error when appliedT-macrosType: Issues with macros and macro expansionType: Issues with macros and macro expansion