mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-27 07:00:55 +00:00
rustfmt tests
This commit is contained in:
parent
1218145bc9
commit
435299be30
252 changed files with 1881 additions and 1983 deletions
|
@ -7,7 +7,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
pub trait A {}
|
pub trait A {}
|
||||||
|
|
||||||
macro_rules! __implicit_hasher_test_macro {
|
macro_rules! __implicit_hasher_test_macro {
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
pub trait Trait {
|
pub trait Trait {
|
||||||
const CONSTANT: u8;
|
const CONSTANT: u8;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
enum Baz {
|
enum Baz {
|
||||||
One,
|
One,
|
||||||
|
@ -19,7 +18,7 @@ struct Test {
|
||||||
b: Baz,
|
b: Baz,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() { }
|
fn main() {}
|
||||||
|
|
||||||
pub fn foo() {
|
pub fn foo() {
|
||||||
use Baz::*;
|
use Baz::*;
|
||||||
|
@ -27,10 +26,7 @@ pub fn foo() {
|
||||||
|
|
||||||
match x {
|
match x {
|
||||||
Test { t: Some(_), b: One } => unreachable!(),
|
Test { t: Some(_), b: One } => unreachable!(),
|
||||||
Test {
|
Test { t: Some(42), b: Two } => unreachable!(),
|
||||||
t: Some(42),
|
|
||||||
b: Two,
|
|
||||||
} => unreachable!(),
|
|
||||||
Test { t: None, .. } => unreachable!(),
|
Test { t: None, .. } => unreachable!(),
|
||||||
Test { .. } => unreachable!(),
|
Test { .. } => unreachable!(),
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,12 +7,9 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#![deny(clippy::all)]
|
#![deny(clippy::all)]
|
||||||
#![allow(unused_imports)]
|
#![allow(unused_imports)]
|
||||||
|
|
||||||
use std::*;
|
use std::*;
|
||||||
|
|
||||||
fn main() { }
|
fn main() {}
|
||||||
|
|
|
@ -7,17 +7,14 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#![allow(clippy::all)]
|
#![allow(clippy::all)]
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
match 1 {
|
match 1 {
|
||||||
1 => {}
|
1 => {},
|
||||||
2 => {
|
2 => {
|
||||||
[0; 1];
|
[0; 1];
|
||||||
}
|
},
|
||||||
_ => {}
|
_ => {},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,20 +7,28 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
#![allow(dead_code, unused_variables)]
|
#![allow(dead_code, unused_variables)]
|
||||||
|
|
||||||
/// Should not trigger an ICE in `SpanlessEq` / `consts::constant`
|
/// Should not trigger an ICE in `SpanlessEq` / `consts::constant`
|
||||||
///
|
///
|
||||||
/// Issue: https://github.com/rust-lang/rust-clippy/issues/1782
|
/// Issue: https://github.com/rust-lang/rust-clippy/issues/1782
|
||||||
|
|
||||||
use std::{mem, ptr};
|
use std::{mem, ptr};
|
||||||
|
|
||||||
fn spanless_eq_ice() {
|
fn spanless_eq_ice() {
|
||||||
let txt = "something";
|
let txt = "something";
|
||||||
match txt {
|
match txt {
|
||||||
"something" => unsafe { ptr::write(ptr::null_mut() as *mut u32, mem::transmute::<[u8; 4], _>([0, 0, 0, 255])) },
|
"something" => unsafe {
|
||||||
_ => unsafe { ptr::write(ptr::null_mut() as *mut u32, mem::transmute::<[u8; 4], _>([13, 246, 24, 255])) },
|
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]),
|
||||||
|
)
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,12 +7,9 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#![allow(clippy::all)]
|
#![allow(clippy::all)]
|
||||||
|
|
||||||
fn main() { }
|
fn main() {}
|
||||||
|
|
||||||
pub trait Convert {
|
pub trait Convert {
|
||||||
type Action: From<*const f64>;
|
type Action: From<*const f64>;
|
||||||
|
|
|
@ -7,9 +7,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#![allow(dead_code, clippy::char_lit_as_u8, clippy::needless_bool)]
|
#![allow(dead_code, clippy::char_lit_as_u8, clippy::needless_bool)]
|
||||||
|
|
||||||
/// Should not trigger an ICE in `SpanlessHash` / `consts::constant`
|
/// Should not trigger an ICE in `SpanlessHash` / `consts::constant`
|
||||||
|
@ -20,15 +17,17 @@ fn f(s: &[u8]) -> bool {
|
||||||
let t = s[0] as char;
|
let t = s[0] as char;
|
||||||
|
|
||||||
match t {
|
match t {
|
||||||
'E' | 'W' => {}
|
'E' | 'W' => {},
|
||||||
'T' => if s[0..4] != ['0' as u8; 4] {
|
'T' => {
|
||||||
return false;
|
if s[0..4] != ['0' as u8; 4] {
|
||||||
} else {
|
return false;
|
||||||
return true;
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
_ => {
|
_ => {
|
||||||
return false;
|
return false;
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
#![allow(dead_code, unused_variables)]
|
#![allow(dead_code, unused_variables)]
|
||||||
|
|
||||||
/// Should not trigger an ICE in `SpanlessHash` / `consts::constant`
|
/// Should not trigger an ICE in `SpanlessHash` / `consts::constant`
|
||||||
|
@ -21,7 +20,7 @@ fn spanless_hash_ice() {
|
||||||
match txt {
|
match txt {
|
||||||
"something" => {
|
"something" => {
|
||||||
let mut headers = [empty_header; 1];
|
let mut headers = [empty_header; 1];
|
||||||
}
|
},
|
||||||
"" => (),
|
"" => (),
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
pub fn f(new: fn()) {
|
pub fn f(new: fn()) {
|
||||||
new();
|
new();
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,11 +7,12 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
#![allow(
|
||||||
|
unused_variables,
|
||||||
|
clippy::blacklisted_name,
|
||||||
#![allow(unused_variables, clippy::blacklisted_name,
|
clippy::needless_pass_by_value,
|
||||||
clippy::needless_pass_by_value, dead_code)]
|
dead_code
|
||||||
|
)]
|
||||||
|
|
||||||
// This should not compile-fail with:
|
// This should not compile-fail with:
|
||||||
//
|
//
|
||||||
|
|
|
@ -7,9 +7,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
|
||||||
// See https://github.com/rust-lang/rust-clippy/issues/2774
|
// 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
|
// This should not cause a 'cannot relate bound region' ICE
|
||||||
pub fn add_barfoos_to_foos<'a>(bars: &HashSet<&'a Bar>) {
|
pub fn add_barfoos_to_foos<'a>(bars: &HashSet<&'a Bar>) {
|
||||||
let mut foos = HashSet::new();
|
let mut foos = HashSet::new();
|
||||||
foos.extend(
|
foos.extend(bars.iter().map(|b| &b.foo));
|
||||||
bars.iter().map(|b| &b.foo)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::implicit_hasher)]
|
#[allow(clippy::implicit_hasher)]
|
||||||
// Also this should not cause a 'cannot relate bound region' ICE
|
// Also this should not cause a 'cannot relate bound region' ICE
|
||||||
pub fn add_barfoos_to_foos2(bars: &HashSet<&Bar>) {
|
pub fn add_barfoos_to_foos2(bars: &HashSet<&Bar>) {
|
||||||
let mut foos = HashSet::new();
|
let mut foos = HashSet::new();
|
||||||
foos.extend(
|
foos.extend(bars.iter().map(|b| &b.foo));
|
||||||
bars.iter().map(|b| &b.foo)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -7,10 +7,9 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
struct Ice {
|
struct Ice {
|
||||||
size: String
|
size: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> From<String> for Ice {
|
impl<'a> From<String> for Ice {
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct HashMap<V, S> {
|
pub struct HashMap<V, S> {
|
||||||
hash_builder: S,
|
hash_builder: S,
|
||||||
|
@ -17,7 +16,7 @@ pub struct HashMap<V, S> {
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct RawTable<V> {
|
pub struct RawTable<V> {
|
||||||
size: usize,
|
size: usize,
|
||||||
val: V
|
val: V,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
|
@ -7,9 +7,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#![deny(clippy::all)]
|
#![deny(clippy::all)]
|
||||||
|
|
||||||
fn core() {}
|
fn core() {}
|
||||||
|
|
|
@ -7,9 +7,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#![deny(clippy::all)]
|
#![deny(clippy::all)]
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
|
|
|
@ -7,9 +7,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#![deny(clippy::if_same_then_else)]
|
#![deny(clippy::if_same_then_else)]
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
pub trait FooMap {
|
pub trait FooMap {
|
||||||
fn map<B, F: Fn() -> B>(&self, f: F) -> B;
|
fn map<B, F: Fn() -> B>(&self, f: F) -> B;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,14 +7,23 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
#![allow(warnings)]
|
#![allow(warnings)]
|
||||||
|
|
||||||
// this should compile in a reasonable amount of time
|
// this should compile in a reasonable amount of time
|
||||||
fn rust_type_id(name: &str) {
|
fn rust_type_id(name: &str) {
|
||||||
if "bool" == &name[..] || "uint" == &name[..] || "u8" == &name[..] || "u16" == &name[..] || "u32" == &name[..]
|
if "bool" == &name[..]
|
||||||
|| "f32" == &name[..] || "f64" == &name[..] || "i8" == &name[..] || "i16" == &name[..]
|
|| "uint" == &name[..]
|
||||||
|| "i32" == &name[..] || "i64" == &name[..] || "Self" == &name[..] || "str" == &name[..]
|
|| "u8" == &name[..]
|
||||||
|
|| "u16" == &name[..]
|
||||||
|
|| "u32" == &name[..]
|
||||||
|
|| "f32" == &name[..]
|
||||||
|
|| "f64" == &name[..]
|
||||||
|
|| "i8" == &name[..]
|
||||||
|
|| "i16" == &name[..]
|
||||||
|
|| "i32" == &name[..]
|
||||||
|
|| "i64" == &name[..]
|
||||||
|
|| "Self" == &name[..]
|
||||||
|
|| "str" == &name[..]
|
||||||
{
|
{
|
||||||
unreachable!();
|
unreachable!();
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|
||||||
/// Issue: https://github.com/rust-lang/rust-clippy/issues/2596
|
/// Issue: https://github.com/rust-lang/rust-clippy/issues/2596
|
||||||
|
|
|
@ -7,9 +7,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#![deny(clippy::match_same_arms)]
|
#![deny(clippy::match_same_arms)]
|
||||||
|
|
||||||
const PRICE_OF_SWEETS: u32 = 5;
|
const PRICE_OF_SWEETS: u32 = 5;
|
||||||
|
@ -21,7 +18,7 @@ pub fn price(thing: &str) -> u32 {
|
||||||
"rolo" => PRICE_OF_SWEETS,
|
"rolo" => PRICE_OF_SWEETS,
|
||||||
"advice" => PRICE_OF_KINDNESS,
|
"advice" => PRICE_OF_KINDNESS,
|
||||||
"juice" => PRICE_OF_DRINKS,
|
"juice" => PRICE_OF_DRINKS,
|
||||||
_ => panic!()
|
_ => panic!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,9 +7,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#![deny(clippy::mut_mut, clippy::zero_ptr, clippy::cmp_nan)]
|
#![deny(clippy::mut_mut, clippy::zero_ptr, clippy::cmp_nan)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|
||||||
|
|
|
@ -7,16 +7,10 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#[deny(clippy::all)]
|
#[deny(clippy::all)]
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
Type(
|
Type(&'static str),
|
||||||
&'static str,
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -7,9 +7,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#![deny(clippy::needless_lifetimes)]
|
#![deny(clippy::needless_lifetimes)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate clippy_mini_macro_test;
|
extern crate clippy_mini_macro_test;
|
||||||
|
|
||||||
|
@ -17,6 +16,5 @@ fn main() {
|
||||||
println!("{:?}", x);
|
println!("{:?}", x);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[derive(ClippyMiniMacroTest, Debug)]
|
#[derive(ClippyMiniMacroTest, Debug)]
|
||||||
struct Foo;
|
struct Foo;
|
|
@ -7,9 +7,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#![allow(clippy::blacklisted_name)]
|
#![allow(clippy::blacklisted_name)]
|
||||||
|
|
||||||
pub fn foo(bar: *const u8) {
|
pub fn foo(bar: *const u8) {
|
||||||
|
|
|
@ -7,11 +7,12 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
#[deny(warnings)]
|
#[deny(warnings)]
|
||||||
fn cfg_return() -> i32 {
|
fn cfg_return() -> i32 {
|
||||||
#[cfg(unix)] return 1;
|
#[cfg(unix)]
|
||||||
#[cfg(not(unix))] return 2;
|
return 1;
|
||||||
|
#[cfg(not(unix))]
|
||||||
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deny(warnings)]
|
#[deny(warnings)]
|
||||||
|
|
|
@ -7,9 +7,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#![warn(clippy::single_match_else)]
|
#![warn(clippy::single_match_else)]
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
|
@ -7,9 +7,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#![allow(clippy::useless_attribute)] //issue #2910
|
#![allow(clippy::useless_attribute)] //issue #2910
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
|
|
@ -7,5 +7,4 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -7,10 +7,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
// error-pattern: error reading Clippy's configuration file
|
// error-pattern: error reading Clippy's configuration file
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
// error-pattern: error reading Clippy's configuration file: `blacklisted-names` is expected to be a
|
||||||
// error-pattern: error reading Clippy's configuration file: `blacklisted-names` is expected to be a `Vec < String >` but is a `integer`
|
// `Vec < String >` but is a `integer`
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -7,10 +7,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
#![allow(clippy::single_match)]
|
#![allow(clippy::single_match)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
|
|
|
@ -7,8 +7,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#![allow(clippy::many_single_char_names)]
|
#![allow(clippy::many_single_char_names)]
|
||||||
|
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
|
@ -17,11 +15,9 @@ struct Foo(u8);
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
struct Bar(u32);
|
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() {
|
fn main() {
|
||||||
let (mut a, b, c, d, x, y) = (0, 0, Bar(0), 0, 0, Foo(0));
|
let (mut a, b, c, d, x, y) = (0, 0, Bar(0), 0, 0, Foo(0));
|
||||||
|
|
|
@ -7,10 +7,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
// error-pattern: error reading Clippy's configuration file: unknown key `foobar`
|
// error-pattern: error reading Clippy's configuration file: unknown key `foobar`
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -8,7 +8,13 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
#![warn(clippy::absurd_extreme_comparisons)]
|
#![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]
|
#[rustfmt::skip]
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
|
@ -7,10 +7,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#[warn(clippy::approx_constant)]
|
#[warn(clippy::approx_constant)]
|
||||||
#[allow(unused, clippy::shadow_unrelated, clippy::similar_names, clippy::unreadable_literal)]
|
#[allow(unused, clippy::shadow_unrelated, clippy::similar_names, clippy::unreadable_literal)]
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
|
@ -7,9 +7,14 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
#![warn(clippy::integer_arithmetic, clippy::float_arithmetic)]
|
#![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]
|
#[rustfmt::skip]
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
|
@ -7,9 +7,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#[allow(dead_code, unused_assignments)]
|
#[allow(dead_code, unused_assignments)]
|
||||||
#[warn(clippy::assign_op_pattern)]
|
#[warn(clippy::assign_op_pattern)]
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
|
@ -7,10 +7,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#[allow(unused_assignments)]
|
#[allow(unused_assignments)]
|
||||||
#[warn(clippy::misrefactored_assign_op, clippy::assign_op_pattern)]
|
#[warn(clippy::misrefactored_assign_op, clippy::assign_op_pattern)]
|
||||||
fn main() {
|
fn main() {
|
||||||
|
@ -65,6 +61,4 @@ fn cow_add_assign() {
|
||||||
// this should not as cow<str> Add is not commutative
|
// this should not as cow<str> Add is not commutative
|
||||||
buf = cows + buf;
|
buf = cows + buf;
|
||||||
println!("{}", buf);
|
println!("{}", buf);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,10 +7,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#![warn(clippy::inline_always, clippy::deprecated_semver)]
|
#![warn(clippy::inline_always, clippy::deprecated_semver)]
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
|
@ -30,22 +26,27 @@ fn false_positive_stmt() {
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn empty_and_false_positive_stmt() {
|
fn empty_and_false_positive_stmt() {
|
||||||
;
|
|
||||||
unreachable!();
|
unreachable!();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[deprecated(since = "forever")]
|
#[deprecated(since = "forever")]
|
||||||
pub const SOME_CONST : u8 = 42;
|
pub const SOME_CONST: u8 = 42;
|
||||||
|
|
||||||
#[deprecated(since = "1")]
|
#[deprecated(since = "1")]
|
||||||
pub const ANOTHER_CONST : u8 = 23;
|
pub const ANOTHER_CONST: u8 = 23;
|
||||||
|
|
||||||
#[deprecated(since = "0.1.1")]
|
#[deprecated(since = "0.1.1")]
|
||||||
pub const YET_ANOTHER_CONST : u8 = 0;
|
pub const YET_ANOTHER_CONST: u8 = 0;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
test_attr_lint();
|
test_attr_lint();
|
||||||
if false { false_positive_expr() }
|
if false {
|
||||||
if false { false_positive_stmt() }
|
false_positive_expr()
|
||||||
if false { empty_and_false_positive_stmt() }
|
}
|
||||||
|
if false {
|
||||||
|
false_positive_stmt()
|
||||||
|
}
|
||||||
|
if false {
|
||||||
|
empty_and_false_positive_stmt()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,11 +7,7 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
||||||
#[clippy::author]
|
#[clippy::author]
|
||||||
let x: char = 0x45 as char;
|
let x: char = 0x45 as char;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,9 +7,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
#[clippy::author]
|
#[clippy::author]
|
||||||
let _ = ::std::cmp::min(3, 4);
|
let _ = ::std::cmp::min(3, 4);
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
#![feature(stmt_expr_attributes)]
|
#![feature(stmt_expr_attributes)]
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
#![feature(tool_attributes)]
|
#![feature(tool_attributes)]
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
|
@ -7,15 +7,16 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// 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)]
|
#[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() {
|
fn main() {
|
||||||
let x = 5;
|
let x = 5;
|
||||||
|
|
||||||
|
|
|
@ -7,11 +7,14 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
#![allow(
|
||||||
|
dead_code,
|
||||||
|
clippy::similar_names,
|
||||||
|
clippy::single_match,
|
||||||
#![allow(dead_code, clippy::similar_names, clippy::single_match, clippy::toplevel_ref_arg, unused_mut, unused_variables)]
|
clippy::toplevel_ref_arg,
|
||||||
|
unused_mut,
|
||||||
|
unused_variables
|
||||||
|
)]
|
||||||
#![warn(clippy::blacklisted_name)]
|
#![warn(clippy::blacklisted_name)]
|
||||||
|
|
||||||
fn test(foo: ()) {}
|
fn test(foo: ()) {}
|
||||||
|
|
|
@ -7,33 +7,28 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#![warn(clippy::block_in_if_condition_expr)]
|
#![warn(clippy::block_in_if_condition_expr)]
|
||||||
#![warn(clippy::block_in_if_condition_stmt)]
|
#![warn(clippy::block_in_if_condition_stmt)]
|
||||||
#![allow(unused, clippy::let_and_return)]
|
#![allow(unused, clippy::let_and_return)]
|
||||||
#![warn(clippy::nonminimal_bool)]
|
#![warn(clippy::nonminimal_bool)]
|
||||||
|
|
||||||
|
|
||||||
macro_rules! blocky {
|
macro_rules! blocky {
|
||||||
() => {{true}}
|
() => {{
|
||||||
|
true
|
||||||
|
}};
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! blocky_too {
|
macro_rules! blocky_too {
|
||||||
() => {{
|
() => {{
|
||||||
let r = true;
|
let r = true;
|
||||||
r
|
r
|
||||||
}}
|
}};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn macro_if() {
|
fn macro_if() {
|
||||||
if blocky!() {
|
if blocky!() {}
|
||||||
}
|
|
||||||
|
|
||||||
if blocky_too!() {
|
if blocky_too!() {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn condition_has_block() -> i32 {
|
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)
|
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
|
// 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
|
// inside a closure that the condition is using. same principle applies. add some extra
|
||||||
// expressions to make sure linter isn't confused by them.
|
// 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 {
|
fn condition_is_normal() -> i32 {
|
||||||
|
@ -82,9 +90,7 @@ fn condition_is_normal() -> i32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn closure_without_block() {
|
fn closure_without_block() {
|
||||||
if predicate(|x| x == 3, 6) {
|
if predicate(|x| x == 3, 6) {}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn condition_is_unsafe_block() {
|
fn condition_is_unsafe_block() {
|
||||||
|
@ -96,8 +102,7 @@ fn condition_is_unsafe_block() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {}
|
||||||
}
|
|
||||||
|
|
||||||
fn macro_in_closure() {
|
fn macro_in_closure() {
|
||||||
let option = Some(true);
|
let option = Some(true);
|
||||||
|
|
|
@ -7,19 +7,47 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#[warn(clippy::bool_comparison)]
|
#[warn(clippy::bool_comparison)]
|
||||||
fn main() {
|
fn main() {
|
||||||
let x = true;
|
let x = true;
|
||||||
if x == true { "yes" } else { "no" };
|
if x == true {
|
||||||
if x == false { "yes" } else { "no" };
|
"yes"
|
||||||
if true == x { "yes" } else { "no" };
|
} else {
|
||||||
if false == x { "yes" } else { "no" };
|
"no"
|
||||||
if x != true { "yes" } else { "no" };
|
};
|
||||||
if x != false { "yes" } else { "no" };
|
if x == false {
|
||||||
if true != x { "yes" } else { "no" };
|
"yes"
|
||||||
if false != x { "yes" } else { "no" };
|
} 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"
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,9 +7,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#![warn(clippy::nonminimal_bool, clippy::logic_bug)]
|
#![warn(clippy::nonminimal_bool, clippy::logic_bug)]
|
||||||
|
|
||||||
#[allow(unused, clippy::many_single_char_names)]
|
#[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
|
// 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
|
// clippy::nonminimal_bool should only check the built-in Result and Some type, not
|
||||||
// any other types like the following.
|
// any other types like the following.
|
||||||
enum CustomResultOk<E> { Ok, Err(E) }
|
enum CustomResultOk<E> {
|
||||||
enum CustomResultErr<E> { Ok, Err(E) }
|
Ok,
|
||||||
enum CustomSomeSome<T> { Some(T), None }
|
Err(E),
|
||||||
enum CustomSomeNone<T> { Some(T), None }
|
}
|
||||||
|
enum CustomResultErr<E> {
|
||||||
|
Ok,
|
||||||
|
Err(E),
|
||||||
|
}
|
||||||
|
enum CustomSomeSome<T> {
|
||||||
|
Some(T),
|
||||||
|
None,
|
||||||
|
}
|
||||||
|
enum CustomSomeNone<T> {
|
||||||
|
Some(T),
|
||||||
|
None,
|
||||||
|
}
|
||||||
|
|
||||||
impl<E> CustomResultOk<E> {
|
impl<E> CustomResultOk<E> {
|
||||||
pub fn is_ok(&self) -> bool { true }
|
pub fn is_ok(&self) -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<E> CustomResultErr<E> {
|
impl<E> CustomResultErr<E> {
|
||||||
pub fn is_err(&self) -> bool { true }
|
pub fn is_err(&self) -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> CustomSomeSome<T> {
|
impl<T> CustomSomeSome<T> {
|
||||||
pub fn is_some(&self) -> bool { true }
|
pub fn is_some(&self) -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> CustomSomeNone<T> {
|
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() {
|
fn dont_warn_for_custom_methods_with_negation() {
|
||||||
let res = CustomResultOk::Err("Error");
|
let res = CustomResultOk::Err("Error");
|
||||||
// Should not warn and suggest 'is_err()' because the type does not
|
// Should not warn and suggest 'is_err()' because the type does not
|
||||||
// implement is_err().
|
// implement is_err().
|
||||||
if !res.is_ok() { }
|
if !res.is_ok() {}
|
||||||
|
|
||||||
let res = CustomResultErr::Err("Error");
|
let res = CustomResultErr::Err("Error");
|
||||||
// Should not warn and suggest 'is_ok()' because the type does not
|
// Should not warn and suggest 'is_ok()' because the type does not
|
||||||
// implement is_ok().
|
// implement is_ok().
|
||||||
if !res.is_err() { }
|
if !res.is_err() {}
|
||||||
|
|
||||||
let res = CustomSomeSome::Some("thing");
|
let res = CustomSomeSome::Some("thing");
|
||||||
// Should not warn and suggest 'is_none()' because the type does not
|
// Should not warn and suggest 'is_none()' because the type does not
|
||||||
// implement is_none().
|
// implement is_none().
|
||||||
if !res.is_some() { }
|
if !res.is_some() {}
|
||||||
|
|
||||||
let res = CustomSomeNone::Some("thing");
|
let res = CustomSomeNone::Some("thing");
|
||||||
// Should not warn and suggest 'is_some()' because the type does not
|
// Should not warn and suggest 'is_some()' because the type does not
|
||||||
// implement is_some().
|
// implement is_some().
|
||||||
if !res.is_none() { }
|
if !res.is_none() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only Built-in Result and Some types should suggest the negated alternative
|
// Only Built-in Result and Some types should suggest the negated alternative
|
||||||
fn warn_for_built_in_methods_with_negation() {
|
fn warn_for_built_in_methods_with_negation() {
|
||||||
let res: Result<usize, usize> = Ok(1);
|
let res: Result<usize, usize> = Ok(1);
|
||||||
if !res.is_ok() { }
|
if !res.is_ok() {}
|
||||||
if !res.is_err() { }
|
if !res.is_err() {}
|
||||||
|
|
||||||
let res = Some(1);
|
let res = Some(1);
|
||||||
if !res.is_some() { }
|
if !res.is_some() {}
|
||||||
if !res.is_none() { }
|
if !res.is_none() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::neg_cmp_op_on_partial_ord)]
|
#[allow(clippy::neg_cmp_op_on_partial_ord)]
|
||||||
|
|
|
@ -7,10 +7,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#![deny(clippy::borrowed_box)]
|
#![deny(clippy::borrowed_box)]
|
||||||
#![allow(clippy::blacklisted_name)]
|
#![allow(clippy::blacklisted_name)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
|
@ -25,7 +21,7 @@ pub fn test2() {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Test3<'a> {
|
struct Test3<'a> {
|
||||||
foo: &'a Box<bool>
|
foo: &'a Box<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
trait Test4 {
|
trait Test4 {
|
||||||
|
@ -49,7 +45,7 @@ pub fn test6() {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Test7<'a> {
|
struct Test7<'a> {
|
||||||
foo: &'a Box<Any>
|
foo: &'a Box<Any>,
|
||||||
}
|
}
|
||||||
|
|
||||||
trait Test8 {
|
trait Test8 {
|
||||||
|
@ -71,7 +67,7 @@ pub fn test10() {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Test11<'a> {
|
struct Test11<'a> {
|
||||||
foo: &'a Box<Any + Send>
|
foo: &'a Box<Any + Send>,
|
||||||
}
|
}
|
||||||
|
|
||||||
trait Test12 {
|
trait Test12 {
|
||||||
|
@ -84,7 +80,7 @@ impl<'a> Test12 for Test11<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main(){
|
fn main() {
|
||||||
test1(&mut Box::new(false));
|
test1(&mut Box::new(false));
|
||||||
test2();
|
test2();
|
||||||
test5(&mut (Box::new(false) as Box<Any>));
|
test5(&mut (Box::new(false) as Box<Any>));
|
||||||
|
|
|
@ -7,10 +7,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#![warn(clippy::all)]
|
#![warn(clippy::all)]
|
||||||
#![allow(clippy::boxed_local, clippy::needless_pass_by_value)]
|
#![allow(clippy::boxed_local, clippy::needless_pass_by_value)]
|
||||||
#![allow(clippy::blacklisted_name)]
|
#![allow(clippy::blacklisted_name)]
|
||||||
|
@ -18,7 +14,7 @@
|
||||||
macro_rules! boxit {
|
macro_rules! boxit {
|
||||||
($init:expr, $x:ty) => {
|
($init:expr, $x:ty) => {
|
||||||
let _: Box<$x> = Box::new($init);
|
let _: Box<$x> = Box::new($init);
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_macro() {
|
fn test_macro() {
|
||||||
|
@ -28,7 +24,8 @@ pub fn test(foo: Box<Vec<bool>>) {
|
||||||
println!("{:?}", foo.get(0))
|
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])
|
foo(vec![1, 2, 3])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +33,7 @@ pub fn test_local_not_linted() {
|
||||||
let _: Box<Vec<bool>>;
|
let _: Box<Vec<bool>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main(){
|
fn main() {
|
||||||
test(Box::new(Vec::new()));
|
test(Box::new(Vec::new()));
|
||||||
test2(Box::new(|v| println!("{:?}", v)));
|
test2(Box::new(|v| println!("{:?}", v)));
|
||||||
test_macro();
|
test_macro();
|
||||||
|
|
|
@ -7,9 +7,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#![warn(clippy::builtin_type_shadow)]
|
#![warn(clippy::builtin_type_shadow)]
|
||||||
|
|
||||||
fn foo<u32>(a: u32) -> u32 {
|
fn foo<u32>(a: u32) -> u32 {
|
||||||
|
@ -17,5 +14,4 @@ fn foo<u32>(a: u32) -> u32 {
|
||||||
// ^ rustc's type error
|
// ^ rustc's type error
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {}
|
||||||
}
|
|
||||||
|
|
|
@ -7,10 +7,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#[deny(clippy::naive_bytecount)]
|
#[deny(clippy::naive_bytecount)]
|
||||||
fn main() {
|
fn main() {
|
||||||
let x = vec![0_u8; 16];
|
let x = vec![0_u8; 16];
|
||||||
|
|
|
@ -7,11 +7,13 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
#[warn(
|
||||||
|
clippy::cast_precision_loss,
|
||||||
|
clippy::cast_possible_truncation,
|
||||||
|
clippy::cast_sign_loss,
|
||||||
#[warn(clippy::cast_precision_loss, clippy::cast_possible_truncation, clippy::cast_sign_loss, clippy::cast_possible_wrap, clippy::cast_lossless)]
|
clippy::cast_possible_wrap,
|
||||||
|
clippy::cast_lossless
|
||||||
|
)]
|
||||||
#[allow(clippy::no_effect, clippy::unnecessary_operation)]
|
#[allow(clippy::no_effect, clippy::unnecessary_operation)]
|
||||||
fn main() {
|
fn main() {
|
||||||
// Test clippy::cast_precision_loss
|
// Test clippy::cast_precision_loss
|
||||||
|
@ -49,7 +51,7 @@ fn main() {
|
||||||
false as bool;
|
false as bool;
|
||||||
&1i32 as &i32;
|
&1i32 as &i32;
|
||||||
// Should not trigger
|
// Should not trigger
|
||||||
let v = vec!(1);
|
let v = vec![1];
|
||||||
&v as &[i32];
|
&v as &[i32];
|
||||||
1.0 as f64;
|
1.0 as f64;
|
||||||
1 as u64;
|
1 as u64;
|
||||||
|
|
|
@ -7,9 +7,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//! Test casts for alignment issues
|
//! Test casts for alignment issues
|
||||||
|
|
||||||
#![feature(libc)]
|
#![feature(libc)]
|
||||||
|
|
|
@ -7,9 +7,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#[warn(clippy::cast_lossless)]
|
#[warn(clippy::cast_lossless)]
|
||||||
#[allow(clippy::no_effect, clippy::unnecessary_operation)]
|
#[allow(clippy::no_effect, clippy::unnecessary_operation)]
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
|
@ -7,8 +7,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#[warn(clippy::cast_lossless)]
|
#[warn(clippy::cast_lossless)]
|
||||||
#[allow(clippy::no_effect, clippy::unnecessary_operation)]
|
#[allow(clippy::no_effect, clippy::unnecessary_operation)]
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
|
@ -7,10 +7,13 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
#[warn(
|
||||||
|
clippy::cast_precision_loss,
|
||||||
|
clippy::cast_possible_truncation,
|
||||||
#[warn(clippy::cast_precision_loss, clippy::cast_possible_truncation, clippy::cast_sign_loss, clippy::cast_possible_wrap, clippy::cast_lossless)]
|
clippy::cast_sign_loss,
|
||||||
|
clippy::cast_possible_wrap,
|
||||||
|
clippy::cast_lossless
|
||||||
|
)]
|
||||||
#[allow(clippy::no_effect, clippy::unnecessary_operation)]
|
#[allow(clippy::no_effect, clippy::unnecessary_operation)]
|
||||||
fn main() {
|
fn main() {
|
||||||
// Casting from *size
|
// Casting from *size
|
||||||
|
|
|
@ -7,10 +7,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#![warn(clippy::char_lit_as_u8)]
|
#![warn(clippy::char_lit_as_u8)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
|
@ -7,9 +7,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)]
|
#![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)]
|
||||||
#![allow(clippy::if_same_then_else)]
|
#![allow(clippy::if_same_then_else)]
|
||||||
|
|
||||||
|
@ -43,11 +40,11 @@ fn main() {
|
||||||
if x.is_ok() {
|
if x.is_ok() {
|
||||||
x = Err(());
|
x = Err(());
|
||||||
x.unwrap(); // not unnecessary because of mutation of x
|
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 {
|
} else {
|
||||||
x = Ok(());
|
x = Ok(());
|
||||||
x.unwrap_err(); // not unnecessary because of mutation of x
|
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).
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,9 +7,8 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
use std::marker::PhantomData;
|
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
pub struct Key<T> {
|
pub struct Key<T> {
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
|
|
|
@ -7,9 +7,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
pub fn dec_read_dec(i: &mut i32) -> i32 {
|
pub fn dec_read_dec(i: &mut i32) -> i32 {
|
||||||
*i -= 1;
|
*i -= 1;
|
||||||
let ret = *i;
|
let ret = *i;
|
||||||
|
|
|
@ -7,10 +7,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#[warn(clippy::cmp_nan)]
|
#[warn(clippy::cmp_nan)]
|
||||||
#[allow(clippy::float_cmp, clippy::no_effect, clippy::unnecessary_operation)]
|
#[allow(clippy::float_cmp, clippy::no_effect, clippy::unnecessary_operation)]
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
|
@ -7,9 +7,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#![warn(clippy::cmp_null)]
|
#![warn(clippy::cmp_null)]
|
||||||
#![allow(unused_mut)]
|
#![allow(unused_mut)]
|
||||||
|
|
||||||
|
@ -17,12 +14,12 @@ use std::ptr;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let x = 0;
|
let x = 0;
|
||||||
let p : *const usize = &x;
|
let p: *const usize = &x;
|
||||||
if p == ptr::null() {
|
if p == ptr::null() {
|
||||||
println!("This is surprising!");
|
println!("This is surprising!");
|
||||||
}
|
}
|
||||||
let mut y = 0;
|
let mut y = 0;
|
||||||
let mut m : *mut usize = &mut y;
|
let mut m: *mut usize = &mut y;
|
||||||
if m == ptr::null_mut() {
|
if m == ptr::null_mut() {
|
||||||
println!("This is surprising, too!");
|
println!("This is surprising, too!");
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,14 +7,10 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#[warn(clippy::cmp_owned)]
|
#[warn(clippy::cmp_owned)]
|
||||||
#[allow(clippy::unnecessary_operation)]
|
#[allow(clippy::unnecessary_operation)]
|
||||||
fn main() {
|
fn main() {
|
||||||
fn with_to_string(x : &str) {
|
fn with_to_string(x: &str) {
|
||||||
x != "foo".to_string();
|
x != "foo".to_string();
|
||||||
|
|
||||||
"foo".to_string() != x;
|
"foo".to_string() != x;
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
#[warn(clippy::collapsible_if)]
|
#[warn(clippy::collapsible_if)]
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
|
@ -7,9 +7,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#![warn(clippy::all)]
|
#![warn(clippy::all)]
|
||||||
#![allow(unused, clippy::needless_pass_by_value)]
|
#![allow(unused, clippy::needless_pass_by_value)]
|
||||||
#![feature(associated_type_defaults)]
|
#![feature(associated_type_defaults)]
|
||||||
|
@ -32,19 +29,21 @@ enum E {
|
||||||
|
|
||||||
impl S {
|
impl S {
|
||||||
const A: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0))));
|
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 {
|
trait T {
|
||||||
const A: Vec<Vec<Box<(u32, u32, u32, u32)>>>;
|
const A: Vec<Vec<Box<(u32, u32, u32, u32)>>>;
|
||||||
type B = 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 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() {
|
fn test3() {
|
||||||
let _y: Vec<Vec<Box<(u32, u32, u32, u32)>>> = vec![];
|
let _y: Vec<Vec<Box<(u32, u32, u32, u32)>>> = vec![];
|
||||||
|
@ -67,5 +66,4 @@ struct D {
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {}
|
||||||
}
|
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct Foo {}
|
struct Foo {}
|
||||||
|
|
||||||
|
|
|
@ -7,13 +7,23 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
#![allow(clippy::blacklisted_name, clippy::collapsible_if, clippy::cyclomatic_complexity, clippy::eq_op, clippy::needless_continue,
|
#![allow(
|
||||||
clippy::needless_return, clippy::never_loop, clippy::no_effect, clippy::zero_divided_by_zero, clippy::unused_unit)]
|
clippy::blacklisted_name,
|
||||||
|
clippy::collapsible_if,
|
||||||
|
clippy::cyclomatic_complexity,
|
||||||
|
clippy::eq_op,
|
||||||
|
clippy::needless_continue,
|
||||||
|
clippy::needless_return,
|
||||||
|
clippy::never_loop,
|
||||||
|
clippy::no_effect,
|
||||||
|
clippy::zero_divided_by_zero,
|
||||||
|
clippy::unused_unit
|
||||||
|
)]
|
||||||
|
|
||||||
fn bar<T>(_: T) {}
|
fn bar<T>(_: T) {}
|
||||||
fn foo() -> bool { unimplemented!() }
|
fn foo() -> bool {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
struct Foo {
|
struct Foo {
|
||||||
bar: u8,
|
bar: u8,
|
||||||
|
@ -37,8 +47,8 @@ fn if_same_then_else() -> Result<&'static str, ()> {
|
||||||
..10;
|
..10;
|
||||||
0..=10;
|
0..=10;
|
||||||
foo();
|
foo();
|
||||||
}
|
} else {
|
||||||
else { //~ ERROR same body as `if` block
|
//~ ERROR same body as `if` block
|
||||||
Foo { bar: 42 };
|
Foo { bar: 42 };
|
||||||
0..10;
|
0..10;
|
||||||
..;
|
..;
|
||||||
|
@ -50,30 +60,26 @@ fn if_same_then_else() -> Result<&'static str, ()> {
|
||||||
|
|
||||||
if true {
|
if true {
|
||||||
Foo { bar: 42 };
|
Foo { bar: 42 };
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
Foo { bar: 43 };
|
Foo { bar: 43 };
|
||||||
}
|
}
|
||||||
|
|
||||||
if true {
|
if true {
|
||||||
();
|
();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
()
|
()
|
||||||
}
|
}
|
||||||
|
|
||||||
if true {
|
if true {
|
||||||
0..10;
|
0..10;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
0..=10;
|
0..=10;
|
||||||
}
|
}
|
||||||
|
|
||||||
if true {
|
if true {
|
||||||
foo();
|
foo();
|
||||||
foo();
|
foo();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
foo();
|
foo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,18 +90,19 @@ fn if_same_then_else() -> Result<&'static str, ()> {
|
||||||
if true {
|
if true {
|
||||||
a += 7;
|
a += 7;
|
||||||
}
|
}
|
||||||
a = -31-a;
|
a = -31 - a;
|
||||||
a
|
a
|
||||||
}
|
},
|
||||||
_ => { //~ ERROR match arms have same body
|
_ => {
|
||||||
|
//~ ERROR match arms have same body
|
||||||
foo();
|
foo();
|
||||||
let mut a = 42 + [23].len() as i32;
|
let mut a = 42 + [23].len() as i32;
|
||||||
if true {
|
if true {
|
||||||
a += 7;
|
a += 7;
|
||||||
}
|
}
|
||||||
a = -31-a;
|
a = -31 - a;
|
||||||
a
|
a
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
let _ = match Abc::A {
|
let _ = match Abc::A {
|
||||||
|
@ -110,8 +117,8 @@ fn if_same_then_else() -> Result<&'static str, ()> {
|
||||||
|
|
||||||
let _ = if true {
|
let _ = if true {
|
||||||
42
|
42
|
||||||
}
|
} else {
|
||||||
else { //~ ERROR same body as `if` block
|
//~ ERROR same body as `if` block
|
||||||
42
|
42
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -124,8 +131,8 @@ fn if_same_then_else() -> Result<&'static str, ()> {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else { //~ ERROR same body as `if` block
|
//~ ERROR same body as `if` block
|
||||||
for _ in &[42] {
|
for _ in &[42] {
|
||||||
let foo: &Option<_> = &Some::<u8>(42);
|
let foo: &Option<_> = &Some::<u8>(42);
|
||||||
if true {
|
if true {
|
||||||
|
@ -137,25 +144,19 @@ fn if_same_then_else() -> Result<&'static str, ()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if true {
|
if true {
|
||||||
let bar = if true {
|
let bar = if true { 42 } else { 43 };
|
||||||
42
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
43
|
|
||||||
};
|
|
||||||
|
|
||||||
while foo() { break; }
|
while foo() {
|
||||||
|
break;
|
||||||
|
}
|
||||||
bar + 1;
|
bar + 1;
|
||||||
}
|
} else {
|
||||||
else { //~ ERROR same body as `if` block
|
//~ ERROR same body as `if` block
|
||||||
let bar = if true {
|
let bar = if true { 42 } else { 43 };
|
||||||
42
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
43
|
|
||||||
};
|
|
||||||
|
|
||||||
while foo() { break; }
|
while foo() {
|
||||||
|
break;
|
||||||
|
}
|
||||||
bar + 1;
|
bar + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,11 +167,9 @@ fn if_same_then_else() -> Result<&'static str, ()> {
|
||||||
10..=15 => 3,
|
10..=15 => 3,
|
||||||
_ => 4,
|
_ => 4,
|
||||||
};
|
};
|
||||||
}
|
} else if false {
|
||||||
else if false {
|
|
||||||
foo();
|
foo();
|
||||||
}
|
} else if foo() {
|
||||||
else if foo() {
|
|
||||||
let _ = match 42 {
|
let _ = match 42 {
|
||||||
42 => 1,
|
42 => 1,
|
||||||
a if a > 0 => 2,
|
a if a > 0 => 2,
|
||||||
|
@ -181,64 +180,57 @@ fn if_same_then_else() -> Result<&'static str, ()> {
|
||||||
|
|
||||||
if true {
|
if true {
|
||||||
if let Some(a) = Some(42) {}
|
if let Some(a) = Some(42) {}
|
||||||
}
|
} else {
|
||||||
else { //~ ERROR same body as `if` block
|
//~ ERROR same body as `if` block
|
||||||
if let Some(a) = Some(42) {}
|
if let Some(a) = Some(42) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
if true {
|
if true {
|
||||||
if let (1, .., 3) = (1, 2, 3) {}
|
if let (1, .., 3) = (1, 2, 3) {}
|
||||||
}
|
} else {
|
||||||
else { //~ ERROR same body as `if` block
|
//~ ERROR same body as `if` block
|
||||||
if let (1, .., 3) = (1, 2, 3) {}
|
if let (1, .., 3) = (1, 2, 3) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
if true {
|
if true {
|
||||||
if let (1, .., 3) = (1, 2, 3) {}
|
if let (1, .., 3) = (1, 2, 3) {}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if let (.., 3) = (1, 2, 3) {}
|
if let (.., 3) = (1, 2, 3) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
if true {
|
if true {
|
||||||
if let (1, .., 3) = (1, 2, 3) {}
|
if let (1, .., 3) = (1, 2, 3) {}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if let (.., 4) = (1, 2, 3) {}
|
if let (.., 4) = (1, 2, 3) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
if true {
|
if true {
|
||||||
if let (1, .., 3) = (1, 2, 3) {}
|
if let (1, .., 3) = (1, 2, 3) {}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if let (.., 1, 3) = (1, 2, 3) {}
|
if let (.., 1, 3) = (1, 2, 3) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
if true {
|
if true {
|
||||||
if let Some(42) = None {}
|
if let Some(42) = None {}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if let Option::Some(42) = None {}
|
if let Option::Some(42) = None {}
|
||||||
}
|
}
|
||||||
|
|
||||||
if true {
|
if true {
|
||||||
if let Some(42) = None::<u8> {}
|
if let Some(42) = None::<u8> {}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if let Some(42) = None {}
|
if let Some(42) = None {}
|
||||||
}
|
}
|
||||||
|
|
||||||
if true {
|
if true {
|
||||||
if let Some(42) = None::<u8> {}
|
if let Some(42) = None::<u8> {}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if let Some(42) = None::<u32> {}
|
if let Some(42) = None::<u32> {}
|
||||||
}
|
}
|
||||||
|
|
||||||
if true {
|
if true {
|
||||||
if let Some(a) = Some(42) {}
|
if let Some(a) = Some(42) {}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if let Some(a) = Some(43) {}
|
if let Some(a) = Some(43) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -288,41 +280,36 @@ fn if_same_then_else() -> Result<&'static str, ()> {
|
||||||
_ => 0,
|
_ => 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
let _ = if true {
|
|
||||||
0.0
|
|
||||||
} else { //~ ERROR same body as `if` block
|
|
||||||
0.0
|
|
||||||
};
|
|
||||||
|
|
||||||
let _ = if true {
|
|
||||||
-0.0
|
|
||||||
} else { //~ ERROR same body as `if` block
|
|
||||||
-0.0
|
|
||||||
};
|
|
||||||
|
|
||||||
let _ = if true {
|
let _ = if true {
|
||||||
0.0
|
0.0
|
||||||
} else {
|
} else {
|
||||||
|
//~ ERROR same body as `if` block
|
||||||
|
0.0
|
||||||
|
};
|
||||||
|
|
||||||
|
let _ = if true {
|
||||||
|
-0.0
|
||||||
|
} else {
|
||||||
|
//~ ERROR same body as `if` block
|
||||||
-0.0
|
-0.0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let _ = if true { 0.0 } else { -0.0 };
|
||||||
|
|
||||||
// Different NaNs
|
// Different NaNs
|
||||||
let _ = if true {
|
let _ = if true { 0.0 / 0.0 } else { std::f32::NAN };
|
||||||
0.0 / 0.0
|
|
||||||
} else {
|
|
||||||
std::f32::NAN
|
|
||||||
};
|
|
||||||
|
|
||||||
// Same NaNs
|
// Same NaNs
|
||||||
let _ = if true {
|
let _ = if true {
|
||||||
std::f32::NAN
|
std::f32::NAN
|
||||||
} else { //~ ERROR same body as `if` block
|
} else {
|
||||||
|
//~ ERROR same body as `if` block
|
||||||
std::f32::NAN
|
std::f32::NAN
|
||||||
};
|
};
|
||||||
|
|
||||||
let _ = match Some(()) {
|
let _ = match Some(()) {
|
||||||
Some(()) => 0.0,
|
Some(()) => 0.0,
|
||||||
None => -0.0
|
None => -0.0,
|
||||||
};
|
};
|
||||||
|
|
||||||
match (Some(42), Some("")) {
|
match (Some(42), Some("")) {
|
||||||
|
@ -333,20 +320,18 @@ fn if_same_then_else() -> Result<&'static str, ()> {
|
||||||
|
|
||||||
if true {
|
if true {
|
||||||
try!(Ok("foo"));
|
try!(Ok("foo"));
|
||||||
}
|
} else {
|
||||||
else { //~ ERROR same body as `if` block
|
//~ ERROR same body as `if` block
|
||||||
try!(Ok("foo"));
|
try!(Ok("foo"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if true {
|
if true {
|
||||||
let foo = "";
|
let foo = "";
|
||||||
return Ok(&foo[0..]);
|
return Ok(&foo[0..]);
|
||||||
}
|
} else if false {
|
||||||
else if false {
|
|
||||||
let foo = "bar";
|
let foo = "bar";
|
||||||
return Ok(&foo[0..]);
|
return Ok(&foo[0..]);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
let foo = "";
|
let foo = "";
|
||||||
return Ok(&foo[0..]);
|
return Ok(&foo[0..]);
|
||||||
}
|
}
|
||||||
|
@ -359,22 +344,20 @@ fn ifs_same_cond() {
|
||||||
let b = false;
|
let b = false;
|
||||||
|
|
||||||
if b {
|
if b {
|
||||||
}
|
} else if b {
|
||||||
else if b { //~ ERROR ifs same condition
|
//~ ERROR ifs same condition
|
||||||
}
|
}
|
||||||
|
|
||||||
if a == 1 {
|
if a == 1 {
|
||||||
}
|
} else if a == 1 {
|
||||||
else if a == 1 { //~ ERROR ifs same condition
|
//~ ERROR ifs same condition
|
||||||
}
|
}
|
||||||
|
|
||||||
if 2*a == 1 {
|
if 2 * a == 1 {
|
||||||
}
|
} else if 2 * a == 2 {
|
||||||
else if 2*a == 2 {
|
} else if 2 * a == 1 {
|
||||||
}
|
//~ ERROR ifs same condition
|
||||||
else if 2*a == 1 { //~ ERROR ifs same condition
|
} else if a == 1 {
|
||||||
}
|
|
||||||
else if a == 1 {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// See #659
|
// See #659
|
||||||
|
@ -387,14 +370,14 @@ fn ifs_same_cond() {
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut v = vec![1];
|
let mut v = vec![1];
|
||||||
if v.pop() == None { // ok, functions
|
if v.pop() == None {
|
||||||
}
|
// ok, functions
|
||||||
else if v.pop() == None {
|
} else if v.pop() == None {
|
||||||
}
|
}
|
||||||
|
|
||||||
if v.len() == 42 { // ok, functions
|
if v.len() == 42 {
|
||||||
}
|
// ok, functions
|
||||||
else if v.len() == 42 {
|
} else if v.len() == 42 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,9 +7,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#![warn(clippy::copy_iterator)]
|
#![warn(clippy::copy_iterator)]
|
||||||
|
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
|
|
|
@ -7,9 +7,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
||||||
#[allow(clippy::result_unwrap_used)]
|
#[allow(clippy::result_unwrap_used)]
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
#![allow(clippy::all)]
|
#![allow(clippy::all)]
|
||||||
#![warn(clippy::cyclomatic_complexity)]
|
#![warn(clippy::cyclomatic_complexity)]
|
||||||
#![allow(unused)]
|
#![allow(unused)]
|
||||||
|
@ -181,8 +180,8 @@ fn bar() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[clippy::cyclomatic_complexity = "0"]
|
#[clippy::cyclomatic_complexity = "0"]
|
||||||
/// Tests are usually complex but simple at the same time. `clippy::cyclomatic_complexity` used to give
|
/// Tests are usually complex but simple at the same time. `clippy::cyclomatic_complexity` used to
|
||||||
/// lots of false-positives in tests.
|
/// give lots of false-positives in tests.
|
||||||
fn dont_warn_on_tests() {
|
fn dont_warn_on_tests() {
|
||||||
match 99 {
|
match 99 {
|
||||||
0 => println!("hi"),
|
0 => println!("hi"),
|
||||||
|
@ -278,7 +277,6 @@ fn cake() {
|
||||||
println!("whee");
|
println!("whee");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[clippy::cyclomatic_complexity = "0"]
|
#[clippy::cyclomatic_complexity = "0"]
|
||||||
pub fn read_file(input_path: &str) -> String {
|
pub fn read_file(input_path: &str) -> String {
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
|
@ -288,7 +286,7 @@ pub fn read_file(input_path: &str) -> String {
|
||||||
Ok(f) => f,
|
Ok(f) => f,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
panic!("Can't open {}: {}", input_path, err);
|
panic!("Can't open {}: {}", input_path, err);
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut bytes = Vec::new();
|
let mut bytes = Vec::new();
|
||||||
|
@ -297,14 +295,14 @@ pub fn read_file(input_path: &str) -> String {
|
||||||
Ok(..) => {},
|
Ok(..) => {},
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
panic!("Can't read {}", input_path);
|
panic!("Can't read {}", input_path);
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
match String::from_utf8(bytes) {
|
match String::from_utf8(bytes) {
|
||||||
Ok(contents) => contents,
|
Ok(contents) => contents,
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
panic!("{} is not UTF-8 encoded", input_path);
|
panic!("{} is not UTF-8 encoded", input_path);
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -313,8 +311,7 @@ enum Void {}
|
||||||
#[clippy::cyclomatic_complexity = "0"]
|
#[clippy::cyclomatic_complexity = "0"]
|
||||||
fn void(void: Void) {
|
fn void(void: Void) {
|
||||||
if true {
|
if true {
|
||||||
match void {
|
match void {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,9 +7,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#![warn(clippy::cyclomatic_complexity)]
|
#![warn(clippy::cyclomatic_complexity)]
|
||||||
#![warn(unused)]
|
#![warn(unused)]
|
||||||
|
|
||||||
|
|
|
@ -7,24 +7,22 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#[warn(clippy::decimal_literal_representation)]
|
#[warn(clippy::decimal_literal_representation)]
|
||||||
#[allow(unused_variables)]
|
#[allow(unused_variables)]
|
||||||
fn main() {
|
fn main() {
|
||||||
let good = ( // Hex:
|
let good = (
|
||||||
127, // 0x7F
|
// Hex:
|
||||||
256, // 0x100
|
127, // 0x7F
|
||||||
511, // 0x1FF
|
256, // 0x100
|
||||||
2048, // 0x800
|
511, // 0x1FF
|
||||||
4090, // 0xFFA
|
2048, // 0x800
|
||||||
16_371, // 0x3FF3
|
4090, // 0xFFA
|
||||||
61_683, // 0xF0F3
|
16_371, // 0x3FF3
|
||||||
2_131_750_925, // 0x7F0F_F00D
|
61_683, // 0xF0F3
|
||||||
|
2_131_750_925, // 0x7F0F_F00D
|
||||||
);
|
);
|
||||||
let bad = ( // Hex:
|
let bad = (
|
||||||
|
// Hex:
|
||||||
32_773, // 0x8005
|
32_773, // 0x8005
|
||||||
65_280, // 0xFF00
|
65_280, // 0xFF00
|
||||||
2_131_750_927, // 0x7F0F_F00F
|
2_131_750_927, // 0x7F0F_F00F
|
||||||
|
|
|
@ -7,14 +7,11 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#![warn(clippy::default_trait_access)]
|
#![warn(clippy::default_trait_access)]
|
||||||
|
|
||||||
|
use std::default;
|
||||||
use std::default::Default as D2;
|
use std::default::Default as D2;
|
||||||
use std::string;
|
use std::string;
|
||||||
use std::default;
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let s1: String = Default::default();
|
let s1: String = Default::default();
|
||||||
|
|
|
@ -7,18 +7,10 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#[warn(str_to_string)]
|
#[warn(str_to_string)]
|
||||||
|
|
||||||
#[warn(string_to_string)]
|
#[warn(string_to_string)]
|
||||||
|
|
||||||
#[warn(unstable_as_slice)]
|
#[warn(unstable_as_slice)]
|
||||||
|
|
||||||
#[warn(unstable_as_mut_slice)]
|
#[warn(unstable_as_mut_slice)]
|
||||||
|
|
||||||
#[warn(misaligned_transmute)]
|
#[warn(misaligned_transmute)]
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -7,11 +7,7 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#![feature(untagged_unions)]
|
#![feature(untagged_unions)]
|
||||||
|
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
#![warn(clippy::expl_impl_clone_on_copy)]
|
#![warn(clippy::expl_impl_clone_on_copy)]
|
||||||
|
|
||||||
|
@ -21,21 +17,27 @@ use std::hash::{Hash, Hasher};
|
||||||
struct Foo;
|
struct Foo;
|
||||||
|
|
||||||
impl PartialEq<u64> for Foo {
|
impl PartialEq<u64> for Foo {
|
||||||
fn eq(&self, _: &u64) -> bool { true }
|
fn eq(&self, _: &u64) -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Hash)]
|
#[derive(Hash)]
|
||||||
struct Bar;
|
struct Bar;
|
||||||
|
|
||||||
impl PartialEq for Bar {
|
impl PartialEq for Bar {
|
||||||
fn eq(&self, _: &Bar) -> bool { true }
|
fn eq(&self, _: &Bar) -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Hash)]
|
#[derive(Hash)]
|
||||||
struct Baz;
|
struct Baz;
|
||||||
|
|
||||||
impl PartialEq<Baz> for Baz {
|
impl PartialEq<Baz> for Baz {
|
||||||
fn eq(&self, _: &Baz) -> bool { true }
|
fn eq(&self, _: &Baz) -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq)]
|
#[derive(PartialEq)]
|
||||||
|
@ -49,7 +51,9 @@ impl Hash for Bah {
|
||||||
struct Qux;
|
struct Qux;
|
||||||
|
|
||||||
impl Clone for Qux {
|
impl Clone for Qux {
|
||||||
fn clone(&self) -> Self { Qux }
|
fn clone(&self) -> Self {
|
||||||
|
Qux
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// looks like unions don't support deriving Clone for now
|
// looks like unions don't support deriving Clone for now
|
||||||
|
@ -60,9 +64,7 @@ union Union {
|
||||||
|
|
||||||
impl Clone for Union {
|
impl Clone for Union {
|
||||||
fn clone(&self) -> Self {
|
fn clone(&self) -> Self {
|
||||||
Union {
|
Union { a: 42 }
|
||||||
a: 42,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +75,9 @@ struct Lt<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Clone for Lt<'a> {
|
impl<'a> Clone for Lt<'a> {
|
||||||
fn clone(&self) -> Self { unimplemented!() }
|
fn clone(&self) -> Self {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ok, `Clone` cannot be derived because of the big array
|
// Ok, `Clone` cannot be derived because of the big array
|
||||||
|
@ -83,7 +87,9 @@ struct BigArray {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Clone for BigArray {
|
impl Clone for BigArray {
|
||||||
fn clone(&self) -> Self { unimplemented!() }
|
fn clone(&self) -> Self {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ok, function pointers are not always Clone
|
// Ok, function pointers are not always Clone
|
||||||
|
@ -93,7 +99,9 @@ struct FnPtr {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Clone for FnPtr {
|
impl Clone for FnPtr {
|
||||||
fn clone(&self) -> Self { unimplemented!() }
|
fn clone(&self) -> Self {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ok, generics
|
// Ok, generics
|
||||||
|
@ -103,7 +111,9 @@ struct Generic<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> Clone for Generic<T> {
|
impl<T> Clone for Generic<T> {
|
||||||
fn clone(&self) -> Self { unimplemented!() }
|
fn clone(&self) -> Self {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -7,21 +7,21 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#![feature(never_type)]
|
#![feature(never_type)]
|
||||||
|
|
||||||
#![warn(clippy::diverging_sub_expression)]
|
#![warn(clippy::diverging_sub_expression)]
|
||||||
#![allow(clippy::match_same_arms, clippy::logic_bug)]
|
#![allow(clippy::match_same_arms, clippy::logic_bug)]
|
||||||
|
|
||||||
#[allow(clippy::empty_loop)]
|
#[allow(clippy::empty_loop)]
|
||||||
fn diverge() -> ! { loop {} }
|
fn diverge() -> ! {
|
||||||
|
loop {}
|
||||||
|
}
|
||||||
|
|
||||||
struct A;
|
struct A;
|
||||||
|
|
||||||
impl A {
|
impl A {
|
||||||
fn foo(&self) -> ! { diverge() }
|
fn foo(&self) -> ! {
|
||||||
|
diverge()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused_variables, clippy::unnecessary_operation, clippy::short_circuit_statement)]
|
#[allow(unused_variables, clippy::unnecessary_operation, clippy::short_circuit_statement)]
|
||||||
|
|
|
@ -7,13 +7,8 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#![feature(alloc)]
|
#![feature(alloc)]
|
||||||
#![feature(associated_type_defaults)]
|
#![feature(associated_type_defaults)]
|
||||||
|
|
||||||
|
|
||||||
#![warn(clippy::linkedlist)]
|
#![warn(clippy::linkedlist)]
|
||||||
#![allow(dead_code, clippy::needless_pass_by_value)]
|
#![allow(dead_code, clippy::needless_pass_by_value)]
|
||||||
|
|
||||||
|
@ -23,13 +18,13 @@ use alloc::collections::linked_list::LinkedList;
|
||||||
trait Foo {
|
trait Foo {
|
||||||
type Baz = LinkedList<u8>;
|
type Baz = LinkedList<u8>;
|
||||||
fn foo(LinkedList<u8>);
|
fn foo(LinkedList<u8>);
|
||||||
const BAR : Option<LinkedList<u8>>;
|
const BAR: Option<LinkedList<u8>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ok, we don’t want to warn for implementations, see #605
|
// ok, we don’t want to warn for implementations, see #605
|
||||||
impl Foo for LinkedList<u8> {
|
impl Foo for LinkedList<u8> {
|
||||||
fn foo(_: LinkedList<u8>) {}
|
fn foo(_: LinkedList<u8>) {}
|
||||||
const BAR : Option<LinkedList<u8>> = None;
|
const BAR: Option<LinkedList<u8>> = None;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Bar;
|
struct Bar;
|
||||||
|
@ -49,7 +44,7 @@ pub fn test_local_not_linted() {
|
||||||
let _: LinkedList<u8>;
|
let _: LinkedList<u8>;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main(){
|
fn main() {
|
||||||
test(LinkedList::new());
|
test(LinkedList::new());
|
||||||
test_local_not_linted();
|
test_local_not_linted();
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let x = 1;
|
let x = 1;
|
||||||
let y = 2;
|
let y = 2;
|
||||||
|
|
|
@ -7,10 +7,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#[warn(clippy::double_neg)]
|
#[warn(clippy::double_neg)]
|
||||||
fn main() {
|
fn main() {
|
||||||
let x = 1;
|
let x = 1;
|
||||||
|
|
|
@ -7,10 +7,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#![warn(clippy::drop_copy, clippy::forget_copy)]
|
#![warn(clippy::drop_copy, clippy::forget_copy)]
|
||||||
#![allow(clippy::toplevel_ref_arg, clippy::drop_ref, clippy::forget_ref, unused_mut)]
|
#![allow(clippy::toplevel_ref_arg, clippy::drop_ref, clippy::forget_ref, unused_mut)]
|
||||||
|
|
||||||
|
@ -18,18 +14,21 @@ use std::mem::{drop, forget};
|
||||||
use std::vec::Vec;
|
use std::vec::Vec;
|
||||||
|
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
struct SomeStruct {
|
struct SomeStruct {}
|
||||||
}
|
|
||||||
|
|
||||||
struct AnotherStruct {
|
struct AnotherStruct {
|
||||||
x: u8,
|
x: u8,
|
||||||
y: u8,
|
y: u8,
|
||||||
z: Vec<u8>
|
z: Vec<u8>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Clone for AnotherStruct {
|
impl Clone for AnotherStruct {
|
||||||
fn clone(& self) -> AnotherStruct {
|
fn clone(&self) -> AnotherStruct {
|
||||||
AnotherStruct{x: self.x, y: self.y, z: self.z.clone()}
|
AnotherStruct {
|
||||||
|
x: self.x,
|
||||||
|
y: self.y,
|
||||||
|
z: self.z.clone(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +51,11 @@ fn main() {
|
||||||
forget(s4);
|
forget(s4);
|
||||||
forget(s5);
|
forget(s5);
|
||||||
|
|
||||||
let a1 = AnotherStruct {x: 255, y: 0, z: vec![1, 2, 3]};
|
let a1 = AnotherStruct {
|
||||||
|
x: 255,
|
||||||
|
y: 0,
|
||||||
|
z: vec![1, 2, 3],
|
||||||
|
};
|
||||||
let a2 = &a1;
|
let a2 = &a1;
|
||||||
let mut a3 = a1.clone();
|
let mut a3 = a1.clone();
|
||||||
let ref a4 = a1;
|
let ref a4 = a1;
|
||||||
|
|
|
@ -7,10 +7,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#![warn(clippy::drop_ref, clippy::forget_ref)]
|
#![warn(clippy::drop_ref, clippy::forget_ref)]
|
||||||
#![allow(clippy::toplevel_ref_arg, clippy::similar_names, clippy::needless_pass_by_value)]
|
#![allow(clippy::toplevel_ref_arg, clippy::similar_names, clippy::needless_pass_by_value)]
|
||||||
|
|
||||||
|
|
|
@ -7,10 +7,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#![warn(clippy::duplicate_underscore_argument)]
|
#![warn(clippy::duplicate_underscore_argument)]
|
||||||
#[allow(dead_code, unused)]
|
#[allow(dead_code, unused)]
|
||||||
|
|
||||||
|
|
|
@ -7,9 +7,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#![warn(clippy::duration_subsec)]
|
#![warn(clippy::duration_subsec)]
|
||||||
|
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
|
@ -7,15 +7,18 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#![warn(clippy::all)]
|
#![warn(clippy::all)]
|
||||||
#![warn(clippy::else_if_without_else)]
|
#![warn(clippy::else_if_without_else)]
|
||||||
|
|
||||||
fn bla1() -> bool { unimplemented!() }
|
fn bla1() -> bool {
|
||||||
fn bla2() -> bool { unimplemented!() }
|
unimplemented!()
|
||||||
fn bla3() -> bool { unimplemented!() }
|
}
|
||||||
|
fn bla2() -> bool {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
fn bla3() -> bool {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
if bla1() {
|
if bla1() {
|
||||||
|
@ -48,7 +51,8 @@ fn main() {
|
||||||
|
|
||||||
if bla1() {
|
if bla1() {
|
||||||
println!("if");
|
println!("if");
|
||||||
} else if bla2() { //~ ERROR else if without else
|
} else if bla2() {
|
||||||
|
//~ ERROR else if without else
|
||||||
println!("else if");
|
println!("else if");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +60,8 @@ fn main() {
|
||||||
println!("if");
|
println!("if");
|
||||||
} else if bla2() {
|
} else if bla2() {
|
||||||
println!("else if 1");
|
println!("else if 1");
|
||||||
} else if bla3() { //~ ERROR else if without else
|
} else if bla3() {
|
||||||
|
//~ ERROR else if without else
|
||||||
println!("else if 2");
|
println!("else if 2");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,14 +7,9 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
#![warn(clippy::empty_enum)]
|
#![warn(clippy::empty_enum)]
|
||||||
|
|
||||||
enum Empty {}
|
enum Empty {}
|
||||||
|
|
||||||
fn main() {
|
fn main() {}
|
||||||
}
|
|
||||||
|
|
|
@ -7,11 +7,7 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#![allow(unused, clippy::needless_pass_by_value)]
|
#![allow(unused, clippy::needless_pass_by_value)]
|
||||||
|
|
||||||
#![warn(clippy::map_entry)]
|
#![warn(clippy::map_entry)]
|
||||||
|
|
||||||
use std::collections::{BTreeMap, HashMap};
|
use std::collections::{BTreeMap, HashMap};
|
||||||
|
@ -20,36 +16,65 @@ use std::hash::Hash;
|
||||||
fn foo() {}
|
fn foo() {}
|
||||||
|
|
||||||
fn insert_if_absent0<K: Eq + Hash, V>(m: &mut HashMap<K, V>, k: K, v: V) {
|
fn insert_if_absent0<K: Eq + Hash, V>(m: &mut HashMap<K, V>, k: K, v: V) {
|
||||||
if !m.contains_key(&k) { m.insert(k, v); }
|
if !m.contains_key(&k) {
|
||||||
|
m.insert(k, v);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn insert_if_absent1<K: Eq + Hash, V>(m: &mut HashMap<K, V>, k: K, v: V) {
|
fn insert_if_absent1<K: Eq + Hash, V>(m: &mut HashMap<K, V>, k: K, v: V) {
|
||||||
if !m.contains_key(&k) { foo(); m.insert(k, v); }
|
if !m.contains_key(&k) {
|
||||||
|
foo();
|
||||||
|
m.insert(k, v);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn insert_if_absent2<K: Eq + Hash, V>(m: &mut HashMap<K, V>, k: K, v: V) {
|
fn insert_if_absent2<K: Eq + Hash, V>(m: &mut HashMap<K, V>, k: K, v: V) {
|
||||||
if !m.contains_key(&k) { m.insert(k, v) } else { None };
|
if !m.contains_key(&k) {
|
||||||
|
m.insert(k, v)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn insert_if_present2<K: Eq + Hash, V>(m: &mut HashMap<K, V>, k: K, v: V) {
|
fn insert_if_present2<K: Eq + Hash, V>(m: &mut HashMap<K, V>, k: K, v: V) {
|
||||||
if m.contains_key(&k) { None } else { m.insert(k, v) };
|
if m.contains_key(&k) {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
m.insert(k, v)
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn insert_if_absent3<K: Eq + Hash, V>(m: &mut HashMap<K, V>, k: K, v: V) {
|
fn insert_if_absent3<K: Eq + Hash, V>(m: &mut HashMap<K, V>, k: K, v: V) {
|
||||||
if !m.contains_key(&k) { foo(); m.insert(k, v) } else { None };
|
if !m.contains_key(&k) {
|
||||||
|
foo();
|
||||||
|
m.insert(k, v)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn insert_if_present3<K: Eq + Hash, V>(m: &mut HashMap<K, V>, k: K, v: V) {
|
fn insert_if_present3<K: Eq + Hash, V>(m: &mut HashMap<K, V>, k: K, v: V) {
|
||||||
if m.contains_key(&k) { None } else { foo(); m.insert(k, v) };
|
if m.contains_key(&k) {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
foo();
|
||||||
|
m.insert(k, v)
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn insert_in_btreemap<K: Ord, V>(m: &mut BTreeMap<K, V>, k: K, v: V) {
|
fn insert_in_btreemap<K: Ord, V>(m: &mut BTreeMap<K, V>, k: K, v: V) {
|
||||||
if !m.contains_key(&k) { foo(); m.insert(k, v) } else { None };
|
if !m.contains_key(&k) {
|
||||||
|
foo();
|
||||||
|
m.insert(k, v)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn insert_other_if_absent<K: Eq + Hash, V>(m: &mut HashMap<K, V>, k: K, o: K, v: V) {
|
fn insert_other_if_absent<K: Eq + Hash, V>(m: &mut HashMap<K, V>, k: K, o: K, v: V) {
|
||||||
if !m.contains_key(&k) { m.insert(o, v); }
|
if !m.contains_key(&k) {
|
||||||
|
m.insert(o, v);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {}
|
||||||
}
|
|
||||||
|
|
|
@ -7,9 +7,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#![warn(clippy::all, clippy::pedantic)]
|
#![warn(clippy::all, clippy::pedantic)]
|
||||||
#![allow(unused_imports, dead_code, clippy::missing_docs_in_private_items)]
|
#![allow(unused_imports, dead_code, clippy::missing_docs_in_private_items)]
|
||||||
|
|
||||||
|
@ -34,8 +31,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
mod CamelCaseName {
|
mod CamelCaseName {}
|
||||||
}
|
|
||||||
|
|
||||||
use CamelCaseName::*;
|
use CamelCaseName::*;
|
||||||
|
|
||||||
|
|
|
@ -7,19 +7,17 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#![feature(non_ascii_idents)]
|
#![feature(non_ascii_idents)]
|
||||||
|
|
||||||
#![warn(clippy::all, clippy::pub_enum_variant_names)]
|
#![warn(clippy::all, clippy::pub_enum_variant_names)]
|
||||||
|
|
||||||
enum FakeCallType {
|
enum FakeCallType {
|
||||||
CALL, CREATE
|
CALL,
|
||||||
|
CREATE,
|
||||||
}
|
}
|
||||||
|
|
||||||
enum FakeCallType2 {
|
enum FakeCallType2 {
|
||||||
CALL, CREATELL
|
CALL,
|
||||||
|
CREATELL,
|
||||||
}
|
}
|
||||||
|
|
||||||
enum Foo {
|
enum Foo {
|
||||||
|
@ -49,7 +47,8 @@ enum BadCallType {
|
||||||
CallTypeDestroy,
|
CallTypeDestroy,
|
||||||
}
|
}
|
||||||
|
|
||||||
enum TwoCallType { // no error
|
enum TwoCallType {
|
||||||
|
// no error
|
||||||
CallTypeCall,
|
CallTypeCall,
|
||||||
CallTypeCreate,
|
CallTypeCreate,
|
||||||
}
|
}
|
||||||
|
@ -60,7 +59,8 @@ enum Consts {
|
||||||
ConstantLie,
|
ConstantLie,
|
||||||
}
|
}
|
||||||
|
|
||||||
enum Two { // no error here
|
enum Two {
|
||||||
|
// no error here
|
||||||
ConstantInt,
|
ConstantInt,
|
||||||
ConstantInfer,
|
ConstantInfer,
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,14 +7,9 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ignore-x86
|
// ignore-x86
|
||||||
|
|
||||||
|
|
||||||
#![warn(clippy::all)]
|
#![warn(clippy::all)]
|
||||||
|
|
||||||
#![allow(unused)]
|
#![allow(unused)]
|
||||||
|
|
||||||
#[repr(usize)]
|
#[repr(usize)]
|
||||||
|
@ -62,5 +57,4 @@ trait Trait {
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
fn main() {
|
fn main() {}
|
||||||
}
|
|
||||||
|
|
|
@ -7,10 +7,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#[allow(clippy::no_effect)]
|
#[allow(clippy::no_effect)]
|
||||||
#[warn(clippy::erasing_op)]
|
#[warn(clippy::erasing_op)]
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
#![feature(box_syntax)]
|
#![feature(box_syntax)]
|
||||||
|
|
||||||
#![allow(clippy::borrowed_box, clippy::needless_pass_by_value, clippy::unused_unit)]
|
#![allow(clippy::borrowed_box, clippy::needless_pass_by_value, clippy::unused_unit)]
|
||||||
#![warn(clippy::boxed_local)]
|
#![warn(clippy::boxed_local)]
|
||||||
|
|
||||||
|
@ -16,7 +15,7 @@
|
||||||
struct A;
|
struct A;
|
||||||
|
|
||||||
impl A {
|
impl A {
|
||||||
fn foo(&self){}
|
fn foo(&self) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
trait Z {
|
trait Z {
|
||||||
|
@ -29,8 +28,7 @@ impl Z for A {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {}
|
||||||
}
|
|
||||||
|
|
||||||
fn ok_box_trait(boxed_trait: &Box<Z>) {
|
fn ok_box_trait(boxed_trait: &Box<Z>) {
|
||||||
let boxed_local = boxed_trait;
|
let boxed_local = boxed_trait;
|
||||||
|
@ -85,11 +83,9 @@ fn nowarn_pass() {
|
||||||
take_box(&bx); // fn needs &Box
|
take_box(&bx); // fn needs &Box
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn take_box(x: &Box<A>) {}
|
fn take_box(x: &Box<A>) {}
|
||||||
fn take_ref(x: &A) {}
|
fn take_ref(x: &A) {}
|
||||||
|
|
||||||
|
|
||||||
fn nowarn_ref_take() {
|
fn nowarn_ref_take() {
|
||||||
// false positive, should actually warn
|
// false positive, should actually warn
|
||||||
let x = box A;
|
let x = box A;
|
||||||
|
@ -100,14 +96,15 @@ fn nowarn_ref_take() {
|
||||||
fn nowarn_match() {
|
fn nowarn_match() {
|
||||||
let x = box A; // moved into a match
|
let x = box A; // moved into a match
|
||||||
match x {
|
match x {
|
||||||
y => drop(y)
|
y => drop(y),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn warn_match() {
|
fn warn_match() {
|
||||||
let x = box A;
|
let x = box A;
|
||||||
match &x { // not moved
|
match &x {
|
||||||
ref y => ()
|
// not moved
|
||||||
|
ref y => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,12 +112,12 @@ fn nowarn_large_array() {
|
||||||
// should not warn, is large array
|
// should not warn, is large array
|
||||||
// and should not be on stack
|
// and should not be on stack
|
||||||
let x = box [1; 10000];
|
let x = box [1; 10000];
|
||||||
match &x { // not moved
|
match &x {
|
||||||
ref y => ()
|
// not moved
|
||||||
|
ref y => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// ICE regression test
|
/// ICE regression test
|
||||||
pub trait Foo {
|
pub trait Foo {
|
||||||
type Item;
|
type Item;
|
||||||
|
@ -134,8 +131,7 @@ pub struct PeekableSeekable<I: Foo> {
|
||||||
_peeked: I::Item,
|
_peeked: I::Item,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(_needs_name: Box<PeekableSeekable<&()>>) -> () {
|
pub fn new(_needs_name: Box<PeekableSeekable<&()>>) -> () {}
|
||||||
}
|
|
||||||
|
|
||||||
/// Regression for #916, #1123
|
/// Regression for #916, #1123
|
||||||
///
|
///
|
||||||
|
|
|
@ -7,10 +7,15 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
#![allow(
|
||||||
|
unused,
|
||||||
|
clippy::no_effect,
|
||||||
#![allow(unused, clippy::no_effect, clippy::redundant_closure_call, clippy::many_single_char_names, clippy::needless_pass_by_value, clippy::option_map_unit_fn, clippy::trivially_copy_pass_by_ref)]
|
clippy::redundant_closure_call,
|
||||||
|
clippy::many_single_char_names,
|
||||||
|
clippy::needless_pass_by_value,
|
||||||
|
clippy::option_map_unit_fn,
|
||||||
|
clippy::trivially_copy_pass_by_ref
|
||||||
|
)]
|
||||||
#![warn(clippy::redundant_closure, clippy::needless_borrow)]
|
#![warn(clippy::redundant_closure, clippy::needless_borrow)]
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
@ -32,25 +37,31 @@ fn main() {
|
||||||
Some(vec![1i32, 2]).map(|v| -> Box<::std::ops::Deref<Target = [i32]>> { Box::new(v) });
|
Some(vec![1i32, 2]).map(|v| -> Box<::std::ops::Deref<Target = [i32]>> { Box::new(v) });
|
||||||
}
|
}
|
||||||
|
|
||||||
fn meta<F>(f: F) where F: Fn(u8) {
|
fn meta<F>(f: F)
|
||||||
|
where
|
||||||
|
F: Fn(u8),
|
||||||
|
{
|
||||||
f(1u8)
|
f(1u8)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn foo(_: u8) {
|
fn foo(_: u8) {}
|
||||||
}
|
|
||||||
|
|
||||||
fn foo2(_: u8) -> u8 {
|
fn foo2(_: u8) -> u8 {
|
||||||
1u8
|
1u8
|
||||||
}
|
}
|
||||||
|
|
||||||
fn all<X, F>(x: &[X], y: &X, f: F) -> bool
|
fn all<X, F>(x: &[X], y: &X, f: F) -> bool
|
||||||
where F: Fn(&X, &X) -> bool {
|
where
|
||||||
|
F: Fn(&X, &X) -> bool,
|
||||||
|
{
|
||||||
x.iter().all(|e| f(e, y))
|
x.iter().all(|e| f(e, y))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn below(x: &u8, y: &u8) -> bool { x < y }
|
fn below(x: &u8, y: &u8) -> bool {
|
||||||
|
x < y
|
||||||
|
}
|
||||||
|
|
||||||
unsafe fn unsafe_fn(_: u8) { }
|
unsafe fn unsafe_fn(_: u8) {}
|
||||||
|
|
||||||
fn divergent(_: u8) -> ! {
|
fn divergent(_: u8) -> ! {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
|
|
|
@ -7,52 +7,112 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#[warn(clippy::eval_order_dependence)]
|
#[warn(clippy::eval_order_dependence)]
|
||||||
#[allow(unused_assignments, unused_variables, clippy::many_single_char_names, clippy::no_effect, dead_code, clippy::blacklisted_name)]
|
#[allow(
|
||||||
|
unused_assignments,
|
||||||
|
unused_variables,
|
||||||
|
clippy::many_single_char_names,
|
||||||
|
clippy::no_effect,
|
||||||
|
dead_code,
|
||||||
|
clippy::blacklisted_name
|
||||||
|
)]
|
||||||
fn main() {
|
fn main() {
|
||||||
let mut x = 0;
|
let mut x = 0;
|
||||||
let a = { x = 1; 1 } + x;
|
let a = {
|
||||||
|
x = 1;
|
||||||
|
1
|
||||||
|
} + x;
|
||||||
|
|
||||||
// Example from iss#277
|
// Example from iss#277
|
||||||
x += { x = 20; 2 };
|
x += {
|
||||||
|
x = 20;
|
||||||
|
2
|
||||||
|
};
|
||||||
|
|
||||||
// Does it work in weird places?
|
// Does it work in weird places?
|
||||||
// ...in the base for a struct expression?
|
// ...in the base for a struct expression?
|
||||||
struct Foo { a: i32, b: i32 };
|
struct Foo {
|
||||||
|
a: i32,
|
||||||
|
b: i32,
|
||||||
|
};
|
||||||
let base = Foo { a: 4, b: 5 };
|
let base = Foo { a: 4, b: 5 };
|
||||||
let foo = Foo { a: x, .. { x = 6; base } };
|
let foo = Foo {
|
||||||
|
a: x,
|
||||||
|
..{
|
||||||
|
x = 6;
|
||||||
|
base
|
||||||
|
}
|
||||||
|
};
|
||||||
// ...inside a closure?
|
// ...inside a closure?
|
||||||
let closure = || {
|
let closure = || {
|
||||||
let mut x = 0;
|
let mut x = 0;
|
||||||
x += { x = 20; 2 };
|
x += {
|
||||||
|
x = 20;
|
||||||
|
2
|
||||||
|
};
|
||||||
};
|
};
|
||||||
// ...not across a closure?
|
// ...not across a closure?
|
||||||
let mut y = 0;
|
let mut y = 0;
|
||||||
let b = (y, || { y = 1 });
|
let b = (y, || y = 1);
|
||||||
|
|
||||||
// && and || evaluate left-to-right.
|
// && and || evaluate left-to-right.
|
||||||
let a = { x = 1; true } && (x == 3);
|
let a = {
|
||||||
let a = { x = 1; true } || (x == 3);
|
x = 1;
|
||||||
|
true
|
||||||
|
} && (x == 3);
|
||||||
|
let a = {
|
||||||
|
x = 1;
|
||||||
|
true
|
||||||
|
} || (x == 3);
|
||||||
|
|
||||||
// Make sure we don't get confused by alpha conversion.
|
// Make sure we don't get confused by alpha conversion.
|
||||||
let a = { let mut x = 1; x = 2; 1 } + x;
|
let a = {
|
||||||
|
let mut x = 1;
|
||||||
|
x = 2;
|
||||||
|
1
|
||||||
|
} + x;
|
||||||
|
|
||||||
// No warning if we don't read the variable...
|
// No warning if we don't read the variable...
|
||||||
x = { x = 20; 2 };
|
x = {
|
||||||
|
x = 20;
|
||||||
|
2
|
||||||
|
};
|
||||||
// ...if the assignment is in a closure...
|
// ...if the assignment is in a closure...
|
||||||
let b = { || { x = 1; }; 1 } + x;
|
let b = {
|
||||||
|
|| {
|
||||||
|
x = 1;
|
||||||
|
};
|
||||||
|
1
|
||||||
|
} + x;
|
||||||
// ... or the access is under an address.
|
// ... or the access is under an address.
|
||||||
let b = ({ let p = &x; 1 }, { x = 1; x });
|
let b = (
|
||||||
|
{
|
||||||
|
let p = &x;
|
||||||
|
1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
x = 1;
|
||||||
|
x
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
// Limitation: l-values other than simple variables don't trigger
|
// Limitation: l-values other than simple variables don't trigger
|
||||||
// the warning.
|
// the warning.
|
||||||
let mut tup = (0, 0);
|
let mut tup = (0, 0);
|
||||||
let c = { tup.0 = 1; 1 } + tup.0;
|
let c = {
|
||||||
|
tup.0 = 1;
|
||||||
|
1
|
||||||
|
} + tup.0;
|
||||||
// Limitation: you can get away with a read under address-of.
|
// Limitation: you can get away with a read under address-of.
|
||||||
let mut z = 0;
|
let mut z = 0;
|
||||||
let b = (&{ z = x; x }, { x = 3; x });
|
let b = (
|
||||||
|
&{
|
||||||
|
z = x;
|
||||||
|
x
|
||||||
|
},
|
||||||
|
{
|
||||||
|
x = 3;
|
||||||
|
x
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,8 +7,6 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#![warn(clippy::excessive_precision)]
|
#![warn(clippy::excessive_precision)]
|
||||||
#![allow(clippy::print_literal)]
|
#![allow(clippy::print_literal)]
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,9 @@ fn expect_fun_call() {
|
||||||
struct Foo;
|
struct Foo;
|
||||||
|
|
||||||
impl Foo {
|
impl Foo {
|
||||||
fn new() -> Self { Foo }
|
fn new() -> Self {
|
||||||
|
Foo
|
||||||
|
}
|
||||||
|
|
||||||
fn expect(&self, msg: &str) {
|
fn expect(&self, msg: &str) {
|
||||||
panic!("{}", msg)
|
panic!("{}", msg)
|
||||||
|
|
|
@ -26,9 +26,11 @@ fn main() {
|
||||||
mod issue_1219 {
|
mod issue_1219 {
|
||||||
pub fn test() {
|
pub fn test() {
|
||||||
// should not trigger the lint because variable is used after the loop #473
|
// should not trigger the lint because variable is used after the loop #473
|
||||||
let vec = vec![1,2,3];
|
let vec = vec![1, 2, 3];
|
||||||
let mut index = 0;
|
let mut index = 0;
|
||||||
for _v in &vec { index += 1 }
|
for _v in &vec {
|
||||||
|
index += 1
|
||||||
|
}
|
||||||
println!("index: {}", index);
|
println!("index: {}", index);
|
||||||
|
|
||||||
// should not trigger the lint because the count is conditional #1219
|
// should not trigger the lint because the count is conditional #1219
|
||||||
|
|
|
@ -7,12 +7,8 @@
|
||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#![warn(clippy::explicit_write)]
|
#![warn(clippy::explicit_write)]
|
||||||
|
|
||||||
|
|
||||||
fn stdout() -> String {
|
fn stdout() -> String {
|
||||||
String::new()
|
String::new()
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue