Auto merge of #3529 - matthiaskrgr:rustfmt_tests, r=phansch

rustfmt tests

also fails CI if tests turn out to not be formatted properly.
This commit is contained in:
bors 2018-12-12 05:57:31 +00:00
commit e2608fc272
457 changed files with 7301 additions and 7184 deletions

View File

@ -29,3 +29,21 @@ cd clippy_dev && cargo test && cd ..
# Perform various checks for lint registration
./util/dev update_lints --check
cargo +nightly fmt --all -- --check
#avoid loop spam
set +ex
# make sure tests are formatted
# some lints are sensitive to formatting, exclude some files
needs_formatting=false
for file in `find tests -not -path "tests/ui/methods.rs" -not -path "tests/ui/format.rs" -not -path "tests/ui/formatting.rs" -not -path "tests/ui/empty_line_after_outer_attribute.rs" -not -path "tests/ui/double_parens.rs" -not -path "tests/ui/doc.rs" -not -path "tests/ui/unused_unit.rs" | grep "\.rs$"` ; do
rustfmt ${file} --check || echo "${file} needs reformatting!" ; needs_formatting=true
done
if [ "${needs_reformatting}" = true] ; then
echo "Tests need reformatting!"
exit 2
fi
set -ex

View File

@ -7,7 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
pub trait A {}
macro_rules! __implicit_hasher_test_macro {

View File

@ -7,7 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
pub trait Trait {
const CONSTANT: u8;
}

View File

@ -7,7 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[allow(dead_code)]
enum Baz {
One,
@ -19,7 +18,7 @@ struct Test {
b: Baz,
}
fn main() { }
fn main() {}
pub fn foo() {
use Baz::*;
@ -27,10 +26,7 @@ pub fn foo() {
match x {
Test { t: Some(_), b: One } => unreachable!(),
Test {
t: Some(42),
b: Two,
} => unreachable!(),
Test { t: Some(42), b: Two } => unreachable!(),
Test { t: None, .. } => unreachable!(),
Test { .. } => unreachable!(),
}

View File

@ -7,12 +7,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![deny(clippy::all)]
#![allow(unused_imports)]
use std::*;
fn main() { }
fn main() {}

View File

@ -7,17 +7,14 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![allow(clippy::all)]
fn main() {
match 1 {
1 => {}
1 => {},
2 => {
[0; 1];
}
_ => {}
},
_ => {},
}
}

View File

@ -7,20 +7,28 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![allow(dead_code, unused_variables)]
/// Should not trigger an ICE in `SpanlessEq` / `consts::constant`
///
/// Issue: https://github.com/rust-lang/rust-clippy/issues/1782
use std::{mem, ptr};
fn spanless_eq_ice() {
let txt = "something";
match txt {
"something" => unsafe { ptr::write(ptr::null_mut() as *mut u32, mem::transmute::<[u8; 4], _>([0, 0, 0, 255])) },
_ => unsafe { ptr::write(ptr::null_mut() as *mut u32, mem::transmute::<[u8; 4], _>([13, 246, 24, 255])) },
"something" => unsafe {
ptr::write(
ptr::null_mut() as *mut u32,
mem::transmute::<[u8; 4], _>([0, 0, 0, 255]),
)
},
_ => unsafe {
ptr::write(
ptr::null_mut() as *mut u32,
mem::transmute::<[u8; 4], _>([13, 246, 24, 255]),
)
},
}
}

View File

@ -7,12 +7,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![allow(clippy::all)]
fn main() { }
fn main() {}
pub trait Convert {
type Action: From<*const f64>;

View File

@ -7,9 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![allow(dead_code, clippy::char_lit_as_u8, clippy::needless_bool)]
/// Should not trigger an ICE in `SpanlessHash` / `consts::constant`
@ -20,15 +17,17 @@ fn f(s: &[u8]) -> bool {
let t = s[0] as char;
match t {
'E' | 'W' => {}
'T' => if s[0..4] != ['0' as u8; 4] {
return false;
} else {
return true;
'E' | 'W' => {},
'T' => {
if s[0..4] != ['0' as u8; 4] {
return false;
} else {
return true;
}
},
_ => {
return false;
}
},
}
true
}

View File

@ -7,7 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![allow(dead_code, unused_variables)]
/// Should not trigger an ICE in `SpanlessHash` / `consts::constant`
@ -21,7 +20,7 @@ fn spanless_hash_ice() {
match txt {
"something" => {
let mut headers = [empty_header; 1];
}
},
"" => (),
_ => (),
}

View File

@ -7,7 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
pub fn f(new: fn()) {
new();
}

View File

@ -7,11 +7,12 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![allow(unused_variables, clippy::blacklisted_name,
clippy::needless_pass_by_value, dead_code)]
#![allow(
unused_variables,
clippy::blacklisted_name,
clippy::needless_pass_by_value,
dead_code
)]
// This should not compile-fail with:
//

View File

@ -7,9 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::collections::HashSet;
// See https://github.com/rust-lang/rust-clippy/issues/2774
@ -26,18 +23,14 @@ pub struct Foo {}
// This should not cause a 'cannot relate bound region' ICE
pub fn add_barfoos_to_foos<'a>(bars: &HashSet<&'a Bar>) {
let mut foos = HashSet::new();
foos.extend(
bars.iter().map(|b| &b.foo)
);
foos.extend(bars.iter().map(|b| &b.foo));
}
#[allow(clippy::implicit_hasher)]
// Also this should not cause a 'cannot relate bound region' ICE
pub fn add_barfoos_to_foos2(bars: &HashSet<&Bar>) {
let mut foos = HashSet::new();
foos.extend(
bars.iter().map(|b| &b.foo)
);
foos.extend(bars.iter().map(|b| &b.foo));
}
fn main() {}

View File

@ -7,10 +7,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[allow(dead_code)]
struct Ice {
size: String
size: String,
}
impl<'a> From<String> for Ice {

View File

@ -7,7 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[derive(Clone)]
pub struct HashMap<V, S> {
hash_builder: S,
@ -17,7 +16,7 @@ pub struct HashMap<V, S> {
#[derive(Clone)]
pub struct RawTable<V> {
size: usize,
val: V
val: V,
}
fn main() {}
fn main() {}

View File

@ -7,9 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![deny(clippy::all)]
fn core() {}

View File

@ -7,9 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![deny(clippy::all)]
#[allow(dead_code)]

View File

@ -7,9 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![deny(clippy::if_same_then_else)]
fn main() {}

View File

@ -7,7 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
pub trait FooMap {
fn map<B, F: Fn() -> B>(&self, f: F) -> B;
}

View File

@ -7,14 +7,23 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![allow(warnings)]
// this should compile in a reasonable amount of time
fn rust_type_id(name: &str) {
if "bool" == &name[..] || "uint" == &name[..] || "u8" == &name[..] || "u16" == &name[..] || "u32" == &name[..]
|| "f32" == &name[..] || "f64" == &name[..] || "i8" == &name[..] || "i16" == &name[..]
|| "i32" == &name[..] || "i64" == &name[..] || "Self" == &name[..] || "str" == &name[..]
if "bool" == &name[..]
|| "uint" == &name[..]
|| "u8" == &name[..]
|| "u16" == &name[..]
|| "u32" == &name[..]
|| "f32" == &name[..]
|| "f64" == &name[..]
|| "i8" == &name[..]
|| "i16" == &name[..]
|| "i32" == &name[..]
|| "i64" == &name[..]
|| "Self" == &name[..]
|| "str" == &name[..]
{
unreachable!();
}

View File

@ -7,7 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![allow(dead_code)]
/// Issue: https://github.com/rust-lang/rust-clippy/issues/2596

View File

@ -7,9 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![deny(clippy::match_same_arms)]
const PRICE_OF_SWEETS: u32 = 5;
@ -21,7 +18,7 @@ pub fn price(thing: &str) -> u32 {
"rolo" => PRICE_OF_SWEETS,
"advice" => PRICE_OF_KINDNESS,
"juice" => PRICE_OF_DRINKS,
_ => panic!()
_ => panic!(),
}
}

View File

@ -7,9 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![deny(clippy::mut_mut, clippy::zero_ptr, clippy::cmp_nan)]
#![allow(dead_code)]

View File

@ -7,16 +7,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[deny(clippy::all)]
#[derive(Debug)]
pub enum Error {
Type(
&'static str,
),
Type(&'static str),
}
fn main() {}

View File

@ -7,9 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![deny(clippy::needless_lifetimes)]
#![allow(dead_code)]

View File

@ -7,7 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[macro_use]
extern crate clippy_mini_macro_test;
@ -17,6 +16,5 @@ fn main() {
println!("{:?}", x);
}
#[derive(ClippyMiniMacroTest, Debug)]
struct Foo;
struct Foo;

View File

@ -7,9 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![allow(clippy::blacklisted_name)]
pub fn foo(bar: *const u8) {

View File

@ -7,11 +7,12 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[deny(warnings)]
fn cfg_return() -> i32 {
#[cfg(unix)] return 1;
#[cfg(not(unix))] return 2;
#[cfg(unix)]
return 1;
#[cfg(not(unix))]
return 2;
}
#[deny(warnings)]

View File

@ -7,9 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![warn(clippy::single_match_else)]
fn main() {

View File

@ -7,9 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![allow(clippy::useless_attribute)] //issue #2910
#[macro_use]

View File

@ -7,5 +7,4 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn main() {}

View File

@ -7,10 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// error-pattern: error reading Clippy's configuration file
fn main() {}

View File

@ -7,10 +7,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// error-pattern: error reading Clippy's configuration file: `blacklisted-names` is expected to be a `Vec < String >` but is a `integer`
// error-pattern: error reading Clippy's configuration file: `blacklisted-names` is expected to be a
// `Vec < String >` but is a `integer`
fn main() {}

View File

@ -7,10 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![allow(dead_code)]
#![allow(clippy::single_match)]
#![allow(unused_variables)]

View File

@ -1,45 +1,45 @@
error: use of a blacklisted/placeholder name `toto`
--> $DIR/conf_french_blacklisted_name.rs:19:9
--> $DIR/conf_french_blacklisted_name.rs:15:9
|
19 | fn test(toto: ()) {}
15 | fn test(toto: ()) {}
| ^^^^
|
= note: `-D clippy::blacklisted-name` implied by `-D warnings`
error: use of a blacklisted/placeholder name `toto`
--> $DIR/conf_french_blacklisted_name.rs:22:9
--> $DIR/conf_french_blacklisted_name.rs:18:9
|
22 | let toto = 42;
18 | let toto = 42;
| ^^^^
error: use of a blacklisted/placeholder name `tata`
--> $DIR/conf_french_blacklisted_name.rs:23:9
--> $DIR/conf_french_blacklisted_name.rs:19:9
|
23 | let tata = 42;
19 | let tata = 42;
| ^^^^
error: use of a blacklisted/placeholder name `titi`
--> $DIR/conf_french_blacklisted_name.rs:24:9
--> $DIR/conf_french_blacklisted_name.rs:20:9
|
24 | let titi = 42;
20 | let titi = 42;
| ^^^^
error: use of a blacklisted/placeholder name `toto`
--> $DIR/conf_french_blacklisted_name.rs:30:10
--> $DIR/conf_french_blacklisted_name.rs:26:10
|
30 | (toto, Some(tata), titi @ Some(_)) => (),
26 | (toto, Some(tata), titi @ Some(_)) => (),
| ^^^^
error: use of a blacklisted/placeholder name `tata`
--> $DIR/conf_french_blacklisted_name.rs:30:21
--> $DIR/conf_french_blacklisted_name.rs:26:21
|
30 | (toto, Some(tata), titi @ Some(_)) => (),
26 | (toto, Some(tata), titi @ Some(_)) => (),
| ^^^^
error: use of a blacklisted/placeholder name `titi`
--> $DIR/conf_french_blacklisted_name.rs:30:28
--> $DIR/conf_french_blacklisted_name.rs:26:28
|
30 | (toto, Some(tata), titi @ Some(_)) => (),
26 | (toto, Some(tata), titi @ Some(_)) => (),
| ^^^^
error: aborting due to 7 previous errors

View File

@ -7,8 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![allow(clippy::many_single_char_names)]
#[derive(Copy, Clone)]
@ -17,11 +15,9 @@ struct Foo(u8);
#[derive(Copy, Clone)]
struct Bar(u32);
fn good(a: &mut u32, b: u32, c: &Bar, d: &u32) {
}
fn good(a: &mut u32, b: u32, c: &Bar, d: &u32) {}
fn bad(x: &u16, y: &Foo) {
}
fn bad(x: &u16, y: &Foo) {}
fn main() {
let (mut a, b, c, d, x, y) = (0, 0, Bar(0), 0, 0, Foo(0));

View File

@ -1,15 +1,15 @@
error: this argument is passed by reference, but would be more efficient if passed by value
--> $DIR/test.rs:23:11
--> $DIR/test.rs:20:11
|
23 | fn bad(x: &u16, y: &Foo) {
20 | fn bad(x: &u16, y: &Foo) {}
| ^^^^ help: consider passing by value instead: `u16`
|
= note: `-D clippy::trivially-copy-pass-by-ref` implied by `-D warnings`
error: this argument is passed by reference, but would be more efficient if passed by value
--> $DIR/test.rs:23:20
--> $DIR/test.rs:20:20
|
23 | fn bad(x: &u16, y: &Foo) {
20 | fn bad(x: &u16, y: &Foo) {}
| ^^^^ help: consider passing by value instead: `Foo`
error: aborting due to 2 previous errors

View File

@ -7,10 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// error-pattern: error reading Clippy's configuration file: unknown key `foobar`
fn main() {}

View File

@ -8,7 +8,13 @@
// except according to those terms.
#![warn(clippy::absurd_extreme_comparisons)]
#![allow(unused, clippy::eq_op, clippy::no_effect, clippy::unnecessary_operation, clippy::needless_pass_by_value)]
#![allow(
unused,
clippy::eq_op,
clippy::no_effect,
clippy::unnecessary_operation,
clippy::needless_pass_by_value
)]
#[rustfmt::skip]
fn main() {

View File

@ -1,144 +1,144 @@
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
--> $DIR/absurd-extreme-comparisons.rs:17:5
--> $DIR/absurd-extreme-comparisons.rs:23:5
|
17 | u <= 0;
23 | u <= 0;
| ^^^^^^
|
= note: `-D clippy::absurd-extreme-comparisons` implied by `-D warnings`
= help: because 0 is the minimum value for this type, the case where the two sides are not equal never occurs, consider using u == 0 instead
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
--> $DIR/absurd-extreme-comparisons.rs:18:5
--> $DIR/absurd-extreme-comparisons.rs:24:5
|
18 | u <= Z;
24 | u <= Z;
| ^^^^^^
|
= help: because Z is the minimum value for this type, the case where the two sides are not equal never occurs, consider using u == Z instead
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
--> $DIR/absurd-extreme-comparisons.rs:19:5
--> $DIR/absurd-extreme-comparisons.rs:25:5
|
19 | u < Z;
25 | u < Z;
| ^^^^^
|
= help: because Z is the minimum value for this type, this comparison is always false
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
--> $DIR/absurd-extreme-comparisons.rs:20:5
--> $DIR/absurd-extreme-comparisons.rs:26:5
|
20 | Z >= u;
26 | Z >= u;
| ^^^^^^
|
= help: because Z is the minimum value for this type, the case where the two sides are not equal never occurs, consider using Z == u instead
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
--> $DIR/absurd-extreme-comparisons.rs:21:5
--> $DIR/absurd-extreme-comparisons.rs:27:5
|
21 | Z > u;
27 | Z > u;
| ^^^^^
|
= help: because Z is the minimum value for this type, this comparison is always false
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
--> $DIR/absurd-extreme-comparisons.rs:22:5
--> $DIR/absurd-extreme-comparisons.rs:28:5
|
22 | u > std::u32::MAX;
28 | u > std::u32::MAX;
| ^^^^^^^^^^^^^^^^^
|
= help: because std::u32::MAX is the maximum value for this type, this comparison is always false
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
--> $DIR/absurd-extreme-comparisons.rs:23:5
--> $DIR/absurd-extreme-comparisons.rs:29:5
|
23 | u >= std::u32::MAX;
29 | u >= std::u32::MAX;
| ^^^^^^^^^^^^^^^^^^
|
= help: because std::u32::MAX is the maximum value for this type, the case where the two sides are not equal never occurs, consider using u == std::u32::MAX instead
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
--> $DIR/absurd-extreme-comparisons.rs:24:5
--> $DIR/absurd-extreme-comparisons.rs:30:5
|
24 | std::u32::MAX < u;
30 | std::u32::MAX < u;
| ^^^^^^^^^^^^^^^^^
|
= help: because std::u32::MAX is the maximum value for this type, this comparison is always false
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
--> $DIR/absurd-extreme-comparisons.rs:25:5
--> $DIR/absurd-extreme-comparisons.rs:31:5
|
25 | std::u32::MAX <= u;
31 | std::u32::MAX <= u;
| ^^^^^^^^^^^^^^^^^^
|
= help: because std::u32::MAX is the maximum value for this type, the case where the two sides are not equal never occurs, consider using std::u32::MAX == u instead
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
--> $DIR/absurd-extreme-comparisons.rs:26:5
--> $DIR/absurd-extreme-comparisons.rs:32:5
|
26 | 1-1 > u;
32 | 1-1 > u;
| ^^^^^^^
|
= help: because 1-1 is the minimum value for this type, this comparison is always false
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
--> $DIR/absurd-extreme-comparisons.rs:27:5
--> $DIR/absurd-extreme-comparisons.rs:33:5
|
27 | u >= !0;
33 | u >= !0;
| ^^^^^^^
|
= help: because !0 is the maximum value for this type, the case where the two sides are not equal never occurs, consider using u == !0 instead
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
--> $DIR/absurd-extreme-comparisons.rs:28:5
--> $DIR/absurd-extreme-comparisons.rs:34:5
|
28 | u <= 12 - 2*6;
34 | u <= 12 - 2*6;
| ^^^^^^^^^^^^^
|
= help: because 12 - 2*6 is the minimum value for this type, the case where the two sides are not equal never occurs, consider using u == 12 - 2*6 instead
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
--> $DIR/absurd-extreme-comparisons.rs:30:5
--> $DIR/absurd-extreme-comparisons.rs:36:5
|
30 | i < -127 - 1;
36 | i < -127 - 1;
| ^^^^^^^^^^^^
|
= help: because -127 - 1 is the minimum value for this type, this comparison is always false
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
--> $DIR/absurd-extreme-comparisons.rs:31:5
--> $DIR/absurd-extreme-comparisons.rs:37:5
|
31 | std::i8::MAX >= i;
37 | std::i8::MAX >= i;
| ^^^^^^^^^^^^^^^^^
|
= help: because std::i8::MAX is the maximum value for this type, this comparison is always true
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
--> $DIR/absurd-extreme-comparisons.rs:32:5
--> $DIR/absurd-extreme-comparisons.rs:38:5
|
32 | 3-7 < std::i32::MIN;
38 | 3-7 < std::i32::MIN;
| ^^^^^^^^^^^^^^^^^^^
|
= help: because std::i32::MIN is the minimum value for this type, this comparison is always false
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
--> $DIR/absurd-extreme-comparisons.rs:34:5
--> $DIR/absurd-extreme-comparisons.rs:40:5
|
34 | b >= true;
40 | b >= true;
| ^^^^^^^^^
|
= help: because true is the maximum value for this type, the case where the two sides are not equal never occurs, consider using b == true instead
error: this comparison involving the minimum or maximum element for this type contains a case that is always true or always false
--> $DIR/absurd-extreme-comparisons.rs:35:5
--> $DIR/absurd-extreme-comparisons.rs:41:5
|
35 | false > b;
41 | false > b;
| ^^^^^^^^^
|
= help: because false is the minimum value for this type, this comparison is always false
error: <-comparison of unit values detected. This will always be false
--> $DIR/absurd-extreme-comparisons.rs:38:5
--> $DIR/absurd-extreme-comparisons.rs:44:5
|
38 | () < {};
44 | () < {};
| ^^^^^^^
|
= note: #[deny(clippy::unit_cmp)] on by default

View File

@ -7,10 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[warn(clippy::approx_constant)]
#[allow(unused, clippy::shadow_unrelated, clippy::similar_names, clippy::unreadable_literal)]
fn main() {

View File

@ -1,117 +1,117 @@
error: approximate value of `f{32, 64}::consts::E` found. Consider using it directly
--> $DIR/approx_const.rs:17:16
--> $DIR/approx_const.rs:13:16
|
17 | let my_e = 2.7182;
13 | let my_e = 2.7182;
| ^^^^^^
|
= note: `-D clippy::approx-constant` implied by `-D warnings`
error: approximate value of `f{32, 64}::consts::E` found. Consider using it directly
--> $DIR/approx_const.rs:18:20
--> $DIR/approx_const.rs:14:20
|
18 | let almost_e = 2.718;
14 | let almost_e = 2.718;
| ^^^^^
error: approximate value of `f{32, 64}::consts::FRAC_1_PI` found. Consider using it directly
--> $DIR/approx_const.rs:21:24
--> $DIR/approx_const.rs:17:24
|
21 | let my_1_frac_pi = 0.3183;
17 | let my_1_frac_pi = 0.3183;
| ^^^^^^
error: approximate value of `f{32, 64}::consts::FRAC_1_SQRT_2` found. Consider using it directly
--> $DIR/approx_const.rs:24:28
--> $DIR/approx_const.rs:20:28
|
24 | let my_frac_1_sqrt_2 = 0.70710678;
20 | let my_frac_1_sqrt_2 = 0.70710678;
| ^^^^^^^^^^
error: approximate value of `f{32, 64}::consts::FRAC_1_SQRT_2` found. Consider using it directly
--> $DIR/approx_const.rs:25:32
--> $DIR/approx_const.rs:21:32
|
25 | let almost_frac_1_sqrt_2 = 0.70711;
21 | let almost_frac_1_sqrt_2 = 0.70711;
| ^^^^^^^
error: approximate value of `f{32, 64}::consts::FRAC_2_PI` found. Consider using it directly
--> $DIR/approx_const.rs:28:24
--> $DIR/approx_const.rs:24:24
|
28 | let my_frac_2_pi = 0.63661977;
24 | let my_frac_2_pi = 0.63661977;
| ^^^^^^^^^^
error: approximate value of `f{32, 64}::consts::FRAC_2_SQRT_PI` found. Consider using it directly
--> $DIR/approx_const.rs:31:27
--> $DIR/approx_const.rs:27:27
|
31 | let my_frac_2_sq_pi = 1.128379;
27 | let my_frac_2_sq_pi = 1.128379;
| ^^^^^^^^
error: approximate value of `f{32, 64}::consts::FRAC_PI_2` found. Consider using it directly
--> $DIR/approx_const.rs:34:24
--> $DIR/approx_const.rs:30:24
|
34 | let my_frac_pi_2 = 1.57079632679;
30 | let my_frac_pi_2 = 1.57079632679;
| ^^^^^^^^^^^^^
error: approximate value of `f{32, 64}::consts::FRAC_PI_3` found. Consider using it directly
--> $DIR/approx_const.rs:37:24
--> $DIR/approx_const.rs:33:24
|
37 | let my_frac_pi_3 = 1.04719755119;
33 | let my_frac_pi_3 = 1.04719755119;
| ^^^^^^^^^^^^^
error: approximate value of `f{32, 64}::consts::FRAC_PI_4` found. Consider using it directly
--> $DIR/approx_const.rs:40:24
--> $DIR/approx_const.rs:36:24
|
40 | let my_frac_pi_4 = 0.785398163397;
36 | let my_frac_pi_4 = 0.785398163397;
| ^^^^^^^^^^^^^^
error: approximate value of `f{32, 64}::consts::FRAC_PI_6` found. Consider using it directly
--> $DIR/approx_const.rs:43:24
--> $DIR/approx_const.rs:39:24
|
43 | let my_frac_pi_6 = 0.523598775598;
39 | let my_frac_pi_6 = 0.523598775598;
| ^^^^^^^^^^^^^^
error: approximate value of `f{32, 64}::consts::FRAC_PI_8` found. Consider using it directly
--> $DIR/approx_const.rs:46:24
--> $DIR/approx_const.rs:42:24
|
46 | let my_frac_pi_8 = 0.3926990816987;
42 | let my_frac_pi_8 = 0.3926990816987;
| ^^^^^^^^^^^^^^^
error: approximate value of `f{32, 64}::consts::LN_10` found. Consider using it directly
--> $DIR/approx_const.rs:49:20
--> $DIR/approx_const.rs:45:20
|
49 | let my_ln_10 = 2.302585092994046;
45 | let my_ln_10 = 2.302585092994046;
| ^^^^^^^^^^^^^^^^^
error: approximate value of `f{32, 64}::consts::LN_2` found. Consider using it directly
--> $DIR/approx_const.rs:52:19
--> $DIR/approx_const.rs:48:19
|
52 | let my_ln_2 = 0.6931471805599453;
48 | let my_ln_2 = 0.6931471805599453;
| ^^^^^^^^^^^^^^^^^^
error: approximate value of `f{32, 64}::consts::LOG10_E` found. Consider using it directly
--> $DIR/approx_const.rs:55:22
--> $DIR/approx_const.rs:51:22
|
55 | let my_log10_e = 0.4342944819032518;
51 | let my_log10_e = 0.4342944819032518;
| ^^^^^^^^^^^^^^^^^^
error: approximate value of `f{32, 64}::consts::LOG2_E` found. Consider using it directly
--> $DIR/approx_const.rs:58:21
--> $DIR/approx_const.rs:54:21
|
58 | let my_log2_e = 1.4426950408889634;
54 | let my_log2_e = 1.4426950408889634;
| ^^^^^^^^^^^^^^^^^^
error: approximate value of `f{32, 64}::consts::PI` found. Consider using it directly
--> $DIR/approx_const.rs:61:17
--> $DIR/approx_const.rs:57:17
|
61 | let my_pi = 3.1415;
57 | let my_pi = 3.1415;
| ^^^^^^
error: approximate value of `f{32, 64}::consts::PI` found. Consider using it directly
--> $DIR/approx_const.rs:62:21
--> $DIR/approx_const.rs:58:21
|
62 | let almost_pi = 3.14;
58 | let almost_pi = 3.14;
| ^^^^
error: approximate value of `f{32, 64}::consts::SQRT_2` found. Consider using it directly
--> $DIR/approx_const.rs:65:18
--> $DIR/approx_const.rs:61:18
|
65 | let my_sq2 = 1.4142;
61 | let my_sq2 = 1.4142;
| ^^^^^^
error: aborting due to 19 previous errors

View File

@ -7,9 +7,14 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![warn(clippy::integer_arithmetic, clippy::float_arithmetic)]
#![allow(unused, clippy::shadow_reuse, clippy::shadow_unrelated, clippy::no_effect, clippy::unnecessary_operation)]
#![allow(
unused,
clippy::shadow_reuse,
clippy::shadow_unrelated,
clippy::no_effect,
clippy::unnecessary_operation
)]
#[rustfmt::skip]
fn main() {

View File

@ -1,72 +1,72 @@
error: integer arithmetic detected
--> $DIR/arithmetic.rs:17:5
--> $DIR/arithmetic.rs:22:5
|
17 | 1 + i;
22 | 1 + i;
| ^^^^^
|
= note: `-D clippy::integer-arithmetic` implied by `-D warnings`
error: integer arithmetic detected
--> $DIR/arithmetic.rs:18:5
--> $DIR/arithmetic.rs:23:5
|
18 | i * 2;
23 | i * 2;
| ^^^^^
error: integer arithmetic detected
--> $DIR/arithmetic.rs:19:5
--> $DIR/arithmetic.rs:24:5
|
19 | / 1 %
20 | | i / 2; // no error, this is part of the expression in the preceding line
24 | / 1 %
25 | | i / 2; // no error, this is part of the expression in the preceding line
| |_________^
error: integer arithmetic detected
--> $DIR/arithmetic.rs:21:5
--> $DIR/arithmetic.rs:26:5
|
21 | i - 2 + 2 - i;
26 | i - 2 + 2 - i;
| ^^^^^^^^^^^^^
error: integer arithmetic detected
--> $DIR/arithmetic.rs:22:5
--> $DIR/arithmetic.rs:27:5
|
22 | -i;
27 | -i;
| ^^
error: floating-point arithmetic detected
--> $DIR/arithmetic.rs:32:5
--> $DIR/arithmetic.rs:37:5
|
32 | f * 2.0;
37 | f * 2.0;
| ^^^^^^^
|
= note: `-D clippy::float-arithmetic` implied by `-D warnings`
error: floating-point arithmetic detected
--> $DIR/arithmetic.rs:34:5
--> $DIR/arithmetic.rs:39:5
|
34 | 1.0 + f;
39 | 1.0 + f;
| ^^^^^^^
error: floating-point arithmetic detected
--> $DIR/arithmetic.rs:35:5
--> $DIR/arithmetic.rs:40:5
|
35 | f * 2.0;
40 | f * 2.0;
| ^^^^^^^
error: floating-point arithmetic detected
--> $DIR/arithmetic.rs:36:5
--> $DIR/arithmetic.rs:41:5
|
36 | f / 2.0;
41 | f / 2.0;
| ^^^^^^^
error: floating-point arithmetic detected
--> $DIR/arithmetic.rs:37:5
--> $DIR/arithmetic.rs:42:5
|
37 | f - 2.0 * 4.2;
42 | f - 2.0 * 4.2;
| ^^^^^^^^^^^^^
error: floating-point arithmetic detected
--> $DIR/arithmetic.rs:38:5
--> $DIR/arithmetic.rs:43:5
|
38 | -f;
43 | -f;
| ^^
error: aborting due to 11 previous errors

View File

@ -7,9 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[allow(dead_code, unused_assignments)]
#[warn(clippy::assign_op_pattern)]
fn main() {

View File

@ -1,57 +1,57 @@
error: manual implementation of an assign operation
--> $DIR/assign_ops.rs:17:5
--> $DIR/assign_ops.rs:14:5
|
17 | a = a + 1;
14 | a = a + 1;
| ^^^^^^^^^ help: replace it with: `a += 1`
|
= note: `-D clippy::assign-op-pattern` implied by `-D warnings`
error: manual implementation of an assign operation
--> $DIR/assign_ops.rs:15:5
|
15 | a = 1 + a;
| ^^^^^^^^^ help: replace it with: `a += 1`
error: manual implementation of an assign operation
--> $DIR/assign_ops.rs:16:5
|
16 | a = a - 1;
| ^^^^^^^^^ help: replace it with: `a -= 1`
error: manual implementation of an assign operation
--> $DIR/assign_ops.rs:17:5
|
17 | a = a * 99;
| ^^^^^^^^^^ help: replace it with: `a *= 99`
error: manual implementation of an assign operation
--> $DIR/assign_ops.rs:18:5
|
18 | a = 1 + a;
| ^^^^^^^^^ help: replace it with: `a += 1`
18 | a = 42 * a;
| ^^^^^^^^^^ help: replace it with: `a *= 42`
error: manual implementation of an assign operation
--> $DIR/assign_ops.rs:19:5
|
19 | a = a - 1;
| ^^^^^^^^^ help: replace it with: `a -= 1`
19 | a = a / 2;
| ^^^^^^^^^ help: replace it with: `a /= 2`
error: manual implementation of an assign operation
--> $DIR/assign_ops.rs:20:5
|
20 | a = a * 99;
| ^^^^^^^^^^ help: replace it with: `a *= 99`
20 | a = a % 5;
| ^^^^^^^^^ help: replace it with: `a %= 5`
error: manual implementation of an assign operation
--> $DIR/assign_ops.rs:21:5
|
21 | a = 42 * a;
| ^^^^^^^^^^ help: replace it with: `a *= 42`
error: manual implementation of an assign operation
--> $DIR/assign_ops.rs:22:5
|
22 | a = a / 2;
| ^^^^^^^^^ help: replace it with: `a /= 2`
error: manual implementation of an assign operation
--> $DIR/assign_ops.rs:23:5
|
23 | a = a % 5;
| ^^^^^^^^^ help: replace it with: `a %= 5`
error: manual implementation of an assign operation
--> $DIR/assign_ops.rs:24:5
|
24 | a = a & 1;
21 | a = a & 1;
| ^^^^^^^^^ help: replace it with: `a &= 1`
error: manual implementation of an assign operation
--> $DIR/assign_ops.rs:30:5
--> $DIR/assign_ops.rs:27:5
|
30 | s = s + "bla";
27 | s = s + "bla";
| ^^^^^^^^^^^^^ help: replace it with: `s += "bla"`
error: aborting due to 9 previous errors

View File

@ -7,10 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[allow(unused_assignments)]
#[warn(clippy::misrefactored_assign_op, clippy::assign_op_pattern)]
fn main() {
@ -65,6 +61,4 @@ fn cow_add_assign() {
// this should not as cow<str> Add is not commutative
buf = cows + buf;
println!("{}", buf);
}

View File

@ -1,135 +1,135 @@
error: variable appears on both sides of an assignment operation
--> $DIR/assign_ops2.rs:18:5
--> $DIR/assign_ops2.rs:14:5
|
18 | a += a + 1;
14 | a += a + 1;
| ^^^^^^^^^^
|
= note: `-D clippy::misrefactored-assign-op` implied by `-D warnings`
help: Did you mean a = a + 1 or a = a + a + 1? Consider replacing it with
|
18 | a += 1;
14 | a += 1;
| ^^^^^^
help: or
|
18 | a = a + a + 1;
14 | a = a + a + 1;
| ^^^^^^^^^^^^^
error: variable appears on both sides of an assignment operation
--> $DIR/assign_ops2.rs:15:5
|
15 | a += 1 + a;
| ^^^^^^^^^^
help: Did you mean a = a + 1 or a = a + 1 + a? Consider replacing it with
|
15 | a += 1;
| ^^^^^^
help: or
|
15 | a = a + 1 + a;
| ^^^^^^^^^^^^^
error: variable appears on both sides of an assignment operation
--> $DIR/assign_ops2.rs:16:5
|
16 | a -= a - 1;
| ^^^^^^^^^^
help: Did you mean a = a - 1 or a = a - (a - 1)? Consider replacing it with
|
16 | a -= 1;
| ^^^^^^
help: or
|
16 | a = a - (a - 1);
| ^^^^^^^^^^^^^^^
error: variable appears on both sides of an assignment operation
--> $DIR/assign_ops2.rs:17:5
|
17 | a *= a * 99;
| ^^^^^^^^^^^
help: Did you mean a = a * 99 or a = a * a * 99? Consider replacing it with
|
17 | a *= 99;
| ^^^^^^^
help: or
|
17 | a = a * a * 99;
| ^^^^^^^^^^^^^^
error: variable appears on both sides of an assignment operation
--> $DIR/assign_ops2.rs:18:5
|
18 | a *= 42 * a;
| ^^^^^^^^^^^
help: Did you mean a = a * 42 or a = a * 42 * a? Consider replacing it with
|
18 | a *= 42;
| ^^^^^^^
help: or
|
18 | a = a * 42 * a;
| ^^^^^^^^^^^^^^
error: variable appears on both sides of an assignment operation
--> $DIR/assign_ops2.rs:19:5
|
19 | a += 1 + a;
19 | a /= a / 2;
| ^^^^^^^^^^
help: Did you mean a = a + 1 or a = a + 1 + a? Consider replacing it with
help: Did you mean a = a / 2 or a = a / (a / 2)? Consider replacing it with
|
19 | a += 1;
19 | a /= 2;
| ^^^^^^
help: or
|
19 | a = a + 1 + a;
| ^^^^^^^^^^^^^
19 | a = a / (a / 2);
| ^^^^^^^^^^^^^^^
error: variable appears on both sides of an assignment operation
--> $DIR/assign_ops2.rs:20:5
|
20 | a -= a - 1;
20 | a %= a % 5;
| ^^^^^^^^^^
help: Did you mean a = a - 1 or a = a - (a - 1)? Consider replacing it with
help: Did you mean a = a % 5 or a = a % (a % 5)? Consider replacing it with
|
20 | a -= 1;
20 | a %= 5;
| ^^^^^^
help: or
|
20 | a = a - (a - 1);
20 | a = a % (a % 5);
| ^^^^^^^^^^^^^^^
error: variable appears on both sides of an assignment operation
--> $DIR/assign_ops2.rs:21:5
|
21 | a *= a * 99;
| ^^^^^^^^^^^
help: Did you mean a = a * 99 or a = a * a * 99? Consider replacing it with
21 | a &= a & 1;
| ^^^^^^^^^^
help: Did you mean a = a & 1 or a = a & a & 1? Consider replacing it with
|
21 | a *= 99;
| ^^^^^^^
21 | a &= 1;
| ^^^^^^
help: or
|
21 | a = a * a * 99;
| ^^^^^^^^^^^^^^
21 | a = a & a & 1;
| ^^^^^^^^^^^^^
error: variable appears on both sides of an assignment operation
--> $DIR/assign_ops2.rs:22:5
|
22 | a *= 42 * a;
| ^^^^^^^^^^^
help: Did you mean a = a * 42 or a = a * 42 * a? Consider replacing it with
|
22 | a *= 42;
| ^^^^^^^
help: or
|
22 | a = a * 42 * a;
| ^^^^^^^^^^^^^^
error: variable appears on both sides of an assignment operation
--> $DIR/assign_ops2.rs:23:5
|
23 | a /= a / 2;
| ^^^^^^^^^^
help: Did you mean a = a / 2 or a = a / (a / 2)? Consider replacing it with
|
23 | a /= 2;
| ^^^^^^
help: or
|
23 | a = a / (a / 2);
| ^^^^^^^^^^^^^^^
error: variable appears on both sides of an assignment operation
--> $DIR/assign_ops2.rs:24:5
|
24 | a %= a % 5;
| ^^^^^^^^^^
help: Did you mean a = a % 5 or a = a % (a % 5)? Consider replacing it with
|
24 | a %= 5;
| ^^^^^^
help: or
|
24 | a = a % (a % 5);
| ^^^^^^^^^^^^^^^
error: variable appears on both sides of an assignment operation
--> $DIR/assign_ops2.rs:25:5
|
25 | a &= a & 1;
| ^^^^^^^^^^
help: Did you mean a = a & 1 or a = a & a & 1? Consider replacing it with
|
25 | a &= 1;
| ^^^^^^
help: or
|
25 | a = a & a & 1;
| ^^^^^^^^^^^^^
error: variable appears on both sides of an assignment operation
--> $DIR/assign_ops2.rs:26:5
|
26 | a *= a * a;
22 | a *= a * a;
| ^^^^^^^^^^
help: Did you mean a = a * a or a = a * a * a? Consider replacing it with
|
26 | a *= a;
22 | a *= a;
| ^^^^^^
help: or
|
26 | a = a * a * a;
22 | a = a * a * a;
| ^^^^^^^^^^^^^
error: manual implementation of an assign operation
--> $DIR/assign_ops2.rs:63:5
--> $DIR/assign_ops2.rs:59:5
|
63 | buf = buf + cows.clone();
59 | buf = buf + cows.clone();
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `buf += cows.clone()`
|
= note: `-D clippy::assign-op-pattern` implied by `-D warnings`

View File

@ -7,10 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![warn(clippy::inline_always, clippy::deprecated_semver)]
#[inline(always)]
@ -30,22 +26,27 @@ fn false_positive_stmt() {
#[inline(always)]
fn empty_and_false_positive_stmt() {
;
unreachable!();
}
#[deprecated(since = "forever")]
pub const SOME_CONST : u8 = 42;
pub const SOME_CONST: u8 = 42;
#[deprecated(since = "1")]
pub const ANOTHER_CONST : u8 = 23;
pub const ANOTHER_CONST: u8 = 23;
#[deprecated(since = "0.1.1")]
pub const YET_ANOTHER_CONST : u8 = 0;
pub const YET_ANOTHER_CONST: u8 = 0;
fn main() {
test_attr_lint();
if false { false_positive_expr() }
if false { false_positive_stmt() }
if false { empty_and_false_positive_stmt() }
if false {
false_positive_expr()
}
if false {
false_positive_stmt()
}
if false {
empty_and_false_positive_stmt()
}
}

View File

@ -1,23 +1,23 @@
error: you have declared `#[inline(always)]` on `test_attr_lint`. This is usually a bad idea
--> $DIR/attrs.rs:16:1
--> $DIR/attrs.rs:12:1
|
16 | #[inline(always)]
12 | #[inline(always)]
| ^^^^^^^^^^^^^^^^^
|
= note: `-D clippy::inline-always` implied by `-D warnings`
error: the since field must contain a semver-compliant version
--> $DIR/attrs.rs:37:14
--> $DIR/attrs.rs:32:14
|
37 | #[deprecated(since = "forever")]
32 | #[deprecated(since = "forever")]
| ^^^^^^^^^^^^^^^^^
|
= note: `-D clippy::deprecated-semver` implied by `-D warnings`
error: the since field must contain a semver-compliant version
--> $DIR/attrs.rs:40:14
--> $DIR/attrs.rs:35:14
|
40 | #[deprecated(since = "1")]
35 | #[deprecated(since = "1")]
| ^^^^^^^^^^^
error: aborting due to 3 previous errors

View File

@ -7,11 +7,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn main() {
#[clippy::author]
let x: char = 0x45 as char;
}

View File

@ -7,9 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn main() {
#[clippy::author]
let _ = ::std::cmp::min(3, 4);

View File

@ -7,7 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(stmt_expr_attributes)]
fn main() {

View File

@ -7,7 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(tool_attributes)]
fn main() {

View File

@ -1,14 +1,14 @@
error: returning the result of a let binding from a block. Consider returning the expression directly.
--> $DIR/matches.rs:19:13
--> $DIR/matches.rs:18:13
|
19 | x
18 | x
| ^
|
= note: `-D clippy::let-and-return` implied by `-D warnings`
note: this expression can be directly returned
--> $DIR/matches.rs:18:21
--> $DIR/matches.rs:17:21
|
18 | let x = 3;
17 | let x = 3;
| ^
error: aborting due to previous error

View File

@ -7,15 +7,16 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
const THREE_BITS : i64 = 7;
const EVEN_MORE_REDIRECTION : i64 = THREE_BITS;
const THREE_BITS: i64 = 7;
const EVEN_MORE_REDIRECTION: i64 = THREE_BITS;
#[warn(clippy::bad_bit_mask)]
#[allow(clippy::ineffective_bit_mask, clippy::identity_op, clippy::no_effect, clippy::unnecessary_operation)]
#[allow(
clippy::ineffective_bit_mask,
clippy::identity_op,
clippy::no_effect,
clippy::unnecessary_operation
)]
fn main() {
let x = 5;

View File

@ -1,109 +1,109 @@
error: &-masking with zero
--> $DIR/bit_masks.rs:22:5
--> $DIR/bit_masks.rs:23:5
|
22 | x & 0 == 0;
23 | x & 0 == 0;
| ^^^^^^^^^^
|
= note: `-D clippy::bad-bit-mask` implied by `-D warnings`
error: this operation will always return zero. This is likely not the intended outcome
--> $DIR/bit_masks.rs:22:5
--> $DIR/bit_masks.rs:23:5
|
22 | x & 0 == 0;
23 | x & 0 == 0;
| ^^^^^
|
= note: #[deny(clippy::erasing_op)] on by default
error: incompatible bit mask: `_ & 2` can never be equal to `1`
--> $DIR/bit_masks.rs:25:5
--> $DIR/bit_masks.rs:26:5
|
25 | x & 2 == 1;
26 | x & 2 == 1;
| ^^^^^^^^^^
error: incompatible bit mask: `_ | 3` can never be equal to `2`
--> $DIR/bit_masks.rs:29:5
--> $DIR/bit_masks.rs:30:5
|
29 | x | 3 == 2;
30 | x | 3 == 2;
| ^^^^^^^^^^
error: incompatible bit mask: `_ & 1` will never be higher than `1`
--> $DIR/bit_masks.rs:31:5
--> $DIR/bit_masks.rs:32:5
|
31 | x & 1 > 1;
32 | x & 1 > 1;
| ^^^^^^^^^
error: incompatible bit mask: `_ | 2` will always be higher than `1`
--> $DIR/bit_masks.rs:35:5
--> $DIR/bit_masks.rs:36:5
|
35 | x | 2 > 1;
36 | x | 2 > 1;
| ^^^^^^^^^
error: incompatible bit mask: `_ & 7` can never be equal to `8`
--> $DIR/bit_masks.rs:42:5
--> $DIR/bit_masks.rs:43:5
|
42 | x & THREE_BITS == 8;
43 | x & THREE_BITS == 8;
| ^^^^^^^^^^^^^^^^^^^
error: incompatible bit mask: `_ | 7` will never be lower than `7`
--> $DIR/bit_masks.rs:43:5
--> $DIR/bit_masks.rs:44:5
|
43 | x | EVEN_MORE_REDIRECTION < 7;
44 | x | EVEN_MORE_REDIRECTION < 7;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: &-masking with zero
--> $DIR/bit_masks.rs:45:5
--> $DIR/bit_masks.rs:46:5
|
45 | 0 & x == 0;
46 | 0 & x == 0;
| ^^^^^^^^^^
error: this operation will always return zero. This is likely not the intended outcome
--> $DIR/bit_masks.rs:45:5
--> $DIR/bit_masks.rs:46:5
|
45 | 0 & x == 0;
46 | 0 & x == 0;
| ^^^^^
error: incompatible bit mask: `_ | 2` will always be higher than `1`
--> $DIR/bit_masks.rs:49:5
--> $DIR/bit_masks.rs:50:5
|
49 | 1 < 2 | x;
50 | 1 < 2 | x;
| ^^^^^^^^^
error: incompatible bit mask: `_ | 3` can never be equal to `2`
--> $DIR/bit_masks.rs:50:5
--> $DIR/bit_masks.rs:51:5
|
50 | 2 == 3 | x;
51 | 2 == 3 | x;
| ^^^^^^^^^^
error: incompatible bit mask: `_ & 2` can never be equal to `1`
--> $DIR/bit_masks.rs:51:5
--> $DIR/bit_masks.rs:52:5
|
51 | 1 == x & 2;
52 | 1 == x & 2;
| ^^^^^^^^^^
error: ineffective bit mask: `x | 1` compared to `3`, is the same as x compared directly
--> $DIR/bit_masks.rs:62:5
--> $DIR/bit_masks.rs:63:5
|
62 | x | 1 > 3;
63 | x | 1 > 3;
| ^^^^^^^^^
|
= note: `-D clippy::ineffective-bit-mask` implied by `-D warnings`
error: ineffective bit mask: `x | 1` compared to `4`, is the same as x compared directly
--> $DIR/bit_masks.rs:63:5
--> $DIR/bit_masks.rs:64:5
|
63 | x | 1 < 4;
64 | x | 1 < 4;
| ^^^^^^^^^
error: ineffective bit mask: `x | 1` compared to `3`, is the same as x compared directly
--> $DIR/bit_masks.rs:64:5
--> $DIR/bit_masks.rs:65:5
|
64 | x | 1 <= 3;
65 | x | 1 <= 3;
| ^^^^^^^^^^
error: ineffective bit mask: `x | 1` compared to `8`, is the same as x compared directly
--> $DIR/bit_masks.rs:65:5
--> $DIR/bit_masks.rs:66:5
|
65 | x | 1 >= 8;
66 | x | 1 >= 8;
| ^^^^^^^^^^
error: aborting due to 17 previous errors

View File

@ -7,11 +7,14 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![allow(dead_code, clippy::similar_names, clippy::single_match, clippy::toplevel_ref_arg, unused_mut, unused_variables)]
#![allow(
dead_code,
clippy::similar_names,
clippy::single_match,
clippy::toplevel_ref_arg,
unused_mut,
unused_variables
)]
#![warn(clippy::blacklisted_name)]
fn test(foo: ()) {}

View File

@ -1,87 +1,87 @@
error: use of a blacklisted/placeholder name `foo`
--> $DIR/blacklisted_name.rs:17:9
--> $DIR/blacklisted_name.rs:20:9
|
17 | fn test(foo: ()) {}
20 | fn test(foo: ()) {}
| ^^^
|
= note: `-D clippy::blacklisted-name` implied by `-D warnings`
error: use of a blacklisted/placeholder name `foo`
--> $DIR/blacklisted_name.rs:20:9
--> $DIR/blacklisted_name.rs:23:9
|
20 | let foo = 42;
23 | let foo = 42;
| ^^^
error: use of a blacklisted/placeholder name `bar`
--> $DIR/blacklisted_name.rs:21:9
--> $DIR/blacklisted_name.rs:24:9
|
21 | let bar = 42;
24 | let bar = 42;
| ^^^
error: use of a blacklisted/placeholder name `baz`
--> $DIR/blacklisted_name.rs:22:9
--> $DIR/blacklisted_name.rs:25:9
|
22 | let baz = 42;
25 | let baz = 42;
| ^^^
error: use of a blacklisted/placeholder name `foo`
--> $DIR/blacklisted_name.rs:28:10
--> $DIR/blacklisted_name.rs:31:10
|
28 | (foo, Some(bar), baz @ Some(_)) => (),
31 | (foo, Some(bar), baz @ Some(_)) => (),
| ^^^
error: use of a blacklisted/placeholder name `bar`
--> $DIR/blacklisted_name.rs:28:20
--> $DIR/blacklisted_name.rs:31:20
|
28 | (foo, Some(bar), baz @ Some(_)) => (),
31 | (foo, Some(bar), baz @ Some(_)) => (),
| ^^^
error: use of a blacklisted/placeholder name `baz`
--> $DIR/blacklisted_name.rs:28:26
--> $DIR/blacklisted_name.rs:31:26
|
28 | (foo, Some(bar), baz @ Some(_)) => (),
31 | (foo, Some(bar), baz @ Some(_)) => (),
| ^^^
error: use of a blacklisted/placeholder name `foo`
--> $DIR/blacklisted_name.rs:33:19
--> $DIR/blacklisted_name.rs:36:19
|
33 | fn issue_1647(mut foo: u8) {
36 | fn issue_1647(mut foo: u8) {
| ^^^
error: use of a blacklisted/placeholder name `bar`
--> $DIR/blacklisted_name.rs:34:13
--> $DIR/blacklisted_name.rs:37:13
|
34 | let mut bar = 0;
37 | let mut bar = 0;
| ^^^
error: use of a blacklisted/placeholder name `baz`
--> $DIR/blacklisted_name.rs:35:21
--> $DIR/blacklisted_name.rs:38:21
|
35 | if let Some(mut baz) = Some(42) {}
38 | if let Some(mut baz) = Some(42) {}
| ^^^
error: use of a blacklisted/placeholder name `bar`
--> $DIR/blacklisted_name.rs:39:13
--> $DIR/blacklisted_name.rs:42:13
|
39 | let ref bar = 0;
42 | let ref bar = 0;
| ^^^
error: use of a blacklisted/placeholder name `baz`
--> $DIR/blacklisted_name.rs:40:21
--> $DIR/blacklisted_name.rs:43:21
|
40 | if let Some(ref baz) = Some(42) {}
43 | if let Some(ref baz) = Some(42) {}
| ^^^
error: use of a blacklisted/placeholder name `bar`
--> $DIR/blacklisted_name.rs:44:17
--> $DIR/blacklisted_name.rs:47:17
|
44 | let ref mut bar = 0;
47 | let ref mut bar = 0;
| ^^^
error: use of a blacklisted/placeholder name `baz`
--> $DIR/blacklisted_name.rs:45:25
--> $DIR/blacklisted_name.rs:48:25
|
45 | if let Some(ref mut baz) = Some(42) {}
48 | if let Some(ref mut baz) = Some(42) {}
| ^^^
error: aborting due to 14 previous errors

View File

@ -7,33 +7,28 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![warn(clippy::block_in_if_condition_expr)]
#![warn(clippy::block_in_if_condition_stmt)]
#![allow(unused, clippy::let_and_return)]
#![warn(clippy::nonminimal_bool)]
macro_rules! blocky {
() => {{true}}
() => {{
true
}};
}
macro_rules! blocky_too {
() => {{
let r = true;
r
}}
}};
}
fn macro_if() {
if blocky!() {
}
if blocky!() {}
if blocky_too!() {
}
if blocky_too!() {}
}
fn condition_has_block() -> i32 {
@ -55,7 +50,7 @@ fn condition_has_block_with_single_expression() -> i32 {
}
}
fn predicate<F: FnOnce(T) -> bool, T>(pfn: F, val:T) -> bool {
fn predicate<F: FnOnce(T) -> bool, T>(pfn: F, val: T) -> bool {
pfn(val)
}
@ -65,11 +60,24 @@ fn pred_test() {
// this is a sneaky case, where the block isn't directly in the condition, but is actually
// inside a closure that the condition is using. same principle applies. add some extra
// expressions to make sure linter isn't confused by them.
if v == 3 && sky == "blue" && predicate(|x| { let target = 3; x == target }, v) {
}
if v == 3
&& sky == "blue"
&& predicate(
|x| {
let target = 3;
x == target
},
v,
)
{}
if predicate(|x| { let target = 3; x == target }, v) {
}
if predicate(
|x| {
let target = 3;
x == target
},
v,
) {}
}
fn condition_is_normal() -> i32 {
@ -82,9 +90,7 @@ fn condition_is_normal() -> i32 {
}
fn closure_without_block() {
if predicate(|x| x == 3, 6) {
}
if predicate(|x| x == 3, 6) {}
}
fn condition_is_unsafe_block() {
@ -96,8 +102,7 @@ fn condition_is_unsafe_block() {
}
}
fn main() {
}
fn main() {}
fn macro_in_closure() {
let option = Some(true);

View File

@ -1,11 +1,11 @@
error: in an 'if' condition, avoid complex blocks or closures with blocks; instead, move the block or closure higher and bind it with a 'let'
--> $DIR/block_in_if_condition.rs:40:8
--> $DIR/block_in_if_condition.rs:35:8
|
40 | if {
35 | if {
| ________^
41 | | let x = 3;
42 | | x == 3
43 | | } {
36 | | let x = 3;
37 | | x == 3
38 | | } {
| |_____^
|
= note: `-D clippy::block-in-if-condition-stmt` implied by `-D warnings`
@ -19,9 +19,9 @@ error: in an 'if' condition, avoid complex blocks or closures with blocks; inste
} ...
error: omit braces around single expression condition
--> $DIR/block_in_if_condition.rs:51:8
--> $DIR/block_in_if_condition.rs:46:8
|
51 | if { true } {
46 | if { true } {
| ^^^^^^^^
|
= note: `-D clippy::block-in-if-condition-expr` implied by `-D warnings`
@ -31,21 +31,29 @@ error: omit braces around single expression condition
} ...
error: in an 'if' condition, avoid complex blocks or closures with blocks; instead, move the block or closure higher and bind it with a 'let'
--> $DIR/block_in_if_condition.rs:68:49
--> $DIR/block_in_if_condition.rs:66:17
|
68 | if v == 3 && sky == "blue" && predicate(|x| { let target = 3; x == target }, v) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66 | |x| {
| _________________^
67 | | let target = 3;
68 | | x == target
69 | | },
| |_____________^
error: in an 'if' condition, avoid complex blocks or closures with blocks; instead, move the block or closure higher and bind it with a 'let'
--> $DIR/block_in_if_condition.rs:71:22
--> $DIR/block_in_if_condition.rs:75:13
|
71 | if predicate(|x| { let target = 3; x == target }, v) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
75 | |x| {
| _____________^
76 | | let target = 3;
77 | | x == target
78 | | },
| |_________^
error: this boolean expression can be simplified
--> $DIR/block_in_if_condition.rs:77:8
--> $DIR/block_in_if_condition.rs:85:8
|
77 | if true && x == 3 {
85 | if true && x == 3 {
| ^^^^^^^^^^^^^^ help: try: `x == 3`
|
= note: `-D clippy::nonminimal-bool` implied by `-D warnings`

View File

@ -7,19 +7,47 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[warn(clippy::bool_comparison)]
fn main() {
let x = true;
if x == true { "yes" } else { "no" };
if x == false { "yes" } else { "no" };
if true == x { "yes" } else { "no" };
if false == x { "yes" } else { "no" };
if x != true { "yes" } else { "no" };
if x != false { "yes" } else { "no" };
if true != x { "yes" } else { "no" };
if false != x { "yes" } else { "no" };
if x == true {
"yes"
} else {
"no"
};
if x == false {
"yes"
} else {
"no"
};
if true == x {
"yes"
} else {
"no"
};
if false == x {
"yes"
} else {
"no"
};
if x != true {
"yes"
} else {
"no"
};
if x != false {
"yes"
} else {
"no"
};
if true != x {
"yes"
} else {
"no"
};
if false != x {
"yes"
} else {
"no"
};
}

View File

@ -1,7 +1,7 @@
error: equality checks against true are unnecessary
--> $DIR/bool_comparison.rs:17:8
--> $DIR/bool_comparison.rs:13:8
|
17 | if x == true { "yes" } else { "no" };
13 | if x == true {
| ^^^^^^^^^ help: try simplifying it as shown: `x`
|
= note: `-D clippy::bool-comparison` implied by `-D warnings`
@ -9,43 +9,43 @@ error: equality checks against true are unnecessary
error: equality checks against false can be replaced by a negation
--> $DIR/bool_comparison.rs:18:8
|
18 | if x == false { "yes" } else { "no" };
18 | if x == false {
| ^^^^^^^^^^ help: try simplifying it as shown: `!x`
error: equality checks against true are unnecessary
--> $DIR/bool_comparison.rs:19:8
--> $DIR/bool_comparison.rs:23:8
|
19 | if true == x { "yes" } else { "no" };
23 | if true == x {
| ^^^^^^^^^ help: try simplifying it as shown: `x`
error: equality checks against false can be replaced by a negation
--> $DIR/bool_comparison.rs:20:8
--> $DIR/bool_comparison.rs:28:8
|
20 | if false == x { "yes" } else { "no" };
28 | if false == x {
| ^^^^^^^^^^ help: try simplifying it as shown: `!x`
error: inequality checks against true can be replaced by a negation
--> $DIR/bool_comparison.rs:21:8
--> $DIR/bool_comparison.rs:33:8
|
21 | if x != true { "yes" } else { "no" };
33 | if x != true {
| ^^^^^^^^^ help: try simplifying it as shown: `!x`
error: inequality checks against false are unnecessary
--> $DIR/bool_comparison.rs:22:8
--> $DIR/bool_comparison.rs:38:8
|
22 | if x != false { "yes" } else { "no" };
38 | if x != false {
| ^^^^^^^^^^ help: try simplifying it as shown: `x`
error: inequality checks against true can be replaced by a negation
--> $DIR/bool_comparison.rs:23:8
--> $DIR/bool_comparison.rs:43:8
|
23 | if true != x { "yes" } else { "no" };
43 | if true != x {
| ^^^^^^^^^ help: try simplifying it as shown: `!x`
error: inequality checks against false are unnecessary
--> $DIR/bool_comparison.rs:24:8
--> $DIR/bool_comparison.rs:48:8
|
24 | if false != x { "yes" } else { "no" };
48 | if false != x {
| ^^^^^^^^^^ help: try simplifying it as shown: `x`
error: aborting due to 8 previous errors

View File

@ -7,9 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![warn(clippy::nonminimal_bool, clippy::logic_bug)]
#[allow(unused, clippy::many_single_char_names)]
@ -71,58 +68,78 @@ fn methods_with_negation() {
// Simplified versions of https://github.com/rust-lang/rust-clippy/issues/2638
// clippy::nonminimal_bool should only check the built-in Result and Some type, not
// any other types like the following.
enum CustomResultOk<E> { Ok, Err(E) }
enum CustomResultErr<E> { Ok, Err(E) }
enum CustomSomeSome<T> { Some(T), None }
enum CustomSomeNone<T> { Some(T), None }
enum CustomResultOk<E> {
Ok,
Err(E),
}
enum CustomResultErr<E> {
Ok,
Err(E),
}
enum CustomSomeSome<T> {
Some(T),
None,
}
enum CustomSomeNone<T> {
Some(T),
None,
}
impl<E> CustomResultOk<E> {
pub fn is_ok(&self) -> bool { true }
pub fn is_ok(&self) -> bool {
true
}
}
impl<E> CustomResultErr<E> {
pub fn is_err(&self) -> bool { true }
pub fn is_err(&self) -> bool {
true
}
}
impl<T> CustomSomeSome<T> {
pub fn is_some(&self) -> bool { true }
pub fn is_some(&self) -> bool {
true
}
}
impl<T> CustomSomeNone<T> {
pub fn is_none(&self) -> bool { true }
pub fn is_none(&self) -> bool {
true
}
}
fn dont_warn_for_custom_methods_with_negation() {
let res = CustomResultOk::Err("Error");
// Should not warn and suggest 'is_err()' because the type does not
// implement is_err().
if !res.is_ok() { }
if !res.is_ok() {}
let res = CustomResultErr::Err("Error");
// Should not warn and suggest 'is_ok()' because the type does not
// implement is_ok().
if !res.is_err() { }
if !res.is_err() {}
let res = CustomSomeSome::Some("thing");
// Should not warn and suggest 'is_none()' because the type does not
// implement is_none().
if !res.is_some() { }
if !res.is_some() {}
let res = CustomSomeNone::Some("thing");
// Should not warn and suggest 'is_some()' because the type does not
// implement is_some().
if !res.is_none() { }
if !res.is_none() {}
}
// Only Built-in Result and Some types should suggest the negated alternative
fn warn_for_built_in_methods_with_negation() {
let res: Result<usize, usize> = Ok(1);
if !res.is_ok() { }
if !res.is_err() { }
if !res.is_ok() {}
if !res.is_err() {}
let res = Some(1);
if !res.is_some() { }
if !res.is_none() { }
if !res.is_some() {}
if !res.is_none() {}
}
#[allow(clippy::neg_cmp_op_on_partial_ord)]

View File

@ -1,202 +1,202 @@
error: this boolean expression contains a logic bug
--> $DIR/booleans.rs:22:13
--> $DIR/booleans.rs:19:13
|
22 | let _ = a && b || a;
19 | let _ = a && b || a;
| ^^^^^^^^^^^ help: it would look like the following: `a`
|
= note: `-D clippy::logic-bug` implied by `-D warnings`
help: this expression can be optimized out by applying boolean operations to the outer expression
--> $DIR/booleans.rs:22:18
--> $DIR/booleans.rs:19:18
|
22 | let _ = a && b || a;
19 | let _ = a && b || a;
| ^
error: this boolean expression can be simplified
--> $DIR/booleans.rs:24:13
--> $DIR/booleans.rs:21:13
|
24 | let _ = !true;
21 | let _ = !true;
| ^^^^^ help: try: `false`
|
= note: `-D clippy::nonminimal-bool` implied by `-D warnings`
error: this boolean expression can be simplified
--> $DIR/booleans.rs:25:13
--> $DIR/booleans.rs:22:13
|
25 | let _ = !false;
22 | let _ = !false;
| ^^^^^^ help: try: `true`
error: this boolean expression can be simplified
--> $DIR/booleans.rs:26:13
--> $DIR/booleans.rs:23:13
|
26 | let _ = !!a;
23 | let _ = !!a;
| ^^^ help: try: `a`
error: this boolean expression contains a logic bug
--> $DIR/booleans.rs:27:13
--> $DIR/booleans.rs:24:13
|
27 | let _ = false && a;
24 | let _ = false && a;
| ^^^^^^^^^^ help: it would look like the following: `false`
|
help: this expression can be optimized out by applying boolean operations to the outer expression
--> $DIR/booleans.rs:27:22
--> $DIR/booleans.rs:24:22
|
27 | let _ = false && a;
24 | let _ = false && a;
| ^
error: this boolean expression can be simplified
--> $DIR/booleans.rs:28:13
--> $DIR/booleans.rs:25:13
|
28 | let _ = false || a;
25 | let _ = false || a;
| ^^^^^^^^^^ help: try: `a`
error: this boolean expression can be simplified
--> $DIR/booleans.rs:33:13
--> $DIR/booleans.rs:30:13
|
33 | let _ = !(!a && b);
30 | let _ = !(!a && b);
| ^^^^^^^^^^ help: try: `!b || a`
error: this boolean expression contains a logic bug
--> $DIR/booleans.rs:43:13
--> $DIR/booleans.rs:40:13
|
43 | let _ = a == b && a != b;
40 | let _ = a == b && a != b;
| ^^^^^^^^^^^^^^^^ help: it would look like the following: `false`
|
help: this expression can be optimized out by applying boolean operations to the outer expression
--> $DIR/booleans.rs:43:13
--> $DIR/booleans.rs:40:13
|
43 | let _ = a == b && a != b;
40 | let _ = a == b && a != b;
| ^^^^^^
error: this boolean expression can be simplified
--> $DIR/booleans.rs:41:13
|
41 | let _ = a == b && c == 5 && a == b;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
help: try
|
41 | let _ = a == b && c == 5;
| ^^^^^^^^^^^^^^^^
41 | let _ = !(c != 5 || a != b);
| ^^^^^^^^^^^^^^^^^^^
error: this boolean expression can be simplified
--> $DIR/booleans.rs:42:13
|
42 | let _ = a == b && c == 5 && b == a;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
help: try
|
42 | let _ = a == b && c == 5;
| ^^^^^^^^^^^^^^^^
42 | let _ = !(c != 5 || a != b);
| ^^^^^^^^^^^^^^^^^^^
error: this boolean expression contains a logic bug
--> $DIR/booleans.rs:43:13
|
43 | let _ = a < b && a >= b;
| ^^^^^^^^^^^^^^^ help: it would look like the following: `false`
|
help: this expression can be optimized out by applying boolean operations to the outer expression
--> $DIR/booleans.rs:43:13
|
43 | let _ = a < b && a >= b;
| ^^^^^
error: this boolean expression contains a logic bug
--> $DIR/booleans.rs:44:13
|
44 | let _ = a == b && c == 5 && a == b;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
help: try
|
44 | let _ = a == b && c == 5;
| ^^^^^^^^^^^^^^^^
44 | let _ = !(c != 5 || a != b);
| ^^^^^^^^^^^^^^^^^^^
error: this boolean expression can be simplified
--> $DIR/booleans.rs:45:13
|
45 | let _ = a == b && c == 5 && b == a;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
help: try
|
45 | let _ = a == b && c == 5;
| ^^^^^^^^^^^^^^^^
45 | let _ = !(c != 5 || a != b);
| ^^^^^^^^^^^^^^^^^^^
error: this boolean expression contains a logic bug
--> $DIR/booleans.rs:46:13
|
46 | let _ = a < b && a >= b;
44 | let _ = a > b && a <= b;
| ^^^^^^^^^^^^^^^ help: it would look like the following: `false`
|
help: this expression can be optimized out by applying boolean operations to the outer expression
--> $DIR/booleans.rs:46:13
--> $DIR/booleans.rs:44:13
|
46 | let _ = a < b && a >= b;
| ^^^^^
error: this boolean expression contains a logic bug
--> $DIR/booleans.rs:47:13
|
47 | let _ = a > b && a <= b;
| ^^^^^^^^^^^^^^^ help: it would look like the following: `false`
|
help: this expression can be optimized out by applying boolean operations to the outer expression
--> $DIR/booleans.rs:47:13
|
47 | let _ = a > b && a <= b;
44 | let _ = a > b && a <= b;
| ^^^^^
error: this boolean expression can be simplified
--> $DIR/booleans.rs:49:13
--> $DIR/booleans.rs:46:13
|
49 | let _ = a != b || !(a != b || c == d);
46 | let _ = a != b || !(a != b || c == d);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: try
|
49 | let _ = c != d || a != b;
46 | let _ = c != d || a != b;
| ^^^^^^^^^^^^^^^^
49 | let _ = !(a == b && c == d);
46 | let _ = !(a == b && c == d);
| ^^^^^^^^^^^^^^^^^^^
error: this boolean expression can be simplified
--> $DIR/booleans.rs:57:13
--> $DIR/booleans.rs:54:13
|
57 | let _ = !a.is_some();
54 | let _ = !a.is_some();
| ^^^^^^^^^^^^ help: try: `a.is_none()`
error: this boolean expression can be simplified
--> $DIR/booleans.rs:59:13
--> $DIR/booleans.rs:56:13
|
59 | let _ = !a.is_none();
56 | let _ = !a.is_none();
| ^^^^^^^^^^^^ help: try: `a.is_some()`
error: this boolean expression can be simplified
--> $DIR/booleans.rs:61:13
--> $DIR/booleans.rs:58:13
|
61 | let _ = !b.is_err();
58 | let _ = !b.is_err();
| ^^^^^^^^^^^ help: try: `b.is_ok()`
error: this boolean expression can be simplified
--> $DIR/booleans.rs:60:13
|
60 | let _ = !b.is_ok();
| ^^^^^^^^^^ help: try: `b.is_err()`
error: this boolean expression can be simplified
--> $DIR/booleans.rs:62:13
|
62 | let _ = !(a.is_some() && !c);
| ^^^^^^^^^^^^^^^^^^^^ help: try: `c || a.is_none()`
error: this boolean expression can be simplified
--> $DIR/booleans.rs:63:13
|
63 | let _ = !b.is_ok();
| ^^^^^^^^^^ help: try: `b.is_err()`
63 | let _ = !(!c ^ c) || !a.is_some();
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `!(!c ^ c) || a.is_none()`
error: this boolean expression can be simplified
--> $DIR/booleans.rs:64:13
|
64 | let _ = (!c ^ c) || !a.is_some();
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(!c ^ c) || a.is_none()`
error: this boolean expression can be simplified
--> $DIR/booleans.rs:65:13
|
65 | let _ = !(a.is_some() && !c);
| ^^^^^^^^^^^^^^^^^^^^ help: try: `c || a.is_none()`
error: this boolean expression can be simplified
--> $DIR/booleans.rs:66:13
|
66 | let _ = !(!c ^ c) || !a.is_some();
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `!(!c ^ c) || a.is_none()`
error: this boolean expression can be simplified
--> $DIR/booleans.rs:67:13
|
67 | let _ = (!c ^ c) || !a.is_some();
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(!c ^ c) || a.is_none()`
error: this boolean expression can be simplified
--> $DIR/booleans.rs:68:13
|
68 | let _ = !c ^ c || !a.is_some();
65 | let _ = !c ^ c || !a.is_some();
| ^^^^^^^^^^^^^^^^^^^^^^ help: try: `!c ^ c || a.is_none()`
error: this boolean expression can be simplified
--> $DIR/booleans.rs:120:8
--> $DIR/booleans.rs:137:8
|
120 | if !res.is_ok() { }
137 | if !res.is_ok() {}
| ^^^^^^^^^^^^ help: try: `res.is_err()`
error: this boolean expression can be simplified
--> $DIR/booleans.rs:121:8
--> $DIR/booleans.rs:138:8
|
121 | if !res.is_err() { }
138 | if !res.is_err() {}
| ^^^^^^^^^^^^^ help: try: `res.is_ok()`
error: this boolean expression can be simplified
--> $DIR/booleans.rs:124:8
--> $DIR/booleans.rs:141:8
|
124 | if !res.is_some() { }
141 | if !res.is_some() {}
| ^^^^^^^^^^^^^^ help: try: `res.is_none()`
error: this boolean expression can be simplified
--> $DIR/booleans.rs:125:8
--> $DIR/booleans.rs:142:8
|
125 | if !res.is_none() { }
142 | if !res.is_none() {}
| ^^^^^^^^^^^^^^ help: try: `res.is_some()`
error: aborting due to 25 previous errors

View File

@ -7,10 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![deny(clippy::borrowed_box)]
#![allow(clippy::blacklisted_name)]
#![allow(unused_variables)]
@ -25,7 +21,7 @@ pub fn test2() {
}
struct Test3<'a> {
foo: &'a Box<bool>
foo: &'a Box<bool>,
}
trait Test4 {
@ -49,7 +45,7 @@ pub fn test6() {
}
struct Test7<'a> {
foo: &'a Box<Any>
foo: &'a Box<Any>,
}
trait Test8 {
@ -71,7 +67,7 @@ pub fn test10() {
}
struct Test11<'a> {
foo: &'a Box<Any + Send>
foo: &'a Box<Any + Send>,
}
trait Test12 {
@ -84,7 +80,7 @@ impl<'a> Test12 for Test11<'a> {
}
}
fn main(){
fn main() {
test1(&mut Box::new(false));
test2();
test5(&mut (Box::new(false) as Box<Any>));

View File

@ -1,31 +1,31 @@
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
--> $DIR/borrow_box.rs:19:19
--> $DIR/borrow_box.rs:15:19
|
19 | pub fn test1(foo: &mut Box<bool>) {
15 | pub fn test1(foo: &mut Box<bool>) {
| ^^^^^^^^^^^^^^ help: try: `&mut bool`
|
note: lint level defined here
--> $DIR/borrow_box.rs:14:9
--> $DIR/borrow_box.rs:10:9
|
14 | #![deny(clippy::borrowed_box)]
10 | #![deny(clippy::borrowed_box)]
| ^^^^^^^^^^^^^^^^^^^^
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
--> $DIR/borrow_box.rs:24:14
--> $DIR/borrow_box.rs:20:14
|
24 | let foo: &Box<bool>;
20 | let foo: &Box<bool>;
| ^^^^^^^^^^ help: try: `&bool`
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
--> $DIR/borrow_box.rs:28:10
--> $DIR/borrow_box.rs:24:10
|
28 | foo: &'a Box<bool>
24 | foo: &'a Box<bool>,
| ^^^^^^^^^^^^^ help: try: `&'a bool`
error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
--> $DIR/borrow_box.rs:32:17
--> $DIR/borrow_box.rs:28:17
|
32 | fn test4(a: &Box<bool>);
28 | fn test4(a: &Box<bool>);
| ^^^^^^^^^^ help: try: `&bool`
error: aborting due to 4 previous errors

View File

@ -7,10 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![warn(clippy::all)]
#![allow(clippy::boxed_local, clippy::needless_pass_by_value)]
#![allow(clippy::blacklisted_name)]
@ -18,7 +14,7 @@
macro_rules! boxit {
($init:expr, $x:ty) => {
let _: Box<$x> = Box::new($init);
}
};
}
fn test_macro() {
@ -28,7 +24,8 @@ pub fn test(foo: Box<Vec<bool>>) {
println!("{:?}", foo.get(0))
}
pub fn test2(foo: Box<Fn(Vec<u32>)>) { // pass if #31 is fixed
pub fn test2(foo: Box<Fn(Vec<u32>)>) {
// pass if #31 is fixed
foo(vec![1, 2, 3])
}
@ -36,7 +33,7 @@ pub fn test_local_not_linted() {
let _: Box<Vec<bool>>;
}
fn main(){
fn main() {
test(Box::new(Vec::new()));
test2(Box::new(|v| println!("{:?}", v)));
test_macro();

View File

@ -1,7 +1,7 @@
error: you seem to be trying to use `Box<Vec<T>>`. Consider using just `Vec<T>`
--> $DIR/box_vec.rs:27:18
--> $DIR/box_vec.rs:23:18
|
27 | pub fn test(foo: Box<Vec<bool>>) {
23 | pub fn test(foo: Box<Vec<bool>>) {
| ^^^^^^^^^^^^^^
|
= note: `-D clippy::box-vec` implied by `-D warnings`

View File

@ -7,9 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![warn(clippy::builtin_type_shadow)]
fn foo<u32>(a: u32) -> u32 {
@ -17,5 +14,4 @@ fn foo<u32>(a: u32) -> u32 {
// ^ rustc's type error
}
fn main() {
}
fn main() {}

View File

@ -1,17 +1,17 @@
error: This generic shadows the built-in type `u32`
--> $DIR/builtin-type-shadow.rs:15:8
--> $DIR/builtin-type-shadow.rs:12:8
|
15 | fn foo<u32>(a: u32) -> u32 {
12 | fn foo<u32>(a: u32) -> u32 {
| ^^^
|
= note: `-D clippy::builtin-type-shadow` implied by `-D warnings`
error[E0308]: mismatched types
--> $DIR/builtin-type-shadow.rs:16:5
--> $DIR/builtin-type-shadow.rs:13:5
|
15 | fn foo<u32>(a: u32) -> u32 {
12 | fn foo<u32>(a: u32) -> u32 {
| --- expected `u32` because of return type
16 | 42
13 | 42
| ^^ expected type parameter, found integral variable
|
= note: expected type `u32`

View File

@ -7,10 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[deny(clippy::naive_bytecount)]
fn main() {
let x = vec![0_u8; 16];

View File

@ -1,25 +1,25 @@
error: You appear to be counting bytes the naive way
--> $DIR/bytecount.rs:18:13
--> $DIR/bytecount.rs:14:13
|
18 | let _ = x.iter().filter(|&&a| a == 0).count(); // naive byte count
14 | let _ = x.iter().filter(|&&a| a == 0).count(); // naive byte count
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: Consider using the bytecount crate: `bytecount::count(x, 0)`
|
note: lint level defined here
--> $DIR/bytecount.rs:14:8
--> $DIR/bytecount.rs:10:8
|
14 | #[deny(clippy::naive_bytecount)]
10 | #[deny(clippy::naive_bytecount)]
| ^^^^^^^^^^^^^^^^^^^^^^^
error: You appear to be counting bytes the naive way
--> $DIR/bytecount.rs:20:13
--> $DIR/bytecount.rs:16:13
|
20 | let _ = (&x[..]).iter().filter(|&a| *a == 0).count(); // naive byte count
16 | let _ = (&x[..]).iter().filter(|&a| *a == 0).count(); // naive byte count
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: Consider using the bytecount crate: `bytecount::count((&x[..]), 0)`
error: You appear to be counting bytes the naive way
--> $DIR/bytecount.rs:32:13
--> $DIR/bytecount.rs:28:13
|
32 | let _ = x.iter().filter(|a| b + 1 == **a).count(); // naive byte count
28 | let _ = x.iter().filter(|a| b + 1 == **a).count(); // naive byte count
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: Consider using the bytecount crate: `bytecount::count(x, b + 1)`
error: aborting due to 3 previous errors

View File

@ -7,11 +7,13 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[warn(clippy::cast_precision_loss, clippy::cast_possible_truncation, clippy::cast_sign_loss, clippy::cast_possible_wrap, clippy::cast_lossless)]
#[warn(
clippy::cast_precision_loss,
clippy::cast_possible_truncation,
clippy::cast_sign_loss,
clippy::cast_possible_wrap,
clippy::cast_lossless
)]
#[allow(clippy::no_effect, clippy::unnecessary_operation)]
fn main() {
// Test clippy::cast_precision_loss
@ -49,6 +51,7 @@ fn main() {
false as bool;
&1i32 as &i32;
// Should not trigger
#[rustfmt::skip]
let v = vec!(1);
&v as &[i32];
1.0 as f64;

View File

@ -1,181 +1,181 @@
error: casting i32 to f32 causes a loss of precision (i32 is 32 bits wide, but f32's mantissa is only 23 bits wide)
--> $DIR/cast.rs:18:5
--> $DIR/cast.rs:20:5
|
18 | 1i32 as f32;
20 | 1i32 as f32;
| ^^^^^^^^^^^
|
= note: `-D clippy::cast-precision-loss` implied by `-D warnings`
error: casting i64 to f32 causes a loss of precision (i64 is 64 bits wide, but f32's mantissa is only 23 bits wide)
--> $DIR/cast.rs:19:5
--> $DIR/cast.rs:21:5
|
19 | 1i64 as f32;
21 | 1i64 as f32;
| ^^^^^^^^^^^
error: casting i64 to f64 causes a loss of precision (i64 is 64 bits wide, but f64's mantissa is only 52 bits wide)
--> $DIR/cast.rs:20:5
--> $DIR/cast.rs:22:5
|
20 | 1i64 as f64;
22 | 1i64 as f64;
| ^^^^^^^^^^^
error: casting u32 to f32 causes a loss of precision (u32 is 32 bits wide, but f32's mantissa is only 23 bits wide)
--> $DIR/cast.rs:21:5
--> $DIR/cast.rs:23:5
|
21 | 1u32 as f32;
23 | 1u32 as f32;
| ^^^^^^^^^^^
error: casting u64 to f32 causes a loss of precision (u64 is 64 bits wide, but f32's mantissa is only 23 bits wide)
--> $DIR/cast.rs:22:5
--> $DIR/cast.rs:24:5
|
22 | 1u64 as f32;
24 | 1u64 as f32;
| ^^^^^^^^^^^
error: casting u64 to f64 causes a loss of precision (u64 is 64 bits wide, but f64's mantissa is only 52 bits wide)
--> $DIR/cast.rs:23:5
--> $DIR/cast.rs:25:5
|
23 | 1u64 as f64;
25 | 1u64 as f64;
| ^^^^^^^^^^^
error: casting f32 to i32 may truncate the value
--> $DIR/cast.rs:25:5
--> $DIR/cast.rs:27:5
|
25 | 1f32 as i32;
27 | 1f32 as i32;
| ^^^^^^^^^^^
|
= note: `-D clippy::cast-possible-truncation` implied by `-D warnings`
error: casting f32 to u32 may truncate the value
--> $DIR/cast.rs:26:5
--> $DIR/cast.rs:28:5
|
26 | 1f32 as u32;
28 | 1f32 as u32;
| ^^^^^^^^^^^
error: casting f32 to u32 may lose the sign of the value
--> $DIR/cast.rs:26:5
--> $DIR/cast.rs:28:5
|
26 | 1f32 as u32;
28 | 1f32 as u32;
| ^^^^^^^^^^^
|
= note: `-D clippy::cast-sign-loss` implied by `-D warnings`
error: casting f64 to f32 may truncate the value
--> $DIR/cast.rs:27:5
--> $DIR/cast.rs:29:5
|
27 | 1f64 as f32;
29 | 1f64 as f32;
| ^^^^^^^^^^^
error: casting i32 to i8 may truncate the value
--> $DIR/cast.rs:28:5
--> $DIR/cast.rs:30:5
|
28 | 1i32 as i8;
30 | 1i32 as i8;
| ^^^^^^^^^^
error: casting i32 to u8 may lose the sign of the value
--> $DIR/cast.rs:29:5
--> $DIR/cast.rs:31:5
|
29 | 1i32 as u8;
31 | 1i32 as u8;
| ^^^^^^^^^^
error: casting i32 to u8 may truncate the value
--> $DIR/cast.rs:29:5
--> $DIR/cast.rs:31:5
|
29 | 1i32 as u8;
31 | 1i32 as u8;
| ^^^^^^^^^^
error: casting f64 to isize may truncate the value
--> $DIR/cast.rs:30:5
--> $DIR/cast.rs:32:5
|
30 | 1f64 as isize;
32 | 1f64 as isize;
| ^^^^^^^^^^^^^
error: casting f64 to usize may truncate the value
--> $DIR/cast.rs:31:5
--> $DIR/cast.rs:33:5
|
31 | 1f64 as usize;
33 | 1f64 as usize;
| ^^^^^^^^^^^^^
error: casting f64 to usize may lose the sign of the value
--> $DIR/cast.rs:31:5
--> $DIR/cast.rs:33:5
|
31 | 1f64 as usize;
33 | 1f64 as usize;
| ^^^^^^^^^^^^^
error: casting u8 to i8 may wrap around the value
--> $DIR/cast.rs:33:5
--> $DIR/cast.rs:35:5
|
33 | 1u8 as i8;
35 | 1u8 as i8;
| ^^^^^^^^^
|
= note: `-D clippy::cast-possible-wrap` implied by `-D warnings`
error: casting u16 to i16 may wrap around the value
--> $DIR/cast.rs:34:5
--> $DIR/cast.rs:36:5
|
34 | 1u16 as i16;
36 | 1u16 as i16;
| ^^^^^^^^^^^
error: casting u32 to i32 may wrap around the value
--> $DIR/cast.rs:35:5
--> $DIR/cast.rs:37:5
|
35 | 1u32 as i32;
37 | 1u32 as i32;
| ^^^^^^^^^^^
error: casting u64 to i64 may wrap around the value
--> $DIR/cast.rs:36:5
--> $DIR/cast.rs:38:5
|
36 | 1u64 as i64;
38 | 1u64 as i64;
| ^^^^^^^^^^^
error: casting usize to isize may wrap around the value
--> $DIR/cast.rs:37:5
--> $DIR/cast.rs:39:5
|
37 | 1usize as isize;
39 | 1usize as isize;
| ^^^^^^^^^^^^^^^
error: casting f32 to f64 may become silently lossy if types change
--> $DIR/cast.rs:39:5
--> $DIR/cast.rs:41:5
|
39 | 1.0f32 as f64;
41 | 1.0f32 as f64;
| ^^^^^^^^^^^^^ help: try: `f64::from(1.0f32)`
|
= note: `-D clippy::cast-lossless` implied by `-D warnings`
error: casting u8 to u16 may become silently lossy if types change
--> $DIR/cast.rs:41:5
--> $DIR/cast.rs:43:5
|
41 | (1u8 + 1u8) as u16;
43 | (1u8 + 1u8) as u16;
| ^^^^^^^^^^^^^^^^^^ help: try: `u16::from(1u8 + 1u8)`
error: casting i32 to u32 may lose the sign of the value
--> $DIR/cast.rs:43:5
--> $DIR/cast.rs:45:5
|
43 | 1i32 as u32;
45 | 1i32 as u32;
| ^^^^^^^^^^^
error: casting isize to usize may lose the sign of the value
--> $DIR/cast.rs:44:5
--> $DIR/cast.rs:46:5
|
44 | 1isize as usize;
46 | 1isize as usize;
| ^^^^^^^^^^^^^^^
error: casting to the same type is unnecessary (`i32` -> `i32`)
--> $DIR/cast.rs:47:5
--> $DIR/cast.rs:49:5
|
47 | 1i32 as i32;
49 | 1i32 as i32;
| ^^^^^^^^^^^
|
= note: `-D clippy::unnecessary-cast` implied by `-D warnings`
error: casting to the same type is unnecessary (`f32` -> `f32`)
--> $DIR/cast.rs:48:5
--> $DIR/cast.rs:50:5
|
48 | 1f32 as f32;
50 | 1f32 as f32;
| ^^^^^^^^^^^
error: casting to the same type is unnecessary (`bool` -> `bool`)
--> $DIR/cast.rs:49:5
--> $DIR/cast.rs:51:5
|
49 | false as bool;
51 | false as bool;
| ^^^^^^^^^^^^^
error: aborting due to 28 previous errors

View File

@ -7,9 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
//! Test casts for alignment issues
#![feature(libc)]

View File

@ -1,15 +1,15 @@
error: casting from `*const u8` to a more-strictly-aligned pointer (`*const u16`)
--> $DIR/cast_alignment.rs:25:5
--> $DIR/cast_alignment.rs:22:5
|
25 | (&1u8 as *const u8) as *const u16;
22 | (&1u8 as *const u8) as *const u16;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `-D clippy::cast-ptr-alignment` implied by `-D warnings`
error: casting from `*mut u8` to a more-strictly-aligned pointer (`*mut u16`)
--> $DIR/cast_alignment.rs:26:5
--> $DIR/cast_alignment.rs:23:5
|
26 | (&mut 1u8 as *mut u8) as *mut u16;
23 | (&mut 1u8 as *mut u8) as *mut u16;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors

View File

@ -7,9 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[warn(clippy::cast_lossless)]
#[allow(clippy::no_effect, clippy::unnecessary_operation)]
fn main() {

View File

@ -1,63 +1,63 @@
error: casting i8 to f32 may become silently lossy if types change
--> $DIR/cast_lossless_float.rs:17:5
--> $DIR/cast_lossless_float.rs:14:5
|
17 | 1i8 as f32;
14 | 1i8 as f32;
| ^^^^^^^^^^ help: try: `f32::from(1i8)`
|
= note: `-D clippy::cast-lossless` implied by `-D warnings`
error: casting i8 to f64 may become silently lossy if types change
--> $DIR/cast_lossless_float.rs:18:5
--> $DIR/cast_lossless_float.rs:15:5
|
18 | 1i8 as f64;
15 | 1i8 as f64;
| ^^^^^^^^^^ help: try: `f64::from(1i8)`
error: casting u8 to f32 may become silently lossy if types change
--> $DIR/cast_lossless_float.rs:19:5
--> $DIR/cast_lossless_float.rs:16:5
|
19 | 1u8 as f32;
16 | 1u8 as f32;
| ^^^^^^^^^^ help: try: `f32::from(1u8)`
error: casting u8 to f64 may become silently lossy if types change
--> $DIR/cast_lossless_float.rs:20:5
--> $DIR/cast_lossless_float.rs:17:5
|
20 | 1u8 as f64;
17 | 1u8 as f64;
| ^^^^^^^^^^ help: try: `f64::from(1u8)`
error: casting i16 to f32 may become silently lossy if types change
--> $DIR/cast_lossless_float.rs:21:5
--> $DIR/cast_lossless_float.rs:18:5
|
21 | 1i16 as f32;
18 | 1i16 as f32;
| ^^^^^^^^^^^ help: try: `f32::from(1i16)`
error: casting i16 to f64 may become silently lossy if types change
--> $DIR/cast_lossless_float.rs:22:5
--> $DIR/cast_lossless_float.rs:19:5
|
22 | 1i16 as f64;
19 | 1i16 as f64;
| ^^^^^^^^^^^ help: try: `f64::from(1i16)`
error: casting u16 to f32 may become silently lossy if types change
--> $DIR/cast_lossless_float.rs:23:5
--> $DIR/cast_lossless_float.rs:20:5
|
23 | 1u16 as f32;
20 | 1u16 as f32;
| ^^^^^^^^^^^ help: try: `f32::from(1u16)`
error: casting u16 to f64 may become silently lossy if types change
--> $DIR/cast_lossless_float.rs:24:5
--> $DIR/cast_lossless_float.rs:21:5
|
24 | 1u16 as f64;
21 | 1u16 as f64;
| ^^^^^^^^^^^ help: try: `f64::from(1u16)`
error: casting i32 to f64 may become silently lossy if types change
--> $DIR/cast_lossless_float.rs:25:5
--> $DIR/cast_lossless_float.rs:22:5
|
25 | 1i32 as f64;
22 | 1i32 as f64;
| ^^^^^^^^^^^ help: try: `f64::from(1i32)`
error: casting u32 to f64 may become silently lossy if types change
--> $DIR/cast_lossless_float.rs:26:5
--> $DIR/cast_lossless_float.rs:23:5
|
26 | 1u32 as f64;
23 | 1u32 as f64;
| ^^^^^^^^^^^ help: try: `f64::from(1u32)`
error: aborting due to 10 previous errors

View File

@ -7,8 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[warn(clippy::cast_lossless)]
#[allow(clippy::no_effect, clippy::unnecessary_operation)]
fn main() {

View File

@ -1,111 +1,111 @@
error: casting i8 to i16 may become silently lossy if types change
--> $DIR/cast_lossless_integer.rs:16:5
--> $DIR/cast_lossless_integer.rs:14:5
|
16 | 1i8 as i16;
14 | 1i8 as i16;
| ^^^^^^^^^^ help: try: `i16::from(1i8)`
|
= note: `-D clippy::cast-lossless` implied by `-D warnings`
error: casting i8 to i32 may become silently lossy if types change
--> $DIR/cast_lossless_integer.rs:17:5
--> $DIR/cast_lossless_integer.rs:15:5
|
17 | 1i8 as i32;
15 | 1i8 as i32;
| ^^^^^^^^^^ help: try: `i32::from(1i8)`
error: casting i8 to i64 may become silently lossy if types change
--> $DIR/cast_lossless_integer.rs:18:5
--> $DIR/cast_lossless_integer.rs:16:5
|
18 | 1i8 as i64;
16 | 1i8 as i64;
| ^^^^^^^^^^ help: try: `i64::from(1i8)`
error: casting u8 to i16 may become silently lossy if types change
--> $DIR/cast_lossless_integer.rs:19:5
--> $DIR/cast_lossless_integer.rs:17:5
|
19 | 1u8 as i16;
17 | 1u8 as i16;
| ^^^^^^^^^^ help: try: `i16::from(1u8)`
error: casting u8 to i32 may become silently lossy if types change
--> $DIR/cast_lossless_integer.rs:20:5
--> $DIR/cast_lossless_integer.rs:18:5
|
20 | 1u8 as i32;
18 | 1u8 as i32;
| ^^^^^^^^^^ help: try: `i32::from(1u8)`
error: casting u8 to i64 may become silently lossy if types change
--> $DIR/cast_lossless_integer.rs:21:5
--> $DIR/cast_lossless_integer.rs:19:5
|
21 | 1u8 as i64;
19 | 1u8 as i64;
| ^^^^^^^^^^ help: try: `i64::from(1u8)`
error: casting u8 to u16 may become silently lossy if types change
--> $DIR/cast_lossless_integer.rs:22:5
--> $DIR/cast_lossless_integer.rs:20:5
|
22 | 1u8 as u16;
20 | 1u8 as u16;
| ^^^^^^^^^^ help: try: `u16::from(1u8)`
error: casting u8 to u32 may become silently lossy if types change
--> $DIR/cast_lossless_integer.rs:23:5
--> $DIR/cast_lossless_integer.rs:21:5
|
23 | 1u8 as u32;
21 | 1u8 as u32;
| ^^^^^^^^^^ help: try: `u32::from(1u8)`
error: casting u8 to u64 may become silently lossy if types change
--> $DIR/cast_lossless_integer.rs:24:5
--> $DIR/cast_lossless_integer.rs:22:5
|
24 | 1u8 as u64;
22 | 1u8 as u64;
| ^^^^^^^^^^ help: try: `u64::from(1u8)`
error: casting i16 to i32 may become silently lossy if types change
--> $DIR/cast_lossless_integer.rs:25:5
--> $DIR/cast_lossless_integer.rs:23:5
|
25 | 1i16 as i32;
23 | 1i16 as i32;
| ^^^^^^^^^^^ help: try: `i32::from(1i16)`
error: casting i16 to i64 may become silently lossy if types change
--> $DIR/cast_lossless_integer.rs:26:5
--> $DIR/cast_lossless_integer.rs:24:5
|
26 | 1i16 as i64;
24 | 1i16 as i64;
| ^^^^^^^^^^^ help: try: `i64::from(1i16)`
error: casting u16 to i32 may become silently lossy if types change
--> $DIR/cast_lossless_integer.rs:27:5
--> $DIR/cast_lossless_integer.rs:25:5
|
27 | 1u16 as i32;
25 | 1u16 as i32;
| ^^^^^^^^^^^ help: try: `i32::from(1u16)`
error: casting u16 to i64 may become silently lossy if types change
--> $DIR/cast_lossless_integer.rs:28:5
--> $DIR/cast_lossless_integer.rs:26:5
|
28 | 1u16 as i64;
26 | 1u16 as i64;
| ^^^^^^^^^^^ help: try: `i64::from(1u16)`
error: casting u16 to u32 may become silently lossy if types change
--> $DIR/cast_lossless_integer.rs:29:5
--> $DIR/cast_lossless_integer.rs:27:5
|
29 | 1u16 as u32;
27 | 1u16 as u32;
| ^^^^^^^^^^^ help: try: `u32::from(1u16)`
error: casting u16 to u64 may become silently lossy if types change
--> $DIR/cast_lossless_integer.rs:30:5
--> $DIR/cast_lossless_integer.rs:28:5
|
30 | 1u16 as u64;
28 | 1u16 as u64;
| ^^^^^^^^^^^ help: try: `u64::from(1u16)`
error: casting i32 to i64 may become silently lossy if types change
--> $DIR/cast_lossless_integer.rs:31:5
--> $DIR/cast_lossless_integer.rs:29:5
|
31 | 1i32 as i64;
29 | 1i32 as i64;
| ^^^^^^^^^^^ help: try: `i64::from(1i32)`
error: casting u32 to i64 may become silently lossy if types change
--> $DIR/cast_lossless_integer.rs:32:5
--> $DIR/cast_lossless_integer.rs:30:5
|
32 | 1u32 as i64;
30 | 1u32 as i64;
| ^^^^^^^^^^^ help: try: `i64::from(1u32)`
error: casting u32 to u64 may become silently lossy if types change
--> $DIR/cast_lossless_integer.rs:33:5
--> $DIR/cast_lossless_integer.rs:31:5
|
33 | 1u32 as u64;
31 | 1u32 as u64;
| ^^^^^^^^^^^ help: try: `u64::from(1u32)`
error: aborting due to 18 previous errors

View File

@ -7,10 +7,13 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[warn(clippy::cast_precision_loss, clippy::cast_possible_truncation, clippy::cast_sign_loss, clippy::cast_possible_wrap, clippy::cast_lossless)]
#[warn(
clippy::cast_precision_loss,
clippy::cast_possible_truncation,
clippy::cast_sign_loss,
clippy::cast_possible_wrap,
clippy::cast_lossless
)]
#[allow(clippy::no_effect, clippy::unnecessary_operation)]
fn main() {
// Casting from *size

View File

@ -1,123 +1,123 @@
error: casting isize to i8 may truncate the value
--> $DIR/cast_size.rs:17:5
--> $DIR/cast_size.rs:20:5
|
17 | 1isize as i8;
20 | 1isize as i8;
| ^^^^^^^^^^^^
|
= note: `-D clippy::cast-possible-truncation` implied by `-D warnings`
error: casting isize to f64 causes a loss of precision on targets with 64-bit wide pointers (isize is 64 bits wide, but f64's mantissa is only 52 bits wide)
--> $DIR/cast_size.rs:18:5
--> $DIR/cast_size.rs:21:5
|
18 | 1isize as f64;
21 | 1isize as f64;
| ^^^^^^^^^^^^^
|
= note: `-D clippy::cast-precision-loss` implied by `-D warnings`
error: casting usize to f64 causes a loss of precision on targets with 64-bit wide pointers (usize is 64 bits wide, but f64's mantissa is only 52 bits wide)
--> $DIR/cast_size.rs:19:5
--> $DIR/cast_size.rs:22:5
|
19 | 1usize as f64;
22 | 1usize as f64;
| ^^^^^^^^^^^^^
error: casting isize to f32 causes a loss of precision (isize is 32 or 64 bits wide, but f32's mantissa is only 23 bits wide)
--> $DIR/cast_size.rs:20:5
--> $DIR/cast_size.rs:23:5
|
20 | 1isize as f32;
23 | 1isize as f32;
| ^^^^^^^^^^^^^
error: casting usize to f32 causes a loss of precision (usize is 32 or 64 bits wide, but f32's mantissa is only 23 bits wide)
--> $DIR/cast_size.rs:21:5
--> $DIR/cast_size.rs:24:5
|
21 | 1usize as f32;
24 | 1usize as f32;
| ^^^^^^^^^^^^^
error: casting isize to i32 may truncate the value on targets with 64-bit wide pointers
--> $DIR/cast_size.rs:22:5
--> $DIR/cast_size.rs:25:5
|
22 | 1isize as i32;
25 | 1isize as i32;
| ^^^^^^^^^^^^^
error: casting isize to u32 may lose the sign of the value
--> $DIR/cast_size.rs:23:5
--> $DIR/cast_size.rs:26:5
|
23 | 1isize as u32;
26 | 1isize as u32;
| ^^^^^^^^^^^^^
|
= note: `-D clippy::cast-sign-loss` implied by `-D warnings`
error: casting isize to u32 may truncate the value on targets with 64-bit wide pointers
--> $DIR/cast_size.rs:23:5
--> $DIR/cast_size.rs:26:5
|
23 | 1isize as u32;
26 | 1isize as u32;
| ^^^^^^^^^^^^^
error: casting usize to u32 may truncate the value on targets with 64-bit wide pointers
--> $DIR/cast_size.rs:24:5
--> $DIR/cast_size.rs:27:5
|
24 | 1usize as u32;
27 | 1usize as u32;
| ^^^^^^^^^^^^^
error: casting usize to i32 may truncate the value on targets with 64-bit wide pointers
--> $DIR/cast_size.rs:25:5
--> $DIR/cast_size.rs:28:5
|
25 | 1usize as i32;
28 | 1usize as i32;
| ^^^^^^^^^^^^^
error: casting usize to i32 may wrap around the value on targets with 32-bit wide pointers
--> $DIR/cast_size.rs:25:5
--> $DIR/cast_size.rs:28:5
|
25 | 1usize as i32;
28 | 1usize as i32;
| ^^^^^^^^^^^^^
|
= note: `-D clippy::cast-possible-wrap` implied by `-D warnings`
error: casting i64 to isize may truncate the value on targets with 32-bit wide pointers
--> $DIR/cast_size.rs:27:5
--> $DIR/cast_size.rs:30:5
|
27 | 1i64 as isize;
30 | 1i64 as isize;
| ^^^^^^^^^^^^^
error: casting i64 to usize may lose the sign of the value
--> $DIR/cast_size.rs:28:5
--> $DIR/cast_size.rs:31:5
|
28 | 1i64 as usize;
31 | 1i64 as usize;
| ^^^^^^^^^^^^^
error: casting i64 to usize may truncate the value on targets with 32-bit wide pointers
--> $DIR/cast_size.rs:28:5
--> $DIR/cast_size.rs:31:5
|
28 | 1i64 as usize;
31 | 1i64 as usize;
| ^^^^^^^^^^^^^
error: casting u64 to isize may truncate the value on targets with 32-bit wide pointers
--> $DIR/cast_size.rs:29:5
--> $DIR/cast_size.rs:32:5
|
29 | 1u64 as isize;
32 | 1u64 as isize;
| ^^^^^^^^^^^^^
error: casting u64 to isize may wrap around the value on targets with 64-bit wide pointers
--> $DIR/cast_size.rs:29:5
--> $DIR/cast_size.rs:32:5
|
29 | 1u64 as isize;
32 | 1u64 as isize;
| ^^^^^^^^^^^^^
error: casting u64 to usize may truncate the value on targets with 32-bit wide pointers
--> $DIR/cast_size.rs:30:5
--> $DIR/cast_size.rs:33:5
|
30 | 1u64 as usize;
33 | 1u64 as usize;
| ^^^^^^^^^^^^^
error: casting u32 to isize may wrap around the value on targets with 32-bit wide pointers
--> $DIR/cast_size.rs:31:5
--> $DIR/cast_size.rs:34:5
|
31 | 1u32 as isize;
34 | 1u32 as isize;
| ^^^^^^^^^^^^^
error: casting i32 to usize may lose the sign of the value
--> $DIR/cast_size.rs:34:5
--> $DIR/cast_size.rs:37:5
|
34 | 1i32 as usize;
37 | 1i32 as usize;
| ^^^^^^^^^^^^^
error: aborting due to 19 previous errors

View File

@ -7,10 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![warn(clippy::char_lit_as_u8)]
#![allow(unused_variables)]
fn main() {

View File

@ -1,7 +1,7 @@
error: casting character literal to u8. `char`s are 4 bytes wide in rust, so casting to u8 truncates them
--> $DIR/char_lit_as_u8.rs:17:13
--> $DIR/char_lit_as_u8.rs:13:13
|
17 | let c = 'a' as u8;
13 | let c = 'a' as u8;
| ^^^^^^^^^
|
= note: `-D clippy::char-lit-as-u8` implied by `-D warnings`

View File

@ -7,9 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)]
#![allow(clippy::if_same_then_else)]
@ -43,11 +40,11 @@ fn main() {
if x.is_ok() {
x = Err(());
x.unwrap(); // not unnecessary because of mutation of x
// it will always panic but the lint is not smart enough to see this (it only checks if conditions).
// it will always panic but the lint is not smart enough to see this (it only checks if conditions).
} else {
x = Ok(());
x.unwrap_err(); // not unnecessary because of mutation of x
// it will always panic but the lint is not smart enough to see this (it only checks if conditions).
// it will always panic but the lint is not smart enough to see this (it only checks if conditions).
}
}

View File

@ -1,312 +1,312 @@
error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`.
--> $DIR/checked_unwrap.rs:19:9
--> $DIR/checked_unwrap.rs:16:9
|
18 | if x.is_some() {
15 | if x.is_some() {
| ----------- the check is happening here
19 | x.unwrap(); // unnecessary
16 | x.unwrap(); // unnecessary
| ^^^^^^^^^^
|
note: lint level defined here
--> $DIR/checked_unwrap.rs:13:35
--> $DIR/checked_unwrap.rs:10:35
|
13 | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)]
10 | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
error: This call to `unwrap()` will always panic.
--> $DIR/checked_unwrap.rs:18:9
|
15 | if x.is_some() {
| ----------- because of this check
...
18 | x.unwrap(); // will panic
| ^^^^^^^^^^
|
note: lint level defined here
--> $DIR/checked_unwrap.rs:10:9
|
10 | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)]
| ^^^^^^^^^^^^^^^^^^^^^^^^
error: This call to `unwrap()` will always panic.
--> $DIR/checked_unwrap.rs:21:9
|
18 | if x.is_some() {
20 | if x.is_none() {
| ----------- because of this check
...
21 | x.unwrap(); // will panic
| ^^^^^^^^^^
|
note: lint level defined here
--> $DIR/checked_unwrap.rs:13:9
|
13 | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)]
| ^^^^^^^^^^^^^^^^^^^^^^^^
error: This call to `unwrap()` will always panic.
--> $DIR/checked_unwrap.rs:24:9
|
23 | if x.is_none() {
| ----------- because of this check
24 | x.unwrap(); // will panic
| ^^^^^^^^^^
error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`.
--> $DIR/checked_unwrap.rs:26:9
--> $DIR/checked_unwrap.rs:23:9
|
23 | if x.is_none() {
20 | if x.is_none() {
| ----------- the check is happening here
...
26 | x.unwrap(); // unnecessary
23 | x.unwrap(); // unnecessary
| ^^^^^^^^^^
error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`.
--> $DIR/checked_unwrap.rs:27:9
|
26 | if x.is_ok() {
| --------- the check is happening here
27 | x.unwrap(); // unnecessary
| ^^^^^^^^^^
error: This call to `unwrap_err()` will always panic.
--> $DIR/checked_unwrap.rs:28:9
|
26 | if x.is_ok() {
| --------- because of this check
27 | x.unwrap(); // unnecessary
28 | x.unwrap_err(); // will panic
| ^^^^^^^^^^^^^^
error: This call to `unwrap()` will always panic.
--> $DIR/checked_unwrap.rs:30:9
|
29 | if x.is_ok() {
| --------- the check is happening here
30 | x.unwrap(); // unnecessary
26 | if x.is_ok() {
| --------- because of this check
...
30 | x.unwrap(); // will panic
| ^^^^^^^^^^
error: This call to `unwrap_err()` will always panic.
error: You checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`.
--> $DIR/checked_unwrap.rs:31:9
|
29 | if x.is_ok() {
| --------- because of this check
30 | x.unwrap(); // unnecessary
31 | x.unwrap_err(); // will panic
26 | if x.is_ok() {
| --------- the check is happening here
...
31 | x.unwrap_err(); // unnecessary
| ^^^^^^^^^^^^^^
error: This call to `unwrap()` will always panic.
--> $DIR/checked_unwrap.rs:33:9
|
29 | if x.is_ok() {
| --------- because of this check
...
33 | x.unwrap(); // will panic
| ^^^^^^^^^^
error: You checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`.
--> $DIR/checked_unwrap.rs:34:9
|
29 | if x.is_ok() {
| --------- the check is happening here
...
34 | x.unwrap_err(); // unnecessary
33 | if x.is_err() {
| ---------- because of this check
34 | x.unwrap(); // will panic
| ^^^^^^^^^^
error: You checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`.
--> $DIR/checked_unwrap.rs:35:9
|
33 | if x.is_err() {
| ---------- the check is happening here
34 | x.unwrap(); // will panic
35 | x.unwrap_err(); // unnecessary
| ^^^^^^^^^^^^^^
error: This call to `unwrap()` will always panic.
error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`.
--> $DIR/checked_unwrap.rs:37:9
|
36 | if x.is_err() {
| ---------- because of this check
37 | x.unwrap(); // will panic
33 | if x.is_err() {
| ---------- the check is happening here
...
37 | x.unwrap(); // unnecessary
| ^^^^^^^^^^
error: You checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`.
error: This call to `unwrap_err()` will always panic.
--> $DIR/checked_unwrap.rs:38:9
|
36 | if x.is_err() {
| ---------- the check is happening here
37 | x.unwrap(); // will panic
38 | x.unwrap_err(); // unnecessary
| ^^^^^^^^^^^^^^
error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`.
--> $DIR/checked_unwrap.rs:40:9
|
36 | if x.is_err() {
| ---------- the check is happening here
...
40 | x.unwrap(); // unnecessary
| ^^^^^^^^^^
error: This call to `unwrap_err()` will always panic.
--> $DIR/checked_unwrap.rs:41:9
|
36 | if x.is_err() {
33 | if x.is_err() {
| ---------- because of this check
...
41 | x.unwrap_err(); // will panic
38 | x.unwrap_err(); // will panic
| ^^^^^^^^^^^^^^
error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`.
--> $DIR/checked_unwrap.rs:58:9
--> $DIR/checked_unwrap.rs:55:9
|
57 | if x.is_ok() && y.is_err() {
54 | if x.is_ok() && y.is_err() {
| --------- the check is happening here
58 | x.unwrap(); // unnecessary
55 | x.unwrap(); // unnecessary
| ^^^^^^^^^^
error: This call to `unwrap_err()` will always panic.
--> $DIR/checked_unwrap.rs:59:9
--> $DIR/checked_unwrap.rs:56:9
|
57 | if x.is_ok() && y.is_err() {
54 | if x.is_ok() && y.is_err() {
| --------- because of this check
58 | x.unwrap(); // unnecessary
59 | x.unwrap_err(); // will panic
55 | x.unwrap(); // unnecessary
56 | x.unwrap_err(); // will panic
| ^^^^^^^^^^^^^^
error: This call to `unwrap()` will always panic.
--> $DIR/checked_unwrap.rs:60:9
--> $DIR/checked_unwrap.rs:57:9
|
57 | if x.is_ok() && y.is_err() {
54 | if x.is_ok() && y.is_err() {
| ---------- because of this check
...
60 | y.unwrap(); // will panic
57 | y.unwrap(); // will panic
| ^^^^^^^^^^
error: You checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`.
--> $DIR/checked_unwrap.rs:61:9
--> $DIR/checked_unwrap.rs:58:9
|
57 | if x.is_ok() && y.is_err() {
54 | if x.is_ok() && y.is_err() {
| ---------- the check is happening here
...
61 | y.unwrap_err(); // unnecessary
58 | y.unwrap_err(); // unnecessary
| ^^^^^^^^^^^^^^
error: This call to `unwrap()` will always panic.
--> $DIR/checked_unwrap.rs:75:9
--> $DIR/checked_unwrap.rs:72:9
|
70 | if x.is_ok() || y.is_ok() {
67 | if x.is_ok() || y.is_ok() {
| --------- because of this check
...
75 | x.unwrap(); // will panic
72 | x.unwrap(); // will panic
| ^^^^^^^^^^
error: You checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`.
--> $DIR/checked_unwrap.rs:76:9
--> $DIR/checked_unwrap.rs:73:9
|
70 | if x.is_ok() || y.is_ok() {
67 | if x.is_ok() || y.is_ok() {
| --------- the check is happening here
...
76 | x.unwrap_err(); // unnecessary
73 | x.unwrap_err(); // unnecessary
| ^^^^^^^^^^^^^^
error: This call to `unwrap()` will always panic.
--> $DIR/checked_unwrap.rs:77:9
--> $DIR/checked_unwrap.rs:74:9
|
70 | if x.is_ok() || y.is_ok() {
67 | if x.is_ok() || y.is_ok() {
| --------- because of this check
...
77 | y.unwrap(); // will panic
74 | y.unwrap(); // will panic
| ^^^^^^^^^^
error: You checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`.
--> $DIR/checked_unwrap.rs:78:9
--> $DIR/checked_unwrap.rs:75:9
|
70 | if x.is_ok() || y.is_ok() {
67 | if x.is_ok() || y.is_ok() {
| --------- the check is happening here
...
78 | y.unwrap_err(); // unnecessary
75 | y.unwrap_err(); // unnecessary
| ^^^^^^^^^^^^^^
error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`.
--> $DIR/checked_unwrap.rs:79:9
|
78 | if x.is_ok() && !(y.is_ok() || z.is_err()) {
| --------- the check is happening here
79 | x.unwrap(); // unnecessary
| ^^^^^^^^^^
error: This call to `unwrap_err()` will always panic.
--> $DIR/checked_unwrap.rs:80:9
|
78 | if x.is_ok() && !(y.is_ok() || z.is_err()) {
| --------- because of this check
79 | x.unwrap(); // unnecessary
80 | x.unwrap_err(); // will panic
| ^^^^^^^^^^^^^^
error: This call to `unwrap()` will always panic.
--> $DIR/checked_unwrap.rs:81:9
|
78 | if x.is_ok() && !(y.is_ok() || z.is_err()) {
| --------- because of this check
...
81 | y.unwrap(); // will panic
| ^^^^^^^^^^
error: You checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`.
--> $DIR/checked_unwrap.rs:82:9
|
81 | if x.is_ok() && !(y.is_ok() || z.is_err()) {
| --------- the check is happening here
82 | x.unwrap(); // unnecessary
| ^^^^^^^^^^
78 | if x.is_ok() && !(y.is_ok() || z.is_err()) {
| --------- the check is happening here
...
82 | y.unwrap_err(); // unnecessary
| ^^^^^^^^^^^^^^
error: This call to `unwrap_err()` will always panic.
error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`.
--> $DIR/checked_unwrap.rs:83:9
|
81 | if x.is_ok() && !(y.is_ok() || z.is_err()) {
| --------- because of this check
82 | x.unwrap(); // unnecessary
83 | x.unwrap_err(); // will panic
| ^^^^^^^^^^^^^^
error: This call to `unwrap()` will always panic.
--> $DIR/checked_unwrap.rs:84:9
|
81 | if x.is_ok() && !(y.is_ok() || z.is_err()) {
| --------- because of this check
...
84 | y.unwrap(); // will panic
| ^^^^^^^^^^
error: You checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`.
--> $DIR/checked_unwrap.rs:85:9
|
81 | if x.is_ok() && !(y.is_ok() || z.is_err()) {
| --------- the check is happening here
...
85 | y.unwrap_err(); // unnecessary
| ^^^^^^^^^^^^^^
error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`.
--> $DIR/checked_unwrap.rs:86:9
|
81 | if x.is_ok() && !(y.is_ok() || z.is_err()) {
78 | if x.is_ok() && !(y.is_ok() || z.is_err()) {
| ---------- the check is happening here
...
86 | z.unwrap(); // unnecessary
83 | z.unwrap(); // unnecessary
| ^^^^^^^^^^
error: This call to `unwrap_err()` will always panic.
--> $DIR/checked_unwrap.rs:87:9
--> $DIR/checked_unwrap.rs:84:9
|
81 | if x.is_ok() && !(y.is_ok() || z.is_err()) {
78 | if x.is_ok() && !(y.is_ok() || z.is_err()) {
| ---------- because of this check
...
87 | z.unwrap_err(); // will panic
84 | z.unwrap_err(); // will panic
| ^^^^^^^^^^^^^^
error: This call to `unwrap()` will always panic.
--> $DIR/checked_unwrap.rs:95:9
--> $DIR/checked_unwrap.rs:92:9
|
89 | if x.is_ok() || !(y.is_ok() && z.is_err()) {
86 | if x.is_ok() || !(y.is_ok() && z.is_err()) {
| --------- because of this check
...
95 | x.unwrap(); // will panic
92 | x.unwrap(); // will panic
| ^^^^^^^^^^
error: You checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`.
--> $DIR/checked_unwrap.rs:96:9
--> $DIR/checked_unwrap.rs:93:9
|
89 | if x.is_ok() || !(y.is_ok() && z.is_err()) {
86 | if x.is_ok() || !(y.is_ok() && z.is_err()) {
| --------- the check is happening here
...
96 | x.unwrap_err(); // unnecessary
93 | x.unwrap_err(); // unnecessary
| ^^^^^^^^^^^^^^
error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`.
--> $DIR/checked_unwrap.rs:97:9
--> $DIR/checked_unwrap.rs:94:9
|
89 | if x.is_ok() || !(y.is_ok() && z.is_err()) {
86 | if x.is_ok() || !(y.is_ok() && z.is_err()) {
| --------- the check is happening here
...
97 | y.unwrap(); // unnecessary
94 | y.unwrap(); // unnecessary
| ^^^^^^^^^^
error: This call to `unwrap_err()` will always panic.
--> $DIR/checked_unwrap.rs:98:9
--> $DIR/checked_unwrap.rs:95:9
|
89 | if x.is_ok() || !(y.is_ok() && z.is_err()) {
86 | if x.is_ok() || !(y.is_ok() && z.is_err()) {
| --------- because of this check
...
98 | y.unwrap_err(); // will panic
95 | y.unwrap_err(); // will panic
| ^^^^^^^^^^^^^^
error: This call to `unwrap()` will always panic.
--> $DIR/checked_unwrap.rs:99:9
--> $DIR/checked_unwrap.rs:96:9
|
89 | if x.is_ok() || !(y.is_ok() && z.is_err()) {
86 | if x.is_ok() || !(y.is_ok() && z.is_err()) {
| ---------- because of this check
...
99 | z.unwrap(); // will panic
96 | z.unwrap(); // will panic
| ^^^^^^^^^^
error: You checked before that `unwrap_err()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`.
--> $DIR/checked_unwrap.rs:100:9
|
89 | if x.is_ok() || !(y.is_ok() && z.is_err()) {
| ---------- the check is happening here
--> $DIR/checked_unwrap.rs:97:9
|
86 | if x.is_ok() || !(y.is_ok() && z.is_err()) {
| ---------- the check is happening here
...
100 | z.unwrap_err(); // unnecessary
| ^^^^^^^^^^^^^^
97 | z.unwrap_err(); // unnecessary
| ^^^^^^^^^^^^^^
error: You checked before that `unwrap()` cannot fail. Instead of checking and unwrapping, it's better to use `if let` or `match`.
--> $DIR/checked_unwrap.rs:108:13
--> $DIR/checked_unwrap.rs:105:13
|
107 | if x.is_some() {
104 | if x.is_some() {
| ----------- the check is happening here
108 | x.unwrap(); // unnecessary
105 | x.unwrap(); // unnecessary
| ^^^^^^^^^^
error: This call to `unwrap()` will always panic.
--> $DIR/checked_unwrap.rs:110:13
--> $DIR/checked_unwrap.rs:107:13
|
107 | if x.is_some() {
104 | if x.is_some() {
| ----------- because of this check
...
110 | x.unwrap(); // will panic
107 | x.unwrap(); // will panic
| ^^^^^^^^^^
error: aborting due to 34 previous errors

View File

@ -7,9 +7,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::marker::PhantomData;
use std::fmt;
use std::marker::PhantomData;
pub struct Key<T> {
#[doc(hidden)]

View File

@ -7,9 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
pub fn dec_read_dec(i: &mut i32) -> i32 {
*i -= 1;
let ret = *i;

View File

@ -7,10 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[warn(clippy::cmp_nan)]
#[allow(clippy::float_cmp, clippy::no_effect, clippy::unnecessary_operation)]
fn main() {

View File

@ -1,75 +1,75 @@
error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
--> $DIR/cmp_nan.rs:18:5
--> $DIR/cmp_nan.rs:14:5
|
18 | x == std::f32::NAN;
14 | x == std::f32::NAN;
| ^^^^^^^^^^^^^^^^^^
|
= note: `-D clippy::cmp-nan` implied by `-D warnings`
error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
--> $DIR/cmp_nan.rs:19:5
--> $DIR/cmp_nan.rs:15:5
|
19 | x != std::f32::NAN;
15 | x != std::f32::NAN;
| ^^^^^^^^^^^^^^^^^^
error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
--> $DIR/cmp_nan.rs:20:5
--> $DIR/cmp_nan.rs:16:5
|
20 | x < std::f32::NAN;
16 | x < std::f32::NAN;
| ^^^^^^^^^^^^^^^^^
error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
--> $DIR/cmp_nan.rs:21:5
--> $DIR/cmp_nan.rs:17:5
|
21 | x > std::f32::NAN;
17 | x > std::f32::NAN;
| ^^^^^^^^^^^^^^^^^
error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
--> $DIR/cmp_nan.rs:18:5
|
18 | x <= std::f32::NAN;
| ^^^^^^^^^^^^^^^^^^
error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
--> $DIR/cmp_nan.rs:19:5
|
19 | x >= std::f32::NAN;
| ^^^^^^^^^^^^^^^^^^
error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
--> $DIR/cmp_nan.rs:22:5
|
22 | x <= std::f32::NAN;
22 | y == std::f64::NAN;
| ^^^^^^^^^^^^^^^^^^
error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
--> $DIR/cmp_nan.rs:23:5
|
23 | x >= std::f32::NAN;
23 | y != std::f64::NAN;
| ^^^^^^^^^^^^^^^^^^
error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
--> $DIR/cmp_nan.rs:24:5
|
24 | y < std::f64::NAN;
| ^^^^^^^^^^^^^^^^^
error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
--> $DIR/cmp_nan.rs:25:5
|
25 | y > std::f64::NAN;
| ^^^^^^^^^^^^^^^^^
error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
--> $DIR/cmp_nan.rs:26:5
|
26 | y == std::f64::NAN;
26 | y <= std::f64::NAN;
| ^^^^^^^^^^^^^^^^^^
error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
--> $DIR/cmp_nan.rs:27:5
|
27 | y != std::f64::NAN;
| ^^^^^^^^^^^^^^^^^^
error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
--> $DIR/cmp_nan.rs:28:5
|
28 | y < std::f64::NAN;
| ^^^^^^^^^^^^^^^^^
error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
--> $DIR/cmp_nan.rs:29:5
|
29 | y > std::f64::NAN;
| ^^^^^^^^^^^^^^^^^
error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
--> $DIR/cmp_nan.rs:30:5
|
30 | y <= std::f64::NAN;
| ^^^^^^^^^^^^^^^^^^
error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
--> $DIR/cmp_nan.rs:31:5
|
31 | y >= std::f64::NAN;
27 | y >= std::f64::NAN;
| ^^^^^^^^^^^^^^^^^^
error: aborting due to 12 previous errors

View File

@ -7,9 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![warn(clippy::cmp_null)]
#![allow(unused_mut)]
@ -17,12 +14,12 @@ use std::ptr;
fn main() {
let x = 0;
let p : *const usize = &x;
let p: *const usize = &x;
if p == ptr::null() {
println!("This is surprising!");
}
let mut y = 0;
let mut m : *mut usize = &mut y;
let mut m: *mut usize = &mut y;
if m == ptr::null_mut() {
println!("This is surprising, too!");
}

View File

@ -1,15 +1,15 @@
error: Comparing with null is better expressed by the .is_null() method
--> $DIR/cmp_null.rs:21:8
--> $DIR/cmp_null.rs:18:8
|
21 | if p == ptr::null() {
18 | if p == ptr::null() {
| ^^^^^^^^^^^^^^^^
|
= note: `-D clippy::cmp-null` implied by `-D warnings`
error: Comparing with null is better expressed by the .is_null() method
--> $DIR/cmp_null.rs:26:8
--> $DIR/cmp_null.rs:23:8
|
26 | if m == ptr::null_mut() {
23 | if m == ptr::null_mut() {
| ^^^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors

View File

@ -7,14 +7,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[warn(clippy::cmp_owned)]
#[allow(clippy::unnecessary_operation)]
fn main() {
fn with_to_string(x : &str) {
fn with_to_string(x: &str) {
x != "foo".to_string();
"foo".to_string() != x;

View File

@ -1,57 +1,57 @@
error: this creates an owned instance just for comparison
--> $DIR/cmp_owned.rs:18:14
--> $DIR/cmp_owned.rs:14:14
|
18 | x != "foo".to_string();
14 | x != "foo".to_string();
| ^^^^^^^^^^^^^^^^^ help: try: `"foo"`
|
= note: `-D clippy::cmp-owned` implied by `-D warnings`
error: this creates an owned instance just for comparison
--> $DIR/cmp_owned.rs:20:9
--> $DIR/cmp_owned.rs:16:9
|
20 | "foo".to_string() != x;
16 | "foo".to_string() != x;
| ^^^^^^^^^^^^^^^^^ help: try: `"foo"`
error: this creates an owned instance just for comparison
--> $DIR/cmp_owned.rs:27:10
--> $DIR/cmp_owned.rs:23:10
|
27 | x != "foo".to_owned();
23 | x != "foo".to_owned();
| ^^^^^^^^^^^^^^^^ help: try: `"foo"`
error: this creates an owned instance just for comparison
--> $DIR/cmp_owned.rs:29:10
--> $DIR/cmp_owned.rs:25:10
|
29 | x != String::from("foo");
25 | x != String::from("foo");
| ^^^^^^^^^^^^^^^^^^^ help: try: `"foo"`
error: this creates an owned instance just for comparison
--> $DIR/cmp_owned.rs:33:5
--> $DIR/cmp_owned.rs:29:5
|
33 | Foo.to_owned() == Foo;
29 | Foo.to_owned() == Foo;
| ^^^^^^^^^^^^^^ help: try: `Foo`
error: this creates an owned instance just for comparison
--> $DIR/cmp_owned.rs:35:30
--> $DIR/cmp_owned.rs:31:30
|
35 | "abc".chars().filter(|c| c.to_owned() != 'X');
31 | "abc".chars().filter(|c| c.to_owned() != 'X');
| ^^^^^^^^^^^^ help: try: `*c`
error: this creates an owned instance just for comparison
--> $DIR/cmp_owned.rs:42:5
--> $DIR/cmp_owned.rs:38:5
|
42 | y.to_owned() == *x;
38 | y.to_owned() == *x;
| ^^^^^^^^^^^^^^^^^^ try implementing the comparison without allocating
error: this creates an owned instance just for comparison
--> $DIR/cmp_owned.rs:47:5
--> $DIR/cmp_owned.rs:43:5
|
47 | y.to_owned() == **x;
43 | y.to_owned() == **x;
| ^^^^^^^^^^^^^^^^^^^ try implementing the comparison without allocating
error: this creates an owned instance just for comparison
--> $DIR/cmp_owned.rs:54:9
--> $DIR/cmp_owned.rs:50:9
|
54 | self.to_owned() == *other
50 | self.to_owned() == *other
| ^^^^^^^^^^^^^^^^^^^^^^^^^ try implementing the comparison without allocating
error: aborting due to 9 previous errors

View File

@ -7,7 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[rustfmt::skip]
#[warn(clippy::collapsible_if)]
fn main() {

View File

@ -1,259 +1,259 @@
error: this if statement can be collapsed
--> $DIR/collapsible_if.rs:16:5
--> $DIR/collapsible_if.rs:15:5
|
16 | / if x == "hello" {
17 | | if y == "world" {
18 | | println!("Hello world!");
19 | | }
20 | | }
15 | / if x == "hello" {
16 | | if y == "world" {
17 | | println!("Hello world!");
18 | | }
19 | | }
| |_____^
|
= note: `-D clippy::collapsible-if` implied by `-D warnings`
help: try
|
16 | if x == "hello" && y == "world" {
17 | println!("Hello world!");
18 | }
15 | if x == "hello" && y == "world" {
16 | println!("Hello world!");
17 | }
|
error: this if statement can be collapsed
--> $DIR/collapsible_if.rs:22:5
--> $DIR/collapsible_if.rs:21:5
|
22 | / if x == "hello" || x == "world" {
23 | | if y == "world" || y == "hello" {
24 | | println!("Hello world!");
25 | | }
26 | | }
21 | / if x == "hello" || x == "world" {
22 | | if y == "world" || y == "hello" {
23 | | println!("Hello world!");
24 | | }
25 | | }
| |_____^
help: try
|
22 | if (x == "hello" || x == "world") && (y == "world" || y == "hello") {
23 | println!("Hello world!");
24 | }
21 | if (x == "hello" || x == "world") && (y == "world" || y == "hello") {
22 | println!("Hello world!");
23 | }
|
error: this if statement can be collapsed
--> $DIR/collapsible_if.rs:28:5
--> $DIR/collapsible_if.rs:27:5
|
28 | / if x == "hello" && x == "world" {
29 | | if y == "world" || y == "hello" {
30 | | println!("Hello world!");
31 | | }
32 | | }
27 | / if x == "hello" && x == "world" {
28 | | if y == "world" || y == "hello" {
29 | | println!("Hello world!");
30 | | }
31 | | }
| |_____^
help: try
|
28 | if x == "hello" && x == "world" && (y == "world" || y == "hello") {
29 | println!("Hello world!");
30 | }
27 | if x == "hello" && x == "world" && (y == "world" || y == "hello") {
28 | println!("Hello world!");
29 | }
|
error: this if statement can be collapsed
--> $DIR/collapsible_if.rs:34:5
--> $DIR/collapsible_if.rs:33:5
|
34 | / if x == "hello" || x == "world" {
35 | | if y == "world" && y == "hello" {
36 | | println!("Hello world!");
37 | | }
38 | | }
33 | / if x == "hello" || x == "world" {
34 | | if y == "world" && y == "hello" {
35 | | println!("Hello world!");
36 | | }
37 | | }
| |_____^
help: try
|
34 | if (x == "hello" || x == "world") && y == "world" && y == "hello" {
35 | println!("Hello world!");
36 | }
33 | if (x == "hello" || x == "world") && y == "world" && y == "hello" {
34 | println!("Hello world!");
35 | }
|
error: this if statement can be collapsed
--> $DIR/collapsible_if.rs:40:5
--> $DIR/collapsible_if.rs:39:5
|
40 | / if x == "hello" && x == "world" {
41 | | if y == "world" && y == "hello" {
42 | | println!("Hello world!");
43 | | }
44 | | }
39 | / if x == "hello" && x == "world" {
40 | | if y == "world" && y == "hello" {
41 | | println!("Hello world!");
42 | | }
43 | | }
| |_____^
help: try
|
40 | if x == "hello" && x == "world" && y == "world" && y == "hello" {
41 | println!("Hello world!");
42 | }
39 | if x == "hello" && x == "world" && y == "world" && y == "hello" {
40 | println!("Hello world!");
41 | }
|
error: this if statement can be collapsed
--> $DIR/collapsible_if.rs:46:5
--> $DIR/collapsible_if.rs:45:5
|
46 | / if 42 == 1337 {
47 | | if 'a' != 'A' {
48 | | println!("world!")
49 | | }
50 | | }
45 | / if 42 == 1337 {
46 | | if 'a' != 'A' {
47 | | println!("world!")
48 | | }
49 | | }
| |_____^
help: try
|
46 | if 42 == 1337 && 'a' != 'A' {
47 | println!("world!")
48 | }
45 | if 42 == 1337 && 'a' != 'A' {
46 | println!("world!")
47 | }
|
error: this `else { if .. }` block can be collapsed
--> $DIR/collapsible_if.rs:55:12
--> $DIR/collapsible_if.rs:54:12
|
55 | } else {
54 | } else {
| ____________^
56 | | if y == "world" {
57 | | println!("world!")
58 | | }
59 | | }
55 | | if y == "world" {
56 | | println!("world!")
57 | | }
58 | | }
| |_____^
help: try
|
55 | } else if y == "world" {
56 | println!("world!")
57 | }
54 | } else if y == "world" {
55 | println!("world!")
56 | }
|
error: this `else { if .. }` block can be collapsed
--> $DIR/collapsible_if.rs:63:12
--> $DIR/collapsible_if.rs:62:12
|
63 | } else {
62 | } else {
| ____________^
64 | | if let Some(42) = Some(42) {
65 | | println!("world!")
66 | | }
67 | | }
63 | | if let Some(42) = Some(42) {
64 | | println!("world!")
65 | | }
66 | | }
| |_____^
help: try
|
63 | } else if let Some(42) = Some(42) {
64 | println!("world!")
65 | }
62 | } else if let Some(42) = Some(42) {
63 | println!("world!")
64 | }
|
error: this `else { if .. }` block can be collapsed
--> $DIR/collapsible_if.rs:71:12
--> $DIR/collapsible_if.rs:70:12
|
71 | } else {
70 | } else {
| ____________^
72 | | if y == "world" {
73 | | println!("world")
74 | | }
71 | | if y == "world" {
72 | | println!("world")
73 | | }
... |
77 | | }
78 | | }
76 | | }
77 | | }
| |_____^
help: try
|
71 | } else if y == "world" {
72 | println!("world")
73 | }
74 | else {
75 | println!("!")
76 | }
70 | } else if y == "world" {
71 | println!("world")
72 | }
73 | else {
74 | println!("!")
75 | }
|
error: this `else { if .. }` block can be collapsed
--> $DIR/collapsible_if.rs:82:12
--> $DIR/collapsible_if.rs:81:12
|
82 | } else {
81 | } else {
| ____________^
83 | | if let Some(42) = Some(42) {
84 | | println!("world")
85 | | }
82 | | if let Some(42) = Some(42) {
83 | | println!("world")
84 | | }
... |
88 | | }
89 | | }
87 | | }
88 | | }
| |_____^
help: try
|
82 | } else if let Some(42) = Some(42) {
83 | println!("world")
84 | }
85 | else {
86 | println!("!")
87 | }
81 | } else if let Some(42) = Some(42) {
82 | println!("world")
83 | }
84 | else {
85 | println!("!")
86 | }
|
error: this `else { if .. }` block can be collapsed
--> $DIR/collapsible_if.rs:93:12
--> $DIR/collapsible_if.rs:92:12
|
92 | } else {
| ____________^
93 | | if let Some(42) = Some(42) {
94 | | println!("world")
95 | | }
... |
98 | | }
99 | | }
| |_____^
help: try
|
92 | } else if let Some(42) = Some(42) {
93 | println!("world")
94 | }
95 | else {
96 | println!("!")
97 | }
|
error: this `else { if .. }` block can be collapsed
--> $DIR/collapsible_if.rs:103:12
|
93 | } else {
103 | } else {
| ____________^
94 | | if let Some(42) = Some(42) {
95 | | println!("world")
96 | | }
104 | | if x == "hello" {
105 | | println!("world")
106 | | }
... |
99 | | }
100 | | }
109 | | }
110 | | }
| |_____^
help: try
|
93 | } else if let Some(42) = Some(42) {
94 | println!("world")
95 | }
96 | else {
97 | println!("!")
98 | }
103 | } else if x == "hello" {
104 | println!("world")
105 | }
106 | else {
107 | println!("!")
108 | }
|
error: this `else { if .. }` block can be collapsed
--> $DIR/collapsible_if.rs:104:12
--> $DIR/collapsible_if.rs:114:12
|
104 | } else {
114 | } else {
| ____________^
105 | | if x == "hello" {
106 | | println!("world")
107 | | }
115 | | if let Some(42) = Some(42) {
116 | | println!("world")
117 | | }
... |
110 | | }
111 | | }
120 | | }
121 | | }
| |_____^
help: try
|
104 | } else if x == "hello" {
105 | println!("world")
106 | }
107 | else {
108 | println!("!")
109 | }
|
error: this `else { if .. }` block can be collapsed
--> $DIR/collapsible_if.rs:115:12
|
115 | } else {
| ____________^
116 | | if let Some(42) = Some(42) {
117 | | println!("world")
118 | | }
... |
121 | | }
122 | | }
| |_____^
help: try
|
115 | } else if let Some(42) = Some(42) {
116 | println!("world")
117 | }
118 | else {
119 | println!("!")
120 | }
114 | } else if let Some(42) = Some(42) {
115 | println!("world")
116 | }
117 | else {
118 | println!("!")
119 | }
|
error: this if statement can be collapsed
--> $DIR/collapsible_if.rs:174:5
--> $DIR/collapsible_if.rs:173:5
|
174 | / if x == "hello" {
175 | | if y == "world" { // Collapsible
176 | | println!("Hello world!");
177 | | }
178 | | }
173 | / if x == "hello" {
174 | | if y == "world" { // Collapsible
175 | | println!("Hello world!");
176 | | }
177 | | }
| |_____^
help: try
|
174 | if x == "hello" && y == "world" { // Collapsible
175 | println!("Hello world!");
176 | }
173 | if x == "hello" && y == "world" { // Collapsible
174 | println!("Hello world!");
175 | }
|
error: aborting due to 14 previous errors

View File

@ -7,9 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![warn(clippy::all)]
#![allow(unused, clippy::needless_pass_by_value)]
#![feature(associated_type_defaults)]
@ -32,19 +29,21 @@ enum E {
impl S {
const A: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0))));
fn impl_method(&self, p: Vec<Vec<Box<(u32, u32, u32, u32)>>>) { }
fn impl_method(&self, p: Vec<Vec<Box<(u32, u32, u32, u32)>>>) {}
}
trait T {
const A: Vec<Vec<Box<(u32, u32, u32, u32)>>>;
type B = Vec<Vec<Box<(u32, u32, u32, u32)>>>;
fn method(&self, p: Vec<Vec<Box<(u32, u32, u32, u32)>>>);
fn def_method(&self, p: Vec<Vec<Box<(u32, u32, u32, u32)>>>) { }
fn def_method(&self, p: Vec<Vec<Box<(u32, u32, u32, u32)>>>) {}
}
fn test1() -> Vec<Vec<Box<(u32, u32, u32, u32)>>> { vec![] }
fn test1() -> Vec<Vec<Box<(u32, u32, u32, u32)>>> {
vec![]
}
fn test2(_x: Vec<Vec<Box<(u32, u32, u32, u32)>>>) { }
fn test2(_x: Vec<Vec<Box<(u32, u32, u32, u32)>>>) {}
fn test3() {
let _y: Vec<Vec<Box<(u32, u32, u32, u32)>>> = vec![];
@ -67,5 +66,4 @@ struct D {
),
}
fn main() {
}
fn main() {}

View File

@ -1,93 +1,93 @@
error: very complex type used. Consider factoring parts into `type` definitions
--> $DIR/complex_types.rs:19:12
--> $DIR/complex_types.rs:16:12
|
19 | const CST: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0))));
16 | const CST: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0))));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `-D clippy::type-complexity` implied by `-D warnings`
error: very complex type used. Consider factoring parts into `type` definitions
--> $DIR/complex_types.rs:20:12
--> $DIR/complex_types.rs:17:12
|
20 | static ST: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0))));
17 | static ST: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0))));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: very complex type used. Consider factoring parts into `type` definitions
--> $DIR/complex_types.rs:23:8
--> $DIR/complex_types.rs:20:8
|
23 | f: Vec<Vec<Box<(u32, u32, u32, u32)>>>,
20 | f: Vec<Vec<Box<(u32, u32, u32, u32)>>>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: very complex type used. Consider factoring parts into `type` definitions
--> $DIR/complex_types.rs:23:11
|
23 | struct TS(Vec<Vec<Box<(u32, u32, u32, u32)>>>);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: very complex type used. Consider factoring parts into `type` definitions
--> $DIR/complex_types.rs:26:11
|
26 | struct TS(Vec<Vec<Box<(u32, u32, u32, u32)>>>);
26 | Tuple(Vec<Vec<Box<(u32, u32, u32, u32)>>>),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: very complex type used. Consider factoring parts into `type` definitions
--> $DIR/complex_types.rs:29:11
--> $DIR/complex_types.rs:27:17
|
29 | Tuple(Vec<Vec<Box<(u32, u32, u32, u32)>>>),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: very complex type used. Consider factoring parts into `type` definitions
--> $DIR/complex_types.rs:30:17
|
30 | Struct { f: Vec<Vec<Box<(u32, u32, u32, u32)>>> },
27 | Struct { f: Vec<Vec<Box<(u32, u32, u32, u32)>>> },
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: very complex type used. Consider factoring parts into `type` definitions
--> $DIR/complex_types.rs:34:14
--> $DIR/complex_types.rs:31:14
|
34 | const A: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0))));
31 | const A: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0))));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: very complex type used. Consider factoring parts into `type` definitions
--> $DIR/complex_types.rs:35:30
--> $DIR/complex_types.rs:32:30
|
35 | fn impl_method(&self, p: Vec<Vec<Box<(u32, u32, u32, u32)>>>) { }
32 | fn impl_method(&self, p: Vec<Vec<Box<(u32, u32, u32, u32)>>>) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: very complex type used. Consider factoring parts into `type` definitions
--> $DIR/complex_types.rs:39:14
--> $DIR/complex_types.rs:36:14
|
39 | const A: Vec<Vec<Box<(u32, u32, u32, u32)>>>;
36 | const A: Vec<Vec<Box<(u32, u32, u32, u32)>>>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: very complex type used. Consider factoring parts into `type` definitions
--> $DIR/complex_types.rs:40:14
--> $DIR/complex_types.rs:37:14
|
40 | type B = Vec<Vec<Box<(u32, u32, u32, u32)>>>;
37 | type B = Vec<Vec<Box<(u32, u32, u32, u32)>>>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: very complex type used. Consider factoring parts into `type` definitions
--> $DIR/complex_types.rs:41:25
--> $DIR/complex_types.rs:38:25
|
41 | fn method(&self, p: Vec<Vec<Box<(u32, u32, u32, u32)>>>);
38 | fn method(&self, p: Vec<Vec<Box<(u32, u32, u32, u32)>>>);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: very complex type used. Consider factoring parts into `type` definitions
--> $DIR/complex_types.rs:42:29
--> $DIR/complex_types.rs:39:29
|
42 | fn def_method(&self, p: Vec<Vec<Box<(u32, u32, u32, u32)>>>) { }
39 | fn def_method(&self, p: Vec<Vec<Box<(u32, u32, u32, u32)>>>) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: very complex type used. Consider factoring parts into `type` definitions
--> $DIR/complex_types.rs:45:15
--> $DIR/complex_types.rs:42:15
|
45 | fn test1() -> Vec<Vec<Box<(u32, u32, u32, u32)>>> { vec![] }
42 | fn test1() -> Vec<Vec<Box<(u32, u32, u32, u32)>>> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: very complex type used. Consider factoring parts into `type` definitions
--> $DIR/complex_types.rs:47:14
--> $DIR/complex_types.rs:46:14
|
47 | fn test2(_x: Vec<Vec<Box<(u32, u32, u32, u32)>>>) { }
46 | fn test2(_x: Vec<Vec<Box<(u32, u32, u32, u32)>>>) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: very complex type used. Consider factoring parts into `type` definitions
--> $DIR/complex_types.rs:50:13
--> $DIR/complex_types.rs:49:13
|
50 | let _y: Vec<Vec<Box<(u32, u32, u32, u32)>>> = vec![];
49 | let _y: Vec<Vec<Box<(u32, u32, u32, u32)>>> = vec![];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 15 previous errors

View File

@ -7,7 +7,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[derive(Debug)]
struct Foo {}

Some files were not shown because too many files have changed in this diff Show More