remove all //~ from tests
This commit is contained in:
parent
b6d9c86579
commit
1f2c97a291
@ -15,21 +15,19 @@ use std::iter::FromIterator;
|
||||
struct T;
|
||||
|
||||
impl T {
|
||||
fn add(self, other: T) -> T { self } //~ERROR defining a method called `add`
|
||||
fn drop(&mut self) { } //~ERROR defining a method called `drop`
|
||||
fn add(self, other: T) -> T { self }
|
||||
fn drop(&mut self) { }
|
||||
|
||||
fn sub(&self, other: T) -> &T { self } // no error, self is a ref
|
||||
fn div(self) -> T { self } // no error, different #arguments
|
||||
fn rem(self, other: T) { } // no error, wrong return type
|
||||
|
||||
fn into_u32(self) -> u32 { 0 } // fine
|
||||
fn into_u16(&self) -> u16 { 0 } //~ERROR methods called `into_*` usually take self by value
|
||||
fn into_u16(&self) -> u16 { 0 }
|
||||
|
||||
fn to_something(self) -> u32 { 0 } //~ERROR methods called `to_*` usually take self by reference
|
||||
fn to_something(self) -> u32 { 0 }
|
||||
|
||||
fn new(self) {}
|
||||
//~^ ERROR methods called `new` usually take no self
|
||||
//~| ERROR methods called `new` usually return `Self`
|
||||
}
|
||||
|
||||
struct Lt<'a> {
|
||||
@ -96,15 +94,15 @@ fn option_methods() {
|
||||
|
||||
// Check OPTION_MAP_UNWRAP_OR
|
||||
// single line case
|
||||
let _ = opt.map(|x| x + 1) //~ ERROR called `map(f).unwrap_or(a)`
|
||||
//~| NOTE replace `map(|x| x + 1).unwrap_or(0)`
|
||||
let _ = opt.map(|x| x + 1)
|
||||
|
||||
.unwrap_or(0); // should lint even though this call is on a separate line
|
||||
// multi line cases
|
||||
let _ = opt.map(|x| { //~ ERROR called `map(f).unwrap_or(a)`
|
||||
let _ = opt.map(|x| {
|
||||
x + 1
|
||||
}
|
||||
).unwrap_or(0);
|
||||
let _ = opt.map(|x| x + 1) //~ ERROR called `map(f).unwrap_or(a)`
|
||||
let _ = opt.map(|x| x + 1)
|
||||
.unwrap_or({
|
||||
0
|
||||
});
|
||||
@ -113,15 +111,15 @@ fn option_methods() {
|
||||
|
||||
// Check OPTION_MAP_UNWRAP_OR_ELSE
|
||||
// single line case
|
||||
let _ = opt.map(|x| x + 1) //~ ERROR called `map(f).unwrap_or_else(g)`
|
||||
//~| NOTE replace `map(|x| x + 1).unwrap_or_else(|| 0)`
|
||||
let _ = opt.map(|x| x + 1)
|
||||
|
||||
.unwrap_or_else(|| 0); // should lint even though this call is on a separate line
|
||||
// multi line cases
|
||||
let _ = opt.map(|x| { //~ ERROR called `map(f).unwrap_or_else(g)`
|
||||
let _ = opt.map(|x| {
|
||||
x + 1
|
||||
}
|
||||
).unwrap_or_else(|| 0);
|
||||
let _ = opt.map(|x| x + 1) //~ ERROR called `map(f).unwrap_or_else(g)`
|
||||
let _ = opt.map(|x| x + 1)
|
||||
.unwrap_or_else(||
|
||||
0
|
||||
);
|
||||
@ -194,11 +192,11 @@ fn filter_next() {
|
||||
|
||||
// check single-line case
|
||||
let _ = v.iter().filter(|&x| *x < 0).next();
|
||||
//~^ ERROR called `filter(p).next()` on an `Iterator`.
|
||||
//~| NOTE replace `filter(|&x| *x < 0).next()`
|
||||
|
||||
|
||||
|
||||
// check multi-line case
|
||||
let _ = v.iter().filter(|&x| { //~ERROR called `filter(p).next()` on an `Iterator`.
|
||||
let _ = v.iter().filter(|&x| {
|
||||
*x < 0
|
||||
}
|
||||
).next();
|
||||
@ -214,33 +212,33 @@ fn search_is_some() {
|
||||
|
||||
// check `find().is_some()`, single-line
|
||||
let _ = v.iter().find(|&x| *x < 0).is_some();
|
||||
//~^ ERROR called `is_some()` after searching
|
||||
//~| NOTE replace `find(|&x| *x < 0).is_some()`
|
||||
|
||||
|
||||
|
||||
// check `find().is_some()`, multi-line
|
||||
let _ = v.iter().find(|&x| { //~ERROR called `is_some()` after searching
|
||||
let _ = v.iter().find(|&x| {
|
||||
*x < 0
|
||||
}
|
||||
).is_some();
|
||||
|
||||
// check `position().is_some()`, single-line
|
||||
let _ = v.iter().position(|&x| x < 0).is_some();
|
||||
//~^ ERROR called `is_some()` after searching
|
||||
//~| NOTE replace `position(|&x| x < 0).is_some()`
|
||||
|
||||
|
||||
|
||||
// check `position().is_some()`, multi-line
|
||||
let _ = v.iter().position(|&x| { //~ERROR called `is_some()` after searching
|
||||
let _ = v.iter().position(|&x| {
|
||||
x < 0
|
||||
}
|
||||
).is_some();
|
||||
|
||||
// check `rposition().is_some()`, single-line
|
||||
let _ = v.iter().rposition(|&x| x < 0).is_some();
|
||||
//~^ ERROR called `is_some()` after searching
|
||||
//~| NOTE replace `rposition(|&x| x < 0).is_some()`
|
||||
|
||||
|
||||
|
||||
// check `rposition().is_some()`, multi-line
|
||||
let _ = v.iter().rposition(|&x| { //~ERROR called `is_some()` after searching
|
||||
let _ = v.iter().rposition(|&x| {
|
||||
x < 0
|
||||
}
|
||||
).is_some();
|
||||
@ -276,75 +274,75 @@ fn or_fun_call() {
|
||||
|
||||
let with_constructor = Some(vec![1]);
|
||||
with_constructor.unwrap_or(make());
|
||||
//~^ERROR use of `unwrap_or`
|
||||
//~|HELP try this
|
||||
//~|SUGGESTION with_constructor.unwrap_or_else(make)
|
||||
|
||||
|
||||
|
||||
|
||||
let with_new = Some(vec![1]);
|
||||
with_new.unwrap_or(Vec::new());
|
||||
//~^ERROR use of `unwrap_or`
|
||||
//~|HELP try this
|
||||
//~|SUGGESTION with_new.unwrap_or_default();
|
||||
|
||||
|
||||
|
||||
|
||||
let with_const_args = Some(vec![1]);
|
||||
with_const_args.unwrap_or(Vec::with_capacity(12));
|
||||
//~^ERROR use of `unwrap_or`
|
||||
//~|HELP try this
|
||||
//~|SUGGESTION with_const_args.unwrap_or_else(|| Vec::with_capacity(12));
|
||||
|
||||
|
||||
|
||||
|
||||
let with_err : Result<_, ()> = Ok(vec![1]);
|
||||
with_err.unwrap_or(make());
|
||||
//~^ERROR use of `unwrap_or`
|
||||
//~|HELP try this
|
||||
//~|SUGGESTION with_err.unwrap_or_else(|_| make());
|
||||
|
||||
|
||||
|
||||
|
||||
let with_err_args : Result<_, ()> = Ok(vec![1]);
|
||||
with_err_args.unwrap_or(Vec::with_capacity(12));
|
||||
//~^ERROR use of `unwrap_or`
|
||||
//~|HELP try this
|
||||
//~|SUGGESTION with_err_args.unwrap_or_else(|_| Vec::with_capacity(12));
|
||||
|
||||
|
||||
|
||||
|
||||
let with_default_trait = Some(1);
|
||||
with_default_trait.unwrap_or(Default::default());
|
||||
//~^ERROR use of `unwrap_or`
|
||||
//~|HELP try this
|
||||
//~|SUGGESTION with_default_trait.unwrap_or_default();
|
||||
|
||||
|
||||
|
||||
|
||||
let with_default_type = Some(1);
|
||||
with_default_type.unwrap_or(u64::default());
|
||||
//~^ERROR use of `unwrap_or`
|
||||
//~|HELP try this
|
||||
//~|SUGGESTION with_default_type.unwrap_or_default();
|
||||
|
||||
|
||||
|
||||
|
||||
let with_vec = Some(vec![1]);
|
||||
with_vec.unwrap_or(vec![]);
|
||||
//~^ERROR use of `unwrap_or`
|
||||
//~|HELP try this
|
||||
|
||||
|
||||
// FIXME #944: ~|SUGGESTION with_vec.unwrap_or_else(|| vec![]);
|
||||
|
||||
let without_default = Some(Foo);
|
||||
without_default.unwrap_or(Foo::new());
|
||||
//~^ERROR use of `unwrap_or`
|
||||
//~|HELP try this
|
||||
//~|SUGGESTION without_default.unwrap_or_else(Foo::new);
|
||||
|
||||
|
||||
|
||||
|
||||
let mut map = HashMap::<u64, String>::new();
|
||||
map.entry(42).or_insert(String::new());
|
||||
//~^ERROR use of `or_insert` followed by a function call
|
||||
//~|HELP try this
|
||||
//~|SUGGESTION map.entry(42).or_insert_with(String::new);
|
||||
|
||||
|
||||
|
||||
|
||||
let mut btree = BTreeMap::<u64, String>::new();
|
||||
btree.entry(42).or_insert(String::new());
|
||||
//~^ERROR use of `or_insert` followed by a function call
|
||||
//~|HELP try this
|
||||
//~|SUGGESTION btree.entry(42).or_insert_with(String::new);
|
||||
|
||||
|
||||
|
||||
|
||||
let stringy = Some(String::from(""));
|
||||
let _ = stringy.unwrap_or("".to_owned());
|
||||
//~^ERROR use of `unwrap_or`
|
||||
//~|HELP try this
|
||||
//~|SUGGESTION stringy.unwrap_or_else(|| "".to_owned());
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// Checks implementation of `ITER_NTH` lint
|
||||
@ -356,27 +354,27 @@ fn iter_nth() {
|
||||
{
|
||||
// Make sure we lint `.iter()` for relevant types
|
||||
let bad_vec = some_vec.iter().nth(3);
|
||||
//~^ERROR called `.iter().nth()` on a Vec. Calling `.get()` is both faster and more readable
|
||||
|
||||
let bad_slice = &some_vec[..].iter().nth(3);
|
||||
//~^ERROR called `.iter().nth()` on a slice. Calling `.get()` is both faster and more readable
|
||||
|
||||
let bad_boxed_slice = boxed_slice.iter().nth(3);
|
||||
//~^ERROR called `.iter().nth()` on a slice. Calling `.get()` is both faster and more readable
|
||||
|
||||
let bad_vec_deque = some_vec_deque.iter().nth(3);
|
||||
//~^ERROR called `.iter().nth()` on a VecDeque. Calling `.get()` is both faster and more readable
|
||||
|
||||
}
|
||||
|
||||
{
|
||||
// Make sure we lint `.iter_mut()` for relevant types
|
||||
let bad_vec = some_vec.iter_mut().nth(3);
|
||||
//~^ERROR called `.iter_mut().nth()` on a Vec. Calling `.get_mut()` is both faster and more readable
|
||||
|
||||
}
|
||||
{
|
||||
let bad_slice = &some_vec[..].iter_mut().nth(3);
|
||||
//~^ERROR called `.iter_mut().nth()` on a slice. Calling `.get_mut()` is both faster and more readable
|
||||
|
||||
}
|
||||
{
|
||||
let bad_vec_deque = some_vec_deque.iter_mut().nth(3);
|
||||
//~^ERROR called `.iter_mut().nth()` on a VecDeque. Calling `.get_mut()` is both faster and more readable
|
||||
|
||||
}
|
||||
|
||||
// Make sure we don't lint for non-relevant types
|
||||
@ -390,16 +388,16 @@ fn iter_skip_next() {
|
||||
let mut some_vec = vec![0, 1, 2, 3];
|
||||
|
||||
let _ = some_vec.iter().skip(42).next();
|
||||
//~^ERROR called `skip(x).next()` on an iterator. This is more succinctly expressed by calling `nth(x)`
|
||||
|
||||
|
||||
let _ = some_vec.iter().cycle().skip(42).next();
|
||||
//~^ERROR called `skip(x).next()` on an iterator. This is more succinctly expressed by calling `nth(x)`
|
||||
|
||||
|
||||
let _ = (1..10).skip(10).next();
|
||||
//~^ERROR called `skip(x).next()` on an iterator. This is more succinctly expressed by calling `nth(x)`
|
||||
|
||||
|
||||
let _ = &some_vec[..].iter().skip(3).next();
|
||||
//~^ERROR called `skip(x).next()` on an iterator. This is more succinctly expressed by calling `nth(x)`
|
||||
|
||||
|
||||
let foo = IteratorFalsePositives { foo : 0 };
|
||||
let _ = foo.skip(42).next();
|
||||
@ -427,50 +425,50 @@ fn get_unwrap() {
|
||||
|
||||
{ // Test `get().unwrap()`
|
||||
let _ = boxed_slice.get(1).unwrap();
|
||||
//~^ERROR called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise
|
||||
//~|HELP try this
|
||||
//~|SUGGESTION boxed_slice[1]
|
||||
|
||||
|
||||
|
||||
let _ = some_slice.get(0).unwrap();
|
||||
//~^ERROR called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise
|
||||
//~|HELP try this
|
||||
//~|SUGGESTION some_slice[0]
|
||||
|
||||
|
||||
|
||||
let _ = some_vec.get(0).unwrap();
|
||||
//~^ERROR called `.get().unwrap()` on a Vec. Using `[]` is more clear and more concise
|
||||
//~|HELP try this
|
||||
//~|SUGGESTION some_vec[0]
|
||||
|
||||
|
||||
|
||||
let _ = some_vecdeque.get(0).unwrap();
|
||||
//~^ERROR called `.get().unwrap()` on a VecDeque. Using `[]` is more clear and more concise
|
||||
//~|HELP try this
|
||||
//~|SUGGESTION some_vecdeque[0]
|
||||
|
||||
|
||||
|
||||
let _ = some_hashmap.get(&1).unwrap();
|
||||
//~^ERROR called `.get().unwrap()` on a HashMap. Using `[]` is more clear and more concise
|
||||
//~|HELP try this
|
||||
//~|SUGGESTION some_hashmap[&1]
|
||||
|
||||
|
||||
|
||||
let _ = some_btreemap.get(&1).unwrap();
|
||||
//~^ERROR called `.get().unwrap()` on a BTreeMap. Using `[]` is more clear and more concise
|
||||
//~|HELP try this
|
||||
//~|SUGGESTION some_btreemap[&1]
|
||||
|
||||
|
||||
|
||||
|
||||
let _ = false_positive.get(0).unwrap();
|
||||
}
|
||||
|
||||
{ // Test `get_mut().unwrap()`
|
||||
*boxed_slice.get_mut(0).unwrap() = 1;
|
||||
//~^ERROR called `.get_mut().unwrap()` on a slice. Using `[]` is more clear and more concise
|
||||
//~|HELP try this
|
||||
//~|SUGGESTION &mut boxed_slice[0]
|
||||
|
||||
|
||||
|
||||
*some_slice.get_mut(0).unwrap() = 1;
|
||||
//~^ERROR called `.get_mut().unwrap()` on a slice. Using `[]` is more clear and more concise
|
||||
//~|HELP try this
|
||||
//~|SUGGESTION &mut some_slice[0]
|
||||
|
||||
|
||||
|
||||
*some_vec.get_mut(0).unwrap() = 1;
|
||||
//~^ERROR called `.get_mut().unwrap()` on a Vec. Using `[]` is more clear and more concise
|
||||
//~|HELP try this
|
||||
//~|SUGGESTION &mut some_vec[0]
|
||||
|
||||
|
||||
|
||||
*some_vecdeque.get_mut(0).unwrap() = 1;
|
||||
//~^ERROR called `.get_mut().unwrap()` on a VecDeque. Using `[]` is more clear and more concise
|
||||
//~|HELP try this
|
||||
//~|SUGGESTION &mut some_vecdeque[0]
|
||||
|
||||
|
||||
|
||||
|
||||
// Check false positives
|
||||
*some_hashmap.get_mut(&1).unwrap() = 'b';
|
||||
@ -485,24 +483,24 @@ fn main() {
|
||||
use std::io;
|
||||
|
||||
let opt = Some(0);
|
||||
let _ = opt.unwrap(); //~ERROR used unwrap() on an Option
|
||||
let _ = opt.unwrap();
|
||||
|
||||
let res: Result<i32, ()> = Ok(0);
|
||||
let _ = res.unwrap(); //~ERROR used unwrap() on a Result
|
||||
let _ = res.unwrap();
|
||||
|
||||
res.ok().expect("disaster!"); //~ERROR called `ok().expect()`
|
||||
res.ok().expect("disaster!");
|
||||
// the following should not warn, since `expect` isn't implemented unless
|
||||
// the error type implements `Debug`
|
||||
let res2: Result<i32, MyError> = Ok(0);
|
||||
res2.ok().expect("oh noes!");
|
||||
let res3: Result<u32, MyErrorWithParam<u8>>= Ok(0);
|
||||
res3.ok().expect("whoof"); //~ERROR called `ok().expect()`
|
||||
res3.ok().expect("whoof");
|
||||
let res4: Result<u32, io::Error> = Ok(0);
|
||||
res4.ok().expect("argh"); //~ERROR called `ok().expect()`
|
||||
res4.ok().expect("argh");
|
||||
let res5: io::Result<u32> = Ok(0);
|
||||
res5.ok().expect("oops"); //~ERROR called `ok().expect()`
|
||||
res5.ok().expect("oops");
|
||||
let res6: Result<u32, &str> = Ok(0);
|
||||
res6.ok().expect("meh"); //~ERROR called `ok().expect()`
|
||||
res6.ok().expect("meh");
|
||||
}
|
||||
|
||||
struct MyError(()); // doesn't implement Debug
|
||||
@ -515,14 +513,14 @@ struct MyErrorWithParam<T> {
|
||||
#[allow(unnecessary_operation)]
|
||||
fn starts_with() {
|
||||
"".chars().next() == Some(' ');
|
||||
//~^ ERROR starts_with
|
||||
//~| HELP like this
|
||||
//~| SUGGESTION "".starts_with(' ')
|
||||
|
||||
|
||||
|
||||
|
||||
Some(' ') != "".chars().next();
|
||||
//~^ ERROR starts_with
|
||||
//~| HELP like this
|
||||
//~| SUGGESTION !"".starts_with(' ')
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
fn str_extend_chars() {
|
||||
@ -532,21 +530,21 @@ fn str_extend_chars() {
|
||||
|
||||
s.push_str(abc);
|
||||
s.extend(abc.chars());
|
||||
//~^ERROR calling `.extend(_.chars())`
|
||||
//~|HELP try this
|
||||
//~|SUGGESTION s.push_str(abc)
|
||||
|
||||
|
||||
|
||||
|
||||
s.push_str("abc");
|
||||
s.extend("abc".chars());
|
||||
//~^ERROR calling `.extend(_.chars())`
|
||||
//~|HELP try this
|
||||
//~|SUGGESTION s.push_str("abc")
|
||||
|
||||
|
||||
|
||||
|
||||
s.push_str(&def);
|
||||
s.extend(def.chars());
|
||||
//~^ERROR calling `.extend(_.chars())`
|
||||
//~|HELP try this
|
||||
//~|SUGGESTION s.push_str(&def)
|
||||
|
||||
|
||||
|
||||
|
||||
s.extend(abc.chars().skip(1));
|
||||
s.extend("abc".chars().skip(1));
|
||||
@ -557,40 +555,40 @@ fn str_extend_chars() {
|
||||
}
|
||||
|
||||
fn clone_on_copy() {
|
||||
42.clone(); //~ERROR using `clone` on a `Copy` type
|
||||
//~| HELP try removing the `clone` call
|
||||
//~| SUGGESTION 42
|
||||
42.clone();
|
||||
|
||||
|
||||
vec![1].clone(); // ok, not a Copy type
|
||||
Some(vec![1]).clone(); // ok, not a Copy type
|
||||
(&42).clone(); //~ERROR using `clone` on a `Copy` type
|
||||
//~| HELP try dereferencing it
|
||||
//~| SUGGESTION *(&42)
|
||||
(&42).clone();
|
||||
|
||||
|
||||
}
|
||||
|
||||
fn clone_on_copy_generic<T: Copy>(t: T) {
|
||||
t.clone(); //~ERROR using `clone` on a `Copy` type
|
||||
//~| HELP try removing the `clone` call
|
||||
//~| SUGGESTION t
|
||||
Some(t).clone(); //~ERROR using `clone` on a `Copy` type
|
||||
//~| HELP try removing the `clone` call
|
||||
//~| SUGGESTION Some(t)
|
||||
t.clone();
|
||||
|
||||
|
||||
Some(t).clone();
|
||||
|
||||
|
||||
}
|
||||
|
||||
fn clone_on_double_ref() {
|
||||
let x = vec![1];
|
||||
let y = &&x;
|
||||
let z: &Vec<_> = y.clone(); //~ERROR using `clone` on a double
|
||||
//~| HELP try dereferencing it
|
||||
//~| SUGGESTION let z: &Vec<_> = (*y).clone();
|
||||
let z: &Vec<_> = y.clone();
|
||||
|
||||
|
||||
println!("{:p} {:p}",*y, z);
|
||||
}
|
||||
|
||||
fn single_char_pattern() {
|
||||
let x = "foo";
|
||||
x.split("x");
|
||||
//~^ ERROR single-character string constant used as pattern
|
||||
//~| HELP try using a char instead:
|
||||
//~| SUGGESTION x.split('x');
|
||||
|
||||
|
||||
|
||||
|
||||
x.split("xx");
|
||||
|
||||
@ -612,69 +610,69 @@ fn single_char_pattern() {
|
||||
x.split("❤️");
|
||||
|
||||
x.contains("x");
|
||||
//~^ ERROR single-character string constant used as pattern
|
||||
//~| HELP try using a char instead:
|
||||
//~| SUGGESTION x.contains('x');
|
||||
|
||||
|
||||
|
||||
x.starts_with("x");
|
||||
//~^ ERROR single-character string constant used as pattern
|
||||
//~| HELP try using a char instead:
|
||||
//~| SUGGESTION x.starts_with('x');
|
||||
|
||||
|
||||
|
||||
x.ends_with("x");
|
||||
//~^ ERROR single-character string constant used as pattern
|
||||
//~| HELP try using a char instead:
|
||||
//~| SUGGESTION x.ends_with('x');
|
||||
|
||||
|
||||
|
||||
x.find("x");
|
||||
//~^ ERROR single-character string constant used as pattern
|
||||
//~| HELP try using a char instead:
|
||||
//~| SUGGESTION x.find('x');
|
||||
|
||||
|
||||
|
||||
x.rfind("x");
|
||||
//~^ ERROR single-character string constant used as pattern
|
||||
//~| HELP try using a char instead:
|
||||
//~| SUGGESTION x.rfind('x');
|
||||
|
||||
|
||||
|
||||
x.rsplit("x");
|
||||
//~^ ERROR single-character string constant used as pattern
|
||||
//~| HELP try using a char instead:
|
||||
//~| SUGGESTION x.rsplit('x');
|
||||
|
||||
|
||||
|
||||
x.split_terminator("x");
|
||||
//~^ ERROR single-character string constant used as pattern
|
||||
//~| HELP try using a char instead:
|
||||
//~| SUGGESTION x.split_terminator('x');
|
||||
|
||||
|
||||
|
||||
x.rsplit_terminator("x");
|
||||
//~^ ERROR single-character string constant used as pattern
|
||||
//~| HELP try using a char instead:
|
||||
//~| SUGGESTION x.rsplit_terminator('x');
|
||||
|
||||
|
||||
|
||||
x.splitn(0, "x");
|
||||
//~^ ERROR single-character string constant used as pattern
|
||||
//~| HELP try using a char instead:
|
||||
//~| SUGGESTION x.splitn(0, 'x');
|
||||
|
||||
|
||||
|
||||
x.rsplitn(0, "x");
|
||||
//~^ ERROR single-character string constant used as pattern
|
||||
//~| HELP try using a char instead:
|
||||
//~| SUGGESTION x.rsplitn(0, 'x');
|
||||
|
||||
|
||||
|
||||
x.matches("x");
|
||||
//~^ ERROR single-character string constant used as pattern
|
||||
//~| HELP try using a char instead:
|
||||
//~| SUGGESTION x.matches('x');
|
||||
|
||||
|
||||
|
||||
x.rmatches("x");
|
||||
//~^ ERROR single-character string constant used as pattern
|
||||
//~| HELP try using a char instead:
|
||||
//~| SUGGESTION x.rmatches('x');
|
||||
|
||||
|
||||
|
||||
x.match_indices("x");
|
||||
//~^ ERROR single-character string constant used as pattern
|
||||
//~| HELP try using a char instead:
|
||||
//~| SUGGESTION x.match_indices('x');
|
||||
|
||||
|
||||
|
||||
x.rmatch_indices("x");
|
||||
//~^ ERROR single-character string constant used as pattern
|
||||
//~| HELP try using a char instead:
|
||||
//~| SUGGESTION x.rmatch_indices('x');
|
||||
|
||||
|
||||
|
||||
x.trim_left_matches("x");
|
||||
//~^ ERROR single-character string constant used as pattern
|
||||
//~| HELP try using a char instead:
|
||||
//~| SUGGESTION x.trim_left_matches('x');
|
||||
|
||||
|
||||
|
||||
x.trim_right_matches("x");
|
||||
//~^ ERROR single-character string constant used as pattern
|
||||
//~| HELP try using a char instead:
|
||||
//~| SUGGESTION x.trim_right_matches('x');
|
||||
|
||||
|
||||
|
||||
|
||||
let h = HashSet::<String>::new();
|
||||
h.contains("X"); // should not warn
|
||||
@ -685,7 +683,7 @@ fn temporary_cstring() {
|
||||
use std::ffi::CString;
|
||||
|
||||
CString::new("foo").unwrap().as_ptr();
|
||||
//~^ ERROR you are getting the inner pointer of a temporary `CString`
|
||||
//~| NOTE that pointer will be invalid outside this expression
|
||||
//~| HELP assign the `CString` to a variable to extend its lifetime
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,17 +1,17 @@
|
||||
#![feature(plugin)]
|
||||
#![plugin(clippy)]
|
||||
#![deny(clippy,similar_names)]
|
||||
//~^ NOTE: lint level defined here
|
||||
//~| NOTE: lint level defined here
|
||||
//~| NOTE: lint level defined here
|
||||
//~| NOTE: lint level defined here
|
||||
//~| NOTE: lint level defined here
|
||||
//~| NOTE: lint level defined here
|
||||
//~| NOTE: lint level defined here
|
||||
//~| NOTE: lint level defined here
|
||||
//~| NOTE: lint level defined here
|
||||
//~| NOTE: lint level defined here
|
||||
//~| NOTE: lint level defined here
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#![allow(unused)]
|
||||
|
||||
|
||||
@ -24,12 +24,12 @@ fn main() {
|
||||
let specter: i32;
|
||||
let spectre: i32;
|
||||
|
||||
let apple: i32; //~ NOTE: existing binding defined here
|
||||
//~^ NOTE: existing binding defined here
|
||||
let bpple: i32; //~ ERROR: name is too similar
|
||||
//~| HELP: separate the discriminating character by an underscore like: `b_pple`
|
||||
let cpple: i32; //~ ERROR: name is too similar
|
||||
//~| HELP: separate the discriminating character by an underscore like: `c_pple`
|
||||
let apple: i32;
|
||||
|
||||
let bpple: i32;
|
||||
|
||||
let cpple: i32;
|
||||
|
||||
|
||||
let a_bar: i32;
|
||||
let b_bar: i32;
|
||||
@ -52,13 +52,13 @@ fn main() {
|
||||
let blubrhs: i32;
|
||||
let blublhs: i32;
|
||||
|
||||
let blubx: i32; //~ NOTE: existing binding defined here
|
||||
let bluby: i32; //~ ERROR: name is too similar
|
||||
//~| HELP: separate the discriminating character by an underscore like: `blub_y`
|
||||
let blubx: i32;
|
||||
let bluby: i32;
|
||||
|
||||
let cake: i32; //~ NOTE: existing binding defined here
|
||||
|
||||
let cake: i32;
|
||||
let cakes: i32;
|
||||
let coke: i32; //~ ERROR: name is too similar
|
||||
let coke: i32;
|
||||
|
||||
match 5 {
|
||||
cheese @ 1 => {},
|
||||
@ -74,14 +74,14 @@ fn main() {
|
||||
let ipv6: i32;
|
||||
let abcd1: i32;
|
||||
let abdc2: i32;
|
||||
let xyz1abc: i32; //~ NOTE: existing binding defined here
|
||||
let xyz1abc: i32;
|
||||
let xyz2abc: i32;
|
||||
let xyzeabc: i32; //~ ERROR: name is too similar
|
||||
let xyzeabc: i32;
|
||||
|
||||
let parser: i32; //~ NOTE: existing binding defined here
|
||||
let parser: i32;
|
||||
let parsed: i32;
|
||||
let parsee: i32; //~ ERROR: name is too similar
|
||||
//~| HELP: separate the discriminating character by an underscore like: `parse_e`
|
||||
let parsee: i32;
|
||||
|
||||
|
||||
let setter: i32;
|
||||
let getter: i32;
|
||||
@ -93,8 +93,8 @@ fn main() {
|
||||
|
||||
fn foo() {
|
||||
let Foo { apple, bpple } = unimplemented!();
|
||||
let Foo { apple: spring, //~NOTE existing binding defined here
|
||||
bpple: sprang } = unimplemented!(); //~ ERROR: name is too similar
|
||||
let Foo { apple: spring,
|
||||
bpple: sprang } = unimplemented!();
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
@ -128,19 +128,19 @@ fn bla() {
|
||||
let blar: i32;
|
||||
}
|
||||
{
|
||||
let e: i32; //~ ERROR: 5th binding whose name is just one char
|
||||
//~^ NOTE implied by
|
||||
let e: i32;
|
||||
|
||||
}
|
||||
{
|
||||
let e: i32; //~ ERROR: 5th binding whose name is just one char
|
||||
//~^ NOTE implied by
|
||||
let f: i32; //~ ERROR: 6th binding whose name is just one char
|
||||
//~^ NOTE implied by
|
||||
let e: i32;
|
||||
|
||||
let f: i32;
|
||||
|
||||
}
|
||||
match 5 {
|
||||
1 => println!(""),
|
||||
e => panic!(), //~ ERROR: 5th binding whose name is just one char
|
||||
//~^ NOTE implied by
|
||||
e => panic!(),
|
||||
|
||||
}
|
||||
match 5 {
|
||||
1 => println!(""),
|
||||
|
@ -7,11 +7,11 @@ fn add_only() { // ignores assignment distinction
|
||||
let mut x = "".to_owned();
|
||||
|
||||
for _ in 1..3 {
|
||||
x = x + "."; //~ERROR you added something to a string.
|
||||
x = x + ".";
|
||||
}
|
||||
|
||||
let y = "".to_owned();
|
||||
let z = y + "..."; //~ERROR you added something to a string.
|
||||
let z = y + "...";
|
||||
|
||||
assert_eq!(&x, &z);
|
||||
}
|
||||
@ -21,7 +21,7 @@ fn add_assign_only() {
|
||||
let mut x = "".to_owned();
|
||||
|
||||
for _ in 1..3 {
|
||||
x = x + "."; //~ERROR you assigned the result of adding something to this string.
|
||||
x = x + ".";
|
||||
}
|
||||
|
||||
let y = "".to_owned();
|
||||
@ -35,11 +35,11 @@ fn both() {
|
||||
let mut x = "".to_owned();
|
||||
|
||||
for _ in 1..3 {
|
||||
x = x + "."; //~ERROR you assigned the result of adding something to this string.
|
||||
x = x + ".";
|
||||
}
|
||||
|
||||
let y = "".to_owned();
|
||||
let z = y + "..."; //~ERROR you added something to a string.
|
||||
let z = y + "...";
|
||||
|
||||
assert_eq!(&x, &z);
|
||||
}
|
||||
@ -48,9 +48,9 @@ fn both() {
|
||||
#[deny(string_lit_as_bytes)]
|
||||
fn str_lit_as_bytes() {
|
||||
let bs = "hello there".as_bytes();
|
||||
//~^ERROR calling `as_bytes()`
|
||||
//~|HELP byte string literal
|
||||
//~|SUGGESTION b"hello there"
|
||||
|
||||
|
||||
|
||||
|
||||
// no warning, because this cannot be written as a byte string literal:
|
||||
let ubs = "☃".as_bytes();
|
||||
@ -66,8 +66,8 @@ fn main() {
|
||||
// the add is only caught for `String`
|
||||
let mut x = 1;
|
||||
; x = x + 1;
|
||||
//~^ WARN manual implementation of an assign operation
|
||||
//~| HELP replace
|
||||
//~| SUGGESTION ; x += 1;
|
||||
|
||||
|
||||
|
||||
assert_eq!(2, x);
|
||||
}
|
||||
|
@ -8,36 +8,36 @@ struct Foo(u32);
|
||||
|
||||
fn array() {
|
||||
let mut foo = [1, 2];
|
||||
let temp = foo[0]; //~ NOTE implied by
|
||||
let temp = foo[0];
|
||||
foo[0] = foo[1];
|
||||
foo[1] = temp;
|
||||
//~^^^ ERROR this looks like you are swapping elements of `foo` manually
|
||||
//~| HELP try
|
||||
//~| SUGGESTION foo.swap(0, 1);
|
||||
|
||||
|
||||
|
||||
|
||||
foo.swap(0, 1);
|
||||
}
|
||||
|
||||
fn slice() {
|
||||
let foo = &mut [1, 2];
|
||||
let temp = foo[0]; //~ NOTE implied by
|
||||
let temp = foo[0];
|
||||
foo[0] = foo[1];
|
||||
foo[1] = temp;
|
||||
//~^^^ ERROR this looks like you are swapping elements of `foo` manually
|
||||
//~| HELP try
|
||||
//~| SUGGESTION foo.swap(0, 1);
|
||||
|
||||
|
||||
|
||||
|
||||
foo.swap(0, 1);
|
||||
}
|
||||
|
||||
fn vec() {
|
||||
let mut foo = vec![1, 2];
|
||||
let temp = foo[0]; //~ NOTE implied by
|
||||
let temp = foo[0];
|
||||
foo[0] = foo[1];
|
||||
foo[1] = temp;
|
||||
//~^^^ ERROR this looks like you are swapping elements of `foo` manually
|
||||
//~| HELP try
|
||||
//~| SUGGESTION foo.swap(0, 1);
|
||||
|
||||
|
||||
|
||||
|
||||
foo.swap(0, 1);
|
||||
}
|
||||
@ -50,35 +50,35 @@ fn main() {
|
||||
let mut a = 42;
|
||||
let mut b = 1337;
|
||||
|
||||
a = b; //~ NOTE implied by
|
||||
a = b;
|
||||
b = a;
|
||||
//~^^ ERROR this looks like you are trying to swap `a` and `b`
|
||||
//~| HELP try
|
||||
//~| SUGGESTION std::mem::swap(&mut a, &mut b);
|
||||
//~| NOTE or maybe you should use `std::mem::replace`?
|
||||
|
||||
; let t = a; //~ NOTE implied by
|
||||
|
||||
|
||||
|
||||
|
||||
; let t = a;
|
||||
a = b;
|
||||
b = t;
|
||||
//~^^^ ERROR this looks like you are swapping `a` and `b` manually
|
||||
//~| HELP try
|
||||
//~| SUGGESTION ; std::mem::swap(&mut a, &mut b);
|
||||
//~| NOTE or maybe you should use `std::mem::replace`?
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
let mut c = Foo(42);
|
||||
|
||||
c.0 = a; //~ NOTE implied by
|
||||
c.0 = a;
|
||||
a = c.0;
|
||||
//~^^ ERROR this looks like you are trying to swap `c.0` and `a`
|
||||
//~| HELP try
|
||||
//~| SUGGESTION std::mem::swap(&mut c.0, &mut a);
|
||||
//~| NOTE or maybe you should use `std::mem::replace`?
|
||||
|
||||
; let t = c.0; //~ NOTE implied by
|
||||
|
||||
|
||||
|
||||
|
||||
; let t = c.0;
|
||||
c.0 = a;
|
||||
a = t;
|
||||
//~^^^ ERROR this looks like you are swapping `c.0` and `a` manually
|
||||
//~| HELP try
|
||||
//~| SUGGESTION ; std::mem::swap(&mut c.0, &mut a);
|
||||
//~| NOTE or maybe you should use `std::mem::replace`?
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -2,11 +2,11 @@
|
||||
#![plugin(clippy)]
|
||||
|
||||
#[warn(str_to_string)]
|
||||
//~^WARNING: lint str_to_string has been removed: using `str::to_string`
|
||||
|
||||
#[warn(string_to_string)]
|
||||
//~^WARNING: lint string_to_string has been removed: using `string::to_string`
|
||||
|
||||
#[warn(unstable_as_slice)]
|
||||
//~^WARNING: lint unstable_as_slice has been removed: `Vec::as_slice` has been stabilized
|
||||
|
||||
#[warn(unstable_as_mut_slice)]
|
||||
//~^WARNING: lint unstable_as_mut_slice has been removed: `Vec::as_mut_slice` has been stabilized
|
||||
|
||||
fn main() {}
|
||||
|
@ -10,66 +10,66 @@ fn main() {
|
||||
let u: u32 = 42;
|
||||
|
||||
u <= 0;
|
||||
//~^ ERROR this comparison involving the minimum or maximum element for this type contains a
|
||||
//~| HELP using u == 0 instead
|
||||
|
||||
|
||||
u <= Z;
|
||||
//~^ ERROR this comparison involving
|
||||
//~| HELP using u == Z instead
|
||||
|
||||
|
||||
u < Z;
|
||||
//~^ ERROR this comparison involving
|
||||
//~| HELP comparison is always false
|
||||
|
||||
|
||||
Z >= u;
|
||||
//~^ ERROR this comparison involving
|
||||
//~| HELP using Z == u instead
|
||||
|
||||
|
||||
Z > u;
|
||||
//~^ ERROR this comparison involving
|
||||
//~| HELP comparison is always false
|
||||
|
||||
|
||||
u > std::u32::MAX;
|
||||
//~^ ERROR this comparison involving
|
||||
//~| HELP comparison is always false
|
||||
|
||||
|
||||
u >= std::u32::MAX;
|
||||
//~^ ERROR this comparison involving
|
||||
//~| HELP using u == std::u32::MAX instead
|
||||
|
||||
|
||||
std::u32::MAX < u;
|
||||
//~^ ERROR this comparison involving
|
||||
//~| HELP comparison is always false
|
||||
|
||||
|
||||
std::u32::MAX <= u;
|
||||
//~^ ERROR this comparison involving
|
||||
//~| HELP using std::u32::MAX == u instead
|
||||
|
||||
|
||||
|
||||
1-1 > u;
|
||||
//~^ ERROR this comparison involving
|
||||
//~| HELP because 1-1 is the minimum value for this type, this comparison is always false
|
||||
|
||||
|
||||
u >= !0;
|
||||
//~^ ERROR this comparison involving
|
||||
//~| HELP consider using u == !0 instead
|
||||
|
||||
|
||||
u <= 12 - 2*6;
|
||||
//~^ ERROR this comparison involving
|
||||
//~| HELP consider using u == 12 - 2*6 instead
|
||||
|
||||
|
||||
|
||||
let i: i8 = 0;
|
||||
i < -127 - 1;
|
||||
//~^ ERROR this comparison involving
|
||||
//~| HELP comparison is always false
|
||||
|
||||
|
||||
std::i8::MAX >= i;
|
||||
//~^ ERROR this comparison involving
|
||||
//~| HELP comparison is always true
|
||||
|
||||
|
||||
3-7 < std::i32::MIN;
|
||||
//~^ ERROR this comparison involving
|
||||
//~| HELP comparison is always false
|
||||
|
||||
|
||||
|
||||
let b = false;
|
||||
b >= true;
|
||||
//~^ ERROR this comparison involving
|
||||
//~| HELP using b == true instead
|
||||
|
||||
|
||||
false > b;
|
||||
//~^ ERROR this comparison involving
|
||||
//~| HELP comparison is always false
|
||||
|
||||
|
||||
|
||||
u > 0; // ok
|
||||
|
||||
// this is handled by unit_cmp
|
||||
() < {}; //~WARNING <-comparison of unit values detected.
|
||||
() < {};
|
||||
}
|
||||
|
||||
use std::cmp::{Ordering, PartialEq, PartialOrd};
|
||||
|
@ -142,7 +142,7 @@ error: this comparison involving the minimum or maximum element for this type co
|
||||
warning: <-comparison of unit values detected. This will always be false
|
||||
--> $DIR/absurd-extreme-comparisons.rs:72:5
|
||||
|
|
||||
72 | () < {}; //~WARNING <-comparison of unit values detected.
|
||||
72 | () < {};
|
||||
| ^^^^^^^
|
||||
|
|
||||
= note: #[warn(unit_cmp)] on by default
|
||||
|
@ -4,54 +4,54 @@
|
||||
#[deny(approx_constant)]
|
||||
#[allow(unused, shadow_unrelated, similar_names)]
|
||||
fn main() {
|
||||
let my_e = 2.7182; //~ERROR approximate value of `f{32, 64}::consts::E` found
|
||||
let almost_e = 2.718; //~ERROR approximate value of `f{32, 64}::consts::E` found
|
||||
let my_e = 2.7182;
|
||||
let almost_e = 2.718;
|
||||
let no_e = 2.71;
|
||||
|
||||
let my_1_frac_pi = 0.3183; //~ERROR approximate value of `f{32, 64}::consts::FRAC_1_PI` found
|
||||
let my_1_frac_pi = 0.3183;
|
||||
let no_1_frac_pi = 0.31;
|
||||
|
||||
let my_frac_1_sqrt_2 = 0.70710678; //~ERROR approximate value of `f{32, 64}::consts::FRAC_1_SQRT_2` found
|
||||
let almost_frac_1_sqrt_2 = 0.70711; //~ERROR approximate value of `f{32, 64}::consts::FRAC_1_SQRT_2` found
|
||||
let my_frac_1_sqrt_2 = 0.70710678;
|
||||
let almost_frac_1_sqrt_2 = 0.70711;
|
||||
let my_frac_1_sqrt_2 = 0.707;
|
||||
|
||||
let my_frac_2_pi = 0.63661977; //~ERROR approximate value of `f{32, 64}::consts::FRAC_2_PI` found
|
||||
let my_frac_2_pi = 0.63661977;
|
||||
let no_frac_2_pi = 0.636;
|
||||
|
||||
let my_frac_2_sq_pi = 1.128379; //~ERROR approximate value of `f{32, 64}::consts::FRAC_2_SQRT_PI` found
|
||||
let my_frac_2_sq_pi = 1.128379;
|
||||
let no_frac_2_sq_pi = 1.128;
|
||||
|
||||
let my_frac_pi_2 = 1.57079632679; //~ERROR approximate value of `f{32, 64}::consts::FRAC_PI_2` found
|
||||
let my_frac_pi_2 = 1.57079632679;
|
||||
let no_frac_pi_2 = 1.5705;
|
||||
|
||||
let my_frac_pi_3 = 1.04719755119; //~ERROR approximate value of `f{32, 64}::consts::FRAC_PI_3` found
|
||||
let my_frac_pi_3 = 1.04719755119;
|
||||
let no_frac_pi_3 = 1.047;
|
||||
|
||||
let my_frac_pi_4 = 0.785398163397; //~ERROR approximate value of `f{32, 64}::consts::FRAC_PI_4` found
|
||||
let my_frac_pi_4 = 0.785398163397;
|
||||
let no_frac_pi_4 = 0.785;
|
||||
|
||||
let my_frac_pi_6 = 0.523598775598; //~ERROR approximate value of `f{32, 64}::consts::FRAC_PI_6` found
|
||||
let my_frac_pi_6 = 0.523598775598;
|
||||
let no_frac_pi_6 = 0.523;
|
||||
|
||||
let my_frac_pi_8 = 0.3926990816987; //~ERROR approximate value of `f{32, 64}::consts::FRAC_PI_8` found
|
||||
let my_frac_pi_8 = 0.3926990816987;
|
||||
let no_frac_pi_8 = 0.392;
|
||||
|
||||
let my_ln_10 = 2.302585092994046; //~ERROR approximate value of `f{32, 64}::consts::LN_10` found
|
||||
let my_ln_10 = 2.302585092994046;
|
||||
let no_ln_10 = 2.303;
|
||||
|
||||
let my_ln_2 = 0.6931471805599453; //~ERROR approximate value of `f{32, 64}::consts::LN_2` found
|
||||
let my_ln_2 = 0.6931471805599453;
|
||||
let no_ln_2 = 0.693;
|
||||
|
||||
let my_log10_e = 0.43429448190325182; //~ERROR approximate value of `f{32, 64}::consts::LOG10_E` found
|
||||
let my_log10_e = 0.43429448190325182;
|
||||
let no_log10_e = 0.434;
|
||||
|
||||
let my_log2_e = 1.4426950408889634; //~ERROR approximate value of `f{32, 64}::consts::LOG2_E` found
|
||||
let my_log2_e = 1.4426950408889634;
|
||||
let no_log2_e = 1.442;
|
||||
|
||||
let my_pi = 3.1415; //~ERROR approximate value of `f{32, 64}::consts::PI` found
|
||||
let almost_pi = 3.14; //~ERROR approximate value of `f{32, 64}::consts::PI` found
|
||||
let my_pi = 3.1415;
|
||||
let almost_pi = 3.14;
|
||||
let no_pi = 3.15;
|
||||
|
||||
let my_sq2 = 1.4142; //~ERROR approximate value of `f{32, 64}::consts::SQRT_2` found
|
||||
let my_sq2 = 1.4142;
|
||||
let no_sq2 = 1.414;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
error: approximate value of `f{32, 64}::consts::E` found. Consider using it directly
|
||||
--> $DIR/approx_const.rs:7:16
|
||||
|
|
||||
7 | let my_e = 2.7182; //~ERROR approximate value of `f{32, 64}::consts::E` found
|
||||
7 | let my_e = 2.7182;
|
||||
| ^^^^^^
|
||||
|
|
||||
note: lint level defined here
|
||||
@ -13,109 +13,109 @@ note: lint level defined here
|
||||
error: approximate value of `f{32, 64}::consts::E` found. Consider using it directly
|
||||
--> $DIR/approx_const.rs:8:20
|
||||
|
|
||||
8 | let almost_e = 2.718; //~ERROR approximate value of `f{32, 64}::consts::E` found
|
||||
8 | let almost_e = 2.718;
|
||||
| ^^^^^
|
||||
|
||||
error: approximate value of `f{32, 64}::consts::FRAC_1_PI` found. Consider using it directly
|
||||
--> $DIR/approx_const.rs:11:24
|
||||
|
|
||||
11 | let my_1_frac_pi = 0.3183; //~ERROR approximate value of `f{32, 64}::consts::FRAC_1_PI` found
|
||||
11 | let my_1_frac_pi = 0.3183;
|
||||
| ^^^^^^
|
||||
|
||||
error: approximate value of `f{32, 64}::consts::FRAC_1_SQRT_2` found. Consider using it directly
|
||||
--> $DIR/approx_const.rs:14:28
|
||||
|
|
||||
14 | let my_frac_1_sqrt_2 = 0.70710678; //~ERROR approximate value of `f{32, 64}::consts::FRAC_1_SQRT_2` found
|
||||
14 | let my_frac_1_sqrt_2 = 0.70710678;
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: approximate value of `f{32, 64}::consts::FRAC_1_SQRT_2` found. Consider using it directly
|
||||
--> $DIR/approx_const.rs:15:32
|
||||
|
|
||||
15 | let almost_frac_1_sqrt_2 = 0.70711; //~ERROR approximate value of `f{32, 64}::consts::FRAC_1_SQRT_2` found
|
||||
15 | let almost_frac_1_sqrt_2 = 0.70711;
|
||||
| ^^^^^^^
|
||||
|
||||
error: approximate value of `f{32, 64}::consts::FRAC_2_PI` found. Consider using it directly
|
||||
--> $DIR/approx_const.rs:18:24
|
||||
|
|
||||
18 | let my_frac_2_pi = 0.63661977; //~ERROR approximate value of `f{32, 64}::consts::FRAC_2_PI` found
|
||||
18 | let my_frac_2_pi = 0.63661977;
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: approximate value of `f{32, 64}::consts::FRAC_2_SQRT_PI` found. Consider using it directly
|
||||
--> $DIR/approx_const.rs:21:27
|
||||
|
|
||||
21 | let my_frac_2_sq_pi = 1.128379; //~ERROR approximate value of `f{32, 64}::consts::FRAC_2_SQRT_PI` found
|
||||
21 | let my_frac_2_sq_pi = 1.128379;
|
||||
| ^^^^^^^^
|
||||
|
||||
error: approximate value of `f{32, 64}::consts::FRAC_PI_2` found. Consider using it directly
|
||||
--> $DIR/approx_const.rs:24:24
|
||||
|
|
||||
24 | let my_frac_pi_2 = 1.57079632679; //~ERROR approximate value of `f{32, 64}::consts::FRAC_PI_2` found
|
||||
24 | let my_frac_pi_2 = 1.57079632679;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: approximate value of `f{32, 64}::consts::FRAC_PI_3` found. Consider using it directly
|
||||
--> $DIR/approx_const.rs:27:24
|
||||
|
|
||||
27 | let my_frac_pi_3 = 1.04719755119; //~ERROR approximate value of `f{32, 64}::consts::FRAC_PI_3` found
|
||||
27 | let my_frac_pi_3 = 1.04719755119;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: approximate value of `f{32, 64}::consts::FRAC_PI_4` found. Consider using it directly
|
||||
--> $DIR/approx_const.rs:30:24
|
||||
|
|
||||
30 | let my_frac_pi_4 = 0.785398163397; //~ERROR approximate value of `f{32, 64}::consts::FRAC_PI_4` found
|
||||
30 | let my_frac_pi_4 = 0.785398163397;
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: approximate value of `f{32, 64}::consts::FRAC_PI_6` found. Consider using it directly
|
||||
--> $DIR/approx_const.rs:33:24
|
||||
|
|
||||
33 | let my_frac_pi_6 = 0.523598775598; //~ERROR approximate value of `f{32, 64}::consts::FRAC_PI_6` found
|
||||
33 | let my_frac_pi_6 = 0.523598775598;
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: approximate value of `f{32, 64}::consts::FRAC_PI_8` found. Consider using it directly
|
||||
--> $DIR/approx_const.rs:36:24
|
||||
|
|
||||
36 | let my_frac_pi_8 = 0.3926990816987; //~ERROR approximate value of `f{32, 64}::consts::FRAC_PI_8` found
|
||||
36 | let my_frac_pi_8 = 0.3926990816987;
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error: approximate value of `f{32, 64}::consts::LN_10` found. Consider using it directly
|
||||
--> $DIR/approx_const.rs:39:20
|
||||
|
|
||||
39 | let my_ln_10 = 2.302585092994046; //~ERROR approximate value of `f{32, 64}::consts::LN_10` found
|
||||
39 | let my_ln_10 = 2.302585092994046;
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: approximate value of `f{32, 64}::consts::LN_2` found. Consider using it directly
|
||||
--> $DIR/approx_const.rs:42:19
|
||||
|
|
||||
42 | let my_ln_2 = 0.6931471805599453; //~ERROR approximate value of `f{32, 64}::consts::LN_2` found
|
||||
42 | let my_ln_2 = 0.6931471805599453;
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: approximate value of `f{32, 64}::consts::LOG10_E` found. Consider using it directly
|
||||
--> $DIR/approx_const.rs:45:22
|
||||
|
|
||||
45 | let my_log10_e = 0.43429448190325182; //~ERROR approximate value of `f{32, 64}::consts::LOG10_E` found
|
||||
45 | let my_log10_e = 0.43429448190325182;
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: approximate value of `f{32, 64}::consts::LOG2_E` found. Consider using it directly
|
||||
--> $DIR/approx_const.rs:48:21
|
||||
|
|
||||
48 | let my_log2_e = 1.4426950408889634; //~ERROR approximate value of `f{32, 64}::consts::LOG2_E` found
|
||||
48 | let my_log2_e = 1.4426950408889634;
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: approximate value of `f{32, 64}::consts::PI` found. Consider using it directly
|
||||
--> $DIR/approx_const.rs:51:17
|
||||
|
|
||||
51 | let my_pi = 3.1415; //~ERROR approximate value of `f{32, 64}::consts::PI` found
|
||||
51 | let my_pi = 3.1415;
|
||||
| ^^^^^^
|
||||
|
||||
error: approximate value of `f{32, 64}::consts::PI` found. Consider using it directly
|
||||
--> $DIR/approx_const.rs:52:21
|
||||
|
|
||||
52 | let almost_pi = 3.14; //~ERROR approximate value of `f{32, 64}::consts::PI` found
|
||||
52 | let almost_pi = 3.14;
|
||||
| ^^^^
|
||||
|
||||
error: approximate value of `f{32, 64}::consts::SQRT_2` found. Consider using it directly
|
||||
--> $DIR/approx_const.rs:55:18
|
||||
|
|
||||
55 | let my_sq2 = 1.4142; //~ERROR approximate value of `f{32, 64}::consts::SQRT_2` found
|
||||
55 | let my_sq2 = 1.4142;
|
||||
| ^^^^^^
|
||||
|
||||
error: aborting due to 19 previous errors
|
||||
|
@ -5,12 +5,12 @@
|
||||
#![allow(unused, shadow_reuse, shadow_unrelated, no_effect, unnecessary_operation)]
|
||||
fn main() {
|
||||
let i = 1i32;
|
||||
1 + i; //~ERROR integer arithmetic detected
|
||||
i * 2; //~ERROR integer arithmetic detected
|
||||
1 % //~ERROR integer arithmetic detected
|
||||
1 + i;
|
||||
i * 2;
|
||||
1 %
|
||||
i / 2; // no error, this is part of the expression in the preceding line
|
||||
i - 2 + 2 - i; //~ERROR integer arithmetic detected
|
||||
-i; //~ERROR integer arithmetic detected
|
||||
i - 2 + 2 - i;
|
||||
-i;
|
||||
|
||||
i & 1; // no wrapping
|
||||
i | 1;
|
||||
@ -20,11 +20,11 @@ fn main() {
|
||||
|
||||
let f = 1.0f32;
|
||||
|
||||
f * 2.0; //~ERROR floating-point arithmetic detected
|
||||
f * 2.0;
|
||||
|
||||
1.0 + f; //~ERROR floating-point arithmetic detected
|
||||
f * 2.0; //~ERROR floating-point arithmetic detected
|
||||
f / 2.0; //~ERROR floating-point arithmetic detected
|
||||
f - 2.0 * 4.2; //~ERROR floating-point arithmetic detected
|
||||
-f; //~ERROR floating-point arithmetic detected
|
||||
1.0 + f;
|
||||
f * 2.0;
|
||||
f / 2.0;
|
||||
f - 2.0 * 4.2;
|
||||
-f;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
error: integer arithmetic detected
|
||||
--> $DIR/arithmetic.rs:8:5
|
||||
|
|
||||
8 | 1 + i; //~ERROR integer arithmetic detected
|
||||
8 | 1 + i;
|
||||
| ^^^^^
|
||||
|
|
||||
note: lint level defined here
|
||||
@ -13,13 +13,13 @@ note: lint level defined here
|
||||
error: integer arithmetic detected
|
||||
--> $DIR/arithmetic.rs:9:5
|
||||
|
|
||||
9 | i * 2; //~ERROR integer arithmetic detected
|
||||
9 | i * 2;
|
||||
| ^^^^^
|
||||
|
||||
error: integer arithmetic detected
|
||||
--> $DIR/arithmetic.rs:10:5
|
||||
|
|
||||
10 | 1 % //~ERROR integer arithmetic detected
|
||||
10 | 1 %
|
||||
| _____^ starting here...
|
||||
11 | | i / 2; // no error, this is part of the expression in the preceding line
|
||||
| |_________^ ...ending here
|
||||
@ -27,19 +27,19 @@ error: integer arithmetic detected
|
||||
error: integer arithmetic detected
|
||||
--> $DIR/arithmetic.rs:12:5
|
||||
|
|
||||
12 | i - 2 + 2 - i; //~ERROR integer arithmetic detected
|
||||
12 | i - 2 + 2 - i;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: integer arithmetic detected
|
||||
--> $DIR/arithmetic.rs:13:5
|
||||
|
|
||||
13 | -i; //~ERROR integer arithmetic detected
|
||||
13 | -i;
|
||||
| ^^
|
||||
|
||||
error: floating-point arithmetic detected
|
||||
--> $DIR/arithmetic.rs:23:5
|
||||
|
|
||||
23 | f * 2.0; //~ERROR floating-point arithmetic detected
|
||||
23 | f * 2.0;
|
||||
| ^^^^^^^
|
||||
|
|
||||
note: lint level defined here
|
||||
@ -51,31 +51,31 @@ note: lint level defined here
|
||||
error: floating-point arithmetic detected
|
||||
--> $DIR/arithmetic.rs:25:5
|
||||
|
|
||||
25 | 1.0 + f; //~ERROR floating-point arithmetic detected
|
||||
25 | 1.0 + f;
|
||||
| ^^^^^^^
|
||||
|
||||
error: floating-point arithmetic detected
|
||||
--> $DIR/arithmetic.rs:26:5
|
||||
|
|
||||
26 | f * 2.0; //~ERROR floating-point arithmetic detected
|
||||
26 | f * 2.0;
|
||||
| ^^^^^^^
|
||||
|
||||
error: floating-point arithmetic detected
|
||||
--> $DIR/arithmetic.rs:27:5
|
||||
|
|
||||
27 | f / 2.0; //~ERROR floating-point arithmetic detected
|
||||
27 | f / 2.0;
|
||||
| ^^^^^^^
|
||||
|
||||
error: floating-point arithmetic detected
|
||||
--> $DIR/arithmetic.rs:28:5
|
||||
|
|
||||
28 | f - 2.0 * 4.2; //~ERROR floating-point arithmetic detected
|
||||
28 | f - 2.0 * 4.2;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: floating-point arithmetic detected
|
||||
--> $DIR/arithmetic.rs:29:5
|
||||
|
|
||||
29 | -f; //~ERROR floating-point arithmetic detected
|
||||
29 | -f;
|
||||
| ^^
|
||||
|
||||
error: aborting due to 11 previous errors
|
||||
|
@ -9,37 +9,37 @@ fn main() {
|
||||
let x = [1,2,3,4];
|
||||
x[0];
|
||||
x[3];
|
||||
x[4]; //~ERROR: const index is out of bounds
|
||||
x[1 << 3]; //~ERROR: const index is out of bounds
|
||||
&x[1..5]; //~ERROR: range is out of bounds
|
||||
x[4];
|
||||
x[1 << 3];
|
||||
&x[1..5];
|
||||
&x[0..3];
|
||||
&x[0...4]; //~ERROR: range is out of bounds
|
||||
&x[...4]; //~ERROR: range is out of bounds
|
||||
&x[0...4];
|
||||
&x[...4];
|
||||
&x[..];
|
||||
&x[1..];
|
||||
&x[4..];
|
||||
&x[5..]; //~ERROR: range is out of bounds
|
||||
&x[5..];
|
||||
&x[..4];
|
||||
&x[..5]; //~ERROR: range is out of bounds
|
||||
&x[..5];
|
||||
|
||||
let y = &x;
|
||||
y[0]; //~ERROR: indexing may panic
|
||||
&y[1..2]; //~ERROR: slicing may panic
|
||||
y[0];
|
||||
&y[1..2];
|
||||
&y[..];
|
||||
&y[0...4]; //~ERROR: slicing may panic
|
||||
&y[...4]; //~ERROR: slicing may panic
|
||||
&y[0...4];
|
||||
&y[...4];
|
||||
|
||||
let empty: [i8; 0] = [];
|
||||
empty[0]; //~ERROR: const index is out of bounds
|
||||
&empty[1..5]; //~ERROR: range is out of bounds
|
||||
&empty[0...4]; //~ERROR: range is out of bounds
|
||||
&empty[...4]; //~ERROR: range is out of bounds
|
||||
empty[0];
|
||||
&empty[1..5];
|
||||
&empty[0...4];
|
||||
&empty[...4];
|
||||
&empty[..];
|
||||
&empty[0..];
|
||||
&empty[0..0];
|
||||
&empty[0...0]; //~ERROR: range is out of bounds
|
||||
&empty[...0]; //~ERROR: range is out of bounds
|
||||
&empty[0...0];
|
||||
&empty[...0];
|
||||
&empty[..0];
|
||||
&empty[1..]; //~ERROR: range is out of bounds
|
||||
&empty[..4]; //~ERROR: range is out of bounds
|
||||
&empty[1..];
|
||||
&empty[..4];
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
error: const index is out of bounds
|
||||
--> $DIR/array_indexing.rs:12:5
|
||||
|
|
||||
12 | x[4]; //~ERROR: const index is out of bounds
|
||||
12 | x[4];
|
||||
| ^^^^
|
||||
|
|
||||
= note: #[deny(out_of_bounds_indexing)] on by default
|
||||
@ -9,7 +9,7 @@ error: const index is out of bounds
|
||||
error: const index is out of bounds
|
||||
--> $DIR/array_indexing.rs:13:5
|
||||
|
|
||||
13 | x[1 << 3]; //~ERROR: const index is out of bounds
|
||||
13 | x[1 << 3];
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: #[deny(out_of_bounds_indexing)] on by default
|
||||
@ -17,7 +17,7 @@ error: const index is out of bounds
|
||||
error: range is out of bounds
|
||||
--> $DIR/array_indexing.rs:14:6
|
||||
|
|
||||
14 | &x[1..5]; //~ERROR: range is out of bounds
|
||||
14 | &x[1..5];
|
||||
| ^^^^^^^
|
||||
|
|
||||
= note: #[deny(out_of_bounds_indexing)] on by default
|
||||
@ -25,7 +25,7 @@ error: range is out of bounds
|
||||
error: range is out of bounds
|
||||
--> $DIR/array_indexing.rs:16:6
|
||||
|
|
||||
16 | &x[0...4]; //~ERROR: range is out of bounds
|
||||
16 | &x[0...4];
|
||||
| ^^^^^^^^
|
||||
|
|
||||
= note: #[deny(out_of_bounds_indexing)] on by default
|
||||
@ -33,7 +33,7 @@ error: range is out of bounds
|
||||
error: range is out of bounds
|
||||
--> $DIR/array_indexing.rs:17:6
|
||||
|
|
||||
17 | &x[...4]; //~ERROR: range is out of bounds
|
||||
17 | &x[...4];
|
||||
| ^^^^^^^
|
||||
|
|
||||
= note: #[deny(out_of_bounds_indexing)] on by default
|
||||
@ -41,7 +41,7 @@ error: range is out of bounds
|
||||
error: range is out of bounds
|
||||
--> $DIR/array_indexing.rs:21:6
|
||||
|
|
||||
21 | &x[5..]; //~ERROR: range is out of bounds
|
||||
21 | &x[5..];
|
||||
| ^^^^^^
|
||||
|
|
||||
= note: #[deny(out_of_bounds_indexing)] on by default
|
||||
@ -49,7 +49,7 @@ error: range is out of bounds
|
||||
error: range is out of bounds
|
||||
--> $DIR/array_indexing.rs:23:6
|
||||
|
|
||||
23 | &x[..5]; //~ERROR: range is out of bounds
|
||||
23 | &x[..5];
|
||||
| ^^^^^^
|
||||
|
|
||||
= note: #[deny(out_of_bounds_indexing)] on by default
|
||||
@ -57,7 +57,7 @@ error: range is out of bounds
|
||||
error: indexing may panic
|
||||
--> $DIR/array_indexing.rs:26:5
|
||||
|
|
||||
26 | y[0]; //~ERROR: indexing may panic
|
||||
26 | y[0];
|
||||
| ^^^^
|
||||
|
|
||||
note: lint level defined here
|
||||
@ -69,25 +69,25 @@ note: lint level defined here
|
||||
error: slicing may panic
|
||||
--> $DIR/array_indexing.rs:27:6
|
||||
|
|
||||
27 | &y[1..2]; //~ERROR: slicing may panic
|
||||
27 | &y[1..2];
|
||||
| ^^^^^^^
|
||||
|
||||
error: slicing may panic
|
||||
--> $DIR/array_indexing.rs:29:6
|
||||
|
|
||||
29 | &y[0...4]; //~ERROR: slicing may panic
|
||||
29 | &y[0...4];
|
||||
| ^^^^^^^^
|
||||
|
||||
error: slicing may panic
|
||||
--> $DIR/array_indexing.rs:30:6
|
||||
|
|
||||
30 | &y[...4]; //~ERROR: slicing may panic
|
||||
30 | &y[...4];
|
||||
| ^^^^^^^
|
||||
|
||||
error: const index is out of bounds
|
||||
--> $DIR/array_indexing.rs:33:5
|
||||
|
|
||||
33 | empty[0]; //~ERROR: const index is out of bounds
|
||||
33 | empty[0];
|
||||
| ^^^^^^^^
|
||||
|
|
||||
= note: #[deny(out_of_bounds_indexing)] on by default
|
||||
@ -95,7 +95,7 @@ error: const index is out of bounds
|
||||
error: range is out of bounds
|
||||
--> $DIR/array_indexing.rs:34:6
|
||||
|
|
||||
34 | &empty[1..5]; //~ERROR: range is out of bounds
|
||||
34 | &empty[1..5];
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
= note: #[deny(out_of_bounds_indexing)] on by default
|
||||
@ -103,7 +103,7 @@ error: range is out of bounds
|
||||
error: range is out of bounds
|
||||
--> $DIR/array_indexing.rs:35:6
|
||||
|
|
||||
35 | &empty[0...4]; //~ERROR: range is out of bounds
|
||||
35 | &empty[0...4];
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
||||
= note: #[deny(out_of_bounds_indexing)] on by default
|
||||
@ -111,7 +111,7 @@ error: range is out of bounds
|
||||
error: range is out of bounds
|
||||
--> $DIR/array_indexing.rs:36:6
|
||||
|
|
||||
36 | &empty[...4]; //~ERROR: range is out of bounds
|
||||
36 | &empty[...4];
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
= note: #[deny(out_of_bounds_indexing)] on by default
|
||||
@ -119,7 +119,7 @@ error: range is out of bounds
|
||||
error: range is out of bounds
|
||||
--> $DIR/array_indexing.rs:40:6
|
||||
|
|
||||
40 | &empty[0...0]; //~ERROR: range is out of bounds
|
||||
40 | &empty[0...0];
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
||||
= note: #[deny(out_of_bounds_indexing)] on by default
|
||||
@ -127,7 +127,7 @@ error: range is out of bounds
|
||||
error: range is out of bounds
|
||||
--> $DIR/array_indexing.rs:41:6
|
||||
|
|
||||
41 | &empty[...0]; //~ERROR: range is out of bounds
|
||||
41 | &empty[...0];
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
= note: #[deny(out_of_bounds_indexing)] on by default
|
||||
@ -135,7 +135,7 @@ error: range is out of bounds
|
||||
error: range is out of bounds
|
||||
--> $DIR/array_indexing.rs:43:6
|
||||
|
|
||||
43 | &empty[1..]; //~ERROR: range is out of bounds
|
||||
43 | &empty[1..];
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
= note: #[deny(out_of_bounds_indexing)] on by default
|
||||
@ -143,7 +143,7 @@ error: range is out of bounds
|
||||
error: range is out of bounds
|
||||
--> $DIR/array_indexing.rs:44:6
|
||||
|
|
||||
44 | &empty[..4]; //~ERROR: range is out of bounds
|
||||
44 | &empty[..4];
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
= note: #[deny(out_of_bounds_indexing)] on by default
|
||||
|
@ -5,77 +5,77 @@
|
||||
#[allow(unused_assignments)]
|
||||
fn main() {
|
||||
let mut i = 1i32;
|
||||
i += 2; //~ ERROR assign operation detected
|
||||
//~^ HELP replace it with
|
||||
//~| SUGGESTION i = i + 2
|
||||
i += 2 + 17; //~ ERROR assign operation detected
|
||||
//~^ HELP replace it with
|
||||
//~| SUGGESTION i = i + 2 + 17
|
||||
i -= 6; //~ ERROR assign operation detected
|
||||
//~^ HELP replace it with
|
||||
//~| SUGGESTION i = i - 6
|
||||
i += 2;
|
||||
|
||||
|
||||
i += 2 + 17;
|
||||
|
||||
|
||||
i -= 6;
|
||||
|
||||
|
||||
i -= 2 - 1;
|
||||
//~^ ERROR assign operation detected
|
||||
//~| HELP replace it with
|
||||
//~| SUGGESTION i = i - (2 - 1)
|
||||
i *= 5; //~ ERROR assign operation detected
|
||||
//~^ HELP replace it with
|
||||
//~| SUGGESTION i = i * 5
|
||||
i *= 1+5; //~ ERROR assign operation detected
|
||||
//~^ HELP replace it with
|
||||
//~| SUGGESTION i = i * (1+5)
|
||||
i /= 32; //~ ERROR assign operation detected
|
||||
//~^ HELP replace it with
|
||||
//~| SUGGESTION i = i / 32
|
||||
i /= 32 | 5; //~ ERROR assign operation detected
|
||||
//~^ HELP replace it with
|
||||
//~| SUGGESTION i = i / (32 | 5)
|
||||
i /= 32 / 5; //~ ERROR assign operation detected
|
||||
//~^ HELP replace it with
|
||||
//~| SUGGESTION i = i / (32 / 5)
|
||||
i %= 42; //~ ERROR assign operation detected
|
||||
//~^ HELP replace it with
|
||||
//~| SUGGESTION i = i % 42
|
||||
i >>= i; //~ ERROR assign operation detected
|
||||
//~^ HELP replace it with
|
||||
//~| SUGGESTION i = i >> i
|
||||
i <<= 9 + 6 - 7; //~ ERROR assign operation detected
|
||||
//~^ HELP replace it with
|
||||
//~| SUGGESTION i = i << (9 + 6 - 7)
|
||||
|
||||
|
||||
|
||||
i *= 5;
|
||||
|
||||
|
||||
i *= 1+5;
|
||||
|
||||
|
||||
i /= 32;
|
||||
|
||||
|
||||
i /= 32 | 5;
|
||||
|
||||
|
||||
i /= 32 / 5;
|
||||
|
||||
|
||||
i %= 42;
|
||||
|
||||
|
||||
i >>= i;
|
||||
|
||||
|
||||
i <<= 9 + 6 - 7;
|
||||
|
||||
|
||||
i += 1 << 5;
|
||||
//~^ ERROR assign operation detected
|
||||
//~| HELP replace it with
|
||||
//~| SUGGESTION i = i + (1 << 5)
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
#[allow(dead_code, unused_assignments)]
|
||||
#[deny(assign_op_pattern)]
|
||||
fn bla() {
|
||||
let mut a = 5;
|
||||
a = a + 1; //~ ERROR manual implementation of an assign operation
|
||||
//~^ HELP replace it with
|
||||
//~| SUGGESTION a += 1
|
||||
a = 1 + a; //~ ERROR manual implementation of an assign operation
|
||||
//~^ HELP replace it with
|
||||
//~| SUGGESTION a += 1
|
||||
a = a - 1; //~ ERROR manual implementation of an assign operation
|
||||
//~^ HELP replace it with
|
||||
//~| SUGGESTION a -= 1
|
||||
a = a * 99; //~ ERROR manual implementation of an assign operation
|
||||
//~^ HELP replace it with
|
||||
//~| SUGGESTION a *= 99
|
||||
a = 42 * a; //~ ERROR manual implementation of an assign operation
|
||||
//~^ HELP replace it with
|
||||
//~| SUGGESTION a *= 42
|
||||
a = a / 2; //~ ERROR manual implementation of an assign operation
|
||||
//~^ HELP replace it with
|
||||
//~| SUGGESTION a /= 2
|
||||
a = a % 5; //~ ERROR manual implementation of an assign operation
|
||||
//~^ HELP replace it with
|
||||
//~| SUGGESTION a %= 5
|
||||
a = a & 1; //~ ERROR manual implementation of an assign operation
|
||||
//~^ HELP replace it with
|
||||
//~| SUGGESTION a &= 1
|
||||
a = a + 1;
|
||||
|
||||
|
||||
a = 1 + a;
|
||||
|
||||
|
||||
a = a - 1;
|
||||
|
||||
|
||||
a = a * 99;
|
||||
|
||||
|
||||
a = 42 * a;
|
||||
|
||||
|
||||
a = a / 2;
|
||||
|
||||
|
||||
a = a % 5;
|
||||
|
||||
|
||||
a = a & 1;
|
||||
|
||||
|
||||
a = 1 - a;
|
||||
a = 5 / a;
|
||||
a = 42 % a;
|
||||
|
@ -1,7 +1,7 @@
|
||||
error: assign operation detected
|
||||
--> $DIR/assign_ops.rs:8:5
|
||||
|
|
||||
8 | i += 2; //~ ERROR assign operation detected
|
||||
8 | i += 2;
|
||||
| ^^^^^^
|
||||
|
|
||||
note: lint level defined here
|
||||
@ -10,25 +10,25 @@ note: lint level defined here
|
||||
4 | #[deny(assign_ops)]
|
||||
| ^^^^^^^^^^
|
||||
help: replace it with
|
||||
| i = i + 2; //~ ERROR assign operation detected
|
||||
| i = i + 2;
|
||||
|
||||
error: assign operation detected
|
||||
--> $DIR/assign_ops.rs:11:5
|
||||
|
|
||||
11 | i += 2 + 17; //~ ERROR assign operation detected
|
||||
11 | i += 2 + 17;
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
help: replace it with
|
||||
| i = i + 2 + 17; //~ ERROR assign operation detected
|
||||
| i = i + 2 + 17;
|
||||
|
||||
error: assign operation detected
|
||||
--> $DIR/assign_ops.rs:14:5
|
||||
|
|
||||
14 | i -= 6; //~ ERROR assign operation detected
|
||||
14 | i -= 6;
|
||||
| ^^^^^^
|
||||
|
|
||||
help: replace it with
|
||||
| i = i - 6; //~ ERROR assign operation detected
|
||||
| i = i - 6;
|
||||
|
||||
error: assign operation detected
|
||||
--> $DIR/assign_ops.rs:17:5
|
||||
@ -42,74 +42,74 @@ help: replace it with
|
||||
error: assign operation detected
|
||||
--> $DIR/assign_ops.rs:21:5
|
||||
|
|
||||
21 | i *= 5; //~ ERROR assign operation detected
|
||||
21 | i *= 5;
|
||||
| ^^^^^^
|
||||
|
|
||||
help: replace it with
|
||||
| i = i * 5; //~ ERROR assign operation detected
|
||||
| i = i * 5;
|
||||
|
||||
error: assign operation detected
|
||||
--> $DIR/assign_ops.rs:24:5
|
||||
|
|
||||
24 | i *= 1+5; //~ ERROR assign operation detected
|
||||
24 | i *= 1+5;
|
||||
| ^^^^^^^^
|
||||
|
|
||||
help: replace it with
|
||||
| i = i * (1+5); //~ ERROR assign operation detected
|
||||
| i = i * (1+5);
|
||||
|
||||
error: assign operation detected
|
||||
--> $DIR/assign_ops.rs:27:5
|
||||
|
|
||||
27 | i /= 32; //~ ERROR assign operation detected
|
||||
27 | i /= 32;
|
||||
| ^^^^^^^
|
||||
|
|
||||
help: replace it with
|
||||
| i = i / 32; //~ ERROR assign operation detected
|
||||
| i = i / 32;
|
||||
|
||||
error: assign operation detected
|
||||
--> $DIR/assign_ops.rs:30:5
|
||||
|
|
||||
30 | i /= 32 | 5; //~ ERROR assign operation detected
|
||||
30 | i /= 32 | 5;
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
help: replace it with
|
||||
| i = i / (32 | 5); //~ ERROR assign operation detected
|
||||
| i = i / (32 | 5);
|
||||
|
||||
error: assign operation detected
|
||||
--> $DIR/assign_ops.rs:33:5
|
||||
|
|
||||
33 | i /= 32 / 5; //~ ERROR assign operation detected
|
||||
33 | i /= 32 / 5;
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
help: replace it with
|
||||
| i = i / (32 / 5); //~ ERROR assign operation detected
|
||||
| i = i / (32 / 5);
|
||||
|
||||
error: assign operation detected
|
||||
--> $DIR/assign_ops.rs:36:5
|
||||
|
|
||||
36 | i %= 42; //~ ERROR assign operation detected
|
||||
36 | i %= 42;
|
||||
| ^^^^^^^
|
||||
|
|
||||
help: replace it with
|
||||
| i = i % 42; //~ ERROR assign operation detected
|
||||
| i = i % 42;
|
||||
|
||||
error: assign operation detected
|
||||
--> $DIR/assign_ops.rs:39:5
|
||||
|
|
||||
39 | i >>= i; //~ ERROR assign operation detected
|
||||
39 | i >>= i;
|
||||
| ^^^^^^^
|
||||
|
|
||||
help: replace it with
|
||||
| i = i >> i; //~ ERROR assign operation detected
|
||||
| i = i >> i;
|
||||
|
||||
error: assign operation detected
|
||||
--> $DIR/assign_ops.rs:42:5
|
||||
|
|
||||
42 | i <<= 9 + 6 - 7; //~ ERROR assign operation detected
|
||||
42 | i <<= 9 + 6 - 7;
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: replace it with
|
||||
| i = i << (9 + 6 - 7); //~ ERROR assign operation detected
|
||||
| i = i << (9 + 6 - 7);
|
||||
|
||||
error: assign operation detected
|
||||
--> $DIR/assign_ops.rs:45:5
|
||||
@ -123,7 +123,7 @@ help: replace it with
|
||||
error: manual implementation of an assign operation
|
||||
--> $DIR/assign_ops.rs:55:5
|
||||
|
|
||||
55 | a = a + 1; //~ ERROR manual implementation of an assign operation
|
||||
55 | a = a + 1;
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
note: lint level defined here
|
||||
@ -132,70 +132,70 @@ note: lint level defined here
|
||||
52 | #[deny(assign_op_pattern)]
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
help: replace it with
|
||||
| a += 1; //~ ERROR manual implementation of an assign operation
|
||||
| a += 1;
|
||||
|
||||
error: manual implementation of an assign operation
|
||||
--> $DIR/assign_ops.rs:58:5
|
||||
|
|
||||
58 | a = 1 + a; //~ ERROR manual implementation of an assign operation
|
||||
58 | a = 1 + a;
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
help: replace it with
|
||||
| a += 1; //~ ERROR manual implementation of an assign operation
|
||||
| a += 1;
|
||||
|
||||
error: manual implementation of an assign operation
|
||||
--> $DIR/assign_ops.rs:61:5
|
||||
|
|
||||
61 | a = a - 1; //~ ERROR manual implementation of an assign operation
|
||||
61 | a = a - 1;
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
help: replace it with
|
||||
| a -= 1; //~ ERROR manual implementation of an assign operation
|
||||
| a -= 1;
|
||||
|
||||
error: manual implementation of an assign operation
|
||||
--> $DIR/assign_ops.rs:64:5
|
||||
|
|
||||
64 | a = a * 99; //~ ERROR manual implementation of an assign operation
|
||||
64 | a = a * 99;
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
help: replace it with
|
||||
| a *= 99; //~ ERROR manual implementation of an assign operation
|
||||
| a *= 99;
|
||||
|
||||
error: manual implementation of an assign operation
|
||||
--> $DIR/assign_ops.rs:67:5
|
||||
|
|
||||
67 | a = 42 * a; //~ ERROR manual implementation of an assign operation
|
||||
67 | a = 42 * a;
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
help: replace it with
|
||||
| a *= 42; //~ ERROR manual implementation of an assign operation
|
||||
| a *= 42;
|
||||
|
||||
error: manual implementation of an assign operation
|
||||
--> $DIR/assign_ops.rs:70:5
|
||||
|
|
||||
70 | a = a / 2; //~ ERROR manual implementation of an assign operation
|
||||
70 | a = a / 2;
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
help: replace it with
|
||||
| a /= 2; //~ ERROR manual implementation of an assign operation
|
||||
| a /= 2;
|
||||
|
||||
error: manual implementation of an assign operation
|
||||
--> $DIR/assign_ops.rs:73:5
|
||||
|
|
||||
73 | a = a % 5; //~ ERROR manual implementation of an assign operation
|
||||
73 | a = a % 5;
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
help: replace it with
|
||||
| a %= 5; //~ ERROR manual implementation of an assign operation
|
||||
| a %= 5;
|
||||
|
||||
error: manual implementation of an assign operation
|
||||
--> $DIR/assign_ops.rs:76:5
|
||||
|
|
||||
76 | a = a & 1; //~ ERROR manual implementation of an assign operation
|
||||
76 | a = a & 1;
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
help: replace it with
|
||||
| a &= 1; //~ ERROR manual implementation of an assign operation
|
||||
| a &= 1;
|
||||
|
||||
error: aborting due to 21 previous errors
|
||||
|
||||
|
@ -5,30 +5,30 @@
|
||||
#[deny(misrefactored_assign_op)]
|
||||
fn main() {
|
||||
let mut a = 5;
|
||||
a += a + 1; //~ ERROR variable appears on both sides of an assignment operation
|
||||
//~^ HELP replace it with
|
||||
//~| SUGGESTION a += 1
|
||||
a += 1 + a; //~ ERROR variable appears on both sides of an assignment operation
|
||||
//~^ HELP replace it with
|
||||
//~| SUGGESTION a += 1
|
||||
a -= a - 1; //~ ERROR variable appears on both sides of an assignment operation
|
||||
//~^ HELP replace it with
|
||||
//~| SUGGESTION a -= 1
|
||||
a *= a * 99; //~ ERROR variable appears on both sides of an assignment operation
|
||||
//~^ HELP replace it with
|
||||
//~| SUGGESTION a *= 99
|
||||
a *= 42 * a; //~ ERROR variable appears on both sides of an assignment operation
|
||||
//~^ HELP replace it with
|
||||
//~| SUGGESTION a *= 42
|
||||
a /= a / 2; //~ ERROR variable appears on both sides of an assignment operation
|
||||
//~^ HELP replace it with
|
||||
//~| SUGGESTION a /= 2
|
||||
a %= a % 5; //~ ERROR variable appears on both sides of an assignment operation
|
||||
//~^ HELP replace it with
|
||||
//~| SUGGESTION a %= 5
|
||||
a &= a & 1; //~ ERROR variable appears on both sides of an assignment operation
|
||||
//~^ HELP replace it with
|
||||
//~| SUGGESTION a &= 1
|
||||
a += a + 1;
|
||||
|
||||
|
||||
a += 1 + a;
|
||||
|
||||
|
||||
a -= a - 1;
|
||||
|
||||
|
||||
a *= a * 99;
|
||||
|
||||
|
||||
a *= 42 * a;
|
||||
|
||||
|
||||
a /= a / 2;
|
||||
|
||||
|
||||
a %= a % 5;
|
||||
|
||||
|
||||
a &= a & 1;
|
||||
|
||||
|
||||
a -= 1 - a;
|
||||
a /= 5 / a;
|
||||
a %= 42 % a;
|
||||
|
@ -1,7 +1,7 @@
|
||||
error: variable appears on both sides of an assignment operation
|
||||
--> $DIR/assign_ops2.rs:8:5
|
||||
|
|
||||
8 | a += a + 1; //~ ERROR variable appears on both sides of an assignment operation
|
||||
8 | a += a + 1;
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
note: lint level defined here
|
||||
@ -10,70 +10,70 @@ note: lint level defined here
|
||||
5 | #[deny(misrefactored_assign_op)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
help: replace it with
|
||||
| a += 1; //~ ERROR variable appears on both sides of an assignment operation
|
||||
| a += 1;
|
||||
|
||||
error: variable appears on both sides of an assignment operation
|
||||
--> $DIR/assign_ops2.rs:11:5
|
||||
|
|
||||
11 | a += 1 + a; //~ ERROR variable appears on both sides of an assignment operation
|
||||
11 | a += 1 + a;
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
help: replace it with
|
||||
| a += 1; //~ ERROR variable appears on both sides of an assignment operation
|
||||
| a += 1;
|
||||
|
||||
error: variable appears on both sides of an assignment operation
|
||||
--> $DIR/assign_ops2.rs:14:5
|
||||
|
|
||||
14 | a -= a - 1; //~ ERROR variable appears on both sides of an assignment operation
|
||||
14 | a -= a - 1;
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
help: replace it with
|
||||
| a -= 1; //~ ERROR variable appears on both sides of an assignment operation
|
||||
| a -= 1;
|
||||
|
||||
error: variable appears on both sides of an assignment operation
|
||||
--> $DIR/assign_ops2.rs:17:5
|
||||
|
|
||||
17 | a *= a * 99; //~ ERROR variable appears on both sides of an assignment operation
|
||||
17 | a *= a * 99;
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
help: replace it with
|
||||
| a *= 99; //~ ERROR variable appears on both sides of an assignment operation
|
||||
| a *= 99;
|
||||
|
||||
error: variable appears on both sides of an assignment operation
|
||||
--> $DIR/assign_ops2.rs:20:5
|
||||
|
|
||||
20 | a *= 42 * a; //~ ERROR variable appears on both sides of an assignment operation
|
||||
20 | a *= 42 * a;
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
help: replace it with
|
||||
| a *= 42; //~ ERROR variable appears on both sides of an assignment operation
|
||||
| a *= 42;
|
||||
|
||||
error: variable appears on both sides of an assignment operation
|
||||
--> $DIR/assign_ops2.rs:23:5
|
||||
|
|
||||
23 | a /= a / 2; //~ ERROR variable appears on both sides of an assignment operation
|
||||
23 | a /= a / 2;
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
help: replace it with
|
||||
| a /= 2; //~ ERROR variable appears on both sides of an assignment operation
|
||||
| a /= 2;
|
||||
|
||||
error: variable appears on both sides of an assignment operation
|
||||
--> $DIR/assign_ops2.rs:26:5
|
||||
|
|
||||
26 | a %= a % 5; //~ ERROR variable appears on both sides of an assignment operation
|
||||
26 | a %= a % 5;
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
help: replace it with
|
||||
| a %= 5; //~ ERROR variable appears on both sides of an assignment operation
|
||||
| a %= 5;
|
||||
|
||||
error: variable appears on both sides of an assignment operation
|
||||
--> $DIR/assign_ops2.rs:29:5
|
||||
|
|
||||
29 | a &= a & 1; //~ ERROR variable appears on both sides of an assignment operation
|
||||
29 | a &= a & 1;
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
help: replace it with
|
||||
| a &= 1; //~ ERROR variable appears on both sides of an assignment operation
|
||||
| a &= 1;
|
||||
|
||||
error: aborting due to 8 previous errors
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
#![deny(inline_always, deprecated_semver)]
|
||||
|
||||
#[inline(always)] //~ERROR you have declared `#[inline(always)]` on `test_attr_lint`.
|
||||
#[inline(always)]
|
||||
fn test_attr_lint() {
|
||||
assert!(true)
|
||||
}
|
||||
@ -24,10 +24,10 @@ fn empty_and_false_positive_stmt() {
|
||||
unreachable!();
|
||||
}
|
||||
|
||||
#[deprecated(since = "forever")] //~ERROR the since field must contain a semver-compliant version
|
||||
#[deprecated(since = "forever")]
|
||||
pub const SOME_CONST : u8 = 42;
|
||||
|
||||
#[deprecated(since = "1")] //~ERROR the since field must contain a semver-compliant version
|
||||
#[deprecated(since = "1")]
|
||||
pub const ANOTHER_CONST : u8 = 23;
|
||||
|
||||
#[deprecated(since = "0.1.1")]
|
||||
|
@ -1,7 +1,7 @@
|
||||
error: you have declared `#[inline(always)]` on `test_attr_lint`. This is usually a bad idea
|
||||
--> $DIR/attrs.rs:6:1
|
||||
|
|
||||
6 | #[inline(always)] //~ERROR you have declared `#[inline(always)]` on `test_attr_lint`.
|
||||
6 | #[inline(always)]
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: lint level defined here
|
||||
@ -13,7 +13,7 @@ note: lint level defined here
|
||||
error: the since field must contain a semver-compliant version
|
||||
--> $DIR/attrs.rs:27:14
|
||||
|
|
||||
27 | #[deprecated(since = "forever")] //~ERROR the since field must contain a semver-compliant version
|
||||
27 | #[deprecated(since = "forever")]
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: lint level defined here
|
||||
@ -25,7 +25,7 @@ note: lint level defined here
|
||||
error: the since field must contain a semver-compliant version
|
||||
--> $DIR/attrs.rs:30:14
|
||||
|
|
||||
30 | #[deprecated(since = "1")] //~ERROR the since field must contain a semver-compliant version
|
||||
30 | #[deprecated(since = "1")]
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
@ -9,36 +9,36 @@ const EVEN_MORE_REDIRECTION : i64 = THREE_BITS;
|
||||
fn main() {
|
||||
let x = 5;
|
||||
|
||||
x & 0 == 0; //~ERROR &-masking with zero
|
||||
x & 0 == 0;
|
||||
x & 1 == 1; //ok, distinguishes bit 0
|
||||
x & 1 == 0; //ok, compared with zero
|
||||
x & 2 == 1; //~ERROR incompatible bit mask
|
||||
x & 2 == 1;
|
||||
x | 0 == 0; //ok, equals x == 0 (maybe warn?)
|
||||
x | 1 == 3; //ok, equals x == 2 || x == 3
|
||||
x | 3 == 3; //ok, equals x <= 3
|
||||
x | 3 == 2; //~ERROR incompatible bit mask
|
||||
x | 3 == 2;
|
||||
|
||||
x & 1 > 1; //~ERROR incompatible bit mask
|
||||
x & 1 > 1;
|
||||
x & 2 > 1; // ok, distinguishes x & 2 == 2 from x & 2 == 0
|
||||
x & 2 < 1; // ok, distinguishes x & 2 == 2 from x & 2 == 0
|
||||
x | 1 > 1; // ok (if a bit silly), equals x > 1
|
||||
x | 2 > 1; //~ERROR incompatible bit mask
|
||||
x | 2 > 1;
|
||||
x | 2 <= 2; // ok (if a bit silly), equals x <= 2
|
||||
|
||||
x & 192 == 128; // ok, tests for bit 7 and not bit 6
|
||||
x & 0xffc0 == 0xfe80; // ok
|
||||
|
||||
// this also now works with constants
|
||||
x & THREE_BITS == 8; //~ERROR incompatible bit mask
|
||||
x | EVEN_MORE_REDIRECTION < 7; //~ERROR incompatible bit mask
|
||||
x & THREE_BITS == 8;
|
||||
x | EVEN_MORE_REDIRECTION < 7;
|
||||
|
||||
0 & x == 0; //~ERROR &-masking with zero
|
||||
0 & x == 0;
|
||||
1 | x > 1;
|
||||
|
||||
// and should now also match uncommon usage
|
||||
1 < 2 | x; //~ERROR incompatible bit mask
|
||||
2 == 3 | x; //~ERROR incompatible bit mask
|
||||
1 == x & 2; //~ERROR incompatible bit mask
|
||||
1 < 2 | x;
|
||||
2 == 3 | x;
|
||||
1 == x & 2;
|
||||
|
||||
x | 1 > 2; // no error, because we allowed ineffective bit masks
|
||||
ineffective();
|
||||
@ -49,10 +49,10 @@ fn main() {
|
||||
fn ineffective() {
|
||||
let x = 5;
|
||||
|
||||
x | 1 > 3; //~ERROR ineffective bit mask
|
||||
x | 1 < 4; //~ERROR ineffective bit mask
|
||||
x | 1 <= 3; //~ERROR ineffective bit mask
|
||||
x | 1 >= 8; //~ERROR ineffective bit mask
|
||||
x | 1 > 3;
|
||||
x | 1 < 4;
|
||||
x | 1 <= 3;
|
||||
x | 1 >= 8;
|
||||
|
||||
x | 1 > 2; // not an error (yet), better written as x >= 2
|
||||
x | 1 >= 7; // not an error (yet), better written as x >= 6
|
||||
|
@ -1,7 +1,7 @@
|
||||
error: &-masking with zero
|
||||
--> $DIR/bit_masks.rs:12:5
|
||||
|
|
||||
12 | x & 0 == 0; //~ERROR &-masking with zero
|
||||
12 | x & 0 == 0;
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
note: lint level defined here
|
||||
@ -13,67 +13,67 @@ note: lint level defined here
|
||||
error: incompatible bit mask: `_ & 2` can never be equal to `1`
|
||||
--> $DIR/bit_masks.rs:15:5
|
||||
|
|
||||
15 | x & 2 == 1; //~ERROR incompatible bit mask
|
||||
15 | x & 2 == 1;
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: incompatible bit mask: `_ | 3` can never be equal to `2`
|
||||
--> $DIR/bit_masks.rs:19:5
|
||||
|
|
||||
19 | x | 3 == 2; //~ERROR incompatible bit mask
|
||||
19 | x | 3 == 2;
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: incompatible bit mask: `_ & 1` will never be higher than `1`
|
||||
--> $DIR/bit_masks.rs:21:5
|
||||
|
|
||||
21 | x & 1 > 1; //~ERROR incompatible bit mask
|
||||
21 | x & 1 > 1;
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: incompatible bit mask: `_ | 2` will always be higher than `1`
|
||||
--> $DIR/bit_masks.rs:25:5
|
||||
|
|
||||
25 | x | 2 > 1; //~ERROR incompatible bit mask
|
||||
25 | x | 2 > 1;
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: incompatible bit mask: `_ & 7` can never be equal to `8`
|
||||
--> $DIR/bit_masks.rs:32:5
|
||||
|
|
||||
32 | x & THREE_BITS == 8; //~ERROR incompatible bit mask
|
||||
32 | x & THREE_BITS == 8;
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: incompatible bit mask: `_ | 7` will never be lower than `7`
|
||||
--> $DIR/bit_masks.rs:33:5
|
||||
|
|
||||
33 | x | EVEN_MORE_REDIRECTION < 7; //~ERROR incompatible bit mask
|
||||
33 | x | EVEN_MORE_REDIRECTION < 7;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: &-masking with zero
|
||||
--> $DIR/bit_masks.rs:35:5
|
||||
|
|
||||
35 | 0 & x == 0; //~ERROR &-masking with zero
|
||||
35 | 0 & x == 0;
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: incompatible bit mask: `_ | 2` will always be higher than `1`
|
||||
--> $DIR/bit_masks.rs:39:5
|
||||
|
|
||||
39 | 1 < 2 | x; //~ERROR incompatible bit mask
|
||||
39 | 1 < 2 | x;
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: incompatible bit mask: `_ | 3` can never be equal to `2`
|
||||
--> $DIR/bit_masks.rs:40:5
|
||||
|
|
||||
40 | 2 == 3 | x; //~ERROR incompatible bit mask
|
||||
40 | 2 == 3 | x;
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: incompatible bit mask: `_ & 2` can never be equal to `1`
|
||||
--> $DIR/bit_masks.rs:41:5
|
||||
|
|
||||
41 | 1 == x & 2; //~ERROR incompatible bit mask
|
||||
41 | 1 == x & 2;
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: ineffective bit mask: `x | 1` compared to `3`, is the same as x compared directly
|
||||
--> $DIR/bit_masks.rs:52:5
|
||||
|
|
||||
52 | x | 1 > 3; //~ERROR ineffective bit mask
|
||||
52 | x | 1 > 3;
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
note: lint level defined here
|
||||
@ -85,19 +85,19 @@ note: lint level defined here
|
||||
error: ineffective bit mask: `x | 1` compared to `4`, is the same as x compared directly
|
||||
--> $DIR/bit_masks.rs:53:5
|
||||
|
|
||||
53 | x | 1 < 4; //~ERROR ineffective bit mask
|
||||
53 | x | 1 < 4;
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: ineffective bit mask: `x | 1` compared to `3`, is the same as x compared directly
|
||||
--> $DIR/bit_masks.rs:54:5
|
||||
|
|
||||
54 | x | 1 <= 3; //~ERROR ineffective bit mask
|
||||
54 | x | 1 <= 3;
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: ineffective bit mask: `x | 1` compared to `8`, is the same as x compared directly
|
||||
--> $DIR/bit_masks.rs:55:5
|
||||
|
|
||||
55 | x | 1 >= 8; //~ERROR ineffective bit mask
|
||||
55 | x | 1 >= 8;
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: aborting due to 15 previous errors
|
||||
|
@ -6,21 +6,21 @@
|
||||
#![allow(unused_variables, similar_names)]
|
||||
#![deny(blacklisted_name)]
|
||||
|
||||
fn test(foo: ()) {} //~ERROR use of a blacklisted/placeholder name `foo`
|
||||
fn test(foo: ()) {}
|
||||
|
||||
fn main() {
|
||||
let foo = 42; //~ERROR use of a blacklisted/placeholder name `foo`
|
||||
let bar = 42; //~ERROR use of a blacklisted/placeholder name `bar`
|
||||
let baz = 42; //~ERROR use of a blacklisted/placeholder name `baz`
|
||||
let foo = 42;
|
||||
let bar = 42;
|
||||
let baz = 42;
|
||||
|
||||
let barb = 42;
|
||||
let barbaric = 42;
|
||||
|
||||
match (42, Some(1337), Some(0)) {
|
||||
(foo, Some(bar), baz @ Some(_)) => (),
|
||||
//~^ ERROR use of a blacklisted/placeholder name `foo`
|
||||
//~| ERROR use of a blacklisted/placeholder name `bar`
|
||||
//~| ERROR use of a blacklisted/placeholder name `baz`
|
||||
|
||||
|
||||
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
error: use of a blacklisted/placeholder name `foo`
|
||||
--> $DIR/blacklisted_name.rs:9:9
|
||||
|
|
||||
9 | fn test(foo: ()) {} //~ERROR use of a blacklisted/placeholder name `foo`
|
||||
9 | fn test(foo: ()) {}
|
||||
| ^^^
|
||||
|
|
||||
note: lint level defined here
|
||||
@ -13,19 +13,19 @@ note: lint level defined here
|
||||
error: use of a blacklisted/placeholder name `foo`
|
||||
--> $DIR/blacklisted_name.rs:12:9
|
||||
|
|
||||
12 | let foo = 42; //~ERROR use of a blacklisted/placeholder name `foo`
|
||||
12 | let foo = 42;
|
||||
| ^^^
|
||||
|
||||
error: use of a blacklisted/placeholder name `bar`
|
||||
--> $DIR/blacklisted_name.rs:13:9
|
||||
|
|
||||
13 | let bar = 42; //~ERROR use of a blacklisted/placeholder name `bar`
|
||||
13 | let bar = 42;
|
||||
| ^^^
|
||||
|
||||
error: use of a blacklisted/placeholder name `baz`
|
||||
--> $DIR/blacklisted_name.rs:14:9
|
||||
|
|
||||
14 | let baz = 42; //~ERROR use of a blacklisted/placeholder name `baz`
|
||||
14 | let baz = 42;
|
||||
| ^^^
|
||||
|
||||
error: use of a blacklisted/placeholder name `foo`
|
||||
|
@ -27,7 +27,7 @@ fn macro_if() {
|
||||
}
|
||||
|
||||
fn condition_has_block() -> i32 {
|
||||
if { //~ERROR in an 'if' condition, avoid complex blocks or closures with blocks;
|
||||
if {
|
||||
let x = 3;
|
||||
x == 3
|
||||
} {
|
||||
@ -38,7 +38,7 @@ fn condition_has_block() -> i32 {
|
||||
}
|
||||
|
||||
fn condition_has_block_with_single_expression() -> i32 {
|
||||
if { true } { //~ERROR omit braces around single expression condition
|
||||
if { true } {
|
||||
6
|
||||
} else {
|
||||
10
|
||||
@ -56,18 +56,18 @@ fn pred_test() {
|
||||
// inside a closure that the condition is using. same principle applies. add some extra
|
||||
// expressions to make sure linter isn't confused by them.
|
||||
if v == 3 && sky == "blue" && predicate(|x| { let target = 3; x == target }, v) {
|
||||
//~^ERROR in an 'if' condition, avoid complex blocks or closures with blocks;
|
||||
|
||||
}
|
||||
|
||||
if predicate(|x| { let target = 3; x == target }, v) {
|
||||
//~^ERROR in an 'if' condition, avoid complex blocks or closures with blocks;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fn condition_is_normal() -> i32 {
|
||||
let x = 3;
|
||||
if true && x == 3 { //~ WARN this boolean expression can be simplified
|
||||
if true && x == 3 {
|
||||
6
|
||||
} else {
|
||||
10
|
||||
|
@ -1,7 +1,7 @@
|
||||
error: in an 'if' condition, avoid complex blocks or closures with blocks; instead, move the block or closure higher and bind it with a 'let'
|
||||
--> $DIR/block_in_if_condition.rs:30:8
|
||||
|
|
||||
30 | if { //~ERROR in an 'if' condition, avoid complex blocks or closures with blocks;
|
||||
30 | if {
|
||||
| ________^ starting here...
|
||||
31 | | let x = 3;
|
||||
32 | | x == 3
|
||||
@ -14,7 +14,7 @@ note: lint level defined here
|
||||
5 | #![deny(block_in_if_condition_stmt)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
= help: try
|
||||
let res = { //~ERROR in an 'if' condition, avoid complex blocks or closures with blocks;
|
||||
let res = {
|
||||
let x = 3;
|
||||
x == 3
|
||||
};
|
||||
@ -25,7 +25,7 @@ note: lint level defined here
|
||||
error: omit braces around single expression condition
|
||||
--> $DIR/block_in_if_condition.rs:41:8
|
||||
|
|
||||
41 | if { true } { //~ERROR omit braces around single expression condition
|
||||
41 | if { true } {
|
||||
| ^^^^^^^^
|
||||
|
|
||||
note: lint level defined here
|
||||
@ -34,7 +34,7 @@ note: lint level defined here
|
||||
4 | #![deny(block_in_if_condition_expr)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
= help: try
|
||||
if true { //~ERROR omit braces around single expression condition
|
||||
if true {
|
||||
6
|
||||
} ...
|
||||
|
||||
@ -53,7 +53,7 @@ error: in an 'if' condition, avoid complex blocks or closures with blocks; inste
|
||||
warning: this boolean expression can be simplified
|
||||
--> $DIR/block_in_if_condition.rs:70:8
|
||||
|
|
||||
70 | if true && x == 3 { //~ WARN this boolean expression can be simplified
|
||||
70 | if true && x == 3 {
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
note: lint level defined here
|
||||
@ -62,7 +62,7 @@ note: lint level defined here
|
||||
7 | #![warn(nonminimal_bool)]
|
||||
| ^^^^^^^^^^^^^^^
|
||||
help: try
|
||||
| if x == 3 { //~ WARN this boolean expression can be simplified
|
||||
| if x == 3 {
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
@ -5,19 +5,19 @@
|
||||
fn main() {
|
||||
let x = true;
|
||||
if x == true { "yes" } else { "no" };
|
||||
//~^ ERROR equality checks against true are unnecessary
|
||||
//~| HELP try simplifying it as shown:
|
||||
//~| SUGGESTION if x { "yes" } else { "no" };
|
||||
|
||||
|
||||
|
||||
if x == false { "yes" } else { "no" };
|
||||
//~^ ERROR equality checks against false can be replaced by a negation
|
||||
//~| HELP try simplifying it as shown:
|
||||
//~| SUGGESTION if !x { "yes" } else { "no" };
|
||||
|
||||
|
||||
|
||||
if true == x { "yes" } else { "no" };
|
||||
//~^ ERROR equality checks against true are unnecessary
|
||||
//~| HELP try simplifying it as shown:
|
||||
//~| SUGGESTION if x { "yes" } else { "no" };
|
||||
|
||||
|
||||
|
||||
if false == x { "yes" } else { "no" };
|
||||
//~^ ERROR equality checks against false can be replaced by a negation
|
||||
//~| HELP try simplifying it as shown:
|
||||
//~| SUGGESTION if !x { "yes" } else { "no" };
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -9,29 +9,29 @@ fn main() {
|
||||
let c: bool = unimplemented!();
|
||||
let d: bool = unimplemented!();
|
||||
let e: bool = unimplemented!();
|
||||
let _ = a && b || a; //~ ERROR this boolean expression contains a logic bug
|
||||
//~| HELP this expression can be optimized out
|
||||
//~| HELP it would look like the following
|
||||
//~| SUGGESTION let _ = a;
|
||||
let _ = a && b || a;
|
||||
|
||||
|
||||
|
||||
let _ = !(a && b);
|
||||
let _ = !true; //~ ERROR this boolean expression can be simplified
|
||||
//~| HELP try
|
||||
//~| SUGGESTION let _ = false;
|
||||
let _ = !false; //~ ERROR this boolean expression can be simplified
|
||||
//~| HELP try
|
||||
//~| SUGGESTION let _ = true;
|
||||
let _ = !!a; //~ ERROR this boolean expression can be simplified
|
||||
//~| HELP try
|
||||
//~| SUGGESTION let _ = a;
|
||||
let _ = !true;
|
||||
|
||||
|
||||
let _ = !false;
|
||||
|
||||
|
||||
let _ = !!a;
|
||||
|
||||
|
||||
|
||||
let _ = false && a;
|
||||
|
||||
|
||||
|
||||
|
||||
let _ = false || a;
|
||||
|
||||
let _ = false && a; //~ ERROR this boolean expression contains a logic bug
|
||||
//~| HELP this expression can be optimized out
|
||||
//~| HELP it would look like the following
|
||||
//~| SUGGESTION let _ = false;
|
||||
|
||||
let _ = false || a; //~ ERROR this boolean expression can be simplified
|
||||
//~| HELP try
|
||||
//~| SUGGESTION let _ = a;
|
||||
|
||||
// don't lint on cfgs
|
||||
let _ = cfg!(you_shall_not_not_pass) && a;
|
||||
@ -40,9 +40,9 @@ fn main() {
|
||||
|
||||
let _ = !(a && b || c);
|
||||
|
||||
let _ = !(!a && b); //~ ERROR this boolean expression can be simplified
|
||||
//~| HELP try
|
||||
//~| SUGGESTION let _ = !b || a;
|
||||
let _ = !(!a && b);
|
||||
|
||||
|
||||
}
|
||||
|
||||
#[allow(unused, many_single_char_names)]
|
||||
@ -53,38 +53,38 @@ fn equality_stuff() {
|
||||
let d: i32 = unimplemented!();
|
||||
let e: i32 = unimplemented!();
|
||||
let _ = a == b && a != b;
|
||||
//~^ ERROR this boolean expression contains a logic bug
|
||||
//~| HELP this expression can be optimized out
|
||||
//~| HELP it would look like the following
|
||||
//~| SUGGESTION let _ = false;
|
||||
|
||||
|
||||
|
||||
|
||||
let _ = a == b && c == 5 && a == b;
|
||||
//~^ ERROR this boolean expression can be simplified
|
||||
//~| HELP try
|
||||
//~| SUGGESTION let _ = a == b && c == 5;
|
||||
//~| HELP try
|
||||
//~| SUGGESTION let _ = !(c != 5 || a != b);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
let _ = a == b && c == 5 && b == a;
|
||||
//~^ ERROR this boolean expression can be simplified
|
||||
//~| HELP try
|
||||
//~| SUGGESTION let _ = a == b && c == 5;
|
||||
//~| HELP try
|
||||
//~| SUGGESTION let _ = !(c != 5 || a != b);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
let _ = a < b && a >= b;
|
||||
//~^ ERROR this boolean expression contains a logic bug
|
||||
//~| HELP this expression can be optimized out
|
||||
//~| HELP it would look like the following
|
||||
//~| SUGGESTION let _ = false;
|
||||
|
||||
|
||||
|
||||
|
||||
let _ = a > b && a <= b;
|
||||
//~^ ERROR this boolean expression contains a logic bug
|
||||
//~| HELP this expression can be optimized out
|
||||
//~| HELP it would look like the following
|
||||
//~| SUGGESTION let _ = false;
|
||||
|
||||
|
||||
|
||||
|
||||
let _ = a > b && a == b;
|
||||
|
||||
let _ = a != b || !(a != b || c == d);
|
||||
//~^ ERROR this boolean expression can be simplified
|
||||
//~| HELP try
|
||||
//~| SUGGESTION let _ = c != d || a != b;
|
||||
//~| HELP try
|
||||
//~| SUGGESTION let _ = !(a == b && c == d);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
error: this boolean expression contains a logic bug
|
||||
--> $DIR/booleans.rs:12:13
|
||||
|
|
||||
12 | let _ = a && b || a; //~ ERROR this boolean expression contains a logic bug
|
||||
12 | let _ = a && b || a;
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
note: lint level defined here
|
||||
@ -12,15 +12,15 @@ note: lint level defined here
|
||||
help: this expression can be optimized out by applying boolean operations to the outer expression
|
||||
--> $DIR/booleans.rs:12:18
|
||||
|
|
||||
12 | let _ = a && b || a; //~ ERROR this boolean expression contains a logic bug
|
||||
12 | let _ = a && b || a;
|
||||
| ^
|
||||
help: it would look like the following
|
||||
| let _ = a; //~ ERROR this boolean expression contains a logic bug
|
||||
| let _ = a;
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> $DIR/booleans.rs:17:13
|
||||
|
|
||||
17 | let _ = !true; //~ ERROR this boolean expression can be simplified
|
||||
17 | let _ = !true;
|
||||
| ^^^^^
|
||||
|
|
||||
note: lint level defined here
|
||||
@ -29,57 +29,57 @@ note: lint level defined here
|
||||
3 | #![deny(nonminimal_bool, logic_bug)]
|
||||
| ^^^^^^^^^^^^^^^
|
||||
help: try
|
||||
| let _ = false; //~ ERROR this boolean expression can be simplified
|
||||
| let _ = false;
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> $DIR/booleans.rs:20:13
|
||||
|
|
||||
20 | let _ = !false; //~ ERROR this boolean expression can be simplified
|
||||
20 | let _ = !false;
|
||||
| ^^^^^^
|
||||
|
|
||||
help: try
|
||||
| let _ = true; //~ ERROR this boolean expression can be simplified
|
||||
| let _ = true;
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> $DIR/booleans.rs:23:13
|
||||
|
|
||||
23 | let _ = !!a; //~ ERROR this boolean expression can be simplified
|
||||
23 | let _ = !!a;
|
||||
| ^^^
|
||||
|
|
||||
help: try
|
||||
| let _ = a; //~ ERROR this boolean expression can be simplified
|
||||
| let _ = a;
|
||||
|
||||
error: this boolean expression contains a logic bug
|
||||
--> $DIR/booleans.rs:27:13
|
||||
|
|
||||
27 | let _ = false && a; //~ ERROR this boolean expression contains a logic bug
|
||||
27 | let _ = false && a;
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
help: this expression can be optimized out by applying boolean operations to the outer expression
|
||||
--> $DIR/booleans.rs:27:22
|
||||
|
|
||||
27 | let _ = false && a; //~ ERROR this boolean expression contains a logic bug
|
||||
27 | let _ = false && a;
|
||||
| ^
|
||||
help: it would look like the following
|
||||
| let _ = false; //~ ERROR this boolean expression contains a logic bug
|
||||
| let _ = false;
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> $DIR/booleans.rs:32:13
|
||||
|
|
||||
32 | let _ = false || a; //~ ERROR this boolean expression can be simplified
|
||||
32 | let _ = false || a;
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
help: try
|
||||
| let _ = a; //~ ERROR this boolean expression can be simplified
|
||||
| let _ = a;
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> $DIR/booleans.rs:43:13
|
||||
|
|
||||
43 | let _ = !(!a && b); //~ ERROR this boolean expression can be simplified
|
||||
43 | let _ = !(!a && b);
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
help: try
|
||||
| let _ = !b || a; //~ ERROR this boolean expression can be simplified
|
||||
| let _ = !b || a;
|
||||
|
||||
error: this boolean expression contains a logic bug
|
||||
--> $DIR/booleans.rs:55:13
|
||||
|
@ -14,7 +14,7 @@ macro_rules! boxit {
|
||||
fn test_macro() {
|
||||
boxit!(Vec::new(), Vec<u8>);
|
||||
}
|
||||
pub fn test(foo: Box<Vec<bool>>) { //~ ERROR you seem to be trying to use `Box<Vec<T>>`
|
||||
pub fn test(foo: Box<Vec<bool>>) {
|
||||
println!("{:?}", foo.get(0))
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
error: you seem to be trying to use `Box<Vec<T>>`. Consider using just `Vec<T>`
|
||||
--> $DIR/box_vec.rs:17:18
|
||||
|
|
||||
17 | pub fn test(foo: Box<Vec<bool>>) { //~ ERROR you seem to be trying to use `Box<Vec<T>>`
|
||||
17 | pub fn test(foo: Box<Vec<bool>>) {
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: #[deny(box_vec)] implied by #[deny(clippy)]
|
||||
|
@ -2,8 +2,8 @@
|
||||
#![plugin(clippy)]
|
||||
#![deny(builtin_type_shadow)]
|
||||
|
||||
fn foo<u32>(a: u32) -> u32 { //~ERROR shadows the built-in type `u32`
|
||||
42 //~ERROR E0308
|
||||
fn foo<u32>(a: u32) -> u32 {
|
||||
42
|
||||
// ^ rustc's type error
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
error: This generic shadows the built-in type `u32`
|
||||
--> $DIR/builtin-type-shadow.rs:5:8
|
||||
|
|
||||
5 | fn foo<u32>(a: u32) -> u32 { //~ERROR shadows the built-in type `u32`
|
||||
5 | fn foo<u32>(a: u32) -> u32 {
|
||||
| ^^^
|
||||
|
|
||||
note: lint level defined here
|
||||
@ -13,7 +13,7 @@ note: lint level defined here
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/builtin-type-shadow.rs:6:5
|
||||
|
|
||||
6 | 42 //~ERROR E0308
|
||||
6 | 42
|
||||
| ^^ expected type parameter, found integral variable
|
||||
|
|
||||
= note: expected type `u32`
|
||||
|
@ -5,60 +5,60 @@
|
||||
#[allow(no_effect, unnecessary_operation)]
|
||||
fn main() {
|
||||
// Test cast_precision_loss
|
||||
1i32 as f32; //~ERROR casting i32 to f32 causes a loss of precision (i32 is 32 bits wide, but f32's mantissa is only 23 bits wide)
|
||||
1i64 as f32; //~ERROR casting i64 to f32 causes a loss of precision (i64 is 64 bits wide, but f32's mantissa is only 23 bits wide)
|
||||
1i64 as f64; //~ERROR casting i64 to f64 causes a loss of precision (i64 is 64 bits wide, but f64's mantissa is only 52 bits wide)
|
||||
1u32 as f32; //~ERROR casting u32 to f32 causes a loss of precision (u32 is 32 bits wide, but f32's mantissa is only 23 bits wide)
|
||||
1u64 as f32; //~ERROR casting u64 to f32 causes a loss of precision (u64 is 64 bits wide, but f32's mantissa is only 23 bits wide)
|
||||
1u64 as f64; //~ERROR casting u64 to f64 causes a loss of precision (u64 is 64 bits wide, but f64's mantissa is only 52 bits wide)
|
||||
1i32 as f32;
|
||||
1i64 as f32;
|
||||
1i64 as f64;
|
||||
1u32 as f32;
|
||||
1u64 as f32;
|
||||
1u64 as f64;
|
||||
1i32 as f64; // Should not trigger the lint
|
||||
1u32 as f64; // Should not trigger the lint
|
||||
|
||||
// Test cast_possible_truncation
|
||||
1f32 as i32; //~ERROR casting f32 to i32 may truncate the value
|
||||
1f32 as u32; //~ERROR casting f32 to u32 may truncate the value
|
||||
//~^ERROR casting f32 to u32 may lose the sign of the value
|
||||
1f64 as f32; //~ERROR casting f64 to f32 may truncate the value
|
||||
1i32 as i8; //~ERROR casting i32 to i8 may truncate the value
|
||||
1i32 as u8; //~ERROR casting i32 to u8 may truncate the value
|
||||
//~^ERROR casting i32 to u8 may lose the sign of the value
|
||||
1f64 as isize; //~ERROR casting f64 to isize may truncate the value
|
||||
1f64 as usize; //~ERROR casting f64 to usize may truncate the value
|
||||
//~^ERROR casting f64 to usize may lose the sign of the value
|
||||
1f32 as i32;
|
||||
1f32 as u32;
|
||||
|
||||
1f64 as f32;
|
||||
1i32 as i8;
|
||||
1i32 as u8;
|
||||
|
||||
1f64 as isize;
|
||||
1f64 as usize;
|
||||
|
||||
|
||||
// Test cast_possible_wrap
|
||||
1u8 as i8; //~ERROR casting u8 to i8 may wrap around the value
|
||||
1u16 as i16; //~ERROR casting u16 to i16 may wrap around the value
|
||||
1u32 as i32; //~ERROR casting u32 to i32 may wrap around the value
|
||||
1u64 as i64; //~ERROR casting u64 to i64 may wrap around the value
|
||||
1usize as isize; //~ERROR casting usize to isize may wrap around the value
|
||||
1u8 as i8;
|
||||
1u16 as i16;
|
||||
1u32 as i32;
|
||||
1u64 as i64;
|
||||
1usize as isize;
|
||||
|
||||
// Test cast_sign_loss
|
||||
1i32 as u32; //~ERROR casting i32 to u32 may lose the sign of the value
|
||||
1isize as usize; //~ERROR casting isize to usize may lose the sign of the value
|
||||
1i32 as u32;
|
||||
1isize as usize;
|
||||
|
||||
// Extra checks for *size
|
||||
// Casting from *size
|
||||
1isize as i8; //~ERROR casting isize to i8 may truncate the value
|
||||
1isize as f64; //~ERROR casting isize to f64 causes a loss of precision on targets with 64-bit wide pointers (isize is 64 bits wide, but f64's mantissa is only 52 bits wide)
|
||||
1usize as f64; //~ERROR casting usize to f64 causes a loss of precision on targets with 64-bit wide pointers (usize is 64 bits wide, but f64's mantissa is only 52 bits wide)
|
||||
1isize as f32; //~ERROR casting isize to f32 causes a loss of precision (isize is 32 or 64 bits wide, but f32's mantissa is only 23 bits wide)
|
||||
1usize as f32; //~ERROR casting usize to f32 causes a loss of precision (usize is 32 or 64 bits wide, but f32's mantissa is only 23 bits wide)
|
||||
1isize as i32; //~ERROR casting isize to i32 may truncate the value on targets with 64-bit wide pointers
|
||||
1isize as u32; //~ERROR casting isize to u32 may lose the sign of the value
|
||||
//~^ERROR casting isize to u32 may truncate the value on targets with 64-bit wide pointers
|
||||
1usize as u32; //~ERROR casting usize to u32 may truncate the value on targets with 64-bit wide pointers
|
||||
1usize as i32; //~ERROR casting usize to i32 may truncate the value on targets with 64-bit wide pointers
|
||||
//~^ERROR casting usize to i32 may wrap around the value on targets with 32-bit wide pointers
|
||||
1isize as i8;
|
||||
1isize as f64;
|
||||
1usize as f64;
|
||||
1isize as f32;
|
||||
1usize as f32;
|
||||
1isize as i32;
|
||||
1isize as u32;
|
||||
|
||||
1usize as u32;
|
||||
1usize as i32;
|
||||
|
||||
// Casting to *size
|
||||
1i64 as isize; //~ERROR casting i64 to isize may truncate the value on targets with 32-bit wide pointers
|
||||
1i64 as usize; //~ERROR casting i64 to usize may truncate the value on targets with 32-bit wide pointers
|
||||
//~^ERROR casting i64 to usize may lose the sign of the value
|
||||
1u64 as isize; //~ERROR casting u64 to isize may truncate the value on targets with 32-bit wide pointers
|
||||
//~^ERROR casting u64 to isize may wrap around the value on targets with 64-bit wide pointers
|
||||
1u64 as usize; //~ERROR casting u64 to usize may truncate the value on targets with 32-bit wide pointers
|
||||
1u32 as isize; //~ERROR casting u32 to isize may wrap around the value on targets with 32-bit wide pointers
|
||||
1i64 as isize;
|
||||
1i64 as usize;
|
||||
|
||||
1u64 as isize;
|
||||
|
||||
1u64 as usize;
|
||||
1u32 as isize;
|
||||
1u32 as usize; // Should not trigger any lint
|
||||
1i32 as isize; // Neither should this
|
||||
1i32 as usize; //~ERROR casting i32 to usize may lose the sign of the value
|
||||
1i32 as usize;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
error: casting i32 to f32 causes a loss of precision (i32 is 32 bits wide, but f32's mantissa is only 23 bits wide)
|
||||
--> $DIR/cast.rs:8:5
|
||||
|
|
||||
8 | 1i32 as f32; //~ERROR casting i32 to f32 causes a loss of precision (i32 is 32 bits wide, but f32's mantissa is only 23 bits wide)
|
||||
8 | 1i32 as f32;
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
note: lint level defined here
|
||||
@ -13,37 +13,37 @@ note: lint level defined here
|
||||
error: casting i64 to f32 causes a loss of precision (i64 is 64 bits wide, but f32's mantissa is only 23 bits wide)
|
||||
--> $DIR/cast.rs:9:5
|
||||
|
|
||||
9 | 1i64 as f32; //~ERROR casting i64 to f32 causes a loss of precision (i64 is 64 bits wide, but f32's mantissa is only 23 bits wide)
|
||||
9 | 1i64 as f32;
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: casting i64 to f64 causes a loss of precision (i64 is 64 bits wide, but f64's mantissa is only 52 bits wide)
|
||||
--> $DIR/cast.rs:10:5
|
||||
|
|
||||
10 | 1i64 as f64; //~ERROR casting i64 to f64 causes a loss of precision (i64 is 64 bits wide, but f64's mantissa is only 52 bits wide)
|
||||
10 | 1i64 as f64;
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: casting u32 to f32 causes a loss of precision (u32 is 32 bits wide, but f32's mantissa is only 23 bits wide)
|
||||
--> $DIR/cast.rs:11:5
|
||||
|
|
||||
11 | 1u32 as f32; //~ERROR casting u32 to f32 causes a loss of precision (u32 is 32 bits wide, but f32's mantissa is only 23 bits wide)
|
||||
11 | 1u32 as f32;
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: casting u64 to f32 causes a loss of precision (u64 is 64 bits wide, but f32's mantissa is only 23 bits wide)
|
||||
--> $DIR/cast.rs:12:5
|
||||
|
|
||||
12 | 1u64 as f32; //~ERROR casting u64 to f32 causes a loss of precision (u64 is 64 bits wide, but f32's mantissa is only 23 bits wide)
|
||||
12 | 1u64 as f32;
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: casting u64 to f64 causes a loss of precision (u64 is 64 bits wide, but f64's mantissa is only 52 bits wide)
|
||||
--> $DIR/cast.rs:13:5
|
||||
|
|
||||
13 | 1u64 as f64; //~ERROR casting u64 to f64 causes a loss of precision (u64 is 64 bits wide, but f64's mantissa is only 52 bits wide)
|
||||
13 | 1u64 as f64;
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: casting f32 to i32 may truncate the value
|
||||
--> $DIR/cast.rs:18:5
|
||||
|
|
||||
18 | 1f32 as i32; //~ERROR casting f32 to i32 may truncate the value
|
||||
18 | 1f32 as i32;
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
note: lint level defined here
|
||||
@ -55,13 +55,13 @@ note: lint level defined here
|
||||
error: casting f32 to u32 may truncate the value
|
||||
--> $DIR/cast.rs:19:5
|
||||
|
|
||||
19 | 1f32 as u32; //~ERROR casting f32 to u32 may truncate the value
|
||||
19 | 1f32 as u32;
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: casting f32 to u32 may lose the sign of the value
|
||||
--> $DIR/cast.rs:19:5
|
||||
|
|
||||
19 | 1f32 as u32; //~ERROR casting f32 to u32 may truncate the value
|
||||
19 | 1f32 as u32;
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
note: lint level defined here
|
||||
@ -73,49 +73,49 @@ note: lint level defined here
|
||||
error: casting f64 to f32 may truncate the value
|
||||
--> $DIR/cast.rs:21:5
|
||||
|
|
||||
21 | 1f64 as f32; //~ERROR casting f64 to f32 may truncate the value
|
||||
21 | 1f64 as f32;
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: casting i32 to i8 may truncate the value
|
||||
--> $DIR/cast.rs:22:5
|
||||
|
|
||||
22 | 1i32 as i8; //~ERROR casting i32 to i8 may truncate the value
|
||||
22 | 1i32 as i8;
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: casting i32 to u8 may lose the sign of the value
|
||||
--> $DIR/cast.rs:23:5
|
||||
|
|
||||
23 | 1i32 as u8; //~ERROR casting i32 to u8 may truncate the value
|
||||
23 | 1i32 as u8;
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: casting i32 to u8 may truncate the value
|
||||
--> $DIR/cast.rs:23:5
|
||||
|
|
||||
23 | 1i32 as u8; //~ERROR casting i32 to u8 may truncate the value
|
||||
23 | 1i32 as u8;
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: casting f64 to isize may truncate the value
|
||||
--> $DIR/cast.rs:25:5
|
||||
|
|
||||
25 | 1f64 as isize; //~ERROR casting f64 to isize may truncate the value
|
||||
25 | 1f64 as isize;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: casting f64 to usize may truncate the value
|
||||
--> $DIR/cast.rs:26:5
|
||||
|
|
||||
26 | 1f64 as usize; //~ERROR casting f64 to usize may truncate the value
|
||||
26 | 1f64 as usize;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: casting f64 to usize may lose the sign of the value
|
||||
--> $DIR/cast.rs:26:5
|
||||
|
|
||||
26 | 1f64 as usize; //~ERROR casting f64 to usize may truncate the value
|
||||
26 | 1f64 as usize;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: casting u8 to i8 may wrap around the value
|
||||
--> $DIR/cast.rs:30:5
|
||||
|
|
||||
30 | 1u8 as i8; //~ERROR casting u8 to i8 may wrap around the value
|
||||
30 | 1u8 as i8;
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
note: lint level defined here
|
||||
@ -127,151 +127,151 @@ note: lint level defined here
|
||||
error: casting u16 to i16 may wrap around the value
|
||||
--> $DIR/cast.rs:31:5
|
||||
|
|
||||
31 | 1u16 as i16; //~ERROR casting u16 to i16 may wrap around the value
|
||||
31 | 1u16 as i16;
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: casting u32 to i32 may wrap around the value
|
||||
--> $DIR/cast.rs:32:5
|
||||
|
|
||||
32 | 1u32 as i32; //~ERROR casting u32 to i32 may wrap around the value
|
||||
32 | 1u32 as i32;
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: casting u64 to i64 may wrap around the value
|
||||
--> $DIR/cast.rs:33:5
|
||||
|
|
||||
33 | 1u64 as i64; //~ERROR casting u64 to i64 may wrap around the value
|
||||
33 | 1u64 as i64;
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: casting usize to isize may wrap around the value
|
||||
--> $DIR/cast.rs:34:5
|
||||
|
|
||||
34 | 1usize as isize; //~ERROR casting usize to isize may wrap around the value
|
||||
34 | 1usize as isize;
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error: casting i32 to u32 may lose the sign of the value
|
||||
--> $DIR/cast.rs:37:5
|
||||
|
|
||||
37 | 1i32 as u32; //~ERROR casting i32 to u32 may lose the sign of the value
|
||||
37 | 1i32 as u32;
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: casting isize to usize may lose the sign of the value
|
||||
--> $DIR/cast.rs:38:5
|
||||
|
|
||||
38 | 1isize as usize; //~ERROR casting isize to usize may lose the sign of the value
|
||||
38 | 1isize as usize;
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error: casting isize to i8 may truncate the value
|
||||
--> $DIR/cast.rs:42:5
|
||||
|
|
||||
42 | 1isize as i8; //~ERROR casting isize to i8 may truncate the value
|
||||
42 | 1isize as i8;
|
||||
| ^^^^^^^^^^^^
|
||||
|
||||
error: casting isize to f64 causes a loss of precision on targets with 64-bit wide pointers (isize is 64 bits wide, but f64's mantissa is only 52 bits wide)
|
||||
--> $DIR/cast.rs:43:5
|
||||
|
|
||||
43 | 1isize as f64; //~ERROR casting isize to f64 causes a loss of precision on targets with 64-bit wide pointers (isize is 64 bits wide, but f64's mantissa is only 52 bits wide)
|
||||
43 | 1isize as f64;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: casting usize to f64 causes a loss of precision on targets with 64-bit wide pointers (usize is 64 bits wide, but f64's mantissa is only 52 bits wide)
|
||||
--> $DIR/cast.rs:44:5
|
||||
|
|
||||
44 | 1usize as f64; //~ERROR casting usize to f64 causes a loss of precision on targets with 64-bit wide pointers (usize is 64 bits wide, but f64's mantissa is only 52 bits wide)
|
||||
44 | 1usize as f64;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: casting isize to f32 causes a loss of precision (isize is 32 or 64 bits wide, but f32's mantissa is only 23 bits wide)
|
||||
--> $DIR/cast.rs:45:5
|
||||
|
|
||||
45 | 1isize as f32; //~ERROR casting isize to f32 causes a loss of precision (isize is 32 or 64 bits wide, but f32's mantissa is only 23 bits wide)
|
||||
45 | 1isize as f32;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: casting usize to f32 causes a loss of precision (usize is 32 or 64 bits wide, but f32's mantissa is only 23 bits wide)
|
||||
--> $DIR/cast.rs:46:5
|
||||
|
|
||||
46 | 1usize as f32; //~ERROR casting usize to f32 causes a loss of precision (usize is 32 or 64 bits wide, but f32's mantissa is only 23 bits wide)
|
||||
46 | 1usize as f32;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: casting isize to i32 may truncate the value on targets with 64-bit wide pointers
|
||||
--> $DIR/cast.rs:47:5
|
||||
|
|
||||
47 | 1isize as i32; //~ERROR casting isize to i32 may truncate the value on targets with 64-bit wide pointers
|
||||
47 | 1isize as i32;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: casting isize to u32 may lose the sign of the value
|
||||
--> $DIR/cast.rs:48:5
|
||||
|
|
||||
48 | 1isize as u32; //~ERROR casting isize to u32 may lose the sign of the value
|
||||
48 | 1isize as u32;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: casting isize to u32 may truncate the value on targets with 64-bit wide pointers
|
||||
--> $DIR/cast.rs:48:5
|
||||
|
|
||||
48 | 1isize as u32; //~ERROR casting isize to u32 may lose the sign of the value
|
||||
48 | 1isize as u32;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: casting usize to u32 may truncate the value on targets with 64-bit wide pointers
|
||||
--> $DIR/cast.rs:50:5
|
||||
|
|
||||
50 | 1usize as u32; //~ERROR casting usize to u32 may truncate the value on targets with 64-bit wide pointers
|
||||
50 | 1usize as u32;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: casting usize to i32 may truncate the value on targets with 64-bit wide pointers
|
||||
--> $DIR/cast.rs:51:5
|
||||
|
|
||||
51 | 1usize as i32; //~ERROR casting usize to i32 may truncate the value on targets with 64-bit wide pointers
|
||||
51 | 1usize as i32;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: casting usize to i32 may wrap around the value on targets with 32-bit wide pointers
|
||||
--> $DIR/cast.rs:51:5
|
||||
|
|
||||
51 | 1usize as i32; //~ERROR casting usize to i32 may truncate the value on targets with 64-bit wide pointers
|
||||
51 | 1usize as i32;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: casting i64 to isize may truncate the value on targets with 32-bit wide pointers
|
||||
--> $DIR/cast.rs:54:5
|
||||
|
|
||||
54 | 1i64 as isize; //~ERROR casting i64 to isize may truncate the value on targets with 32-bit wide pointers
|
||||
54 | 1i64 as isize;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: casting i64 to usize may lose the sign of the value
|
||||
--> $DIR/cast.rs:55:5
|
||||
|
|
||||
55 | 1i64 as usize; //~ERROR casting i64 to usize may truncate the value on targets with 32-bit wide pointers
|
||||
55 | 1i64 as usize;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: casting i64 to usize may truncate the value on targets with 32-bit wide pointers
|
||||
--> $DIR/cast.rs:55:5
|
||||
|
|
||||
55 | 1i64 as usize; //~ERROR casting i64 to usize may truncate the value on targets with 32-bit wide pointers
|
||||
55 | 1i64 as usize;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: casting u64 to isize may truncate the value on targets with 32-bit wide pointers
|
||||
--> $DIR/cast.rs:57:5
|
||||
|
|
||||
57 | 1u64 as isize; //~ERROR casting u64 to isize may truncate the value on targets with 32-bit wide pointers
|
||||
57 | 1u64 as isize;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: casting u64 to isize may wrap around the value on targets with 64-bit wide pointers
|
||||
--> $DIR/cast.rs:57:5
|
||||
|
|
||||
57 | 1u64 as isize; //~ERROR casting u64 to isize may truncate the value on targets with 32-bit wide pointers
|
||||
57 | 1u64 as isize;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: casting u64 to usize may truncate the value on targets with 32-bit wide pointers
|
||||
--> $DIR/cast.rs:59:5
|
||||
|
|
||||
59 | 1u64 as usize; //~ERROR casting u64 to usize may truncate the value on targets with 32-bit wide pointers
|
||||
59 | 1u64 as usize;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: casting u32 to isize may wrap around the value on targets with 32-bit wide pointers
|
||||
--> $DIR/cast.rs:60:5
|
||||
|
|
||||
60 | 1u32 as isize; //~ERROR casting u32 to isize may wrap around the value on targets with 32-bit wide pointers
|
||||
60 | 1u32 as isize;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: casting i32 to usize may lose the sign of the value
|
||||
--> $DIR/cast.rs:63:5
|
||||
|
|
||||
63 | 1i32 as usize; //~ERROR casting i32 to usize may lose the sign of the value
|
||||
63 | 1i32 as usize;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 42 previous errors
|
||||
|
@ -4,5 +4,5 @@
|
||||
#![deny(char_lit_as_u8)]
|
||||
#![allow(unused_variables)]
|
||||
fn main() {
|
||||
let c = 'a' as u8; //~ERROR casting character literal
|
||||
let c = 'a' as u8;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
error: casting character literal to u8. `char`s are 4 bytes wide in rust, so casting to u8 truncates them
|
||||
--> $DIR/char_lit_as_u8.rs:7:13
|
||||
|
|
||||
7 | let c = 'a' as u8; //~ERROR casting character literal
|
||||
7 | let c = 'a' as u8;
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
note: lint level defined here
|
||||
|
@ -5,18 +5,18 @@
|
||||
#[allow(float_cmp, no_effect, unnecessary_operation)]
|
||||
fn main() {
|
||||
let x = 5f32;
|
||||
x == std::f32::NAN; //~ERROR doomed comparison with NAN
|
||||
x != std::f32::NAN; //~ERROR doomed comparison with NAN
|
||||
x < std::f32::NAN; //~ERROR doomed comparison with NAN
|
||||
x > std::f32::NAN; //~ERROR doomed comparison with NAN
|
||||
x <= std::f32::NAN; //~ERROR doomed comparison with NAN
|
||||
x >= std::f32::NAN; //~ERROR doomed comparison with NAN
|
||||
x == std::f32::NAN;
|
||||
x != std::f32::NAN;
|
||||
x < std::f32::NAN;
|
||||
x > std::f32::NAN;
|
||||
x <= std::f32::NAN;
|
||||
x >= std::f32::NAN;
|
||||
|
||||
let y = 0f64;
|
||||
y == std::f64::NAN; //~ERROR doomed comparison with NAN
|
||||
y != std::f64::NAN; //~ERROR doomed comparison with NAN
|
||||
y < std::f64::NAN; //~ERROR doomed comparison with NAN
|
||||
y > std::f64::NAN; //~ERROR doomed comparison with NAN
|
||||
y <= std::f64::NAN; //~ERROR doomed comparison with NAN
|
||||
y >= std::f64::NAN; //~ERROR doomed comparison with NAN
|
||||
y == std::f64::NAN;
|
||||
y != std::f64::NAN;
|
||||
y < std::f64::NAN;
|
||||
y > std::f64::NAN;
|
||||
y <= std::f64::NAN;
|
||||
y >= std::f64::NAN;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
|
||||
--> $DIR/cmp_nan.rs:8:5
|
||||
|
|
||||
8 | x == std::f32::NAN; //~ERROR doomed comparison with NAN
|
||||
8 | x == std::f32::NAN;
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: #[deny(cmp_nan)] on by default
|
||||
@ -9,7 +9,7 @@ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
|
||||
error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
|
||||
--> $DIR/cmp_nan.rs:9:5
|
||||
|
|
||||
9 | x != std::f32::NAN; //~ERROR doomed comparison with NAN
|
||||
9 | x != std::f32::NAN;
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: #[deny(cmp_nan)] on by default
|
||||
@ -17,7 +17,7 @@ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
|
||||
error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
|
||||
--> $DIR/cmp_nan.rs:10:5
|
||||
|
|
||||
10 | x < std::f32::NAN; //~ERROR doomed comparison with NAN
|
||||
10 | x < std::f32::NAN;
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: #[deny(cmp_nan)] on by default
|
||||
@ -25,7 +25,7 @@ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
|
||||
error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
|
||||
--> $DIR/cmp_nan.rs:11:5
|
||||
|
|
||||
11 | x > std::f32::NAN; //~ERROR doomed comparison with NAN
|
||||
11 | x > std::f32::NAN;
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: #[deny(cmp_nan)] on by default
|
||||
@ -33,7 +33,7 @@ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
|
||||
error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
|
||||
--> $DIR/cmp_nan.rs:12:5
|
||||
|
|
||||
12 | x <= std::f32::NAN; //~ERROR doomed comparison with NAN
|
||||
12 | x <= std::f32::NAN;
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: #[deny(cmp_nan)] on by default
|
||||
@ -41,7 +41,7 @@ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
|
||||
error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
|
||||
--> $DIR/cmp_nan.rs:13:5
|
||||
|
|
||||
13 | x >= std::f32::NAN; //~ERROR doomed comparison with NAN
|
||||
13 | x >= std::f32::NAN;
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: #[deny(cmp_nan)] on by default
|
||||
@ -49,7 +49,7 @@ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
|
||||
error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
|
||||
--> $DIR/cmp_nan.rs:16:5
|
||||
|
|
||||
16 | y == std::f64::NAN; //~ERROR doomed comparison with NAN
|
||||
16 | y == std::f64::NAN;
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: #[deny(cmp_nan)] on by default
|
||||
@ -57,7 +57,7 @@ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
|
||||
error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
|
||||
--> $DIR/cmp_nan.rs:17:5
|
||||
|
|
||||
17 | y != std::f64::NAN; //~ERROR doomed comparison with NAN
|
||||
17 | y != std::f64::NAN;
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: #[deny(cmp_nan)] on by default
|
||||
@ -65,7 +65,7 @@ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
|
||||
error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
|
||||
--> $DIR/cmp_nan.rs:18:5
|
||||
|
|
||||
18 | y < std::f64::NAN; //~ERROR doomed comparison with NAN
|
||||
18 | y < std::f64::NAN;
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: #[deny(cmp_nan)] on by default
|
||||
@ -73,7 +73,7 @@ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
|
||||
error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
|
||||
--> $DIR/cmp_nan.rs:19:5
|
||||
|
|
||||
19 | y > std::f64::NAN; //~ERROR doomed comparison with NAN
|
||||
19 | y > std::f64::NAN;
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: #[deny(cmp_nan)] on by default
|
||||
@ -81,7 +81,7 @@ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
|
||||
error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
|
||||
--> $DIR/cmp_nan.rs:20:5
|
||||
|
|
||||
20 | y <= std::f64::NAN; //~ERROR doomed comparison with NAN
|
||||
20 | y <= std::f64::NAN;
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: #[deny(cmp_nan)] on by default
|
||||
@ -89,7 +89,7 @@ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
|
||||
error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
|
||||
--> $DIR/cmp_nan.rs:21:5
|
||||
|
|
||||
21 | y >= std::f64::NAN; //~ERROR doomed comparison with NAN
|
||||
21 | y >= std::f64::NAN;
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: #[deny(cmp_nan)] on by default
|
||||
|
@ -8,12 +8,12 @@ use std::ptr;
|
||||
fn main() {
|
||||
let x = 0;
|
||||
let p : *const usize = &x;
|
||||
if p == ptr::null() { //~ERROR: Comparing with null
|
||||
if p == ptr::null() {
|
||||
println!("This is surprising!");
|
||||
}
|
||||
let mut y = 0;
|
||||
let mut m : *mut usize = &mut y;
|
||||
if m == ptr::null_mut() { //~ERROR: Comparing with null
|
||||
if m == ptr::null_mut() {
|
||||
println!("This is surprising, too!");
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
error: Comparing with null is better expressed by the .is_null() method
|
||||
--> $DIR/cmp_null.rs:11:8
|
||||
|
|
||||
11 | if p == ptr::null() { //~ERROR: Comparing with null
|
||||
11 | if p == ptr::null() {
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: lint level defined here
|
||||
@ -13,7 +13,7 @@ note: lint level defined here
|
||||
error: Comparing with null is better expressed by the .is_null() method
|
||||
--> $DIR/cmp_null.rs:16:8
|
||||
|
|
||||
16 | if m == ptr::null_mut() { //~ERROR: Comparing with null
|
||||
16 | if m == ptr::null_mut() {
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
@ -6,22 +6,22 @@
|
||||
fn main() {
|
||||
fn with_to_string(x : &str) {
|
||||
x != "foo".to_string();
|
||||
//~^ ERROR this creates an owned instance just for comparison. Consider using `x != "foo"` to compare without allocation
|
||||
|
||||
|
||||
"foo".to_string() != x;
|
||||
//~^ ERROR this creates an owned instance just for comparison. Consider using `"foo" != x` to compare without allocation
|
||||
|
||||
}
|
||||
|
||||
let x = "oh";
|
||||
|
||||
with_to_string(x);
|
||||
|
||||
x != "foo".to_owned(); //~ERROR this creates an owned instance
|
||||
x != "foo".to_owned();
|
||||
|
||||
// removed String::from_str(..), as it has finally been removed in 1.4.0
|
||||
// as of 2015-08-14
|
||||
|
||||
x != String::from("foo"); //~ERROR this creates an owned instance
|
||||
x != String::from("foo");
|
||||
|
||||
42.to_string() == "42";
|
||||
}
|
||||
|
@ -19,13 +19,13 @@ error: this creates an owned instance just for comparison. Consider using `"foo"
|
||||
error: this creates an owned instance just for comparison. Consider using `x != "foo"` to compare without allocation
|
||||
--> $DIR/cmp_owned.rs:19:10
|
||||
|
|
||||
19 | x != "foo".to_owned(); //~ERROR this creates an owned instance
|
||||
19 | x != "foo".to_owned();
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this creates an owned instance just for comparison. Consider using `x != "foo"` to compare without allocation
|
||||
--> $DIR/cmp_owned.rs:24:10
|
||||
|
|
||||
24 | x != String::from("foo"); //~ERROR this creates an owned instance
|
||||
24 | x != String::from("foo");
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
@ -6,54 +6,54 @@ fn main() {
|
||||
let x = "hello";
|
||||
let y = "world";
|
||||
if x == "hello" {
|
||||
//~^ ERROR this if statement can be collapsed
|
||||
//~| HELP try
|
||||
//~| SUGGESTION if x == "hello" && y == "world" {
|
||||
|
||||
|
||||
|
||||
if y == "world" {
|
||||
println!("Hello world!");
|
||||
}
|
||||
}
|
||||
|
||||
if x == "hello" || x == "world" {
|
||||
//~^ ERROR this if statement can be collapsed
|
||||
//~| HELP try
|
||||
//~| SUGGESTION if (x == "hello" || x == "world") && (y == "world" || y == "hello") {
|
||||
|
||||
|
||||
|
||||
if y == "world" || y == "hello" {
|
||||
println!("Hello world!");
|
||||
}
|
||||
}
|
||||
|
||||
if x == "hello" && x == "world" {
|
||||
//~^ ERROR this if statement can be collapsed
|
||||
//~| HELP try
|
||||
//~| SUGGESTION if x == "hello" && x == "world" && (y == "world" || y == "hello") {
|
||||
|
||||
|
||||
|
||||
if y == "world" || y == "hello" {
|
||||
println!("Hello world!");
|
||||
}
|
||||
}
|
||||
|
||||
if x == "hello" || x == "world" {
|
||||
//~^ ERROR this if statement can be collapsed
|
||||
//~| HELP try
|
||||
//~| SUGGESTION if (x == "hello" || x == "world") && y == "world" && y == "hello" {
|
||||
|
||||
|
||||
|
||||
if y == "world" && y == "hello" {
|
||||
println!("Hello world!");
|
||||
}
|
||||
}
|
||||
|
||||
if x == "hello" && x == "world" {
|
||||
//~^ ERROR this if statement can be collapsed
|
||||
//~| HELP try
|
||||
//~| SUGGESTION if x == "hello" && x == "world" && y == "world" && y == "hello" {
|
||||
|
||||
|
||||
|
||||
if y == "world" && y == "hello" {
|
||||
println!("Hello world!");
|
||||
}
|
||||
}
|
||||
|
||||
if 42 == 1337 {
|
||||
//~^ ERROR this if statement can be collapsed
|
||||
//~| HELP try
|
||||
//~| SUGGESTION if 42 == 1337 && 'a' != 'A' {
|
||||
|
||||
|
||||
|
||||
if 'a' != 'A' {
|
||||
println!("world!")
|
||||
}
|
||||
@ -63,9 +63,9 @@ fn main() {
|
||||
if x == "hello" {
|
||||
print!("Hello ");
|
||||
} else {
|
||||
//~^ ERROR: this `else { if .. }`
|
||||
//~| HELP try
|
||||
//~| SUGGESTION } else if y == "world"
|
||||
|
||||
|
||||
|
||||
if y == "world" {
|
||||
println!("world!")
|
||||
}
|
||||
@ -74,9 +74,9 @@ fn main() {
|
||||
if x == "hello" {
|
||||
print!("Hello ");
|
||||
} else {
|
||||
//~^ ERROR: this `else { if .. }`
|
||||
//~| HELP try
|
||||
//~| SUGGESTION } else if let Some(42)
|
||||
|
||||
|
||||
|
||||
if let Some(42) = Some(42) {
|
||||
println!("world!")
|
||||
}
|
||||
@ -85,9 +85,9 @@ fn main() {
|
||||
if x == "hello" {
|
||||
print!("Hello ");
|
||||
} else {
|
||||
//~^ ERROR this `else { if .. }`
|
||||
//~| HELP try
|
||||
//~| SUGGESTION } else if y == "world"
|
||||
|
||||
|
||||
|
||||
if y == "world" {
|
||||
println!("world")
|
||||
}
|
||||
@ -99,9 +99,9 @@ fn main() {
|
||||
if x == "hello" {
|
||||
print!("Hello ");
|
||||
} else {
|
||||
//~^ ERROR this `else { if .. }`
|
||||
//~| HELP try
|
||||
//~| SUGGESTION } else if let Some(42)
|
||||
|
||||
|
||||
|
||||
if let Some(42) = Some(42) {
|
||||
println!("world")
|
||||
}
|
||||
@ -113,9 +113,9 @@ fn main() {
|
||||
if let Some(42) = Some(42) {
|
||||
print!("Hello ");
|
||||
} else {
|
||||
//~^ ERROR this `else { if .. }`
|
||||
//~| HELP try
|
||||
//~| SUGGESTION } else if let Some(42)
|
||||
|
||||
|
||||
|
||||
if let Some(42) = Some(42) {
|
||||
println!("world")
|
||||
}
|
||||
@ -127,9 +127,9 @@ fn main() {
|
||||
if let Some(42) = Some(42) {
|
||||
print!("Hello ");
|
||||
} else {
|
||||
//~^ ERROR this `else { if .. }`
|
||||
//~| HELP try
|
||||
//~| SUGGESTION } else if x == "hello"
|
||||
|
||||
|
||||
|
||||
if x == "hello" {
|
||||
println!("world")
|
||||
}
|
||||
@ -141,9 +141,9 @@ fn main() {
|
||||
if let Some(42) = Some(42) {
|
||||
print!("Hello ");
|
||||
} else {
|
||||
//~^ ERROR this `else { if .. }`
|
||||
//~| HELP try
|
||||
//~| SUGGESTION } else if let Some(42)
|
||||
|
||||
|
||||
|
||||
if let Some(42) = Some(42) {
|
||||
println!("world")
|
||||
}
|
||||
|
@ -3,9 +3,9 @@ error: this if statement can be collapsed
|
||||
|
|
||||
8 | if x == "hello" {
|
||||
| _____^ starting here...
|
||||
9 | | //~^ ERROR this if statement can be collapsed
|
||||
10 | | //~| HELP try
|
||||
11 | | //~| SUGGESTION if x == "hello" && y == "world" {
|
||||
9 | |
|
||||
10 | |
|
||||
11 | |
|
||||
12 | | if y == "world" {
|
||||
13 | | println!("Hello world!");
|
||||
14 | | }
|
||||
@ -27,9 +27,9 @@ error: this if statement can be collapsed
|
||||
|
|
||||
17 | if x == "hello" || x == "world" {
|
||||
| _____^ starting here...
|
||||
18 | | //~^ ERROR this if statement can be collapsed
|
||||
19 | | //~| HELP try
|
||||
20 | | //~| SUGGESTION if (x == "hello" || x == "world") && (y == "world" || y == "hello") {
|
||||
18 | |
|
||||
19 | |
|
||||
20 | |
|
||||
21 | | if y == "world" || y == "hello" {
|
||||
22 | | println!("Hello world!");
|
||||
23 | | }
|
||||
@ -46,9 +46,9 @@ error: this if statement can be collapsed
|
||||
|
|
||||
26 | if x == "hello" && x == "world" {
|
||||
| _____^ starting here...
|
||||
27 | | //~^ ERROR this if statement can be collapsed
|
||||
28 | | //~| HELP try
|
||||
29 | | //~| SUGGESTION if x == "hello" && x == "world" && (y == "world" || y == "hello") {
|
||||
27 | |
|
||||
28 | |
|
||||
29 | |
|
||||
30 | | if y == "world" || y == "hello" {
|
||||
31 | | println!("Hello world!");
|
||||
32 | | }
|
||||
@ -65,9 +65,9 @@ error: this if statement can be collapsed
|
||||
|
|
||||
35 | if x == "hello" || x == "world" {
|
||||
| _____^ starting here...
|
||||
36 | | //~^ ERROR this if statement can be collapsed
|
||||
37 | | //~| HELP try
|
||||
38 | | //~| SUGGESTION if (x == "hello" || x == "world") && y == "world" && y == "hello" {
|
||||
36 | |
|
||||
37 | |
|
||||
38 | |
|
||||
39 | | if y == "world" && y == "hello" {
|
||||
40 | | println!("Hello world!");
|
||||
41 | | }
|
||||
@ -84,9 +84,9 @@ error: this if statement can be collapsed
|
||||
|
|
||||
44 | if x == "hello" && x == "world" {
|
||||
| _____^ starting here...
|
||||
45 | | //~^ ERROR this if statement can be collapsed
|
||||
46 | | //~| HELP try
|
||||
47 | | //~| SUGGESTION if x == "hello" && x == "world" && y == "world" && y == "hello" {
|
||||
45 | |
|
||||
46 | |
|
||||
47 | |
|
||||
48 | | if y == "world" && y == "hello" {
|
||||
49 | | println!("Hello world!");
|
||||
50 | | }
|
||||
@ -103,9 +103,9 @@ error: this if statement can be collapsed
|
||||
|
|
||||
53 | if 42 == 1337 {
|
||||
| _____^ starting here...
|
||||
54 | | //~^ ERROR this if statement can be collapsed
|
||||
55 | | //~| HELP try
|
||||
56 | | //~| SUGGESTION if 42 == 1337 && 'a' != 'A' {
|
||||
54 | |
|
||||
55 | |
|
||||
56 | |
|
||||
57 | | if 'a' != 'A' {
|
||||
58 | | println!("world!")
|
||||
59 | | }
|
||||
@ -122,9 +122,9 @@ error: this `else { if .. }` block can be collapsed
|
||||
|
|
||||
65 | } else {
|
||||
| ____________^ starting here...
|
||||
66 | | //~^ ERROR: this `else { if .. }`
|
||||
67 | | //~| HELP try
|
||||
68 | | //~| SUGGESTION } else if y == "world"
|
||||
66 | |
|
||||
67 | |
|
||||
68 | |
|
||||
69 | | if y == "world" {
|
||||
70 | | println!("world!")
|
||||
71 | | }
|
||||
@ -141,9 +141,9 @@ error: this `else { if .. }` block can be collapsed
|
||||
|
|
||||
76 | } else {
|
||||
| ____________^ starting here...
|
||||
77 | | //~^ ERROR: this `else { if .. }`
|
||||
78 | | //~| HELP try
|
||||
79 | | //~| SUGGESTION } else if let Some(42)
|
||||
77 | |
|
||||
78 | |
|
||||
79 | |
|
||||
80 | | if let Some(42) = Some(42) {
|
||||
81 | | println!("world!")
|
||||
82 | | }
|
||||
|
@ -6,38 +6,38 @@
|
||||
|
||||
type Alias = Vec<Vec<Box<(u32, u32, u32, u32)>>>; // no warning here
|
||||
|
||||
const CST: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0)))); //~ERROR very complex type
|
||||
static ST: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0)))); //~ERROR very complex type
|
||||
const CST: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0))));
|
||||
static ST: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0))));
|
||||
|
||||
struct S {
|
||||
f: Vec<Vec<Box<(u32, u32, u32, u32)>>>, //~ERROR very complex type
|
||||
f: Vec<Vec<Box<(u32, u32, u32, u32)>>>,
|
||||
}
|
||||
|
||||
struct TS(Vec<Vec<Box<(u32, u32, u32, u32)>>>); //~ERROR very complex type
|
||||
struct TS(Vec<Vec<Box<(u32, u32, u32, u32)>>>);
|
||||
|
||||
enum E {
|
||||
Tuple(Vec<Vec<Box<(u32, u32, u32, u32)>>>), //~ERROR very complex type
|
||||
Struct { f: Vec<Vec<Box<(u32, u32, u32, u32)>>> }, //~ERROR very complex type
|
||||
Tuple(Vec<Vec<Box<(u32, u32, u32, u32)>>>),
|
||||
Struct { f: Vec<Vec<Box<(u32, u32, u32, u32)>>> },
|
||||
}
|
||||
|
||||
impl S {
|
||||
const A: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0)))); //~ERROR very complex type
|
||||
fn impl_method(&self, p: Vec<Vec<Box<(u32, u32, u32, u32)>>>) { } //~ERROR very complex type
|
||||
const A: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0))));
|
||||
fn impl_method(&self, p: Vec<Vec<Box<(u32, u32, u32, u32)>>>) { }
|
||||
}
|
||||
|
||||
trait T {
|
||||
const A: Vec<Vec<Box<(u32, u32, u32, u32)>>>; //~ERROR very complex type
|
||||
type B = Vec<Vec<Box<(u32, u32, u32, u32)>>>; //~ERROR very complex type
|
||||
fn method(&self, p: Vec<Vec<Box<(u32, u32, u32, u32)>>>); //~ERROR very complex type
|
||||
fn def_method(&self, p: Vec<Vec<Box<(u32, u32, u32, u32)>>>) { } //~ERROR very complex type
|
||||
const A: Vec<Vec<Box<(u32, u32, u32, u32)>>>;
|
||||
type B = Vec<Vec<Box<(u32, u32, u32, u32)>>>;
|
||||
fn method(&self, p: Vec<Vec<Box<(u32, u32, u32, u32)>>>);
|
||||
fn def_method(&self, p: Vec<Vec<Box<(u32, u32, u32, u32)>>>) { }
|
||||
}
|
||||
|
||||
fn test1() -> Vec<Vec<Box<(u32, u32, u32, u32)>>> { vec![] } //~ERROR very complex type
|
||||
fn test1() -> Vec<Vec<Box<(u32, u32, u32, u32)>>> { vec![] }
|
||||
|
||||
fn test2(_x: Vec<Vec<Box<(u32, u32, u32, u32)>>>) { } //~ERROR very complex type
|
||||
fn test2(_x: Vec<Vec<Box<(u32, u32, u32, u32)>>>) { }
|
||||
|
||||
fn test3() {
|
||||
let _y: Vec<Vec<Box<(u32, u32, u32, u32)>>> = vec![]; //~ERROR very complex type
|
||||
let _y: Vec<Vec<Box<(u32, u32, u32, u32)>>> = vec![];
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
@ -1,7 +1,7 @@
|
||||
error: very complex type used. Consider factoring parts into `type` definitions
|
||||
--> $DIR/complex_types.rs:9:12
|
||||
|
|
||||
9 | const CST: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0)))); //~ERROR very complex type
|
||||
9 | const CST: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0))));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: #[deny(type_complexity)] implied by #[deny(clippy)]
|
||||
@ -14,7 +14,7 @@ note: lint level defined here
|
||||
error: very complex type used. Consider factoring parts into `type` definitions
|
||||
--> $DIR/complex_types.rs:10:12
|
||||
|
|
||||
10 | static ST: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0)))); //~ERROR very complex type
|
||||
10 | static ST: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0))));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: #[deny(type_complexity)] implied by #[deny(clippy)]
|
||||
@ -22,7 +22,7 @@ error: very complex type used. Consider factoring parts into `type` definitions
|
||||
error: very complex type used. Consider factoring parts into `type` definitions
|
||||
--> $DIR/complex_types.rs:13:8
|
||||
|
|
||||
13 | f: Vec<Vec<Box<(u32, u32, u32, u32)>>>, //~ERROR very complex type
|
||||
13 | f: Vec<Vec<Box<(u32, u32, u32, u32)>>>,
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: #[deny(type_complexity)] implied by #[deny(clippy)]
|
||||
@ -30,7 +30,7 @@ error: very complex type used. Consider factoring parts into `type` definitions
|
||||
error: very complex type used. Consider factoring parts into `type` definitions
|
||||
--> $DIR/complex_types.rs:16:11
|
||||
|
|
||||
16 | struct TS(Vec<Vec<Box<(u32, u32, u32, u32)>>>); //~ERROR very complex type
|
||||
16 | struct TS(Vec<Vec<Box<(u32, u32, u32, u32)>>>);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: #[deny(type_complexity)] implied by #[deny(clippy)]
|
||||
@ -38,7 +38,7 @@ error: very complex type used. Consider factoring parts into `type` definitions
|
||||
error: very complex type used. Consider factoring parts into `type` definitions
|
||||
--> $DIR/complex_types.rs:19:11
|
||||
|
|
||||
19 | Tuple(Vec<Vec<Box<(u32, u32, u32, u32)>>>), //~ERROR very complex type
|
||||
19 | Tuple(Vec<Vec<Box<(u32, u32, u32, u32)>>>),
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: #[deny(type_complexity)] implied by #[deny(clippy)]
|
||||
@ -46,7 +46,7 @@ error: very complex type used. Consider factoring parts into `type` definitions
|
||||
error: very complex type used. Consider factoring parts into `type` definitions
|
||||
--> $DIR/complex_types.rs:20:17
|
||||
|
|
||||
20 | Struct { f: Vec<Vec<Box<(u32, u32, u32, u32)>>> }, //~ERROR very complex type
|
||||
20 | Struct { f: Vec<Vec<Box<(u32, u32, u32, u32)>>> },
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: #[deny(type_complexity)] implied by #[deny(clippy)]
|
||||
@ -54,7 +54,7 @@ error: very complex type used. Consider factoring parts into `type` definitions
|
||||
error: very complex type used. Consider factoring parts into `type` definitions
|
||||
--> $DIR/complex_types.rs:24:14
|
||||
|
|
||||
24 | const A: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0)))); //~ERROR very complex type
|
||||
24 | const A: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0))));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: #[deny(type_complexity)] implied by #[deny(clippy)]
|
||||
@ -62,7 +62,7 @@ error: very complex type used. Consider factoring parts into `type` definitions
|
||||
error: very complex type used. Consider factoring parts into `type` definitions
|
||||
--> $DIR/complex_types.rs:25:30
|
||||
|
|
||||
25 | fn impl_method(&self, p: Vec<Vec<Box<(u32, u32, u32, u32)>>>) { } //~ERROR very complex type
|
||||
25 | fn impl_method(&self, p: Vec<Vec<Box<(u32, u32, u32, u32)>>>) { }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: #[deny(type_complexity)] implied by #[deny(clippy)]
|
||||
@ -70,7 +70,7 @@ error: very complex type used. Consider factoring parts into `type` definitions
|
||||
error: very complex type used. Consider factoring parts into `type` definitions
|
||||
--> $DIR/complex_types.rs:29:14
|
||||
|
|
||||
29 | const A: Vec<Vec<Box<(u32, u32, u32, u32)>>>; //~ERROR very complex type
|
||||
29 | const A: Vec<Vec<Box<(u32, u32, u32, u32)>>>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: #[deny(type_complexity)] implied by #[deny(clippy)]
|
||||
@ -78,7 +78,7 @@ error: very complex type used. Consider factoring parts into `type` definitions
|
||||
error: very complex type used. Consider factoring parts into `type` definitions
|
||||
--> $DIR/complex_types.rs:30:14
|
||||
|
|
||||
30 | type B = Vec<Vec<Box<(u32, u32, u32, u32)>>>; //~ERROR very complex type
|
||||
30 | type B = Vec<Vec<Box<(u32, u32, u32, u32)>>>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: #[deny(type_complexity)] implied by #[deny(clippy)]
|
||||
@ -86,7 +86,7 @@ error: very complex type used. Consider factoring parts into `type` definitions
|
||||
error: very complex type used. Consider factoring parts into `type` definitions
|
||||
--> $DIR/complex_types.rs:31:25
|
||||
|
|
||||
31 | fn method(&self, p: Vec<Vec<Box<(u32, u32, u32, u32)>>>); //~ERROR very complex type
|
||||
31 | fn method(&self, p: Vec<Vec<Box<(u32, u32, u32, u32)>>>);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: #[deny(type_complexity)] implied by #[deny(clippy)]
|
||||
@ -94,7 +94,7 @@ error: very complex type used. Consider factoring parts into `type` definitions
|
||||
error: very complex type used. Consider factoring parts into `type` definitions
|
||||
--> $DIR/complex_types.rs:32:29
|
||||
|
|
||||
32 | fn def_method(&self, p: Vec<Vec<Box<(u32, u32, u32, u32)>>>) { } //~ERROR very complex type
|
||||
32 | fn def_method(&self, p: Vec<Vec<Box<(u32, u32, u32, u32)>>>) { }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: #[deny(type_complexity)] implied by #[deny(clippy)]
|
||||
@ -102,7 +102,7 @@ error: very complex type used. Consider factoring parts into `type` definitions
|
||||
error: very complex type used. Consider factoring parts into `type` definitions
|
||||
--> $DIR/complex_types.rs:35:15
|
||||
|
|
||||
35 | fn test1() -> Vec<Vec<Box<(u32, u32, u32, u32)>>> { vec![] } //~ERROR very complex type
|
||||
35 | fn test1() -> Vec<Vec<Box<(u32, u32, u32, u32)>>> { vec![] }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: #[deny(type_complexity)] implied by #[deny(clippy)]
|
||||
@ -110,7 +110,7 @@ error: very complex type used. Consider factoring parts into `type` definitions
|
||||
error: very complex type used. Consider factoring parts into `type` definitions
|
||||
--> $DIR/complex_types.rs:37:14
|
||||
|
|
||||
37 | fn test2(_x: Vec<Vec<Box<(u32, u32, u32, u32)>>>) { } //~ERROR very complex type
|
||||
37 | fn test2(_x: Vec<Vec<Box<(u32, u32, u32, u32)>>>) { }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: #[deny(type_complexity)] implied by #[deny(clippy)]
|
||||
@ -118,7 +118,7 @@ error: very complex type used. Consider factoring parts into `type` definitions
|
||||
error: very complex type used. Consider factoring parts into `type` definitions
|
||||
--> $DIR/complex_types.rs:40:13
|
||||
|
|
||||
40 | let _y: Vec<Vec<Box<(u32, u32, u32, u32)>>> = vec![]; //~ERROR very complex type
|
||||
40 | let _y: Vec<Vec<Box<(u32, u32, u32, u32)>>> = vec![];
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: #[deny(type_complexity)] implied by #[deny(clippy)]
|
||||
|
@ -6,21 +6,21 @@
|
||||
#![allow(unused_variables)]
|
||||
#![deny(blacklisted_name)]
|
||||
|
||||
fn test(toto: ()) {} //~ERROR use of a blacklisted/placeholder name `toto`
|
||||
fn test(toto: ()) {}
|
||||
|
||||
fn main() {
|
||||
let toto = 42; //~ERROR use of a blacklisted/placeholder name `toto`
|
||||
let tata = 42; //~ERROR use of a blacklisted/placeholder name `tata`
|
||||
let titi = 42; //~ERROR use of a blacklisted/placeholder name `titi`
|
||||
let toto = 42;
|
||||
let tata = 42;
|
||||
let titi = 42;
|
||||
|
||||
let tatab = 42;
|
||||
let tatatataic = 42;
|
||||
|
||||
match (42, Some(1337), Some(0)) {
|
||||
(toto, Some(tata), titi @ Some(_)) => (),
|
||||
//~^ ERROR use of a blacklisted/placeholder name `toto`
|
||||
//~| ERROR use of a blacklisted/placeholder name `tata`
|
||||
//~| ERROR use of a blacklisted/placeholder name `titi`
|
||||
|
||||
|
||||
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
error: use of a blacklisted/placeholder name `toto`
|
||||
--> $DIR/conf_french_blacklisted_name.rs:9:9
|
||||
|
|
||||
9 | fn test(toto: ()) {} //~ERROR use of a blacklisted/placeholder name `toto`
|
||||
9 | fn test(toto: ()) {}
|
||||
| ^^^^
|
||||
|
|
||||
note: lint level defined here
|
||||
@ -13,19 +13,19 @@ note: lint level defined here
|
||||
error: use of a blacklisted/placeholder name `toto`
|
||||
--> $DIR/conf_french_blacklisted_name.rs:12:9
|
||||
|
|
||||
12 | let toto = 42; //~ERROR use of a blacklisted/placeholder name `toto`
|
||||
12 | let toto = 42;
|
||||
| ^^^^
|
||||
|
||||
error: use of a blacklisted/placeholder name `tata`
|
||||
--> $DIR/conf_french_blacklisted_name.rs:13:9
|
||||
|
|
||||
13 | let tata = 42; //~ERROR use of a blacklisted/placeholder name `tata`
|
||||
13 | let tata = 42;
|
||||
| ^^^^
|
||||
|
||||
error: use of a blacklisted/placeholder name `titi`
|
||||
--> $DIR/conf_french_blacklisted_name.rs:14:9
|
||||
|
|
||||
14 | let titi = 42; //~ERROR use of a blacklisted/placeholder name `titi`
|
||||
14 | let titi = 42;
|
||||
| ^^^^
|
||||
|
||||
error: use of a blacklisted/placeholder name `toto`
|
||||
|
@ -1,6 +1,6 @@
|
||||
#![feature(attr_literals)]
|
||||
#![feature(plugin)]
|
||||
#![plugin(clippy(conf_file=42))]
|
||||
//~^ ERROR `conf_file` value must be a string
|
||||
|
||||
|
||||
fn main() {}
|
||||
|
@ -28,7 +28,7 @@ pub enum Abc {
|
||||
#[deny(match_same_arms)]
|
||||
fn if_same_then_else() -> Result<&'static str, ()> {
|
||||
if true {
|
||||
//~^NOTE same as this
|
||||
|
||||
Foo { bar: 42 };
|
||||
0..10;
|
||||
..;
|
||||
@ -37,7 +37,7 @@ fn if_same_then_else() -> Result<&'static str, ()> {
|
||||
0...10;
|
||||
foo();
|
||||
}
|
||||
else { //~ERROR this `if` has identical blocks
|
||||
else {
|
||||
Foo { bar: 42 };
|
||||
0..10;
|
||||
..;
|
||||
@ -78,8 +78,8 @@ fn if_same_then_else() -> Result<&'static str, ()> {
|
||||
|
||||
let _ = match 42 {
|
||||
42 => {
|
||||
//~^ NOTE same as this
|
||||
//~| NOTE removing
|
||||
|
||||
|
||||
foo();
|
||||
let mut a = 42 + [23].len() as i32;
|
||||
if true {
|
||||
@ -88,7 +88,7 @@ fn if_same_then_else() -> Result<&'static str, ()> {
|
||||
a = -31-a;
|
||||
a
|
||||
}
|
||||
_ => { //~ERROR this `match` has identical arm bodies
|
||||
_ => {
|
||||
foo();
|
||||
let mut a = 42 + [23].len() as i32;
|
||||
if true {
|
||||
@ -101,10 +101,10 @@ fn if_same_then_else() -> Result<&'static str, ()> {
|
||||
|
||||
let _ = match Abc::A {
|
||||
Abc::A => 0,
|
||||
//~^ NOTE same as this
|
||||
//~| NOTE removing
|
||||
|
||||
|
||||
Abc::B => 1,
|
||||
_ => 0, //~ERROR this `match` has identical arm bodies
|
||||
_ => 0,
|
||||
};
|
||||
|
||||
if true {
|
||||
@ -112,15 +112,15 @@ fn if_same_then_else() -> Result<&'static str, ()> {
|
||||
}
|
||||
|
||||
let _ = if true {
|
||||
//~^NOTE same as this
|
||||
|
||||
42
|
||||
}
|
||||
else { //~ERROR this `if` has identical blocks
|
||||
else {
|
||||
42
|
||||
};
|
||||
|
||||
if true {
|
||||
//~^NOTE same as this
|
||||
|
||||
for _ in &[42] {
|
||||
let foo: &Option<_> = &Some::<u8>(42);
|
||||
if true {
|
||||
@ -130,7 +130,7 @@ fn if_same_then_else() -> Result<&'static str, ()> {
|
||||
}
|
||||
}
|
||||
}
|
||||
else { //~ERROR this `if` has identical blocks
|
||||
else {
|
||||
for _ in &[42] {
|
||||
let foo: &Option<_> = &Some::<u8>(42);
|
||||
if true {
|
||||
@ -142,7 +142,7 @@ fn if_same_then_else() -> Result<&'static str, ()> {
|
||||
}
|
||||
|
||||
if true {
|
||||
//~^NOTE same as this
|
||||
|
||||
let bar = if true {
|
||||
42
|
||||
}
|
||||
@ -153,7 +153,7 @@ fn if_same_then_else() -> Result<&'static str, ()> {
|
||||
while foo() { break; }
|
||||
bar + 1;
|
||||
}
|
||||
else { //~ERROR this `if` has identical blocks
|
||||
else {
|
||||
let bar = if true {
|
||||
42
|
||||
}
|
||||
@ -166,7 +166,7 @@ fn if_same_then_else() -> Result<&'static str, ()> {
|
||||
}
|
||||
|
||||
if true {
|
||||
//~^NOTE same as this
|
||||
|
||||
let _ = match 42 {
|
||||
42 => 1,
|
||||
a if a > 0 => 2,
|
||||
@ -177,7 +177,7 @@ fn if_same_then_else() -> Result<&'static str, ()> {
|
||||
else if false {
|
||||
foo();
|
||||
}
|
||||
else if foo() { //~ERROR this `if` has identical blocks
|
||||
else if foo() {
|
||||
let _ = match 42 {
|
||||
42 => 1,
|
||||
a if a > 0 => 2,
|
||||
@ -187,18 +187,18 @@ fn if_same_then_else() -> Result<&'static str, ()> {
|
||||
}
|
||||
|
||||
if true {
|
||||
//~^NOTE same as this
|
||||
|
||||
if let Some(a) = Some(42) {}
|
||||
}
|
||||
else { //~ERROR this `if` has identical blocks
|
||||
else {
|
||||
if let Some(a) = Some(42) {}
|
||||
}
|
||||
|
||||
if true {
|
||||
//~^NOTE same as this
|
||||
|
||||
if let (1, .., 3) = (1, 2, 3) {}
|
||||
}
|
||||
else { //~ERROR this `if` has identical blocks
|
||||
else {
|
||||
if let (1, .., 3) = (1, 2, 3) {}
|
||||
}
|
||||
|
||||
@ -253,17 +253,17 @@ fn if_same_then_else() -> Result<&'static str, ()> {
|
||||
|
||||
let _ = match 42 {
|
||||
42 => foo(),
|
||||
//~^NOTE same as this
|
||||
//~|NOTE `42 | 51`
|
||||
51 => foo(), //~ERROR this `match` has identical arm bodies
|
||||
|
||||
|
||||
51 => foo(),
|
||||
_ => true,
|
||||
};
|
||||
|
||||
let _ = match Some(42) {
|
||||
Some(_) => 24,
|
||||
//~^NOTE same as this
|
||||
//~|NOTE `Some(_) | None`
|
||||
None => 24, //~ERROR this `match` has identical arm bodies
|
||||
|
||||
|
||||
None => 24,
|
||||
};
|
||||
|
||||
let _ = match Some(42) {
|
||||
@ -285,39 +285,39 @@ fn if_same_then_else() -> Result<&'static str, ()> {
|
||||
|
||||
match (Some(42), Some(42)) {
|
||||
(Some(a), None) => bar(a),
|
||||
//~^NOTE same as this
|
||||
//~|NOTE `(Some(a), None) | (None, Some(a))`
|
||||
(None, Some(a)) => bar(a), //~ERROR this `match` has identical arm bodies
|
||||
|
||||
|
||||
(None, Some(a)) => bar(a),
|
||||
_ => (),
|
||||
}
|
||||
|
||||
match (Some(42), Some(42)) {
|
||||
(Some(a), ..) => bar(a),
|
||||
//~^NOTE same as this
|
||||
//~|NOTE `(Some(a), ..) | (.., Some(a))`
|
||||
(.., Some(a)) => bar(a), //~ERROR this `match` has identical arm bodies
|
||||
|
||||
|
||||
(.., Some(a)) => bar(a),
|
||||
_ => (),
|
||||
}
|
||||
|
||||
match (1, 2, 3) {
|
||||
(1, .., 3) => 42,
|
||||
//~^NOTE same as this
|
||||
//~|NOTE `(1, .., 3) | (.., 3)`
|
||||
(.., 3) => 42, //~ERROR this `match` has identical arm bodies
|
||||
|
||||
|
||||
(.., 3) => 42,
|
||||
_ => 0,
|
||||
};
|
||||
|
||||
let _ = if true {
|
||||
//~^NOTE same as this
|
||||
|
||||
0.0
|
||||
} else { //~ERROR this `if` has identical blocks
|
||||
} else {
|
||||
0.0
|
||||
};
|
||||
|
||||
let _ = if true {
|
||||
//~^NOTE same as this
|
||||
|
||||
-0.0
|
||||
} else { //~ERROR this `if` has identical blocks
|
||||
} else {
|
||||
-0.0
|
||||
};
|
||||
|
||||
@ -336,9 +336,9 @@ fn if_same_then_else() -> Result<&'static str, ()> {
|
||||
|
||||
// Same NaNs
|
||||
let _ = if true {
|
||||
//~^NOTE same as this
|
||||
|
||||
std::f32::NAN
|
||||
} else { //~ERROR this `if` has identical blocks
|
||||
} else {
|
||||
std::f32::NAN
|
||||
};
|
||||
|
||||
@ -354,15 +354,15 @@ fn if_same_then_else() -> Result<&'static str, ()> {
|
||||
}
|
||||
|
||||
if true {
|
||||
//~^NOTE same as this
|
||||
|
||||
try!(Ok("foo"));
|
||||
}
|
||||
else { //~ERROR this `if` has identical blocks
|
||||
else {
|
||||
try!(Ok("foo"));
|
||||
}
|
||||
|
||||
if true {
|
||||
//~^NOTE same as this
|
||||
|
||||
let foo = "";
|
||||
return Ok(&foo[0..]);
|
||||
}
|
||||
@ -370,7 +370,7 @@ fn if_same_then_else() -> Result<&'static str, ()> {
|
||||
let foo = "bar";
|
||||
return Ok(&foo[0..]);
|
||||
}
|
||||
else { //~ERROR this `if` has identical blocks
|
||||
else {
|
||||
let foo = "";
|
||||
return Ok(&foo[0..]);
|
||||
}
|
||||
@ -383,23 +383,23 @@ fn ifs_same_cond() {
|
||||
let b = false;
|
||||
|
||||
if b {
|
||||
//~^NOTE same as this
|
||||
|
||||
}
|
||||
else if b { //~ERROR this `if` has the same condition as a previous if
|
||||
else if b {
|
||||
}
|
||||
|
||||
if a == 1 {
|
||||
//~^NOTE same as this
|
||||
|
||||
}
|
||||
else if a == 1 { //~ERROR this `if` has the same condition as a previous if
|
||||
else if a == 1 {
|
||||
}
|
||||
|
||||
if 2*a == 1 {
|
||||
//~^NOTE same as this
|
||||
|
||||
}
|
||||
else if 2*a == 2 {
|
||||
}
|
||||
else if 2*a == 1 { //~ERROR this `if` has the same condition as a previous if
|
||||
else if 2*a == 1 {
|
||||
}
|
||||
else if a == 1 {
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
error: this `if` has identical blocks
|
||||
--> $DIR/copies.rs:40:10
|
||||
|
|
||||
40 | else { //~ERROR this `if` has identical blocks
|
||||
40 | else {
|
||||
| __________^ starting here...
|
||||
41 | | Foo { bar: 42 };
|
||||
42 | | 0..10;
|
||||
@ -27,7 +27,7 @@ note: same as this
|
||||
error: this `match` has identical arm bodies
|
||||
--> $DIR/copies.rs:91:14
|
||||
|
|
||||
91 | _ => { //~ERROR this `match` has identical arm bodies
|
||||
91 | _ => {
|
||||
| ______________^ starting here...
|
||||
92 | | foo();
|
||||
93 | | let mut a = 42 + [23].len() as i32;
|
||||
@ -58,7 +58,7 @@ note: `42` has the same arm body as the `_` wildcard, consider removing it`
|
||||
error: this `match` has identical arm bodies
|
||||
--> $DIR/copies.rs:107:14
|
||||
|
|
||||
107 | _ => 0, //~ERROR this `match` has identical arm bodies
|
||||
107 | _ => 0,
|
||||
| ^
|
||||
|
|
||||
note: same as this
|
||||
@ -75,7 +75,7 @@ note: `Abc::A` has the same arm body as the `_` wildcard, consider removing it`
|
||||
error: this `if` has identical blocks
|
||||
--> $DIR/copies.rs:118:10
|
||||
|
|
||||
118 | else { //~ERROR this `if` has identical blocks
|
||||
118 | else {
|
||||
| __________^ starting here...
|
||||
119 | | 42
|
||||
120 | | };
|
||||
@ -86,7 +86,7 @@ note: same as this
|
||||
|
|
||||
114 | let _ = if true {
|
||||
| _____________________^ starting here...
|
||||
115 | | //~^NOTE same as this
|
||||
115 | |
|
||||
116 | | 42
|
||||
117 | | }
|
||||
| |_____^ ...ending here
|
||||
@ -94,7 +94,7 @@ note: same as this
|
||||
error: this `if` has identical blocks
|
||||
--> $DIR/copies.rs:133:10
|
||||
|
|
||||
133 | else { //~ERROR this `if` has identical blocks
|
||||
133 | else {
|
||||
| ^
|
||||
|
|
||||
note: same as this
|
||||
@ -106,7 +106,7 @@ note: same as this
|
||||
error: this `if` has identical blocks
|
||||
--> $DIR/copies.rs:156:10
|
||||
|
|
||||
156 | else { //~ERROR this `if` has identical blocks
|
||||
156 | else {
|
||||
| ^
|
||||
|
|
||||
note: same as this
|
||||
@ -118,7 +118,7 @@ note: same as this
|
||||
error: this `if` has identical blocks
|
||||
--> $DIR/copies.rs:180:19
|
||||
|
|
||||
180 | else if foo() { //~ERROR this `if` has identical blocks
|
||||
180 | else if foo() {
|
||||
| ___________________^ starting here...
|
||||
181 | | let _ = match 42 {
|
||||
182 | | 42 => 1,
|
||||
@ -134,7 +134,7 @@ note: same as this
|
||||
|
|
||||
168 | if true {
|
||||
| _____________^ starting here...
|
||||
169 | | //~^NOTE same as this
|
||||
169 | |
|
||||
170 | | let _ = match 42 {
|
||||
171 | | 42 => 1,
|
||||
172 | | a if a > 0 => 2,
|
||||
@ -147,7 +147,7 @@ note: same as this
|
||||
error: this `if` has identical blocks
|
||||
--> $DIR/copies.rs:193:10
|
||||
|
|
||||
193 | else { //~ERROR this `if` has identical blocks
|
||||
193 | else {
|
||||
| __________^ starting here...
|
||||
194 | | if let Some(a) = Some(42) {}
|
||||
195 | | }
|
||||
@ -158,7 +158,7 @@ note: same as this
|
||||
|
|
||||
189 | if true {
|
||||
| _____________^ starting here...
|
||||
190 | | //~^NOTE same as this
|
||||
190 | |
|
||||
191 | | if let Some(a) = Some(42) {}
|
||||
192 | | }
|
||||
| |_____^ ...ending here
|
||||
@ -166,7 +166,7 @@ note: same as this
|
||||
error: this `if` has identical blocks
|
||||
--> $DIR/copies.rs:201:10
|
||||
|
|
||||
201 | else { //~ERROR this `if` has identical blocks
|
||||
201 | else {
|
||||
| __________^ starting here...
|
||||
202 | | if let (1, .., 3) = (1, 2, 3) {}
|
||||
203 | | }
|
||||
@ -177,7 +177,7 @@ note: same as this
|
||||
|
|
||||
197 | if true {
|
||||
| _____________^ starting here...
|
||||
198 | | //~^NOTE same as this
|
||||
198 | |
|
||||
199 | | if let (1, .., 3) = (1, 2, 3) {}
|
||||
200 | | }
|
||||
| |_____^ ...ending here
|
||||
@ -185,7 +185,7 @@ note: same as this
|
||||
error: this `match` has identical arm bodies
|
||||
--> $DIR/copies.rs:258:15
|
||||
|
|
||||
258 | 51 => foo(), //~ERROR this `match` has identical arm bodies
|
||||
258 | 51 => foo(),
|
||||
| ^^^^^
|
||||
|
|
||||
note: same as this
|
||||
@ -202,7 +202,7 @@ note: consider refactoring into `42 | 51`
|
||||
error: this `match` has identical arm bodies
|
||||
--> $DIR/copies.rs:266:17
|
||||
|
|
||||
266 | None => 24, //~ERROR this `match` has identical arm bodies
|
||||
266 | None => 24,
|
||||
| ^^
|
||||
|
|
||||
note: same as this
|
||||
@ -219,7 +219,7 @@ note: consider refactoring into `Some(_) | None`
|
||||
error: this `match` has identical arm bodies
|
||||
--> $DIR/copies.rs:290:28
|
||||
|
|
||||
290 | (None, Some(a)) => bar(a), //~ERROR this `match` has identical arm bodies
|
||||
290 | (None, Some(a)) => bar(a),
|
||||
| ^^^^^^
|
||||
|
|
||||
note: same as this
|
||||
@ -236,7 +236,7 @@ note: consider refactoring into `(Some(a), None) | (None, Some(a))`
|
||||
error: this `match` has identical arm bodies
|
||||
--> $DIR/copies.rs:298:26
|
||||
|
|
||||
298 | (.., Some(a)) => bar(a), //~ERROR this `match` has identical arm bodies
|
||||
298 | (.., Some(a)) => bar(a),
|
||||
| ^^^^^^
|
||||
|
|
||||
note: same as this
|
||||
@ -253,7 +253,7 @@ note: consider refactoring into `(Some(a), ..) | (.., Some(a))`
|
||||
error: this `match` has identical arm bodies
|
||||
--> $DIR/copies.rs:306:20
|
||||
|
|
||||
306 | (.., 3) => 42, //~ERROR this `match` has identical arm bodies
|
||||
306 | (.., 3) => 42,
|
||||
| ^^
|
||||
|
|
||||
note: same as this
|
||||
@ -270,7 +270,7 @@ note: consider refactoring into `(1, .., 3) | (.., 3)`
|
||||
error: this `if` has identical blocks
|
||||
--> $DIR/copies.rs:313:12
|
||||
|
|
||||
313 | } else { //~ERROR this `if` has identical blocks
|
||||
313 | } else {
|
||||
| ____________^ starting here...
|
||||
314 | | 0.0
|
||||
315 | | };
|
||||
@ -281,15 +281,15 @@ note: same as this
|
||||
|
|
||||
310 | let _ = if true {
|
||||
| _____________________^ starting here...
|
||||
311 | | //~^NOTE same as this
|
||||
311 | |
|
||||
312 | | 0.0
|
||||
313 | | } else { //~ERROR this `if` has identical blocks
|
||||
313 | | } else {
|
||||
| |_____^ ...ending here
|
||||
|
||||
error: this `if` has identical blocks
|
||||
--> $DIR/copies.rs:320:12
|
||||
|
|
||||
320 | } else { //~ERROR this `if` has identical blocks
|
||||
320 | } else {
|
||||
| ____________^ starting here...
|
||||
321 | | -0.0
|
||||
322 | | };
|
||||
@ -300,15 +300,15 @@ note: same as this
|
||||
|
|
||||
317 | let _ = if true {
|
||||
| _____________________^ starting here...
|
||||
318 | | //~^NOTE same as this
|
||||
318 | |
|
||||
319 | | -0.0
|
||||
320 | | } else { //~ERROR this `if` has identical blocks
|
||||
320 | | } else {
|
||||
| |_____^ ...ending here
|
||||
|
||||
error: this `if` has identical blocks
|
||||
--> $DIR/copies.rs:341:12
|
||||
|
|
||||
341 | } else { //~ERROR this `if` has identical blocks
|
||||
341 | } else {
|
||||
| ____________^ starting here...
|
||||
342 | | std::f32::NAN
|
||||
343 | | };
|
||||
@ -319,15 +319,15 @@ note: same as this
|
||||
|
|
||||
338 | let _ = if true {
|
||||
| _____________________^ starting here...
|
||||
339 | | //~^NOTE same as this
|
||||
339 | |
|
||||
340 | | std::f32::NAN
|
||||
341 | | } else { //~ERROR this `if` has identical blocks
|
||||
341 | | } else {
|
||||
| |_____^ ...ending here
|
||||
|
||||
error: this `if` has identical blocks
|
||||
--> $DIR/copies.rs:360:10
|
||||
|
|
||||
360 | else { //~ERROR this `if` has identical blocks
|
||||
360 | else {
|
||||
| __________^ starting here...
|
||||
361 | | try!(Ok("foo"));
|
||||
362 | | }
|
||||
@ -338,7 +338,7 @@ note: same as this
|
||||
|
|
||||
356 | if true {
|
||||
| _____________^ starting here...
|
||||
357 | | //~^NOTE same as this
|
||||
357 | |
|
||||
358 | | try!(Ok("foo"));
|
||||
359 | | }
|
||||
| |_____^ ...ending here
|
||||
@ -346,7 +346,7 @@ note: same as this
|
||||
error: this `if` has identical blocks
|
||||
--> $DIR/copies.rs:373:10
|
||||
|
|
||||
373 | else { //~ERROR this `if` has identical blocks
|
||||
373 | else {
|
||||
| __________^ starting here...
|
||||
374 | | let foo = "";
|
||||
375 | | return Ok(&foo[0..]);
|
||||
@ -358,7 +358,7 @@ note: same as this
|
||||
|
|
||||
364 | if true {
|
||||
| _____________^ starting here...
|
||||
365 | | //~^NOTE same as this
|
||||
365 | |
|
||||
366 | | let foo = "";
|
||||
367 | | return Ok(&foo[0..]);
|
||||
368 | | }
|
||||
@ -367,7 +367,7 @@ note: same as this
|
||||
error: this `if` has the same condition as a previous if
|
||||
--> $DIR/copies.rs:388:13
|
||||
|
|
||||
388 | else if b { //~ERROR this `if` has the same condition as a previous if
|
||||
388 | else if b {
|
||||
| ^
|
||||
|
|
||||
note: lint level defined here
|
||||
@ -384,7 +384,7 @@ note: same as this
|
||||
error: this `if` has the same condition as a previous if
|
||||
--> $DIR/copies.rs:394:13
|
||||
|
|
||||
394 | else if a == 1 { //~ERROR this `if` has the same condition as a previous if
|
||||
394 | else if a == 1 {
|
||||
| ^^^^^^
|
||||
|
|
||||
note: same as this
|
||||
@ -396,7 +396,7 @@ note: same as this
|
||||
error: this `if` has the same condition as a previous if
|
||||
--> $DIR/copies.rs:402:13
|
||||
|
|
||||
402 | else if 2*a == 1 { //~ERROR this `if` has the same condition as a previous if
|
||||
402 | else if 2*a == 1 {
|
||||
| ^^^^^^^^
|
||||
|
|
||||
note: same as this
|
||||
|
@ -4,7 +4,7 @@
|
||||
#![deny(cyclomatic_complexity)]
|
||||
#![allow(unused)]
|
||||
|
||||
fn main() { //~ERROR the function has a cyclomatic complexity of 28
|
||||
fn main() {
|
||||
if true {
|
||||
println!("a");
|
||||
}
|
||||
@ -89,7 +89,7 @@ fn main() { //~ERROR the function has a cyclomatic complexity of 28
|
||||
}
|
||||
|
||||
#[cyclomatic_complexity = "0"]
|
||||
fn kaboom() { //~ ERROR: the function has a cyclomatic complexity of 7
|
||||
fn kaboom() {
|
||||
let n = 0;
|
||||
'a: for i in 0..20 {
|
||||
'b: for j in i..20 {
|
||||
@ -135,18 +135,18 @@ fn bloo() {
|
||||
}
|
||||
|
||||
#[cyclomatic_complexity = "0"]
|
||||
fn lots_of_short_circuits() -> bool { //~ ERROR: the function has a cyclomatic complexity of 1
|
||||
fn lots_of_short_circuits() -> bool {
|
||||
true && false && true && false && true && false && true
|
||||
}
|
||||
|
||||
#[cyclomatic_complexity = "0"]
|
||||
fn lots_of_short_circuits2() -> bool { //~ ERROR: the function has a cyclomatic complexity of 1
|
||||
fn lots_of_short_circuits2() -> bool {
|
||||
true || false || true || false || true || false || true
|
||||
}
|
||||
|
||||
#[cyclomatic_complexity = "0"]
|
||||
fn baa() { //~ ERROR: the function has a cyclomatic complexity of 2
|
||||
let x = || match 99 { //~ ERROR: the function has a cyclomatic complexity of 2
|
||||
fn baa() {
|
||||
let x = || match 99 {
|
||||
0 => 0,
|
||||
1 => 1,
|
||||
2 => 2,
|
||||
@ -163,7 +163,7 @@ fn baa() { //~ ERROR: the function has a cyclomatic complexity of 2
|
||||
}
|
||||
|
||||
#[cyclomatic_complexity = "0"]
|
||||
fn bar() { //~ ERROR: the function has a cyclomatic complexity of 2
|
||||
fn bar() {
|
||||
match 99 {
|
||||
0 => println!("hi"),
|
||||
_ => println!("bye"),
|
||||
@ -182,7 +182,7 @@ fn dont_warn_on_tests() {
|
||||
}
|
||||
|
||||
#[cyclomatic_complexity = "0"]
|
||||
fn barr() { //~ ERROR: the function has a cyclomatic complexity of 2
|
||||
fn barr() {
|
||||
match 99 {
|
||||
0 => println!("hi"),
|
||||
1 => println!("bla"),
|
||||
@ -192,7 +192,7 @@ fn barr() { //~ ERROR: the function has a cyclomatic complexity of 2
|
||||
}
|
||||
|
||||
#[cyclomatic_complexity = "0"]
|
||||
fn barr2() { //~ ERROR: the function has a cyclomatic complexity of 3
|
||||
fn barr2() {
|
||||
match 99 {
|
||||
0 => println!("hi"),
|
||||
1 => println!("bla"),
|
||||
@ -208,7 +208,7 @@ fn barr2() { //~ ERROR: the function has a cyclomatic complexity of 3
|
||||
}
|
||||
|
||||
#[cyclomatic_complexity = "0"]
|
||||
fn barrr() { //~ ERROR: the function has a cyclomatic complexity of 2
|
||||
fn barrr() {
|
||||
match 99 {
|
||||
0 => println!("hi"),
|
||||
1 => panic!("bla"),
|
||||
@ -218,7 +218,7 @@ fn barrr() { //~ ERROR: the function has a cyclomatic complexity of 2
|
||||
}
|
||||
|
||||
#[cyclomatic_complexity = "0"]
|
||||
fn barrr2() { //~ ERROR: the function has a cyclomatic complexity of 3
|
||||
fn barrr2() {
|
||||
match 99 {
|
||||
0 => println!("hi"),
|
||||
1 => panic!("bla"),
|
||||
@ -234,7 +234,7 @@ fn barrr2() { //~ ERROR: the function has a cyclomatic complexity of 3
|
||||
}
|
||||
|
||||
#[cyclomatic_complexity = "0"]
|
||||
fn barrrr() { //~ ERROR: the function has a cyclomatic complexity of 2
|
||||
fn barrrr() {
|
||||
match 99 {
|
||||
0 => println!("hi"),
|
||||
1 => println!("bla"),
|
||||
@ -244,7 +244,7 @@ fn barrrr() { //~ ERROR: the function has a cyclomatic complexity of 2
|
||||
}
|
||||
|
||||
#[cyclomatic_complexity = "0"]
|
||||
fn barrrr2() { //~ ERROR: the function has a cyclomatic complexity of 3
|
||||
fn barrrr2() {
|
||||
match 99 {
|
||||
0 => println!("hi"),
|
||||
1 => println!("bla"),
|
||||
@ -260,7 +260,7 @@ fn barrrr2() { //~ ERROR: the function has a cyclomatic complexity of 3
|
||||
}
|
||||
|
||||
#[cyclomatic_complexity = "0"]
|
||||
fn cake() { //~ ERROR: the function has a cyclomatic complexity of 2
|
||||
fn cake() {
|
||||
if 4 == 5 {
|
||||
println!("yea");
|
||||
} else {
|
||||
@ -271,7 +271,7 @@ fn cake() { //~ ERROR: the function has a cyclomatic complexity of 2
|
||||
|
||||
|
||||
#[cyclomatic_complexity = "0"]
|
||||
pub fn read_file(input_path: &str) -> String { //~ ERROR: the function has a cyclomatic complexity of 4
|
||||
pub fn read_file(input_path: &str) -> String {
|
||||
use std::fs::File;
|
||||
use std::io::{Read, Write};
|
||||
use std::path::Path;
|
||||
@ -302,7 +302,7 @@ pub fn read_file(input_path: &str) -> String { //~ ERROR: the function has a cyc
|
||||
enum Void {}
|
||||
|
||||
#[cyclomatic_complexity = "0"]
|
||||
fn void(void: Void) { //~ ERROR: the function has a cyclomatic complexity of 1
|
||||
fn void(void: Void) {
|
||||
if true {
|
||||
match void {
|
||||
}
|
||||
@ -316,7 +316,7 @@ fn mcarton_sees_all() {
|
||||
}
|
||||
|
||||
#[cyclomatic_complexity = "0"]
|
||||
fn try() -> Result<i32, &'static str> { //~ ERROR: cyclomatic complexity of 1
|
||||
fn try() -> Result<i32, &'static str> {
|
||||
match 5 {
|
||||
5 => Ok(5),
|
||||
_ => return Err("bla"),
|
||||
@ -324,7 +324,7 @@ fn try() -> Result<i32, &'static str> { //~ ERROR: cyclomatic complexity of 1
|
||||
}
|
||||
|
||||
#[cyclomatic_complexity = "0"]
|
||||
fn try_again() -> Result<i32, &'static str> { //~ ERROR: cyclomatic complexity of 1
|
||||
fn try_again() -> Result<i32, &'static str> {
|
||||
let _ = try!(Ok(42));
|
||||
let _ = try!(Ok(43));
|
||||
let _ = try!(Ok(44));
|
||||
@ -340,7 +340,7 @@ fn try_again() -> Result<i32, &'static str> { //~ ERROR: cyclomatic complexity o
|
||||
}
|
||||
|
||||
#[cyclomatic_complexity = "0"]
|
||||
fn early() -> Result<i32, &'static str> { //~ ERROR: cyclomatic complexity of 1
|
||||
fn early() -> Result<i32, &'static str> {
|
||||
return Ok(5);
|
||||
return Ok(5);
|
||||
return Ok(5);
|
||||
@ -353,7 +353,7 @@ fn early() -> Result<i32, &'static str> { //~ ERROR: cyclomatic complexity of 1
|
||||
}
|
||||
|
||||
#[cyclomatic_complexity = "0"]
|
||||
fn early_ret() -> i32 { //~ ERROR: cyclomatic complexity of 8
|
||||
fn early_ret() -> i32 {
|
||||
let a = if true { 42 } else { return 0; };
|
||||
let a = if a < 99 { 42 } else { return 0; };
|
||||
let a = if a < 99 { 42 } else { return 0; };
|
||||
|
@ -1,7 +1,7 @@
|
||||
error: the function has a cyclomatic complexity of 28
|
||||
--> $DIR/cyclomatic_complexity.rs:7:1
|
||||
|
|
||||
7 | fn main() { //~ERROR the function has a cyclomatic complexity of 28
|
||||
7 | fn main() {
|
||||
| ^
|
||||
|
|
||||
note: lint level defined here
|
||||
@ -14,7 +14,7 @@ note: lint level defined here
|
||||
error: the function has a cyclomatic complexity of 7
|
||||
--> $DIR/cyclomatic_complexity.rs:92:1
|
||||
|
|
||||
92 | fn kaboom() { //~ ERROR: the function has a cyclomatic complexity of 7
|
||||
92 | fn kaboom() {
|
||||
| ^
|
||||
|
|
||||
= help: you could split it up into multiple smaller functions
|
||||
@ -22,7 +22,7 @@ error: the function has a cyclomatic complexity of 7
|
||||
error: the function has a cyclomatic complexity of 1
|
||||
--> $DIR/cyclomatic_complexity.rs:138:1
|
||||
|
|
||||
138 | fn lots_of_short_circuits() -> bool { //~ ERROR: the function has a cyclomatic complexity of 1
|
||||
138 | fn lots_of_short_circuits() -> bool {
|
||||
| _^ starting here...
|
||||
139 | | true && false && true && false && true && false && true
|
||||
140 | | }
|
||||
@ -33,7 +33,7 @@ error: the function has a cyclomatic complexity of 1
|
||||
error: the function has a cyclomatic complexity of 1
|
||||
--> $DIR/cyclomatic_complexity.rs:143:1
|
||||
|
|
||||
143 | fn lots_of_short_circuits2() -> bool { //~ ERROR: the function has a cyclomatic complexity of 1
|
||||
143 | fn lots_of_short_circuits2() -> bool {
|
||||
| _^ starting here...
|
||||
144 | | true || false || true || false || true || false || true
|
||||
145 | | }
|
||||
@ -44,7 +44,7 @@ error: the function has a cyclomatic complexity of 1
|
||||
error: the function has a cyclomatic complexity of 2
|
||||
--> $DIR/cyclomatic_complexity.rs:148:1
|
||||
|
|
||||
148 | fn baa() { //~ ERROR: the function has a cyclomatic complexity of 2
|
||||
148 | fn baa() {
|
||||
| ^
|
||||
|
|
||||
= help: you could split it up into multiple smaller functions
|
||||
@ -52,7 +52,7 @@ error: the function has a cyclomatic complexity of 2
|
||||
error: the function has a cyclomatic complexity of 2
|
||||
--> $DIR/cyclomatic_complexity.rs:149:13
|
||||
|
|
||||
149 | let x = || match 99 { //~ ERROR: the function has a cyclomatic complexity of 2
|
||||
149 | let x = || match 99 {
|
||||
| _____________^ starting here...
|
||||
150 | | 0 => 0,
|
||||
151 | | 1 => 1,
|
||||
@ -69,7 +69,7 @@ error: the function has a cyclomatic complexity of 2
|
||||
error: the function has a cyclomatic complexity of 2
|
||||
--> $DIR/cyclomatic_complexity.rs:166:1
|
||||
|
|
||||
166 | fn bar() { //~ ERROR: the function has a cyclomatic complexity of 2
|
||||
166 | fn bar() {
|
||||
| _^ starting here...
|
||||
167 | | match 99 {
|
||||
168 | | 0 => println!("hi"),
|
||||
@ -83,7 +83,7 @@ error: the function has a cyclomatic complexity of 2
|
||||
error: the function has a cyclomatic complexity of 2
|
||||
--> $DIR/cyclomatic_complexity.rs:185:1
|
||||
|
|
||||
185 | fn barr() { //~ ERROR: the function has a cyclomatic complexity of 2
|
||||
185 | fn barr() {
|
||||
| _^ starting here...
|
||||
186 | | match 99 {
|
||||
187 | | 0 => println!("hi"),
|
||||
@ -99,7 +99,7 @@ error: the function has a cyclomatic complexity of 2
|
||||
error: the function has a cyclomatic complexity of 3
|
||||
--> $DIR/cyclomatic_complexity.rs:195:1
|
||||
|
|
||||
195 | fn barr2() { //~ ERROR: the function has a cyclomatic complexity of 3
|
||||
195 | fn barr2() {
|
||||
| ^
|
||||
|
|
||||
= help: you could split it up into multiple smaller functions
|
||||
@ -107,7 +107,7 @@ error: the function has a cyclomatic complexity of 3
|
||||
error: the function has a cyclomatic complexity of 2
|
||||
--> $DIR/cyclomatic_complexity.rs:211:1
|
||||
|
|
||||
211 | fn barrr() { //~ ERROR: the function has a cyclomatic complexity of 2
|
||||
211 | fn barrr() {
|
||||
| _^ starting here...
|
||||
212 | | match 99 {
|
||||
213 | | 0 => println!("hi"),
|
||||
@ -123,7 +123,7 @@ error: the function has a cyclomatic complexity of 2
|
||||
error: the function has a cyclomatic complexity of 3
|
||||
--> $DIR/cyclomatic_complexity.rs:221:1
|
||||
|
|
||||
221 | fn barrr2() { //~ ERROR: the function has a cyclomatic complexity of 3
|
||||
221 | fn barrr2() {
|
||||
| ^
|
||||
|
|
||||
= help: you could split it up into multiple smaller functions
|
||||
@ -131,7 +131,7 @@ error: the function has a cyclomatic complexity of 3
|
||||
error: the function has a cyclomatic complexity of 2
|
||||
--> $DIR/cyclomatic_complexity.rs:237:1
|
||||
|
|
||||
237 | fn barrrr() { //~ ERROR: the function has a cyclomatic complexity of 2
|
||||
237 | fn barrrr() {
|
||||
| _^ starting here...
|
||||
238 | | match 99 {
|
||||
239 | | 0 => println!("hi"),
|
||||
@ -147,7 +147,7 @@ error: the function has a cyclomatic complexity of 2
|
||||
error: the function has a cyclomatic complexity of 3
|
||||
--> $DIR/cyclomatic_complexity.rs:247:1
|
||||
|
|
||||
247 | fn barrrr2() { //~ ERROR: the function has a cyclomatic complexity of 3
|
||||
247 | fn barrrr2() {
|
||||
| ^
|
||||
|
|
||||
= help: you could split it up into multiple smaller functions
|
||||
@ -155,7 +155,7 @@ error: the function has a cyclomatic complexity of 3
|
||||
error: the function has a cyclomatic complexity of 2
|
||||
--> $DIR/cyclomatic_complexity.rs:263:1
|
||||
|
|
||||
263 | fn cake() { //~ ERROR: the function has a cyclomatic complexity of 2
|
||||
263 | fn cake() {
|
||||
| _^ starting here...
|
||||
264 | | if 4 == 5 {
|
||||
265 | | println!("yea");
|
||||
@ -171,7 +171,7 @@ error: the function has a cyclomatic complexity of 2
|
||||
error: the function has a cyclomatic complexity of 4
|
||||
--> $DIR/cyclomatic_complexity.rs:274:1
|
||||
|
|
||||
274 | pub fn read_file(input_path: &str) -> String { //~ ERROR: the function has a cyclomatic complexity of 4
|
||||
274 | pub fn read_file(input_path: &str) -> String {
|
||||
| ^
|
||||
|
|
||||
= help: you could split it up into multiple smaller functions
|
||||
@ -179,7 +179,7 @@ error: the function has a cyclomatic complexity of 4
|
||||
error: the function has a cyclomatic complexity of 1
|
||||
--> $DIR/cyclomatic_complexity.rs:305:1
|
||||
|
|
||||
305 | fn void(void: Void) { //~ ERROR: the function has a cyclomatic complexity of 1
|
||||
305 | fn void(void: Void) {
|
||||
| _^ starting here...
|
||||
306 | | if true {
|
||||
307 | | match void {
|
||||
@ -193,7 +193,7 @@ error: the function has a cyclomatic complexity of 1
|
||||
error: the function has a cyclomatic complexity of 1
|
||||
--> $DIR/cyclomatic_complexity.rs:319:1
|
||||
|
|
||||
319 | fn try() -> Result<i32, &'static str> { //~ ERROR: cyclomatic complexity of 1
|
||||
319 | fn try() -> Result<i32, &'static str> {
|
||||
| _^ starting here...
|
||||
320 | | match 5 {
|
||||
321 | | 5 => Ok(5),
|
||||
@ -207,7 +207,7 @@ error: the function has a cyclomatic complexity of 1
|
||||
error: the function has a cyclomatic complexity of 1
|
||||
--> $DIR/cyclomatic_complexity.rs:327:1
|
||||
|
|
||||
327 | fn try_again() -> Result<i32, &'static str> { //~ ERROR: cyclomatic complexity of 1
|
||||
327 | fn try_again() -> Result<i32, &'static str> {
|
||||
| ^
|
||||
|
|
||||
= help: you could split it up into multiple smaller functions
|
||||
@ -215,7 +215,7 @@ error: the function has a cyclomatic complexity of 1
|
||||
error: the function has a cyclomatic complexity of 1
|
||||
--> $DIR/cyclomatic_complexity.rs:343:1
|
||||
|
|
||||
343 | fn early() -> Result<i32, &'static str> { //~ ERROR: cyclomatic complexity of 1
|
||||
343 | fn early() -> Result<i32, &'static str> {
|
||||
| ^
|
||||
|
|
||||
= help: you could split it up into multiple smaller functions
|
||||
@ -223,7 +223,7 @@ error: the function has a cyclomatic complexity of 1
|
||||
error: the function has a cyclomatic complexity of 8
|
||||
--> $DIR/cyclomatic_complexity.rs:356:1
|
||||
|
|
||||
356 | fn early_ret() -> i32 { //~ ERROR: cyclomatic complexity of 8
|
||||
356 | fn early_ret() -> i32 {
|
||||
| ^
|
||||
|
|
||||
= help: you could split it up into multiple smaller functions
|
||||
|
@ -8,7 +8,7 @@ fn main() {
|
||||
}
|
||||
|
||||
#[cyclomatic_complexity = "0"]
|
||||
fn kaboom() { //~ ERROR: the function has a cyclomatic complexity of 3
|
||||
fn kaboom() {
|
||||
if 42 == 43 {
|
||||
panic!();
|
||||
} else if "cake" == "lie" {
|
||||
|
@ -1,7 +1,7 @@
|
||||
error: the function has a cyclomatic complexity of 3
|
||||
--> $DIR/cyclomatic_complexity_attr_used.rs:11:1
|
||||
|
|
||||
11 | fn kaboom() { //~ ERROR: the function has a cyclomatic complexity of 3
|
||||
11 | fn kaboom() {
|
||||
| _^ starting here...
|
||||
12 | | if 42 == 43 {
|
||||
13 | | panic!();
|
||||
|
@ -16,7 +16,7 @@ impl PartialEq<u64> for Foo {
|
||||
}
|
||||
|
||||
#[derive(Hash)]
|
||||
//~^ ERROR you are deriving `Hash` but have implemented `PartialEq` explicitly
|
||||
|
||||
struct Bar;
|
||||
|
||||
impl PartialEq for Bar {
|
||||
@ -24,7 +24,7 @@ impl PartialEq for Bar {
|
||||
}
|
||||
|
||||
#[derive(Hash)]
|
||||
//~^ ERROR you are deriving `Hash` but have implemented `PartialEq` explicitly
|
||||
|
||||
struct Baz;
|
||||
|
||||
impl PartialEq<Baz> for Baz {
|
||||
@ -35,7 +35,7 @@ impl PartialEq<Baz> for Baz {
|
||||
struct Bah;
|
||||
|
||||
impl Hash for Bah {
|
||||
//~^ ERROR you are implementing `Hash` explicitly but have derived `PartialEq`
|
||||
|
||||
fn hash<H: Hasher>(&self, _: &mut H) {}
|
||||
}
|
||||
|
||||
@ -43,7 +43,7 @@ impl Hash for Bah {
|
||||
struct Qux;
|
||||
|
||||
impl Clone for Qux {
|
||||
//~^ ERROR you are implementing `Clone` explicitly on a `Copy` type
|
||||
|
||||
fn clone(&self) -> Self { Qux }
|
||||
}
|
||||
|
||||
@ -68,7 +68,7 @@ struct Lt<'a> {
|
||||
}
|
||||
|
||||
impl<'a> Clone for Lt<'a> {
|
||||
//~^ ERROR you are implementing `Clone` explicitly on a `Copy` type
|
||||
|
||||
fn clone(&self) -> Self { unimplemented!() }
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ error: you are implementing `Hash` explicitly but have derived `PartialEq`
|
||||
|
|
||||
37 | impl Hash for Bah {
|
||||
| _^ starting here...
|
||||
38 | | //~^ ERROR you are implementing `Hash` explicitly but have derived `PartialEq`
|
||||
38 | |
|
||||
39 | | fn hash<H: Hasher>(&self, _: &mut H) {}
|
||||
40 | | }
|
||||
| |_^ ...ending here
|
||||
@ -57,7 +57,7 @@ error: you are implementing `Clone` explicitly on a `Copy` type
|
||||
|
|
||||
45 | impl Clone for Qux {
|
||||
| _^ starting here...
|
||||
46 | | //~^ ERROR you are implementing `Clone` explicitly on a `Copy` type
|
||||
46 | |
|
||||
47 | | fn clone(&self) -> Self { Qux }
|
||||
48 | | }
|
||||
| |_^ ...ending here
|
||||
@ -73,7 +73,7 @@ note: consider deriving `Clone` or removing `Copy`
|
||||
|
|
||||
45 | impl Clone for Qux {
|
||||
| _^ starting here...
|
||||
46 | | //~^ ERROR you are implementing `Clone` explicitly on a `Copy` type
|
||||
46 | |
|
||||
47 | | fn clone(&self) -> Self { Qux }
|
||||
48 | | }
|
||||
| |_^ ...ending here
|
||||
@ -83,7 +83,7 @@ error: you are implementing `Clone` explicitly on a `Copy` type
|
||||
|
|
||||
70 | impl<'a> Clone for Lt<'a> {
|
||||
| _^ starting here...
|
||||
71 | | //~^ ERROR you are implementing `Clone` explicitly on a `Copy` type
|
||||
71 | |
|
||||
72 | | fn clone(&self) -> Self { unimplemented!() }
|
||||
73 | | }
|
||||
| |_^ ...ending here
|
||||
@ -94,7 +94,7 @@ note: consider deriving `Clone` or removing `Copy`
|
||||
|
|
||||
70 | impl<'a> Clone for Lt<'a> {
|
||||
| _^ starting here...
|
||||
71 | | //~^ ERROR you are implementing `Clone` explicitly on a `Copy` type
|
||||
71 | |
|
||||
72 | | fn clone(&self) -> Self { unimplemented!() }
|
||||
73 | | }
|
||||
| |_^ ...ending here
|
||||
|
@ -15,8 +15,8 @@ impl A {
|
||||
#[allow(unused_variables, unnecessary_operation, short_circuit_statement)]
|
||||
fn main() {
|
||||
let b = true;
|
||||
b || diverge(); //~ ERROR sub-expression diverges
|
||||
b || A.foo(); //~ ERROR sub-expression diverges
|
||||
b || diverge();
|
||||
b || A.foo();
|
||||
}
|
||||
|
||||
#[allow(dead_code, unused_variables)]
|
||||
@ -25,16 +25,16 @@ fn foobar() {
|
||||
let x = match 5 {
|
||||
4 => return,
|
||||
5 => continue,
|
||||
6 => true || return, //~ ERROR sub-expression diverges
|
||||
7 => true || continue, //~ ERROR sub-expression diverges
|
||||
6 => true || return,
|
||||
7 => true || continue,
|
||||
8 => break,
|
||||
9 => diverge(),
|
||||
3 => true || diverge(), //~ ERROR sub-expression diverges
|
||||
3 => true || diverge(),
|
||||
10 => match 42 {
|
||||
99 => return,
|
||||
_ => true || panic!("boo"),
|
||||
},
|
||||
_ => true || break, //~ ERROR sub-expression diverges
|
||||
_ => true || break,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
error: sub-expression diverges
|
||||
--> $DIR/diverging_sub_expression.rs:18:10
|
||||
|
|
||||
18 | b || diverge(); //~ ERROR sub-expression diverges
|
||||
18 | b || diverge();
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
note: lint level defined here
|
||||
@ -13,31 +13,31 @@ note: lint level defined here
|
||||
error: sub-expression diverges
|
||||
--> $DIR/diverging_sub_expression.rs:19:10
|
||||
|
|
||||
19 | b || A.foo(); //~ ERROR sub-expression diverges
|
||||
19 | b || A.foo();
|
||||
| ^^^^^^^
|
||||
|
||||
error: sub-expression diverges
|
||||
--> $DIR/diverging_sub_expression.rs:28:26
|
||||
|
|
||||
28 | 6 => true || return, //~ ERROR sub-expression diverges
|
||||
28 | 6 => true || return,
|
||||
| ^^^^^^
|
||||
|
||||
error: sub-expression diverges
|
||||
--> $DIR/diverging_sub_expression.rs:29:26
|
||||
|
|
||||
29 | 7 => true || continue, //~ ERROR sub-expression diverges
|
||||
29 | 7 => true || continue,
|
||||
| ^^^^^^^^
|
||||
|
||||
error: sub-expression diverges
|
||||
--> $DIR/diverging_sub_expression.rs:32:26
|
||||
|
|
||||
32 | 3 => true || diverge(), //~ ERROR sub-expression diverges
|
||||
32 | 3 => true || diverge(),
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: sub-expression diverges
|
||||
--> $DIR/diverging_sub_expression.rs:37:26
|
||||
|
|
||||
37 | _ => true || break, //~ ERROR sub-expression diverges
|
||||
37 | _ => true || break,
|
||||
| ^^^^^
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
|
@ -10,9 +10,9 @@ extern crate collections;
|
||||
use collections::linked_list::LinkedList;
|
||||
|
||||
trait Foo {
|
||||
type Baz = LinkedList<u8>; //~ ERROR I see you're using a LinkedList!
|
||||
fn foo(LinkedList<u8>); //~ ERROR I see you're using a LinkedList!
|
||||
const BAR : Option<LinkedList<u8>>; //~ ERROR I see you're using a LinkedList!
|
||||
type Baz = LinkedList<u8>;
|
||||
fn foo(LinkedList<u8>);
|
||||
const BAR : Option<LinkedList<u8>>;
|
||||
}
|
||||
|
||||
// ok, we don’t want to warn for implementations, see #605
|
||||
@ -23,14 +23,14 @@ impl Foo for LinkedList<u8> {
|
||||
|
||||
struct Bar;
|
||||
impl Bar {
|
||||
fn foo(_: LinkedList<u8>) {} //~ ERROR I see you're using a LinkedList!
|
||||
fn foo(_: LinkedList<u8>) {}
|
||||
}
|
||||
|
||||
pub fn test(my_favourite_linked_list: LinkedList<u8>) { //~ ERROR I see you're using a LinkedList!
|
||||
pub fn test(my_favourite_linked_list: LinkedList<u8>) {
|
||||
println!("{:?}", my_favourite_linked_list)
|
||||
}
|
||||
|
||||
pub fn test_ret() -> Option<LinkedList<u8>> { //~ ERROR I see you're using a LinkedList!
|
||||
pub fn test_ret() -> Option<LinkedList<u8>> {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
error: I see you're using a LinkedList! Perhaps you meant some other data structure?
|
||||
--> $DIR/dlist.rs:13:16
|
||||
|
|
||||
13 | type Baz = LinkedList<u8>; //~ ERROR I see you're using a LinkedList!
|
||||
13 | type Baz = LinkedList<u8>;
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: #[deny(linkedlist)] implied by #[deny(clippy)]
|
||||
@ -15,7 +15,7 @@ note: lint level defined here
|
||||
error: I see you're using a LinkedList! Perhaps you meant some other data structure?
|
||||
--> $DIR/dlist.rs:14:12
|
||||
|
|
||||
14 | fn foo(LinkedList<u8>); //~ ERROR I see you're using a LinkedList!
|
||||
14 | fn foo(LinkedList<u8>);
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: #[deny(linkedlist)] implied by #[deny(clippy)]
|
||||
@ -24,7 +24,7 @@ error: I see you're using a LinkedList! Perhaps you meant some other data struct
|
||||
error: I see you're using a LinkedList! Perhaps you meant some other data structure?
|
||||
--> $DIR/dlist.rs:15:24
|
||||
|
|
||||
15 | const BAR : Option<LinkedList<u8>>; //~ ERROR I see you're using a LinkedList!
|
||||
15 | const BAR : Option<LinkedList<u8>>;
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: #[deny(linkedlist)] implied by #[deny(clippy)]
|
||||
@ -33,7 +33,7 @@ error: I see you're using a LinkedList! Perhaps you meant some other data struct
|
||||
error: I see you're using a LinkedList! Perhaps you meant some other data structure?
|
||||
--> $DIR/dlist.rs:26:15
|
||||
|
|
||||
26 | fn foo(_: LinkedList<u8>) {} //~ ERROR I see you're using a LinkedList!
|
||||
26 | fn foo(_: LinkedList<u8>) {}
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: #[deny(linkedlist)] implied by #[deny(clippy)]
|
||||
@ -42,7 +42,7 @@ error: I see you're using a LinkedList! Perhaps you meant some other data struct
|
||||
error: I see you're using a LinkedList! Perhaps you meant some other data structure?
|
||||
--> $DIR/dlist.rs:29:39
|
||||
|
|
||||
29 | pub fn test(my_favourite_linked_list: LinkedList<u8>) { //~ ERROR I see you're using a LinkedList!
|
||||
29 | pub fn test(my_favourite_linked_list: LinkedList<u8>) {
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: #[deny(linkedlist)] implied by #[deny(clippy)]
|
||||
@ -51,7 +51,7 @@ error: I see you're using a LinkedList! Perhaps you meant some other data struct
|
||||
error: I see you're using a LinkedList! Perhaps you meant some other data structure?
|
||||
--> $DIR/dlist.rs:33:29
|
||||
|
|
||||
33 | pub fn test_ret() -> Option<LinkedList<u8>> { //~ ERROR I see you're using a LinkedList!
|
||||
33 | pub fn test_ret() -> Option<LinkedList<u8>> {
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: #[deny(linkedlist)] implied by #[deny(clippy)]
|
||||
|
@ -1,5 +1,5 @@
|
||||
//! This file tests for the DOC_MARKDOWN lint
|
||||
//~^ ERROR: you should put `DOC_MARKDOWN` between ticks
|
||||
|
||||
|
||||
#![feature(plugin)]
|
||||
#![plugin(clippy)]
|
||||
@ -7,17 +7,17 @@
|
||||
#![deny(doc_markdown)]
|
||||
|
||||
/// The foo_bar function does _nothing_. See also foo::bar. (note the dot there)
|
||||
//~^ ERROR: you should put `foo_bar` between ticks
|
||||
//~| ERROR: you should put `foo::bar` between ticks
|
||||
|
||||
|
||||
/// Markdown is _weird_. I mean _really weird_. This \_ is ok. So is `_`. But not Foo::some_fun
|
||||
//~^ ERROR: you should put `Foo::some_fun` between ticks
|
||||
|
||||
/// which should be reported only once despite being __doubly bad__.
|
||||
/// Here be ::is::a::global:path.
|
||||
//~^ ERROR: you should put `is::a::global:path` between ticks
|
||||
|
||||
/// That's not code ~NotInCodeBlock~.
|
||||
//~^ ERROR: you should put `NotInCodeBlock` between ticks
|
||||
|
||||
/// be_sure_we_got_to_the_end_of_it
|
||||
//~^ ERROR: you should put `be_sure_we_got_to_the_end_of_it` between ticks
|
||||
|
||||
fn foo_bar() {
|
||||
}
|
||||
|
||||
@ -32,7 +32,7 @@ fn foo_bar() {
|
||||
/// _foo bar_
|
||||
/// ~~~
|
||||
/// be_sure_we_got_to_the_end_of_it
|
||||
//~^ ERROR: you should put `be_sure_we_got_to_the_end_of_it` between ticks
|
||||
|
||||
fn multiline_codeblock() {
|
||||
}
|
||||
|
||||
@ -40,7 +40,7 @@ fn multiline_codeblock() {
|
||||
/// multiline
|
||||
/// emphasis_.
|
||||
/// be_sure_we_got_to_the_end_of_it
|
||||
//~^ ERROR: you should put `be_sure_we_got_to_the_end_of_it` between ticks
|
||||
|
||||
fn test_emphasis() {
|
||||
}
|
||||
|
||||
@ -55,7 +55,7 @@ fn test_emphasis() {
|
||||
/// 32kb 32Mb 32Gb 32Tb 32Pb 32Eb
|
||||
/// NaN
|
||||
/// be_sure_we_got_to_the_end_of_it
|
||||
//~^ ERROR: you should put `be_sure_we_got_to_the_end_of_it` between ticks
|
||||
|
||||
fn test_units() {
|
||||
}
|
||||
|
||||
@ -65,15 +65,15 @@ fn test_units() {
|
||||
/// `💣`
|
||||
/// `❤️`
|
||||
/// ß_foo
|
||||
//~^ ERROR: you should put `ß_foo` between ticks
|
||||
|
||||
/// ℝ_foo
|
||||
//~^ ERROR: you should put `ℝ_foo` between ticks
|
||||
|
||||
/// 💣_foo
|
||||
/// ❤️_foo
|
||||
/// foo_ß
|
||||
//~^ ERROR: you should put `foo_ß` between ticks
|
||||
|
||||
/// foo_ℝ
|
||||
//~^ ERROR: you should put `foo_ℝ` between ticks
|
||||
|
||||
/// foo_💣
|
||||
/// foo_❤️
|
||||
/// [ßdummy textß][foo_1ß]
|
||||
@ -89,16 +89,16 @@ fn test_units() {
|
||||
/// [foo3_💣]: dummy text
|
||||
/// [foo4_❤️]: dummy text
|
||||
/// be_sure_we_got_to_the_end_of_it
|
||||
//~^ ERROR: you should put `be_sure_we_got_to_the_end_of_it` between ticks
|
||||
|
||||
fn test_unicode() {
|
||||
}
|
||||
|
||||
/// This test has [a link_with_underscores][chunked-example] inside it. See #823.
|
||||
//~^ ERROR: you should put `link_with_underscores` between ticks
|
||||
|
||||
/// See also [the issue tracker](https://github.com/Manishearth/rust-clippy/search?q=doc_markdown&type=Issues)
|
||||
/// on GitHub (which is a camel-cased word, but is OK). And here is another [inline link][inline_link].
|
||||
/// It can also be [inline_link2].
|
||||
//~^ ERROR: you should put `inline_link2` between ticks
|
||||
|
||||
///
|
||||
/// [chunked-example]: https://en.wikipedia.org/wiki/Chunked_transfer_encoding#Example
|
||||
/// [inline_link]: https://foobar
|
||||
@ -110,7 +110,7 @@ fn test_unicode() {
|
||||
/// expression of the type `_ <bit_op> m <cmp_op> c` (where `<bit_op>`
|
||||
/// is one of {`&`, '|'} and `<cmp_op>` is one of {`!=`, `>=`, `>` ,
|
||||
/// be_sure_we_got_to_the_end_of_it
|
||||
//~^ ERROR: you should put `be_sure_we_got_to_the_end_of_it` between ticks
|
||||
|
||||
fn main() {
|
||||
foo_bar();
|
||||
multiline_codeblock();
|
||||
@ -124,9 +124,9 @@ fn main() {
|
||||
/// # CamelCaseThing
|
||||
///
|
||||
/// Not a title #897 CamelCaseThing
|
||||
//~^ ERROR: you should put `CamelCaseThing` between ticks
|
||||
|
||||
/// be_sure_we_got_to_the_end_of_it
|
||||
//~^ ERROR: you should put `be_sure_we_got_to_the_end_of_it` between ticks
|
||||
|
||||
fn issue897() {
|
||||
}
|
||||
|
||||
@ -134,7 +134,7 @@ fn issue897() {
|
||||
/// I am confused by brackets? (foo `x_y`)
|
||||
/// I am confused by brackets? (`x_y` foo)
|
||||
/// be_sure_we_got_to_the_end_of_it
|
||||
//~^ ERROR: you should put `be_sure_we_got_to_the_end_of_it` between ticks
|
||||
|
||||
fn issue900() {
|
||||
}
|
||||
|
||||
@ -148,7 +148,7 @@ fn issue900() {
|
||||
/// [iterator]: https://doc.rust-lang.org/stable/std/iter/trait.Iterator.html
|
||||
/// [helper_types]: ../helper_types/index.html
|
||||
/// be_sure_we_got_to_the_end_of_it
|
||||
//~^ ERROR: you should put `be_sure_we_got_to_the_end_of_it` between ticks
|
||||
|
||||
fn issue883() {
|
||||
}
|
||||
|
||||
@ -167,9 +167,9 @@ That's in a code block: `PackedNode`
|
||||
And BarQuz too.
|
||||
be_sure_we_got_to_the_end_of_it
|
||||
*/
|
||||
//~^^^^^^^^ ERROR: you should put `FooBar` between ticks
|
||||
//~^^^^ ERROR: you should put `BarQuz` between ticks
|
||||
//~^^^^ ERROR: you should put `be_sure_we_got_to_the_end_of_it` between ticks
|
||||
|
||||
|
||||
|
||||
fn issue1073() {
|
||||
}
|
||||
|
||||
@ -181,9 +181,9 @@ That's in a code block: PackedNode
|
||||
And BarQuz too.
|
||||
be_sure_we_got_to_the_end_of_it
|
||||
*/
|
||||
//~^^^^^^^^ ERROR: you should put `FooBar` between ticks
|
||||
//~^^^^ ERROR: you should put `BarQuz` between ticks
|
||||
//~^^^^ ERROR: you should put `be_sure_we_got_to_the_end_of_it` between ticks
|
||||
|
||||
|
||||
|
||||
fn issue1073_alt() {
|
||||
}
|
||||
|
||||
@ -194,6 +194,6 @@ fn issue1073_alt() {
|
||||
/// StillDont
|
||||
/// ````
|
||||
/// be_sure_we_got_to_the_end_of_it
|
||||
//~^ ERROR: you should put `be_sure_we_got_to_the_end_of_it` between ticks
|
||||
|
||||
fn four_quotes() {
|
||||
}
|
||||
|
@ -6,5 +6,5 @@ fn main() {
|
||||
let x = 1;
|
||||
-x;
|
||||
-(-x);
|
||||
--x; //~ERROR: `--x` could be misinterpreted as pre-decrement by C programmers, is usually a no-op
|
||||
--x;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
error: `--x` could be misinterpreted as pre-decrement by C programmers, is usually a no-op
|
||||
--> $DIR/double_neg.rs:9:5
|
||||
|
|
||||
9 | --x; //~ERROR: `--x` could be misinterpreted as pre-decrement by C programmers, is usually a no-op
|
||||
9 | --x;
|
||||
| ^^^
|
||||
|
|
||||
note: lint level defined here
|
||||
|
@ -13,23 +13,23 @@ impl DummyStruct {
|
||||
}
|
||||
|
||||
fn simple_double_parens() -> i32 {
|
||||
((0)) //~ERROR Consider removing unnecessary double parentheses
|
||||
((0))
|
||||
}
|
||||
|
||||
fn fn_double_parens() {
|
||||
dummy_fn((0)); //~ERROR Consider removing unnecessary double parentheses
|
||||
dummy_fn((0));
|
||||
}
|
||||
|
||||
fn method_double_parens(x: DummyStruct) {
|
||||
x.dummy_method((0)); //~ERROR Consider removing unnecessary double parentheses
|
||||
x.dummy_method((0));
|
||||
}
|
||||
|
||||
fn tuple_double_parens() -> (i32, i32) {
|
||||
((1, 2)) //~ERROR Consider removing unnecessary double parentheses
|
||||
((1, 2))
|
||||
}
|
||||
|
||||
fn unit_double_parens() {
|
||||
(()) //~ERROR Consider removing unnecessary double parentheses
|
||||
(())
|
||||
}
|
||||
|
||||
fn fn_tuple_ok() {
|
||||
|
@ -1,7 +1,7 @@
|
||||
error: Consider removing unnecessary double parentheses
|
||||
--> $DIR/double_parens.rs:16:5
|
||||
|
|
||||
16 | ((0)) //~ERROR Consider removing unnecessary double parentheses
|
||||
16 | ((0))
|
||||
| ^^^^^
|
||||
|
|
||||
note: lint level defined here
|
||||
@ -13,25 +13,25 @@ note: lint level defined here
|
||||
error: Consider removing unnecessary double parentheses
|
||||
--> $DIR/double_parens.rs:20:14
|
||||
|
|
||||
20 | dummy_fn((0)); //~ERROR Consider removing unnecessary double parentheses
|
||||
20 | dummy_fn((0));
|
||||
| ^^^
|
||||
|
||||
error: Consider removing unnecessary double parentheses
|
||||
--> $DIR/double_parens.rs:24:20
|
||||
|
|
||||
24 | x.dummy_method((0)); //~ERROR Consider removing unnecessary double parentheses
|
||||
24 | x.dummy_method((0));
|
||||
| ^^^
|
||||
|
||||
error: Consider removing unnecessary double parentheses
|
||||
--> $DIR/double_parens.rs:28:5
|
||||
|
|
||||
28 | ((1, 2)) //~ERROR Consider removing unnecessary double parentheses
|
||||
28 | ((1, 2))
|
||||
| ^^^^^^^^
|
||||
|
||||
error: Consider removing unnecessary double parentheses
|
||||
--> $DIR/double_parens.rs:32:5
|
||||
|
|
||||
32 | (()) //~ERROR Consider removing unnecessary double parentheses
|
||||
32 | (())
|
||||
| ^^^^
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
@ -9,43 +9,43 @@ use std::mem::{drop, forget};
|
||||
struct SomeStruct;
|
||||
|
||||
fn main() {
|
||||
drop(&SomeStruct); //~ERROR call to `std::mem::drop` with a reference argument
|
||||
forget(&SomeStruct); //~ERROR call to `std::mem::forget` with a reference argument
|
||||
drop(&SomeStruct);
|
||||
forget(&SomeStruct);
|
||||
|
||||
let mut owned1 = SomeStruct;
|
||||
drop(&owned1); //~ERROR call to `std::mem::drop` with a reference argument
|
||||
drop(&&owned1); //~ERROR call to `std::mem::drop` with a reference argument
|
||||
drop(&mut owned1); //~ERROR call to `std::mem::drop` with a reference argument
|
||||
drop(&owned1);
|
||||
drop(&&owned1);
|
||||
drop(&mut owned1);
|
||||
drop(owned1); //OK
|
||||
let mut owned2 = SomeStruct;
|
||||
forget(&owned2); //~ERROR call to `std::mem::forget` with a reference argument
|
||||
forget(&&owned2); //~ERROR call to `std::mem::forget` with a reference argument
|
||||
forget(&mut owned2); //~ERROR call to `std::mem::forget` with a reference argument
|
||||
forget(&owned2);
|
||||
forget(&&owned2);
|
||||
forget(&mut owned2);
|
||||
forget(owned2); //OK
|
||||
|
||||
let reference1 = &SomeStruct;
|
||||
drop(reference1); //~ERROR call to `std::mem::drop` with a reference argument
|
||||
forget(&*reference1); //~ERROR call to `std::mem::forget` with a reference argument
|
||||
drop(reference1);
|
||||
forget(&*reference1);
|
||||
|
||||
let reference2 = &mut SomeStruct;
|
||||
drop(reference2); //~ERROR call to `std::mem::drop` with a reference argument
|
||||
drop(reference2);
|
||||
let reference3 = &mut SomeStruct;
|
||||
forget(reference3); //~ERROR call to `std::mem::forget` with a reference argument
|
||||
forget(reference3);
|
||||
|
||||
let ref reference4 = SomeStruct;
|
||||
drop(reference4); //~ERROR call to `std::mem::drop` with a reference argument
|
||||
forget(reference4); //~ERROR call to `std::mem::forget` with a reference argument
|
||||
drop(reference4);
|
||||
forget(reference4);
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn test_generic_fn_drop<T>(val: T) {
|
||||
drop(&val); //~ERROR call to `std::mem::drop` with a reference argument
|
||||
drop(&val);
|
||||
drop(val); //OK
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn test_generic_fn_forget<T>(val: T) {
|
||||
forget(&val); //~ERROR call to `std::mem::forget` with a reference argument
|
||||
forget(&val);
|
||||
forget(val); //OK
|
||||
}
|
||||
|
||||
@ -53,8 +53,8 @@ fn test_generic_fn_forget<T>(val: T) {
|
||||
fn test_similarly_named_function() {
|
||||
fn drop<T>(_val: T) {}
|
||||
drop(&SomeStruct); //OK; call to unrelated function which happens to have the same name
|
||||
std::mem::drop(&SomeStruct); //~ERROR call to `std::mem::drop` with a reference argument
|
||||
std::mem::drop(&SomeStruct);
|
||||
fn forget<T>(_val: T) {}
|
||||
forget(&SomeStruct); //OK; call to unrelated function which happens to have the same name
|
||||
std::mem::forget(&SomeStruct); //~ERROR call to `std::mem::forget` with a reference argument
|
||||
std::mem::forget(&SomeStruct);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
error: call to `std::mem::drop` with a reference argument. Dropping a reference does nothing
|
||||
--> $DIR/drop_forget_ref.rs:12:5
|
||||
|
|
||||
12 | drop(&SomeStruct); //~ERROR call to `std::mem::drop` with a reference argument
|
||||
12 | drop(&SomeStruct);
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: lint level defined here
|
||||
@ -12,13 +12,13 @@ note: lint level defined here
|
||||
note: argument has type &SomeStruct
|
||||
--> $DIR/drop_forget_ref.rs:12:10
|
||||
|
|
||||
12 | drop(&SomeStruct); //~ERROR call to `std::mem::drop` with a reference argument
|
||||
12 | drop(&SomeStruct);
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: call to `std::mem::forget` with a reference argument. Forgetting a reference does nothing
|
||||
--> $DIR/drop_forget_ref.rs:13:5
|
||||
|
|
||||
13 | forget(&SomeStruct); //~ERROR call to `std::mem::forget` with a reference argument
|
||||
13 | forget(&SomeStruct);
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: lint level defined here
|
||||
@ -29,199 +29,199 @@ note: lint level defined here
|
||||
note: argument has type &SomeStruct
|
||||
--> $DIR/drop_forget_ref.rs:13:12
|
||||
|
|
||||
13 | forget(&SomeStruct); //~ERROR call to `std::mem::forget` with a reference argument
|
||||
13 | forget(&SomeStruct);
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: call to `std::mem::drop` with a reference argument. Dropping a reference does nothing
|
||||
--> $DIR/drop_forget_ref.rs:16:5
|
||||
|
|
||||
16 | drop(&owned1); //~ERROR call to `std::mem::drop` with a reference argument
|
||||
16 | drop(&owned1);
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
||||
note: argument has type &SomeStruct
|
||||
--> $DIR/drop_forget_ref.rs:16:10
|
||||
|
|
||||
16 | drop(&owned1); //~ERROR call to `std::mem::drop` with a reference argument
|
||||
16 | drop(&owned1);
|
||||
| ^^^^^^^
|
||||
|
||||
error: call to `std::mem::drop` with a reference argument. Dropping a reference does nothing
|
||||
--> $DIR/drop_forget_ref.rs:17:5
|
||||
|
|
||||
17 | drop(&&owned1); //~ERROR call to `std::mem::drop` with a reference argument
|
||||
17 | drop(&&owned1);
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
note: argument has type &&SomeStruct
|
||||
--> $DIR/drop_forget_ref.rs:17:10
|
||||
|
|
||||
17 | drop(&&owned1); //~ERROR call to `std::mem::drop` with a reference argument
|
||||
17 | drop(&&owned1);
|
||||
| ^^^^^^^^
|
||||
|
||||
error: call to `std::mem::drop` with a reference argument. Dropping a reference does nothing
|
||||
--> $DIR/drop_forget_ref.rs:18:5
|
||||
|
|
||||
18 | drop(&mut owned1); //~ERROR call to `std::mem::drop` with a reference argument
|
||||
18 | drop(&mut owned1);
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: argument has type &mut SomeStruct
|
||||
--> $DIR/drop_forget_ref.rs:18:10
|
||||
|
|
||||
18 | drop(&mut owned1); //~ERROR call to `std::mem::drop` with a reference argument
|
||||
18 | drop(&mut owned1);
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: call to `std::mem::forget` with a reference argument. Forgetting a reference does nothing
|
||||
--> $DIR/drop_forget_ref.rs:21:5
|
||||
|
|
||||
21 | forget(&owned2); //~ERROR call to `std::mem::forget` with a reference argument
|
||||
21 | forget(&owned2);
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: argument has type &SomeStruct
|
||||
--> $DIR/drop_forget_ref.rs:21:12
|
||||
|
|
||||
21 | forget(&owned2); //~ERROR call to `std::mem::forget` with a reference argument
|
||||
21 | forget(&owned2);
|
||||
| ^^^^^^^
|
||||
|
||||
error: call to `std::mem::forget` with a reference argument. Forgetting a reference does nothing
|
||||
--> $DIR/drop_forget_ref.rs:22:5
|
||||
|
|
||||
22 | forget(&&owned2); //~ERROR call to `std::mem::forget` with a reference argument
|
||||
22 | forget(&&owned2);
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: argument has type &&SomeStruct
|
||||
--> $DIR/drop_forget_ref.rs:22:12
|
||||
|
|
||||
22 | forget(&&owned2); //~ERROR call to `std::mem::forget` with a reference argument
|
||||
22 | forget(&&owned2);
|
||||
| ^^^^^^^^
|
||||
|
||||
error: call to `std::mem::forget` with a reference argument. Forgetting a reference does nothing
|
||||
--> $DIR/drop_forget_ref.rs:23:5
|
||||
|
|
||||
23 | forget(&mut owned2); //~ERROR call to `std::mem::forget` with a reference argument
|
||||
23 | forget(&mut owned2);
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: argument has type &mut SomeStruct
|
||||
--> $DIR/drop_forget_ref.rs:23:12
|
||||
|
|
||||
23 | forget(&mut owned2); //~ERROR call to `std::mem::forget` with a reference argument
|
||||
23 | forget(&mut owned2);
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: call to `std::mem::drop` with a reference argument. Dropping a reference does nothing
|
||||
--> $DIR/drop_forget_ref.rs:27:5
|
||||
|
|
||||
27 | drop(reference1); //~ERROR call to `std::mem::drop` with a reference argument
|
||||
27 | drop(reference1);
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: argument has type &SomeStruct
|
||||
--> $DIR/drop_forget_ref.rs:27:10
|
||||
|
|
||||
27 | drop(reference1); //~ERROR call to `std::mem::drop` with a reference argument
|
||||
27 | drop(reference1);
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: call to `std::mem::forget` with a reference argument. Forgetting a reference does nothing
|
||||
--> $DIR/drop_forget_ref.rs:28:5
|
||||
|
|
||||
28 | forget(&*reference1); //~ERROR call to `std::mem::forget` with a reference argument
|
||||
28 | forget(&*reference1);
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: argument has type &SomeStruct
|
||||
--> $DIR/drop_forget_ref.rs:28:12
|
||||
|
|
||||
28 | forget(&*reference1); //~ERROR call to `std::mem::forget` with a reference argument
|
||||
28 | forget(&*reference1);
|
||||
| ^^^^^^^^^^^^
|
||||
|
||||
error: call to `std::mem::drop` with a reference argument. Dropping a reference does nothing
|
||||
--> $DIR/drop_forget_ref.rs:31:5
|
||||
|
|
||||
31 | drop(reference2); //~ERROR call to `std::mem::drop` with a reference argument
|
||||
31 | drop(reference2);
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: argument has type &mut SomeStruct
|
||||
--> $DIR/drop_forget_ref.rs:31:10
|
||||
|
|
||||
31 | drop(reference2); //~ERROR call to `std::mem::drop` with a reference argument
|
||||
31 | drop(reference2);
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: call to `std::mem::forget` with a reference argument. Forgetting a reference does nothing
|
||||
--> $DIR/drop_forget_ref.rs:33:5
|
||||
|
|
||||
33 | forget(reference3); //~ERROR call to `std::mem::forget` with a reference argument
|
||||
33 | forget(reference3);
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: argument has type &mut SomeStruct
|
||||
--> $DIR/drop_forget_ref.rs:33:12
|
||||
|
|
||||
33 | forget(reference3); //~ERROR call to `std::mem::forget` with a reference argument
|
||||
33 | forget(reference3);
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: call to `std::mem::drop` with a reference argument. Dropping a reference does nothing
|
||||
--> $DIR/drop_forget_ref.rs:36:5
|
||||
|
|
||||
36 | drop(reference4); //~ERROR call to `std::mem::drop` with a reference argument
|
||||
36 | drop(reference4);
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: argument has type &SomeStruct
|
||||
--> $DIR/drop_forget_ref.rs:36:10
|
||||
|
|
||||
36 | drop(reference4); //~ERROR call to `std::mem::drop` with a reference argument
|
||||
36 | drop(reference4);
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: call to `std::mem::forget` with a reference argument. Forgetting a reference does nothing
|
||||
--> $DIR/drop_forget_ref.rs:37:5
|
||||
|
|
||||
37 | forget(reference4); //~ERROR call to `std::mem::forget` with a reference argument
|
||||
37 | forget(reference4);
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: argument has type &SomeStruct
|
||||
--> $DIR/drop_forget_ref.rs:37:12
|
||||
|
|
||||
37 | forget(reference4); //~ERROR call to `std::mem::forget` with a reference argument
|
||||
37 | forget(reference4);
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: call to `std::mem::drop` with a reference argument. Dropping a reference does nothing
|
||||
--> $DIR/drop_forget_ref.rs:42:5
|
||||
|
|
||||
42 | drop(&val); //~ERROR call to `std::mem::drop` with a reference argument
|
||||
42 | drop(&val);
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
note: argument has type &T
|
||||
--> $DIR/drop_forget_ref.rs:42:10
|
||||
|
|
||||
42 | drop(&val); //~ERROR call to `std::mem::drop` with a reference argument
|
||||
42 | drop(&val);
|
||||
| ^^^^
|
||||
|
||||
error: call to `std::mem::forget` with a reference argument. Forgetting a reference does nothing
|
||||
--> $DIR/drop_forget_ref.rs:48:5
|
||||
|
|
||||
48 | forget(&val); //~ERROR call to `std::mem::forget` with a reference argument
|
||||
48 | forget(&val);
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
||||
note: argument has type &T
|
||||
--> $DIR/drop_forget_ref.rs:48:12
|
||||
|
|
||||
48 | forget(&val); //~ERROR call to `std::mem::forget` with a reference argument
|
||||
48 | forget(&val);
|
||||
| ^^^^
|
||||
|
||||
error: call to `std::mem::drop` with a reference argument. Dropping a reference does nothing
|
||||
--> $DIR/drop_forget_ref.rs:56:5
|
||||
|
|
||||
56 | std::mem::drop(&SomeStruct); //~ERROR call to `std::mem::drop` with a reference argument
|
||||
56 | std::mem::drop(&SomeStruct);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: argument has type &SomeStruct
|
||||
--> $DIR/drop_forget_ref.rs:56:20
|
||||
|
|
||||
56 | std::mem::drop(&SomeStruct); //~ERROR call to `std::mem::drop` with a reference argument
|
||||
56 | std::mem::drop(&SomeStruct);
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: call to `std::mem::forget` with a reference argument. Forgetting a reference does nothing
|
||||
--> $DIR/drop_forget_ref.rs:59:5
|
||||
|
|
||||
59 | std::mem::forget(&SomeStruct); //~ERROR call to `std::mem::forget` with a reference argument
|
||||
59 | std::mem::forget(&SomeStruct);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: argument has type &SomeStruct
|
||||
--> $DIR/drop_forget_ref.rs:59:22
|
||||
|
|
||||
59 | std::mem::forget(&SomeStruct); //~ERROR call to `std::mem::forget` with a reference argument
|
||||
59 | std::mem::forget(&SomeStruct);
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 18 previous errors
|
||||
|
@ -4,10 +4,10 @@
|
||||
#![deny(duplicate_underscore_argument)]
|
||||
#[allow(dead_code, unused)]
|
||||
|
||||
fn join_the_dark_side(darth: i32, _darth: i32) {} //~ERROR `darth` already exists
|
||||
fn join_the_dark_side(darth: i32, _darth: i32) {}
|
||||
fn join_the_light_side(knight: i32, _master: i32) {} // the Force is strong with this one
|
||||
|
||||
fn main() {
|
||||
join_the_dark_side(0, 0);
|
||||
join_the_light_side(0, 0);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
error: `darth` already exists, having another argument having almost the same name makes code comprehension and documentation more difficult
|
||||
--> $DIR/duplicate_underscore_argument.rs:7:23
|
||||
|
|
||||
7 | fn join_the_dark_side(darth: i32, _darth: i32) {} //~ERROR `darth` already exists
|
||||
7 | fn join_the_dark_side(darth: i32, _darth: i32) {}
|
||||
| ^^^^^
|
||||
|
|
||||
note: lint level defined here
|
||||
|
@ -4,8 +4,8 @@
|
||||
#![allow(dead_code)]
|
||||
#![deny(empty_enum)]
|
||||
|
||||
enum Empty {} //~ ERROR enum with no variants
|
||||
//~^ HELP consider using the uninhabited type `!` or a wrapper around it
|
||||
enum Empty {}
|
||||
|
||||
|
||||
fn main() {
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
error: enum with no variants
|
||||
--> $DIR/empty_enum.rs:7:1
|
||||
|
|
||||
7 | enum Empty {} //~ ERROR enum with no variants
|
||||
7 | enum Empty {}
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
||||
note: lint level defined here
|
||||
@ -12,7 +12,7 @@ note: lint level defined here
|
||||
help: consider using the uninhabited type `!` or a wrapper around it
|
||||
--> $DIR/empty_enum.rs:7:1
|
||||
|
|
||||
7 | enum Empty {} //~ ERROR enum with no variants
|
||||
7 | enum Empty {}
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
@ -11,51 +11,51 @@ fn foo() {}
|
||||
|
||||
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); }
|
||||
//~^ ERROR usage of `contains_key` followed by `insert` on a `HashMap`
|
||||
//~| HELP consider
|
||||
//~| SUGGESTION m.entry(k).or_insert(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); }
|
||||
//~^ ERROR usage of `contains_key` followed by `insert` on a `HashMap`
|
||||
//~| HELP consider
|
||||
//~| SUGGESTION m.entry(k)
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
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 };
|
||||
//~^ ERROR usage of `contains_key` followed by `insert` on a `HashMap`
|
||||
//~| HELP consider
|
||||
//~| SUGGESTION m.entry(k)
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
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) };
|
||||
//~^ ERROR usage of `contains_key` followed by `insert` on a `HashMap`
|
||||
//~| HELP consider
|
||||
//~| SUGGESTION m.entry(k)
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
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 };
|
||||
//~^ ERROR usage of `contains_key` followed by `insert` on a `HashMap`
|
||||
//~| HELP consider
|
||||
//~| SUGGESTION m.entry(k)
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
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) };
|
||||
//~^ ERROR usage of `contains_key` followed by `insert` on a `HashMap`
|
||||
//~| HELP consider
|
||||
//~| SUGGESTION m.entry(k)
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
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 };
|
||||
//~^ ERROR usage of `contains_key` followed by `insert` on a `BTreeMap`
|
||||
//~| HELP consider
|
||||
//~| SUGGESTION m.entry(k)
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
fn insert_other_if_absent<K: Eq + Hash, V>(m: &mut HashMap<K, V>, k: K, o: K, v: V) {
|
||||
|
@ -3,13 +3,13 @@
|
||||
#![deny(clippy, clippy_pedantic)]
|
||||
#![allow(unused_imports, dead_code, missing_docs_in_private_items)]
|
||||
|
||||
use std::cmp::Ordering::*; //~ ERROR: don't use glob imports for enum variants
|
||||
use std::cmp::Ordering::*;
|
||||
|
||||
enum Enum {
|
||||
_Foo,
|
||||
}
|
||||
|
||||
use self::Enum::*; //~ ERROR: don't use glob imports for enum variants
|
||||
use self::Enum::*;
|
||||
|
||||
fn blarg() {
|
||||
use self::Enum::*; // ok, just for a function
|
||||
|
@ -1,7 +1,7 @@
|
||||
error: don't use glob imports for enum variants
|
||||
--> $DIR/enum_glob_use.rs:6:1
|
||||
|
|
||||
6 | use std::cmp::Ordering::*; //~ ERROR: don't use glob imports for enum variants
|
||||
6 | use std::cmp::Ordering::*;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: #[deny(enum_glob_use)] implied by #[deny(clippy_pedantic)]
|
||||
@ -14,7 +14,7 @@ note: lint level defined here
|
||||
error: don't use glob imports for enum variants
|
||||
--> $DIR/enum_glob_use.rs:12:1
|
||||
|
|
||||
12 | use self::Enum::*; //~ ERROR: don't use glob imports for enum variants
|
||||
12 | use self::Enum::*;
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: #[deny(enum_glob_use)] implied by #[deny(clippy_pedantic)]
|
||||
|
@ -11,7 +11,7 @@ enum FakeCallType2 {
|
||||
}
|
||||
|
||||
enum Foo {
|
||||
cFoo, //~ ERROR: Variant name ends with the enum's name
|
||||
cFoo,
|
||||
cBar,
|
||||
cBaz,
|
||||
}
|
||||
@ -21,17 +21,17 @@ enum Fooo {
|
||||
cBar,
|
||||
}
|
||||
|
||||
enum Food { //~ ERROR: All variants have the same prefix: `Food`
|
||||
FoodGood, //~ ERROR: Variant name starts with the enum's name
|
||||
FoodMiddle, //~ ERROR: Variant name starts with the enum's name
|
||||
FoodBad, //~ ERROR: Variant name starts with the enum's name
|
||||
enum Food {
|
||||
FoodGood,
|
||||
FoodMiddle,
|
||||
FoodBad,
|
||||
}
|
||||
|
||||
enum Stuff {
|
||||
StuffBad, // no error
|
||||
}
|
||||
|
||||
enum BadCallType { //~ ERROR: All variants have the same prefix: `CallType`
|
||||
enum BadCallType {
|
||||
CallTypeCall,
|
||||
CallTypeCreate,
|
||||
CallTypeDestroy,
|
||||
@ -42,7 +42,7 @@ enum TwoCallType { // no error
|
||||
CallTypeCreate,
|
||||
}
|
||||
|
||||
enum Consts { //~ ERROR: All variants have the same prefix: `Constant`
|
||||
enum Consts {
|
||||
ConstantInt,
|
||||
ConstantCake,
|
||||
ConstantLie,
|
||||
@ -75,19 +75,19 @@ enum Sealll {
|
||||
WithOut,
|
||||
}
|
||||
|
||||
enum Seallll { //~ ERROR: All variants have the same prefix: `With`
|
||||
enum Seallll {
|
||||
WithOutCake,
|
||||
WithOutTea,
|
||||
WithOut,
|
||||
}
|
||||
|
||||
enum NonCaps { //~ ERROR: All variants have the same prefix: `Prefix`
|
||||
enum NonCaps {
|
||||
Prefix的,
|
||||
PrefixTea,
|
||||
PrefixCake,
|
||||
}
|
||||
|
||||
pub enum PubSeall { //~ ERROR: All variants have the same prefix:
|
||||
pub enum PubSeall {
|
||||
WithOutCake,
|
||||
WithOutTea,
|
||||
WithOut,
|
||||
|
@ -1,7 +1,7 @@
|
||||
error: Variant name ends with the enum's name
|
||||
--> $DIR/enum_variants.rs:14:5
|
||||
|
|
||||
14 | cFoo, //~ ERROR: Variant name ends with the enum's name
|
||||
14 | cFoo,
|
||||
| ^^^^
|
||||
|
|
||||
= note: #[deny(enum_variant_names)] implied by #[deny(clippy)]
|
||||
@ -14,7 +14,7 @@ note: lint level defined here
|
||||
error: Variant name starts with the enum's name
|
||||
--> $DIR/enum_variants.rs:25:5
|
||||
|
|
||||
25 | FoodGood, //~ ERROR: Variant name starts with the enum's name
|
||||
25 | FoodGood,
|
||||
| ^^^^^^^^
|
||||
|
|
||||
= note: #[deny(enum_variant_names)] implied by #[deny(clippy)]
|
||||
@ -22,7 +22,7 @@ error: Variant name starts with the enum's name
|
||||
error: Variant name starts with the enum's name
|
||||
--> $DIR/enum_variants.rs:26:5
|
||||
|
|
||||
26 | FoodMiddle, //~ ERROR: Variant name starts with the enum's name
|
||||
26 | FoodMiddle,
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
= note: #[deny(enum_variant_names)] implied by #[deny(clippy)]
|
||||
@ -30,7 +30,7 @@ error: Variant name starts with the enum's name
|
||||
error: Variant name starts with the enum's name
|
||||
--> $DIR/enum_variants.rs:27:5
|
||||
|
|
||||
27 | FoodBad, //~ ERROR: Variant name starts with the enum's name
|
||||
27 | FoodBad,
|
||||
| ^^^^^^^
|
||||
|
|
||||
= note: #[deny(enum_variant_names)] implied by #[deny(clippy)]
|
||||
@ -38,11 +38,11 @@ error: Variant name starts with the enum's name
|
||||
error: All variants have the same prefix: `Food`
|
||||
--> $DIR/enum_variants.rs:24:1
|
||||
|
|
||||
24 | enum Food { //~ ERROR: All variants have the same prefix: `Food`
|
||||
24 | enum Food {
|
||||
| _^ starting here...
|
||||
25 | | FoodGood, //~ ERROR: Variant name starts with the enum's name
|
||||
26 | | FoodMiddle, //~ ERROR: Variant name starts with the enum's name
|
||||
27 | | FoodBad, //~ ERROR: Variant name starts with the enum's name
|
||||
25 | | FoodGood,
|
||||
26 | | FoodMiddle,
|
||||
27 | | FoodBad,
|
||||
28 | | }
|
||||
| |_^ ...ending here
|
||||
|
|
||||
@ -52,7 +52,7 @@ error: All variants have the same prefix: `Food`
|
||||
error: All variants have the same prefix: `CallType`
|
||||
--> $DIR/enum_variants.rs:34:1
|
||||
|
|
||||
34 | enum BadCallType { //~ ERROR: All variants have the same prefix: `CallType`
|
||||
34 | enum BadCallType {
|
||||
| _^ starting here...
|
||||
35 | | CallTypeCall,
|
||||
36 | | CallTypeCreate,
|
||||
@ -66,7 +66,7 @@ error: All variants have the same prefix: `CallType`
|
||||
error: All variants have the same prefix: `Constant`
|
||||
--> $DIR/enum_variants.rs:45:1
|
||||
|
|
||||
45 | enum Consts { //~ ERROR: All variants have the same prefix: `Constant`
|
||||
45 | enum Consts {
|
||||
| _^ starting here...
|
||||
46 | | ConstantInt,
|
||||
47 | | ConstantCake,
|
||||
@ -80,7 +80,7 @@ error: All variants have the same prefix: `Constant`
|
||||
error: All variants have the same prefix: `With`
|
||||
--> $DIR/enum_variants.rs:78:1
|
||||
|
|
||||
78 | enum Seallll { //~ ERROR: All variants have the same prefix: `With`
|
||||
78 | enum Seallll {
|
||||
| _^ starting here...
|
||||
79 | | WithOutCake,
|
||||
80 | | WithOutTea,
|
||||
@ -94,7 +94,7 @@ error: All variants have the same prefix: `With`
|
||||
error: All variants have the same prefix: `Prefix`
|
||||
--> $DIR/enum_variants.rs:84:1
|
||||
|
|
||||
84 | enum NonCaps { //~ ERROR: All variants have the same prefix: `Prefix`
|
||||
84 | enum NonCaps {
|
||||
| _^ starting here...
|
||||
85 | | Prefix的,
|
||||
86 | | PrefixTea,
|
||||
@ -108,7 +108,7 @@ error: All variants have the same prefix: `Prefix`
|
||||
error: All variants have the same prefix: `With`
|
||||
--> $DIR/enum_variants.rs:90:1
|
||||
|
|
||||
90 | pub enum PubSeall { //~ ERROR: All variants have the same prefix:
|
||||
90 | pub enum PubSeall {
|
||||
| _^ starting here...
|
||||
91 | | WithOutCake,
|
||||
92 | | WithOutTea,
|
||||
|
@ -7,34 +7,34 @@
|
||||
|
||||
#[repr(usize)]
|
||||
enum NonPortable {
|
||||
X = 0x1_0000_0000, //~ ERROR: Clike enum variant discriminant is not portable to 32-bit targets
|
||||
X = 0x1_0000_0000,
|
||||
Y = 0,
|
||||
Z = 0x7FFF_FFFF,
|
||||
A = 0xFFFF_FFFF,
|
||||
}
|
||||
|
||||
enum NonPortableNoHint {
|
||||
X = 0x1_0000_0000, //~ ERROR: Clike enum variant discriminant is not portable to 32-bit targets
|
||||
X = 0x1_0000_0000,
|
||||
Y = 0,
|
||||
Z = 0x7FFF_FFFF,
|
||||
A = 0xFFFF_FFFF, //~ ERROR: Clike enum variant discriminant is not portable to 32-bit targets
|
||||
A = 0xFFFF_FFFF,
|
||||
}
|
||||
|
||||
#[repr(isize)]
|
||||
enum NonPortableSigned {
|
||||
X = -1,
|
||||
Y = 0x7FFF_FFFF,
|
||||
Z = 0xFFFF_FFFF, //~ ERROR: Clike enum variant discriminant is not portable to 32-bit targets
|
||||
A = 0x1_0000_0000, //~ ERROR: Clike enum variant discriminant is not portable to 32-bit targets
|
||||
Z = 0xFFFF_FFFF,
|
||||
A = 0x1_0000_0000,
|
||||
B = std::i32::MIN as isize,
|
||||
C = (std::i32::MIN as isize) - 1, //~ ERROR: Clike enum variant discriminant is not portable to 32-bit targets
|
||||
C = (std::i32::MIN as isize) - 1,
|
||||
}
|
||||
|
||||
enum NonPortableSignedNoHint {
|
||||
X = -1,
|
||||
Y = 0x7FFF_FFFF,
|
||||
Z = 0xFFFF_FFFF, //~ ERROR: Clike enum variant discriminant is not portable to 32-bit targets
|
||||
A = 0x1_0000_0000, //~ ERROR: Clike enum variant discriminant is not portable to 32-bit targets
|
||||
Z = 0xFFFF_FFFF,
|
||||
A = 0x1_0000_0000,
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1,7 +1,7 @@
|
||||
error: Clike enum variant discriminant is not portable to 32-bit targets
|
||||
--> $DIR/enums_clike.rs:10:5
|
||||
|
|
||||
10 | X = 0x1_0000_0000, //~ ERROR: Clike enum variant discriminant is not portable to 32-bit targets
|
||||
10 | X = 0x1_0000_0000,
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: #[deny(enum_clike_unportable_variant)] implied by #[deny(clippy)]
|
||||
@ -14,7 +14,7 @@ note: lint level defined here
|
||||
error: Clike enum variant discriminant is not portable to 32-bit targets
|
||||
--> $DIR/enums_clike.rs:17:5
|
||||
|
|
||||
17 | X = 0x1_0000_0000, //~ ERROR: Clike enum variant discriminant is not portable to 32-bit targets
|
||||
17 | X = 0x1_0000_0000,
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: #[deny(enum_clike_unportable_variant)] implied by #[deny(clippy)]
|
||||
@ -22,7 +22,7 @@ error: Clike enum variant discriminant is not portable to 32-bit targets
|
||||
error: Clike enum variant discriminant is not portable to 32-bit targets
|
||||
--> $DIR/enums_clike.rs:20:5
|
||||
|
|
||||
20 | A = 0xFFFF_FFFF, //~ ERROR: Clike enum variant discriminant is not portable to 32-bit targets
|
||||
20 | A = 0xFFFF_FFFF,
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: #[deny(enum_clike_unportable_variant)] implied by #[deny(clippy)]
|
||||
@ -30,7 +30,7 @@ error: Clike enum variant discriminant is not portable to 32-bit targets
|
||||
error: Clike enum variant discriminant is not portable to 32-bit targets
|
||||
--> $DIR/enums_clike.rs:27:5
|
||||
|
|
||||
27 | Z = 0xFFFF_FFFF, //~ ERROR: Clike enum variant discriminant is not portable to 32-bit targets
|
||||
27 | Z = 0xFFFF_FFFF,
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: #[deny(enum_clike_unportable_variant)] implied by #[deny(clippy)]
|
||||
@ -38,7 +38,7 @@ error: Clike enum variant discriminant is not portable to 32-bit targets
|
||||
error: Clike enum variant discriminant is not portable to 32-bit targets
|
||||
--> $DIR/enums_clike.rs:28:5
|
||||
|
|
||||
28 | A = 0x1_0000_0000, //~ ERROR: Clike enum variant discriminant is not portable to 32-bit targets
|
||||
28 | A = 0x1_0000_0000,
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: #[deny(enum_clike_unportable_variant)] implied by #[deny(clippy)]
|
||||
@ -46,7 +46,7 @@ error: Clike enum variant discriminant is not portable to 32-bit targets
|
||||
error: Clike enum variant discriminant is not portable to 32-bit targets
|
||||
--> $DIR/enums_clike.rs:30:5
|
||||
|
|
||||
30 | C = (std::i32::MIN as isize) - 1, //~ ERROR: Clike enum variant discriminant is not portable to 32-bit targets
|
||||
30 | C = (std::i32::MIN as isize) - 1,
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: #[deny(enum_clike_unportable_variant)] implied by #[deny(clippy)]
|
||||
@ -54,7 +54,7 @@ error: Clike enum variant discriminant is not portable to 32-bit targets
|
||||
error: Clike enum variant discriminant is not portable to 32-bit targets
|
||||
--> $DIR/enums_clike.rs:36:5
|
||||
|
|
||||
36 | Z = 0xFFFF_FFFF, //~ ERROR: Clike enum variant discriminant is not portable to 32-bit targets
|
||||
36 | Z = 0xFFFF_FFFF,
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: #[deny(enum_clike_unportable_variant)] implied by #[deny(clippy)]
|
||||
@ -62,7 +62,7 @@ error: Clike enum variant discriminant is not portable to 32-bit targets
|
||||
error: Clike enum variant discriminant is not portable to 32-bit targets
|
||||
--> $DIR/enums_clike.rs:37:5
|
||||
|
|
||||
37 | A = 0x1_0000_0000, //~ ERROR: Clike enum variant discriminant is not portable to 32-bit targets
|
||||
37 | A = 0x1_0000_0000,
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: #[deny(enum_clike_unportable_variant)] implied by #[deny(clippy)]
|
||||
|
@ -7,56 +7,56 @@
|
||||
#[deny(nonminimal_bool)]
|
||||
fn main() {
|
||||
// simple values and comparisons
|
||||
1 == 1; //~ERROR equal expressions
|
||||
"no" == "no"; //~ERROR equal expressions
|
||||
1 == 1;
|
||||
"no" == "no";
|
||||
// even though I agree that no means no ;-)
|
||||
false != false; //~ERROR equal expressions
|
||||
1.5 < 1.5; //~ERROR equal expressions
|
||||
1u64 >= 1u64; //~ERROR equal expressions
|
||||
false != false;
|
||||
1.5 < 1.5;
|
||||
1u64 >= 1u64;
|
||||
|
||||
// casts, methods, parentheses
|
||||
(1 as u64) & (1 as u64); //~ERROR equal expressions
|
||||
1 ^ ((((((1)))))); //~ERROR equal expressions
|
||||
(1 as u64) & (1 as u64);
|
||||
1 ^ ((((((1))))));
|
||||
|
||||
// unary and binary operators
|
||||
(-(2) < -(2)); //~ERROR equal expressions
|
||||
(-(2) < -(2));
|
||||
((1 + 1) & (1 + 1) == (1 + 1) & (1 + 1));
|
||||
//~^ ERROR equal expressions as operands to `==`
|
||||
//~^^ ERROR equal expressions as operands to `&`
|
||||
//~^^^ ERROR equal expressions as operands to `&`
|
||||
(1 * 2) + (3 * 4) == 1 * 2 + 3 * 4; //~ERROR equal expressions
|
||||
|
||||
|
||||
|
||||
(1 * 2) + (3 * 4) == 1 * 2 + 3 * 4;
|
||||
|
||||
// various other things
|
||||
([1] != [1]); //~ERROR equal expressions
|
||||
((1, 2) != (1, 2)); //~ERROR equal expressions
|
||||
([1] != [1]);
|
||||
((1, 2) != (1, 2));
|
||||
vec![1, 2, 3] == vec![1, 2, 3]; //no error yet, as we don't match macros
|
||||
|
||||
// const folding
|
||||
1 + 1 == 2; //~ERROR equal expressions
|
||||
1 - 1 == 0; //~ERROR equal expressions as operands to `==`
|
||||
//~^ ERROR equal expressions as operands to `-`
|
||||
1 + 1 == 2;
|
||||
1 - 1 == 0;
|
||||
|
||||
|
||||
1 - 1;
|
||||
1 / 1;
|
||||
true && true;
|
||||
|
||||
true || true;
|
||||
|
||||
1 - 1; //~ERROR equal expressions
|
||||
1 / 1; //~ERROR equal expressions
|
||||
true && true; //~ERROR equal expressions
|
||||
//~|ERROR this boolean expression can be simplified
|
||||
true || true; //~ERROR equal expressions
|
||||
//~|ERROR this boolean expression can be simplified
|
||||
|
||||
let a: u32 = 0;
|
||||
let b: u32 = 0;
|
||||
|
||||
a == b && b == a; //~ERROR equal expressions
|
||||
//~|ERROR this boolean expression can be simplified
|
||||
a != b && b != a; //~ERROR equal expressions
|
||||
//~|ERROR this boolean expression can be simplified
|
||||
a < b && b > a; //~ERROR equal expressions
|
||||
//~|ERROR this boolean expression can be simplified
|
||||
a <= b && b >= a; //~ERROR equal expressions
|
||||
//~|ERROR this boolean expression can be simplified
|
||||
a == b && b == a;
|
||||
|
||||
a != b && b != a;
|
||||
|
||||
a < b && b > a;
|
||||
|
||||
a <= b && b >= a;
|
||||
|
||||
|
||||
let mut a = vec![1];
|
||||
a == a; //~ERROR equal expressions
|
||||
a == a;
|
||||
2*a.len() == 2*a.len(); // ok, functions
|
||||
a.pop() == a.pop(); // ok, functions
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
error: this boolean expression can be simplified
|
||||
--> $DIR/eq_op.rs:41:5
|
||||
|
|
||||
41 | true && true; //~ERROR equal expressions
|
||||
41 | true && true;
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
||||
note: lint level defined here
|
||||
@ -10,57 +10,57 @@ note: lint level defined here
|
||||
7 | #[deny(nonminimal_bool)]
|
||||
| ^^^^^^^^^^^^^^^
|
||||
help: try
|
||||
| true; //~ERROR equal expressions
|
||||
| true;
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> $DIR/eq_op.rs:43:5
|
||||
|
|
||||
43 | true || true; //~ERROR equal expressions
|
||||
43 | true || true;
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
||||
help: try
|
||||
| true; //~ERROR equal expressions
|
||||
| true;
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> $DIR/eq_op.rs:49:5
|
||||
|
|
||||
49 | a == b && b == a; //~ERROR equal expressions
|
||||
49 | a == b && b == a;
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: try
|
||||
| a == b; //~ERROR equal expressions
|
||||
| a == b;
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> $DIR/eq_op.rs:51:5
|
||||
|
|
||||
51 | a != b && b != a; //~ERROR equal expressions
|
||||
51 | a != b && b != a;
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: try
|
||||
| a != b; //~ERROR equal expressions
|
||||
| a != b;
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> $DIR/eq_op.rs:53:5
|
||||
|
|
||||
53 | a < b && b > a; //~ERROR equal expressions
|
||||
53 | a < b && b > a;
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
help: try
|
||||
| a < b; //~ERROR equal expressions
|
||||
| a < b;
|
||||
|
||||
error: this boolean expression can be simplified
|
||||
--> $DIR/eq_op.rs:55:5
|
||||
|
|
||||
55 | a <= b && b >= a; //~ERROR equal expressions
|
||||
55 | a <= b && b >= a;
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: try
|
||||
| a <= b; //~ERROR equal expressions
|
||||
| a <= b;
|
||||
|
||||
error: equal expressions as operands to `==`
|
||||
--> $DIR/eq_op.rs:10:5
|
||||
|
|
||||
10 | 1 == 1; //~ERROR equal expressions
|
||||
10 | 1 == 1;
|
||||
| ^^^^^^
|
||||
|
|
||||
note: lint level defined here
|
||||
@ -72,43 +72,43 @@ note: lint level defined here
|
||||
error: equal expressions as operands to `==`
|
||||
--> $DIR/eq_op.rs:11:5
|
||||
|
|
||||
11 | "no" == "no"; //~ERROR equal expressions
|
||||
11 | "no" == "no";
|
||||
| ^^^^^^^^^^^^
|
||||
|
||||
error: equal expressions as operands to `!=`
|
||||
--> $DIR/eq_op.rs:13:5
|
||||
|
|
||||
13 | false != false; //~ERROR equal expressions
|
||||
13 | false != false;
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: equal expressions as operands to `<`
|
||||
--> $DIR/eq_op.rs:14:5
|
||||
|
|
||||
14 | 1.5 < 1.5; //~ERROR equal expressions
|
||||
14 | 1.5 < 1.5;
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: equal expressions as operands to `>=`
|
||||
--> $DIR/eq_op.rs:15:5
|
||||
|
|
||||
15 | 1u64 >= 1u64; //~ERROR equal expressions
|
||||
15 | 1u64 >= 1u64;
|
||||
| ^^^^^^^^^^^^
|
||||
|
||||
error: equal expressions as operands to `&`
|
||||
--> $DIR/eq_op.rs:18:5
|
||||
|
|
||||
18 | (1 as u64) & (1 as u64); //~ERROR equal expressions
|
||||
18 | (1 as u64) & (1 as u64);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: equal expressions as operands to `^`
|
||||
--> $DIR/eq_op.rs:19:5
|
||||
|
|
||||
19 | 1 ^ ((((((1)))))); //~ERROR equal expressions
|
||||
19 | 1 ^ ((((((1))))));
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: equal expressions as operands to `<`
|
||||
--> $DIR/eq_op.rs:22:5
|
||||
|
|
||||
22 | (-(2) < -(2)); //~ERROR equal expressions
|
||||
22 | (-(2) < -(2));
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: equal expressions as operands to `==`
|
||||
@ -132,91 +132,91 @@ error: equal expressions as operands to `&`
|
||||
error: equal expressions as operands to `==`
|
||||
--> $DIR/eq_op.rs:27:5
|
||||
|
|
||||
27 | (1 * 2) + (3 * 4) == 1 * 2 + 3 * 4; //~ERROR equal expressions
|
||||
27 | (1 * 2) + (3 * 4) == 1 * 2 + 3 * 4;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: equal expressions as operands to `!=`
|
||||
--> $DIR/eq_op.rs:30:5
|
||||
|
|
||||
30 | ([1] != [1]); //~ERROR equal expressions
|
||||
30 | ([1] != [1]);
|
||||
| ^^^^^^^^^^^^
|
||||
|
||||
error: equal expressions as operands to `!=`
|
||||
--> $DIR/eq_op.rs:31:5
|
||||
|
|
||||
31 | ((1, 2) != (1, 2)); //~ERROR equal expressions
|
||||
31 | ((1, 2) != (1, 2));
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: equal expressions as operands to `==`
|
||||
--> $DIR/eq_op.rs:35:5
|
||||
|
|
||||
35 | 1 + 1 == 2; //~ERROR equal expressions
|
||||
35 | 1 + 1 == 2;
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: equal expressions as operands to `==`
|
||||
--> $DIR/eq_op.rs:36:5
|
||||
|
|
||||
36 | 1 - 1 == 0; //~ERROR equal expressions as operands to `==`
|
||||
36 | 1 - 1 == 0;
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: equal expressions as operands to `-`
|
||||
--> $DIR/eq_op.rs:36:5
|
||||
|
|
||||
36 | 1 - 1 == 0; //~ERROR equal expressions as operands to `==`
|
||||
36 | 1 - 1 == 0;
|
||||
| ^^^^^
|
||||
|
||||
error: equal expressions as operands to `-`
|
||||
--> $DIR/eq_op.rs:39:5
|
||||
|
|
||||
39 | 1 - 1; //~ERROR equal expressions
|
||||
39 | 1 - 1;
|
||||
| ^^^^^
|
||||
|
||||
error: equal expressions as operands to `/`
|
||||
--> $DIR/eq_op.rs:40:5
|
||||
|
|
||||
40 | 1 / 1; //~ERROR equal expressions
|
||||
40 | 1 / 1;
|
||||
| ^^^^^
|
||||
|
||||
error: equal expressions as operands to `&&`
|
||||
--> $DIR/eq_op.rs:41:5
|
||||
|
|
||||
41 | true && true; //~ERROR equal expressions
|
||||
41 | true && true;
|
||||
| ^^^^^^^^^^^^
|
||||
|
||||
error: equal expressions as operands to `||`
|
||||
--> $DIR/eq_op.rs:43:5
|
||||
|
|
||||
43 | true || true; //~ERROR equal expressions
|
||||
43 | true || true;
|
||||
| ^^^^^^^^^^^^
|
||||
|
||||
error: equal expressions as operands to `&&`
|
||||
--> $DIR/eq_op.rs:49:5
|
||||
|
|
||||
49 | a == b && b == a; //~ERROR equal expressions
|
||||
49 | a == b && b == a;
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: equal expressions as operands to `&&`
|
||||
--> $DIR/eq_op.rs:51:5
|
||||
|
|
||||
51 | a != b && b != a; //~ERROR equal expressions
|
||||
51 | a != b && b != a;
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: equal expressions as operands to `&&`
|
||||
--> $DIR/eq_op.rs:53:5
|
||||
|
|
||||
53 | a < b && b > a; //~ERROR equal expressions
|
||||
53 | a < b && b > a;
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: equal expressions as operands to `&&`
|
||||
--> $DIR/eq_op.rs:55:5
|
||||
|
|
||||
55 | a <= b && b >= a; //~ERROR equal expressions
|
||||
55 | a <= b && b >= a;
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: equal expressions as operands to `==`
|
||||
--> $DIR/eq_op.rs:59:5
|
||||
|
|
||||
59 | a == a; //~ERROR equal expressions
|
||||
59 | a == a;
|
||||
| ^^^^^^
|
||||
|
||||
error: aborting due to 32 previous errors
|
||||
|
@ -30,11 +30,11 @@ fn ok_box_trait(boxed_trait: &Box<Z>) {
|
||||
}
|
||||
|
||||
fn warn_call() {
|
||||
let x = box A; //~ ERROR local variable
|
||||
let x = box A;
|
||||
x.foo();
|
||||
}
|
||||
|
||||
fn warn_arg(x: Box<A>) { //~ ERROR local variable
|
||||
fn warn_arg(x: Box<A>) {
|
||||
x.foo();
|
||||
}
|
||||
|
||||
@ -46,16 +46,16 @@ fn nowarn_closure_arg() {
|
||||
fn warn_rename_call() {
|
||||
let x = box A;
|
||||
|
||||
let y = x; //~ ERROR local variable
|
||||
let y = x;
|
||||
y.foo(); // via autoderef
|
||||
}
|
||||
|
||||
fn warn_notuse() {
|
||||
let bz = box A; //~ ERROR local variable
|
||||
let bz = box A;
|
||||
}
|
||||
|
||||
fn warn_pass() {
|
||||
let bz = box A; //~ ERROR local variable
|
||||
let bz = box A;
|
||||
take_ref(&bz); // via deref coercion
|
||||
}
|
||||
|
||||
@ -85,7 +85,7 @@ fn take_ref(x: &A) {}
|
||||
|
||||
fn nowarn_ref_take() {
|
||||
// false positive, should actually warn
|
||||
let x = box A; //~ ERROR local variable
|
||||
let x = box A;
|
||||
let y = &x;
|
||||
take_box(y);
|
||||
}
|
||||
@ -98,7 +98,7 @@ fn nowarn_match() {
|
||||
}
|
||||
|
||||
fn warn_match() {
|
||||
let x = box A; //~ ERROR local variable
|
||||
let x = box A;
|
||||
match &x { // not moved
|
||||
ref y => ()
|
||||
}
|
||||
@ -127,5 +127,5 @@ pub struct PeekableSeekable<I: Foo> {
|
||||
_peeked: I::Item,
|
||||
}
|
||||
|
||||
pub fn new(_needs_name: Box<PeekableSeekable<&()>>) -> () { //~ ERROR local variable doesn't need
|
||||
pub fn new(_needs_name: Box<PeekableSeekable<&()>>) -> () {
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
error: local variable doesn't need to be boxed here
|
||||
--> $DIR/escape_analysis.rs:33:9
|
||||
|
|
||||
33 | let x = box A; //~ ERROR local variable
|
||||
33 | let x = box A;
|
||||
| ^
|
||||
|
|
||||
note: lint level defined here
|
||||
@ -13,43 +13,43 @@ note: lint level defined here
|
||||
error: local variable doesn't need to be boxed here
|
||||
--> $DIR/escape_analysis.rs:37:13
|
||||
|
|
||||
37 | fn warn_arg(x: Box<A>) { //~ ERROR local variable
|
||||
37 | fn warn_arg(x: Box<A>) {
|
||||
| ^
|
||||
|
||||
error: local variable doesn't need to be boxed here
|
||||
--> $DIR/escape_analysis.rs:49:9
|
||||
|
|
||||
49 | let y = x; //~ ERROR local variable
|
||||
49 | let y = x;
|
||||
| ^
|
||||
|
||||
error: local variable doesn't need to be boxed here
|
||||
--> $DIR/escape_analysis.rs:54:9
|
||||
|
|
||||
54 | let bz = box A; //~ ERROR local variable
|
||||
54 | let bz = box A;
|
||||
| ^^
|
||||
|
||||
error: local variable doesn't need to be boxed here
|
||||
--> $DIR/escape_analysis.rs:58:9
|
||||
|
|
||||
58 | let bz = box A; //~ ERROR local variable
|
||||
58 | let bz = box A;
|
||||
| ^^
|
||||
|
||||
error: local variable doesn't need to be boxed here
|
||||
--> $DIR/escape_analysis.rs:88:9
|
||||
|
|
||||
88 | let x = box A; //~ ERROR local variable
|
||||
88 | let x = box A;
|
||||
| ^
|
||||
|
||||
error: local variable doesn't need to be boxed here
|
||||
--> $DIR/escape_analysis.rs:101:9
|
||||
|
|
||||
101 | let x = box A; //~ ERROR local variable
|
||||
101 | let x = box A;
|
||||
| ^
|
||||
|
||||
error: local variable doesn't need to be boxed here
|
||||
--> $DIR/escape_analysis.rs:130:12
|
||||
|
|
||||
130 | pub fn new(_needs_name: Box<PeekableSeekable<&()>>) -> () { //~ ERROR local variable doesn't need
|
||||
130 | pub fn new(_needs_name: Box<PeekableSeekable<&()>>) -> () {
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 8 previous errors
|
||||
|
@ -5,20 +5,20 @@
|
||||
|
||||
fn main() {
|
||||
let a = Some(1u8).map(|a| foo(a));
|
||||
//~^ ERROR redundant closure found
|
||||
//~| HELP remove closure as shown
|
||||
//~| SUGGESTION let a = Some(1u8).map(foo);
|
||||
|
||||
|
||||
|
||||
meta(|a| foo(a));
|
||||
//~^ ERROR redundant closure found
|
||||
//~| HELP remove closure as shown
|
||||
//~| SUGGESTION meta(foo);
|
||||
|
||||
|
||||
|
||||
let c = Some(1u8).map(|a| {1+2; foo}(a));
|
||||
//~^ ERROR redundant closure found
|
||||
//~| HELP remove closure as shown
|
||||
//~| SUGGESTION let c = Some(1u8).map({1+2; foo});
|
||||
|
||||
|
||||
|
||||
let d = Some(1u8).map(|a| foo((|b| foo2(b))(a))); //is adjusted?
|
||||
all(&[1, 2, 3], &&2, |x, y| below(x, y)); //is adjusted
|
||||
//~^ WARN needless_borrow
|
||||
|
||||
unsafe {
|
||||
Some(1u8).map(|a| unsafe_fn(a)); // unsafe fn
|
||||
}
|
||||
@ -26,9 +26,9 @@ fn main() {
|
||||
// See #815
|
||||
let e = Some(1u8).map(|a| divergent(a));
|
||||
let e = Some(1u8).map(|a| generic(a));
|
||||
//~^ ERROR redundant closure found
|
||||
//~| HELP remove closure as shown
|
||||
//~| SUGGESTION map(generic);
|
||||
|
||||
|
||||
|
||||
let e = Some(1u8).map(generic);
|
||||
|
||||
// See #515
|
||||
|
@ -6,21 +6,21 @@
|
||||
fn main() {
|
||||
let mut x = 0;
|
||||
let a = { x = 1; 1 } + x;
|
||||
//~^ ERROR unsequenced read
|
||||
|
||||
|
||||
// Example from iss#277
|
||||
x += { x = 20; 2 }; //~ERROR unsequenced read
|
||||
x += { x = 20; 2 };
|
||||
|
||||
// Does it work in weird places?
|
||||
// ...in the base for a struct expression?
|
||||
struct Foo { a: i32, b: i32 };
|
||||
let base = Foo { a: 4, b: 5 };
|
||||
let foo = Foo { a: x, .. { x = 6; base } };
|
||||
//~^ ERROR unsequenced read
|
||||
|
||||
// ...inside a closure?
|
||||
let closure = || {
|
||||
let mut x = 0;
|
||||
x += { x = 20; 2 }; //~ERROR unsequenced read
|
||||
x += { x = 20; 2 };
|
||||
};
|
||||
// ...not across a closure?
|
||||
let mut y = 0;
|
||||
|
@ -18,13 +18,13 @@ note: whether read occurs before this write depends on evaluation order
|
||||
error: unsequenced read of a variable
|
||||
--> $DIR/eval_order_dependence.rs:12:5
|
||||
|
|
||||
12 | x += { x = 20; 2 }; //~ERROR unsequenced read
|
||||
12 | x += { x = 20; 2 };
|
||||
| ^
|
||||
|
|
||||
note: whether read occurs before this write depends on evaluation order
|
||||
--> $DIR/eval_order_dependence.rs:12:12
|
||||
|
|
||||
12 | x += { x = 20; 2 }; //~ERROR unsequenced read
|
||||
12 | x += { x = 20; 2 };
|
||||
| ^^^^^^
|
||||
|
||||
error: unsequenced read of a variable
|
||||
@ -42,13 +42,13 @@ note: whether read occurs before this write depends on evaluation order
|
||||
error: unsequenced read of a variable
|
||||
--> $DIR/eval_order_dependence.rs:23:9
|
||||
|
|
||||
23 | x += { x = 20; 2 }; //~ERROR unsequenced read
|
||||
23 | x += { x = 20; 2 };
|
||||
| ^
|
||||
|
|
||||
note: whether read occurs before this write depends on evaluation order
|
||||
--> $DIR/eval_order_dependence.rs:23:16
|
||||
|
|
||||
23 | x += { x = 20; 2 }; //~ERROR unsequenced read
|
||||
23 | x += { x = 20; 2 };
|
||||
| ^^^^^^
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
@ -5,22 +5,22 @@
|
||||
#![allow(missing_docs_in_private_items)]
|
||||
|
||||
fn main() {
|
||||
let _: Vec<_> = vec![5; 6].into_iter() //~ERROR called `filter(p).map(q)` on an `Iterator`
|
||||
let _: Vec<_> = vec![5; 6].into_iter()
|
||||
.filter(|&x| x == 0)
|
||||
.map(|x| x * 2)
|
||||
.collect();
|
||||
|
||||
let _: Vec<_> = vec![5_i8; 6].into_iter() //~ERROR called `filter(p).flat_map(q)` on an `Iterator`
|
||||
let _: Vec<_> = vec![5_i8; 6].into_iter()
|
||||
.filter(|&x| x == 0)
|
||||
.flat_map(|x| x.checked_mul(2))
|
||||
.collect();
|
||||
|
||||
let _: Vec<_> = vec![5_i8; 6].into_iter() //~ERROR called `filter_map(p).flat_map(q)` on an `Iterator`
|
||||
let _: Vec<_> = vec![5_i8; 6].into_iter()
|
||||
.filter_map(|x| x.checked_mul(2))
|
||||
.flat_map(|x| x.checked_mul(2))
|
||||
.collect();
|
||||
|
||||
let _: Vec<_> = vec![5_i8; 6].into_iter() //~ERROR called `filter_map(p).map(q)` on an `Iterator`
|
||||
let _: Vec<_> = vec![5_i8; 6].into_iter()
|
||||
.filter_map(|x| x.checked_mul(2))
|
||||
.map(|x| x.checked_mul(2))
|
||||
.collect();
|
||||
|
@ -1,7 +1,7 @@
|
||||
error: called `filter(p).map(q)` on an `Iterator`. This is more succinctly expressed by calling `.filter_map(..)` instead.
|
||||
--> $DIR/filter_methods.rs:8:21
|
||||
|
|
||||
8 | let _: Vec<_> = vec![5; 6].into_iter() //~ERROR called `filter(p).map(q)` on an `Iterator`
|
||||
8 | let _: Vec<_> = vec![5; 6].into_iter()
|
||||
| _____________________^ starting here...
|
||||
9 | | .filter(|&x| x == 0)
|
||||
10 | | .map(|x| x * 2)
|
||||
@ -17,7 +17,7 @@ note: lint level defined here
|
||||
error: called `filter(p).flat_map(q)` on an `Iterator`. This is more succinctly expressed by calling `.flat_map(..)` and filtering by returning an empty Iterator.
|
||||
--> $DIR/filter_methods.rs:13:21
|
||||
|
|
||||
13 | let _: Vec<_> = vec![5_i8; 6].into_iter() //~ERROR called `filter(p).flat_map(q)` on an `Iterator`
|
||||
13 | let _: Vec<_> = vec![5_i8; 6].into_iter()
|
||||
| _____________________^ starting here...
|
||||
14 | | .filter(|&x| x == 0)
|
||||
15 | | .flat_map(|x| x.checked_mul(2))
|
||||
@ -28,7 +28,7 @@ error: called `filter(p).flat_map(q)` on an `Iterator`. This is more succinctly
|
||||
error: called `filter_map(p).flat_map(q)` on an `Iterator`. This is more succinctly expressed by calling `.flat_map(..)` and filtering by returning an empty Iterator.
|
||||
--> $DIR/filter_methods.rs:18:21
|
||||
|
|
||||
18 | let _: Vec<_> = vec![5_i8; 6].into_iter() //~ERROR called `filter_map(p).flat_map(q)` on an `Iterator`
|
||||
18 | let _: Vec<_> = vec![5_i8; 6].into_iter()
|
||||
| _____________________^ starting here...
|
||||
19 | | .filter_map(|x| x.checked_mul(2))
|
||||
20 | | .flat_map(|x| x.checked_mul(2))
|
||||
@ -39,7 +39,7 @@ error: called `filter_map(p).flat_map(q)` on an `Iterator`. This is more succinc
|
||||
error: called `filter_map(p).map(q)` on an `Iterator`. This is more succinctly expressed by only calling `.filter_map(..)` instead.
|
||||
--> $DIR/filter_methods.rs:23:21
|
||||
|
|
||||
23 | let _: Vec<_> = vec![5_i8; 6].into_iter() //~ERROR called `filter_map(p).map(q)` on an `Iterator`
|
||||
23 | let _: Vec<_> = vec![5_i8; 6].into_iter()
|
||||
| _____________________^ starting here...
|
||||
24 | | .filter_map(|x| x.checked_mul(2))
|
||||
25 | | .map(|x| x.checked_mul(2))
|
||||
|
@ -41,46 +41,46 @@ fn main() {
|
||||
ZERO + ZERO != 1.0; //no error, comparison with zero is ok
|
||||
|
||||
ONE == 1f32;
|
||||
//~^ ERROR strict comparison of f32 or f64
|
||||
//~| HELP within some error
|
||||
//~| SUGGESTION (ONE - 1f32).abs() < error
|
||||
|
||||
|
||||
|
||||
ONE == 1.0 + 0.0;
|
||||
//~^ ERROR strict comparison of f32 or f64
|
||||
//~| HELP within some error
|
||||
//~| SUGGESTION (ONE - (1.0 + 0.0)).abs() < error
|
||||
|
||||
|
||||
|
||||
|
||||
ONE + ONE == ZERO + ONE + ONE;
|
||||
//~^ ERROR strict comparison of f32 or f64
|
||||
//~| HELP within some error
|
||||
//~| SUGGESTION (ONE + ONE - (ZERO + ONE + ONE)).abs() < error
|
||||
|
||||
|
||||
|
||||
|
||||
ONE != 2.0;
|
||||
//~^ ERROR strict comparison of f32 or f64
|
||||
//~| HELP within some error
|
||||
//~| SUGGESTION (ONE - 2.0).abs() < error
|
||||
|
||||
|
||||
|
||||
ONE != 0.0; // no error, comparison with zero is ok
|
||||
twice(ONE) != ONE;
|
||||
//~^ ERROR strict comparison of f32 or f64
|
||||
//~| HELP within some error
|
||||
//~| SUGGESTION (twice(ONE) - ONE).abs() < error
|
||||
|
||||
|
||||
|
||||
ONE as f64 != 2.0;
|
||||
//~^ ERROR strict comparison of f32 or f64
|
||||
//~| HELP within some error
|
||||
//~| SUGGESTION (ONE as f64 - 2.0).abs() < error
|
||||
|
||||
|
||||
|
||||
ONE as f64 != 0.0; // no error, comparison with zero is ok
|
||||
|
||||
let x : f64 = 1.0;
|
||||
|
||||
x == 1.0;
|
||||
//~^ ERROR strict comparison of f32 or f64
|
||||
//~| HELP within some error
|
||||
//~| SUGGESTION (x - 1.0).abs() < error
|
||||
|
||||
|
||||
|
||||
x != 0f64; // no error, comparison with zero is ok
|
||||
|
||||
twice(x) != twice(ONE as f64);
|
||||
//~^ ERROR strict comparison of f32 or f64
|
||||
//~| HELP within some error
|
||||
//~| SUGGESTION (twice(x) - twice(ONE as f64)).abs() < error
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
x < 0.0; // no errors, lower or greater comparisons need no fuzzyness
|
||||
|
@ -16,43 +16,43 @@ fn for_loop_over_option_and_result() {
|
||||
// check FOR_LOOP_OVER_OPTION lint
|
||||
|
||||
for x in option {
|
||||
//~^ ERROR for loop over `option`, which is an `Option`.
|
||||
//~| HELP consider replacing `for x in option` with `if let Some(x) = option`
|
||||
|
||||
|
||||
println!("{}", x);
|
||||
}
|
||||
|
||||
// check FOR_LOOP_OVER_RESULT lint
|
||||
|
||||
for x in result {
|
||||
//~^ ERROR for loop over `result`, which is a `Result`.
|
||||
//~| HELP consider replacing `for x in result` with `if let Ok(x) = result`
|
||||
|
||||
|
||||
println!("{}", x);
|
||||
}
|
||||
|
||||
for x in option.ok_or("x not found") {
|
||||
//~^ ERROR for loop over `option.ok_or("x not found")`, which is a `Result`.
|
||||
//~| HELP consider replacing `for x in option.ok_or("x not found")` with `if let Ok(x) = option.ok_or("x not found")`
|
||||
|
||||
|
||||
println!("{}", x);
|
||||
}
|
||||
|
||||
// make sure LOOP_OVER_NEXT lint takes precedence when next() is the last call in the chain
|
||||
|
||||
for x in v.iter().next() {
|
||||
//~^ ERROR you are iterating over `Iterator::next()` which is an Option
|
||||
|
||||
println!("{}", x);
|
||||
}
|
||||
|
||||
// make sure we lint when next() is not the last call in the chain
|
||||
|
||||
for x in v.iter().next().and(Some(0)) {
|
||||
//~^ ERROR for loop over `v.iter().next().and(Some(0))`, which is an `Option`
|
||||
//~| HELP consider replacing `for x in v.iter().next().and(Some(0))` with `if let Some(x) = v.iter().next().and(Some(0))`
|
||||
|
||||
|
||||
println!("{}", x);
|
||||
}
|
||||
|
||||
for x in v.iter().next().ok_or("x not found") {
|
||||
//~^ ERROR for loop over `v.iter().next().ok_or("x not found")`, which is a `Result`
|
||||
//~| HELP consider replacing `for x in v.iter().next().ok_or("x not found")` with `if let Ok(x) = v.iter().next().ok_or("x not found")`
|
||||
|
||||
|
||||
println!("{}", x);
|
||||
}
|
||||
|
||||
@ -97,47 +97,47 @@ fn main() {
|
||||
let mut vec = vec![1, 2, 3, 4];
|
||||
let vec2 = vec![1, 2, 3, 4];
|
||||
for i in 0..vec.len() {
|
||||
//~^ ERROR `i` is only used to index `vec`
|
||||
//~| HELP consider
|
||||
//~| HELP consider
|
||||
//~| SUGGESTION for <item> in &vec {
|
||||
|
||||
|
||||
|
||||
|
||||
println!("{}", vec[i]);
|
||||
}
|
||||
|
||||
for i in 0..vec.len() {
|
||||
//~^ WARNING unused variable
|
||||
|
||||
let i = 42; // make a different `i`
|
||||
println!("{}", vec[i]); // ok, not the `i` of the for-loop
|
||||
}
|
||||
|
||||
for i in 0..vec.len() { let _ = vec[i]; }
|
||||
//~^ ERROR `i` is only used to index `vec`
|
||||
//~| HELP consider
|
||||
//~| HELP consider
|
||||
//~| SUGGESTION for <item> in &vec { let _ = vec[i]; }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// ICE #746
|
||||
for j in 0..4 {
|
||||
//~^ ERROR `j` is only used to index `STATIC`
|
||||
//~| HELP consider
|
||||
//~| HELP consider
|
||||
//~| SUGGESTION for <item> in STATIC.iter().take(4) {
|
||||
|
||||
|
||||
|
||||
|
||||
println!("{:?}", STATIC[j]);
|
||||
}
|
||||
|
||||
for j in 0..4 {
|
||||
//~^ ERROR `j` is only used to index `CONST`
|
||||
//~| HELP consider
|
||||
//~| HELP consider
|
||||
//~| SUGGESTION for <item> in CONST.iter().take(4) {
|
||||
|
||||
|
||||
|
||||
|
||||
println!("{:?}", CONST[j]);
|
||||
}
|
||||
|
||||
for i in 0..vec.len() {
|
||||
//~^ ERROR `i` is used to index `vec`
|
||||
//~| HELP consider
|
||||
//~| HELP consider
|
||||
//~| SUGGESTION for (i, <item>) in vec.iter().enumerate() {
|
||||
|
||||
|
||||
|
||||
|
||||
println!("{} {}", vec[i], i);
|
||||
}
|
||||
for i in 0..vec.len() { // not an error, indexing more than one variable
|
||||
@ -145,90 +145,90 @@ fn main() {
|
||||
}
|
||||
|
||||
for i in 0..vec.len() {
|
||||
//~^ ERROR `i` is only used to index `vec2`
|
||||
//~| HELP consider
|
||||
//~| HELP consider
|
||||
//~| SUGGESTION for <item> in vec2.iter().take(vec.len()) {
|
||||
|
||||
|
||||
|
||||
|
||||
println!("{}", vec2[i]);
|
||||
}
|
||||
|
||||
for i in 5..vec.len() {
|
||||
//~^ ERROR `i` is only used to index `vec`
|
||||
//~| HELP consider
|
||||
//~| HELP consider
|
||||
//~| SUGGESTION for <item> in vec.iter().skip(5) {
|
||||
|
||||
|
||||
|
||||
|
||||
println!("{}", vec[i]);
|
||||
}
|
||||
|
||||
for i in 0..MAX_LEN {
|
||||
//~^ ERROR `i` is only used to index `vec`
|
||||
//~| HELP consider
|
||||
//~| HELP consider
|
||||
//~| SUGGESTION for <item> in vec.iter().take(MAX_LEN) {
|
||||
|
||||
|
||||
|
||||
|
||||
println!("{}", vec[i]);
|
||||
}
|
||||
|
||||
for i in 0...MAX_LEN {
|
||||
//~^ ERROR `i` is only used to index `vec`
|
||||
//~| HELP consider
|
||||
//~| HELP consider
|
||||
//~| SUGGESTION for <item> in vec.iter().take(MAX_LEN + 1) {
|
||||
|
||||
|
||||
|
||||
|
||||
println!("{}", vec[i]);
|
||||
}
|
||||
|
||||
for i in 5..10 {
|
||||
//~^ ERROR `i` is only used to index `vec`
|
||||
//~| HELP consider
|
||||
//~| HELP consider
|
||||
//~| SUGGESTION for <item> in vec.iter().take(10).skip(5) {
|
||||
|
||||
|
||||
|
||||
|
||||
println!("{}", vec[i]);
|
||||
}
|
||||
|
||||
for i in 5...10 {
|
||||
//~^ ERROR `i` is only used to index `vec`
|
||||
//~| HELP consider
|
||||
//~| HELP consider
|
||||
//~| SUGGESTION for <item> in vec.iter().take(10 + 1).skip(5) {
|
||||
|
||||
|
||||
|
||||
|
||||
println!("{}", vec[i]);
|
||||
}
|
||||
|
||||
for i in 5..vec.len() {
|
||||
//~^ ERROR `i` is used to index `vec`
|
||||
//~| HELP consider
|
||||
//~| HELP consider
|
||||
//~| SUGGESTION for (i, <item>) in vec.iter().enumerate().skip(5) {
|
||||
|
||||
|
||||
|
||||
|
||||
println!("{} {}", vec[i], i);
|
||||
}
|
||||
|
||||
for i in 5..10 {
|
||||
//~^ ERROR `i` is used to index `vec`
|
||||
//~| HELP consider
|
||||
//~| HELP consider
|
||||
//~| SUGGESTION for (i, <item>) in vec.iter().enumerate().take(10).skip(5) {
|
||||
|
||||
|
||||
|
||||
|
||||
println!("{} {}", vec[i], i);
|
||||
}
|
||||
|
||||
for i in 10..0 {
|
||||
//~^ERROR this range is empty so this for loop will never run
|
||||
//~|HELP consider
|
||||
//~|SUGGESTION (0..10).rev()
|
||||
|
||||
|
||||
|
||||
println!("{}", i);
|
||||
}
|
||||
|
||||
for i in 10...0 {
|
||||
//~^ERROR this range is empty so this for loop will never run
|
||||
//~|HELP consider
|
||||
//~|SUGGESTION (0...10).rev()
|
||||
|
||||
|
||||
|
||||
println!("{}", i);
|
||||
}
|
||||
|
||||
for i in MAX_LEN..0 { //~ERROR this range is empty so this for loop will never run
|
||||
//~|HELP consider
|
||||
//~|SUGGESTION (0..MAX_LEN).rev()
|
||||
for i in MAX_LEN..0 {
|
||||
|
||||
|
||||
println!("{}", i);
|
||||
}
|
||||
|
||||
for i in 5..5 { //~ERROR this range is empty so this for loop will never run
|
||||
for i in 5..5 {
|
||||
println!("{}", i);
|
||||
}
|
||||
|
||||
@ -250,20 +250,20 @@ fn main() {
|
||||
|
||||
// testing that the empty range lint folds constants
|
||||
for i in 10..5+4 {
|
||||
//~^ ERROR this range is empty so this for loop will never run
|
||||
//~| HELP if you are attempting to iterate over this range in reverse
|
||||
//~| SUGGESTION for i in (5+4..10).rev() {
|
||||
|
||||
|
||||
|
||||
println!("{}", i);
|
||||
}
|
||||
|
||||
for i in (5+2)..(3-1) {
|
||||
//~^ ERROR this range is empty so this for loop will never run
|
||||
//~| HELP if you are attempting to iterate over this range in reverse
|
||||
//~| SUGGESTION for i in ((3-1)..(5+2)).rev() {
|
||||
|
||||
|
||||
|
||||
println!("{}", i);
|
||||
}
|
||||
|
||||
for i in (5+2)..(8-1) { //~ERROR this range is empty so this for loop will never run
|
||||
for i in (5+2)..(8-1) {
|
||||
println!("{}", i);
|
||||
}
|
||||
|
||||
@ -287,98 +287,98 @@ fn main() {
|
||||
}
|
||||
|
||||
for _v in vec.iter() { }
|
||||
//~^ ERROR it is more idiomatic to loop over `&vec`
|
||||
//~| HELP to write this more concisely, try looping over
|
||||
//~| SUGGESTION for _v in &vec {
|
||||
|
||||
|
||||
|
||||
|
||||
for _v in vec.iter_mut() { }
|
||||
//~^ ERROR it is more idiomatic to loop over `&mut vec`
|
||||
//~| HELP to write this more concisely, try looping over
|
||||
//~| SUGGESTION for _v in &mut vec {
|
||||
|
||||
|
||||
|
||||
|
||||
let out_vec = vec![1,2,3];
|
||||
for _v in out_vec.into_iter() { }
|
||||
//~^ ERROR it is more idiomatic to loop over `out_vec` instead of `out_vec.into_iter()`
|
||||
//~| HELP to write this more concisely, try looping over
|
||||
//~| SUGGESTION for _v in out_vec {
|
||||
|
||||
|
||||
|
||||
|
||||
for _v in &vec { } // these are fine
|
||||
for _v in &mut vec { } // these are fine
|
||||
|
||||
for _v in [1, 2, 3].iter() { }
|
||||
//~^ ERROR it is more idiomatic to loop over `&[
|
||||
//~| HELP to write this more concisely, try looping over
|
||||
//~| SUGGESTION for _v in &[1, 2, 3] {
|
||||
|
||||
|
||||
|
||||
|
||||
for _v in (&mut [1, 2, 3]).iter() { } // no error
|
||||
|
||||
for _v in [0; 32].iter() {}
|
||||
//~^ ERROR it is more idiomatic to loop over `&[
|
||||
//~| HELP to write this more concisely, try looping over
|
||||
//~| SUGGESTION for _v in &[0; 32] {
|
||||
|
||||
|
||||
|
||||
|
||||
for _v in [0; 33].iter() {} // no error
|
||||
|
||||
let ll: LinkedList<()> = LinkedList::new();
|
||||
for _v in ll.iter() { }
|
||||
//~^ ERROR it is more idiomatic to loop over `&ll`
|
||||
//~| HELP to write this more concisely, try looping over
|
||||
//~| SUGGESTION for _v in &ll {
|
||||
|
||||
|
||||
|
||||
|
||||
let vd: VecDeque<()> = VecDeque::new();
|
||||
for _v in vd.iter() { }
|
||||
//~^ ERROR it is more idiomatic to loop over `&vd`
|
||||
//~| HELP to write this more concisely, try looping over
|
||||
//~| SUGGESTION for _v in &vd {
|
||||
|
||||
|
||||
|
||||
|
||||
let bh: BinaryHeap<()> = BinaryHeap::new();
|
||||
for _v in bh.iter() { }
|
||||
//~^ ERROR it is more idiomatic to loop over `&bh`
|
||||
//~| HELP to write this more concisely, try looping over
|
||||
//~| SUGGESTION for _v in &bh {
|
||||
|
||||
|
||||
|
||||
|
||||
let hm: HashMap<(), ()> = HashMap::new();
|
||||
for _v in hm.iter() { }
|
||||
//~^ ERROR it is more idiomatic to loop over `&hm`
|
||||
//~| HELP to write this more concisely, try looping over
|
||||
//~| SUGGESTION for _v in &hm {
|
||||
|
||||
|
||||
|
||||
|
||||
let bt: BTreeMap<(), ()> = BTreeMap::new();
|
||||
for _v in bt.iter() { }
|
||||
//~^ ERROR it is more idiomatic to loop over `&bt`
|
||||
//~| HELP to write this more concisely, try looping over
|
||||
//~| SUGGESTION for _v in &bt {
|
||||
|
||||
|
||||
|
||||
|
||||
let hs: HashSet<()> = HashSet::new();
|
||||
for _v in hs.iter() { }
|
||||
//~^ ERROR it is more idiomatic to loop over `&hs`
|
||||
//~| HELP to write this more concisely, try looping over
|
||||
//~| SUGGESTION for _v in &hs {
|
||||
|
||||
|
||||
|
||||
|
||||
let bs: BTreeSet<()> = BTreeSet::new();
|
||||
for _v in bs.iter() { }
|
||||
//~^ ERROR it is more idiomatic to loop over `&bs`
|
||||
//~| HELP to write this more concisely, try looping over
|
||||
//~| SUGGESTION for _v in &bs {
|
||||
|
||||
|
||||
for _v in vec.iter().next() { } //~ERROR you are iterating over `Iterator::next()`
|
||||
|
||||
|
||||
|
||||
for _v in vec.iter().next() { }
|
||||
|
||||
let u = Unrelated(vec![]);
|
||||
for _v in u.next() { } // no error
|
||||
for _v in u.iter() { } // no error
|
||||
|
||||
let mut out = vec![];
|
||||
vec.iter().map(|x| out.push(x)).collect::<Vec<_>>(); //~ERROR you are collect()ing an iterator
|
||||
vec.iter().map(|x| out.push(x)).collect::<Vec<_>>();
|
||||
let _y = vec.iter().map(|x| out.push(x)).collect::<Vec<_>>(); // this is fine
|
||||
|
||||
// Loop with explicit counter variable
|
||||
let mut _index = 0;
|
||||
for _v in &vec { _index += 1 } //~ERROR the variable `_index` is used as a loop counter
|
||||
for _v in &vec { _index += 1 }
|
||||
|
||||
let mut _index = 1;
|
||||
_index = 0;
|
||||
for _v in &vec { _index += 1 } //~ERROR the variable `_index` is used as a loop counter
|
||||
for _v in &vec { _index += 1 }
|
||||
|
||||
// Potential false positives
|
||||
let mut _index = 0;
|
||||
@ -439,19 +439,19 @@ fn main() {
|
||||
|
||||
let m : HashMap<u64, u64> = HashMap::new();
|
||||
for (_, v) in &m {
|
||||
//~^ you seem to want to iterate on a map's values
|
||||
//~| HELP use the corresponding method
|
||||
//~| HELP use the corresponding method
|
||||
//~| SUGGESTION for v in m.values() {
|
||||
|
||||
|
||||
|
||||
|
||||
let _v = v;
|
||||
}
|
||||
|
||||
let m : Rc<HashMap<u64, u64>> = Rc::new(HashMap::new());
|
||||
for (_, v) in &*m {
|
||||
//~^ you seem to want to iterate on a map's values
|
||||
//~| HELP use the corresponding method
|
||||
//~| HELP use the corresponding method
|
||||
//~| SUGGESTION for v in (*m).values() {
|
||||
|
||||
|
||||
|
||||
|
||||
let _v = v;
|
||||
// Here the `*` is not actually necesarry, but the test tests that we don't suggest
|
||||
// `in *m.values()` as we used to
|
||||
@ -459,29 +459,29 @@ fn main() {
|
||||
|
||||
let mut m : HashMap<u64, u64> = HashMap::new();
|
||||
for (_, v) in &mut m {
|
||||
//~^ you seem to want to iterate on a map's values
|
||||
//~| HELP use the corresponding method
|
||||
//~| HELP use the corresponding method
|
||||
//~| SUGGESTION for v in m.values_mut()
|
||||
|
||||
|
||||
|
||||
|
||||
let _v = v;
|
||||
}
|
||||
|
||||
let m: &mut HashMap<u64, u64> = &mut HashMap::new();
|
||||
for (_, v) in &mut *m {
|
||||
//~^ you seem to want to iterate on a map's values
|
||||
//~| HELP use the corresponding method
|
||||
//~| HELP use the corresponding method
|
||||
//~| SUGGESTION for v in (*m).values_mut()
|
||||
|
||||
|
||||
|
||||
|
||||
let _v = v;
|
||||
}
|
||||
|
||||
let m : HashMap<u64, u64> = HashMap::new();
|
||||
let rm = &m;
|
||||
for (k, _value) in rm {
|
||||
//~^ you seem to want to iterate on a map's keys
|
||||
//~| HELP use the corresponding method
|
||||
//~| HELP use the corresponding method
|
||||
//~| SUGGESTION for k in rm.keys() {
|
||||
|
||||
|
||||
|
||||
|
||||
let _k = k;
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ error: you are iterating over `Iterator::next()` which is an Option; this will c
|
||||
|
|
||||
40 | for x in v.iter().next() {
|
||||
| _____^ starting here...
|
||||
41 | | //~^ ERROR you are iterating over `Iterator::next()` which is an Option
|
||||
41 | |
|
||||
42 | | println!("{}", x);
|
||||
43 | | }
|
||||
| |_____^ ...ending here
|
||||
@ -75,10 +75,10 @@ error: the loop variable `i` is only used to index `vec`.
|
||||
|
|
||||
99 | for i in 0..vec.len() {
|
||||
| _____^ starting here...
|
||||
100 | | //~^ ERROR `i` is only used to index `vec`
|
||||
101 | | //~| HELP consider
|
||||
102 | | //~| HELP consider
|
||||
103 | | //~| SUGGESTION for <item> in &vec {
|
||||
100 | |
|
||||
101 | |
|
||||
102 | |
|
||||
103 | |
|
||||
104 | | println!("{}", vec[i]);
|
||||
105 | | }
|
||||
| |_____^ ...ending here
|
||||
@ -113,10 +113,10 @@ error: the loop variable `j` is only used to index `STATIC`.
|
||||
|
|
||||
120 | for j in 0..4 {
|
||||
| _____^ starting here...
|
||||
121 | | //~^ ERROR `j` is only used to index `STATIC`
|
||||
122 | | //~| HELP consider
|
||||
123 | | //~| HELP consider
|
||||
124 | | //~| SUGGESTION for <item> in STATIC.iter().take(4) {
|
||||
121 | |
|
||||
122 | |
|
||||
123 | |
|
||||
124 | |
|
||||
125 | | println!("{:?}", STATIC[j]);
|
||||
126 | | }
|
||||
| |_____^ ...ending here
|
||||
@ -129,10 +129,10 @@ error: the loop variable `j` is only used to index `CONST`.
|
||||
|
|
||||
128 | for j in 0..4 {
|
||||
| _____^ starting here...
|
||||
129 | | //~^ ERROR `j` is only used to index `CONST`
|
||||
130 | | //~| HELP consider
|
||||
131 | | //~| HELP consider
|
||||
132 | | //~| SUGGESTION for <item> in CONST.iter().take(4) {
|
||||
129 | |
|
||||
130 | |
|
||||
131 | |
|
||||
132 | |
|
||||
133 | | println!("{:?}", CONST[j]);
|
||||
134 | | }
|
||||
| |_____^ ...ending here
|
||||
@ -145,10 +145,10 @@ error: the loop variable `i` is used to index `vec`
|
||||
|
|
||||
136 | for i in 0..vec.len() {
|
||||
| _____^ starting here...
|
||||
137 | | //~^ ERROR `i` is used to index `vec`
|
||||
138 | | //~| HELP consider
|
||||
139 | | //~| HELP consider
|
||||
140 | | //~| SUGGESTION for (i, <item>) in vec.iter().enumerate() {
|
||||
137 | |
|
||||
138 | |
|
||||
139 | |
|
||||
140 | |
|
||||
141 | | println!("{} {}", vec[i], i);
|
||||
142 | | }
|
||||
| |_____^ ...ending here
|
||||
@ -161,10 +161,10 @@ error: the loop variable `i` is only used to index `vec2`.
|
||||
|
|
||||
147 | for i in 0..vec.len() {
|
||||
| _____^ starting here...
|
||||
148 | | //~^ ERROR `i` is only used to index `vec2`
|
||||
149 | | //~| HELP consider
|
||||
150 | | //~| HELP consider
|
||||
151 | | //~| SUGGESTION for <item> in vec2.iter().take(vec.len()) {
|
||||
148 | |
|
||||
149 | |
|
||||
150 | |
|
||||
151 | |
|
||||
152 | | println!("{}", vec2[i]);
|
||||
153 | | }
|
||||
| |_____^ ...ending here
|
||||
@ -177,10 +177,10 @@ error: the loop variable `i` is only used to index `vec`.
|
||||
|
|
||||
155 | for i in 5..vec.len() {
|
||||
| _____^ starting here...
|
||||
156 | | //~^ ERROR `i` is only used to index `vec`
|
||||
157 | | //~| HELP consider
|
||||
158 | | //~| HELP consider
|
||||
159 | | //~| SUGGESTION for <item> in vec.iter().skip(5) {
|
||||
156 | |
|
||||
157 | |
|
||||
158 | |
|
||||
159 | |
|
||||
160 | | println!("{}", vec[i]);
|
||||
161 | | }
|
||||
| |_____^ ...ending here
|
||||
@ -193,10 +193,10 @@ error: the loop variable `i` is only used to index `vec`.
|
||||
|
|
||||
163 | for i in 0..MAX_LEN {
|
||||
| _____^ starting here...
|
||||
164 | | //~^ ERROR `i` is only used to index `vec`
|
||||
165 | | //~| HELP consider
|
||||
166 | | //~| HELP consider
|
||||
167 | | //~| SUGGESTION for <item> in vec.iter().take(MAX_LEN) {
|
||||
164 | |
|
||||
165 | |
|
||||
166 | |
|
||||
167 | |
|
||||
168 | | println!("{}", vec[i]);
|
||||
169 | | }
|
||||
| |_____^ ...ending here
|
||||
@ -209,10 +209,10 @@ error: the loop variable `i` is only used to index `vec`.
|
||||
|
|
||||
171 | for i in 0...MAX_LEN {
|
||||
| _____^ starting here...
|
||||
172 | | //~^ ERROR `i` is only used to index `vec`
|
||||
173 | | //~| HELP consider
|
||||
174 | | //~| HELP consider
|
||||
175 | | //~| SUGGESTION for <item> in vec.iter().take(MAX_LEN + 1) {
|
||||
172 | |
|
||||
173 | |
|
||||
174 | |
|
||||
175 | |
|
||||
176 | | println!("{}", vec[i]);
|
||||
177 | | }
|
||||
| |_____^ ...ending here
|
||||
@ -225,10 +225,10 @@ error: the loop variable `i` is only used to index `vec`.
|
||||
|
|
||||
179 | for i in 5..10 {
|
||||
| _____^ starting here...
|
||||
180 | | //~^ ERROR `i` is only used to index `vec`
|
||||
181 | | //~| HELP consider
|
||||
182 | | //~| HELP consider
|
||||
183 | | //~| SUGGESTION for <item> in vec.iter().take(10).skip(5) {
|
||||
180 | |
|
||||
181 | |
|
||||
182 | |
|
||||
183 | |
|
||||
184 | | println!("{}", vec[i]);
|
||||
185 | | }
|
||||
| |_____^ ...ending here
|
||||
@ -241,10 +241,10 @@ error: the loop variable `i` is only used to index `vec`.
|
||||
|
|
||||
187 | for i in 5...10 {
|
||||
| _____^ starting here...
|
||||
188 | | //~^ ERROR `i` is only used to index `vec`
|
||||
189 | | //~| HELP consider
|
||||
190 | | //~| HELP consider
|
||||
191 | | //~| SUGGESTION for <item> in vec.iter().take(10 + 1).skip(5) {
|
||||
188 | |
|
||||
189 | |
|
||||
190 | |
|
||||
191 | |
|
||||
192 | | println!("{}", vec[i]);
|
||||
193 | | }
|
||||
| |_____^ ...ending here
|
||||
@ -257,10 +257,10 @@ error: the loop variable `i` is used to index `vec`
|
||||
|
|
||||
195 | for i in 5..vec.len() {
|
||||
| _____^ starting here...
|
||||
196 | | //~^ ERROR `i` is used to index `vec`
|
||||
197 | | //~| HELP consider
|
||||
198 | | //~| HELP consider
|
||||
199 | | //~| SUGGESTION for (i, <item>) in vec.iter().enumerate().skip(5) {
|
||||
196 | |
|
||||
197 | |
|
||||
198 | |
|
||||
199 | |
|
||||
200 | | println!("{} {}", vec[i], i);
|
||||
201 | | }
|
||||
| |_____^ ...ending here
|
||||
@ -273,10 +273,10 @@ error: the loop variable `i` is used to index `vec`
|
||||
|
|
||||
203 | for i in 5..10 {
|
||||
| _____^ starting here...
|
||||
204 | | //~^ ERROR `i` is used to index `vec`
|
||||
205 | | //~| HELP consider
|
||||
206 | | //~| HELP consider
|
||||
207 | | //~| SUGGESTION for (i, <item>) in vec.iter().enumerate().take(10).skip(5) {
|
||||
204 | |
|
||||
205 | |
|
||||
206 | |
|
||||
207 | |
|
||||
208 | | println!("{} {}", vec[i], i);
|
||||
209 | | }
|
||||
| |_____^ ...ending here
|
||||
@ -289,9 +289,9 @@ error: this range is empty so this for loop will never run
|
||||
|
|
||||
211 | for i in 10..0 {
|
||||
| _____^ starting here...
|
||||
212 | | //~^ERROR this range is empty so this for loop will never run
|
||||
213 | | //~|HELP consider
|
||||
214 | | //~|SUGGESTION (0..10).rev()
|
||||
212 | |
|
||||
213 | |
|
||||
214 | |
|
||||
215 | | println!("{}", i);
|
||||
216 | | }
|
||||
| |_____^ ...ending here
|
||||
@ -309,9 +309,9 @@ error: this range is empty so this for loop will never run
|
||||
|
|
||||
218 | for i in 10...0 {
|
||||
| _____^ starting here...
|
||||
219 | | //~^ERROR this range is empty so this for loop will never run
|
||||
220 | | //~|HELP consider
|
||||
221 | | //~|SUGGESTION (0...10).rev()
|
||||
219 | |
|
||||
220 | |
|
||||
221 | |
|
||||
222 | | println!("{}", i);
|
||||
223 | | }
|
||||
| |_____^ ...ending here
|
||||
@ -322,21 +322,21 @@ help: consider using the following if you are attempting to iterate over this ra
|
||||
error: this range is empty so this for loop will never run
|
||||
--> $DIR/for_loop.rs:225:5
|
||||
|
|
||||
225 | for i in MAX_LEN..0 { //~ERROR this range is empty so this for loop will never run
|
||||
225 | for i in MAX_LEN..0 {
|
||||
| _____^ starting here...
|
||||
226 | | //~|HELP consider
|
||||
227 | | //~|SUGGESTION (0..MAX_LEN).rev()
|
||||
226 | |
|
||||
227 | |
|
||||
228 | | println!("{}", i);
|
||||
229 | | }
|
||||
| |_____^ ...ending here
|
||||
|
|
||||
help: consider using the following if you are attempting to iterate over this range in reverse
|
||||
| for i in (0..MAX_LEN).rev() { //~ERROR this range is empty so this for loop will never run
|
||||
| for i in (0..MAX_LEN).rev() {
|
||||
|
||||
error: this range is empty so this for loop will never run
|
||||
--> $DIR/for_loop.rs:231:5
|
||||
|
|
||||
231 | for i in 5..5 { //~ERROR this range is empty so this for loop will never run
|
||||
231 | for i in 5..5 {
|
||||
| _____^ starting here...
|
||||
232 | | println!("{}", i);
|
||||
233 | | }
|
||||
@ -347,9 +347,9 @@ error: this range is empty so this for loop will never run
|
||||
|
|
||||
252 | for i in 10..5+4 {
|
||||
| _____^ starting here...
|
||||
253 | | //~^ ERROR this range is empty so this for loop will never run
|
||||
254 | | //~| HELP if you are attempting to iterate over this range in reverse
|
||||
255 | | //~| SUGGESTION for i in (5+4..10).rev() {
|
||||
253 | |
|
||||
254 | |
|
||||
255 | |
|
||||
256 | | println!("{}", i);
|
||||
257 | | }
|
||||
| |_____^ ...ending here
|
||||
@ -362,9 +362,9 @@ error: this range is empty so this for loop will never run
|
||||
|
|
||||
259 | for i in (5+2)..(3-1) {
|
||||
| _____^ starting here...
|
||||
260 | | //~^ ERROR this range is empty so this for loop will never run
|
||||
261 | | //~| HELP if you are attempting to iterate over this range in reverse
|
||||
262 | | //~| SUGGESTION for i in ((3-1)..(5+2)).rev() {
|
||||
260 | |
|
||||
261 | |
|
||||
262 | |
|
||||
263 | | println!("{}", i);
|
||||
264 | | }
|
||||
| |_____^ ...ending here
|
||||
@ -375,7 +375,7 @@ help: consider using the following if you are attempting to iterate over this ra
|
||||
error: this range is empty so this for loop will never run
|
||||
--> $DIR/for_loop.rs:266:5
|
||||
|
|
||||
266 | for i in (5+2)..(8-1) { //~ERROR this range is empty so this for loop will never run
|
||||
266 | for i in (5+2)..(8-1) {
|
||||
| _____^ starting here...
|
||||
267 | | println!("{}", i);
|
||||
268 | | }
|
||||
@ -502,7 +502,7 @@ help: to write this more concisely, try looping over
|
||||
error: you are iterating over `Iterator::next()` which is an Option; this will compile but is probably not what you want
|
||||
--> $DIR/for_loop.rs:365:5
|
||||
|
|
||||
365 | for _v in vec.iter().next() { } //~ERROR you are iterating over `Iterator::next()`
|
||||
365 | for _v in vec.iter().next() { }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: lint level defined here
|
||||
@ -514,7 +514,7 @@ note: lint level defined here
|
||||
error: you are collect()ing an iterator and throwing away the result. Consider using an explicit for loop to exhaust the iterator
|
||||
--> $DIR/for_loop.rs:372:5
|
||||
|
|
||||
372 | vec.iter().map(|x| out.push(x)).collect::<Vec<_>>(); //~ERROR you are collect()ing an iterator
|
||||
372 | vec.iter().map(|x| out.push(x)).collect::<Vec<_>>();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: lint level defined here
|
||||
@ -526,7 +526,7 @@ note: lint level defined here
|
||||
error: the variable `_index` is used as a loop counter. Consider using `for (_index, item) in &vec.enumerate()` or similar iterators
|
||||
--> $DIR/for_loop.rs:377:5
|
||||
|
|
||||
377 | for _v in &vec { _index += 1 } //~ERROR the variable `_index` is used as a loop counter
|
||||
377 | for _v in &vec { _index += 1 }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: lint level defined here
|
||||
@ -538,7 +538,7 @@ note: lint level defined here
|
||||
error: the variable `_index` is used as a loop counter. Consider using `for (_index, item) in &vec.enumerate()` or similar iterators
|
||||
--> $DIR/for_loop.rs:381:5
|
||||
|
|
||||
381 | for _v in &vec { _index += 1 } //~ERROR the variable `_index` is used as a loop counter
|
||||
381 | for _v in &vec { _index += 1 }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: you seem to want to iterate on a map's values
|
||||
@ -546,10 +546,10 @@ error: you seem to want to iterate on a map's values
|
||||
|
|
||||
441 | for (_, v) in &m {
|
||||
| _____^ starting here...
|
||||
442 | | //~^ you seem to want to iterate on a map's values
|
||||
443 | | //~| HELP use the corresponding method
|
||||
444 | | //~| HELP use the corresponding method
|
||||
445 | | //~| SUGGESTION for v in m.values() {
|
||||
442 | |
|
||||
443 | |
|
||||
444 | |
|
||||
445 | |
|
||||
446 | | let _v = v;
|
||||
447 | | }
|
||||
| |_____^ ...ending here
|
||||
@ -567,10 +567,10 @@ error: you seem to want to iterate on a map's values
|
||||
|
|
||||
450 | for (_, v) in &*m {
|
||||
| _____^ starting here...
|
||||
451 | | //~^ you seem to want to iterate on a map's values
|
||||
452 | | //~| HELP use the corresponding method
|
||||
453 | | //~| HELP use the corresponding method
|
||||
454 | | //~| SUGGESTION for v in (*m).values() {
|
||||
451 | |
|
||||
452 | |
|
||||
453 | |
|
||||
454 | |
|
||||
455 | | let _v = v;
|
||||
456 | | // Here the `*` is not actually necesarry, but the test tests that we don't suggest
|
||||
457 | | // `in *m.values()` as we used to
|
||||
@ -585,10 +585,10 @@ error: you seem to want to iterate on a map's values
|
||||
|
|
||||
461 | for (_, v) in &mut m {
|
||||
| _____^ starting here...
|
||||
462 | | //~^ you seem to want to iterate on a map's values
|
||||
463 | | //~| HELP use the corresponding method
|
||||
464 | | //~| HELP use the corresponding method
|
||||
465 | | //~| SUGGESTION for v in m.values_mut()
|
||||
462 | |
|
||||
463 | |
|
||||
464 | |
|
||||
465 | |
|
||||
466 | | let _v = v;
|
||||
467 | | }
|
||||
| |_____^ ...ending here
|
||||
@ -601,10 +601,10 @@ error: you seem to want to iterate on a map's values
|
||||
|
|
||||
470 | for (_, v) in &mut *m {
|
||||
| _____^ starting here...
|
||||
471 | | //~^ you seem to want to iterate on a map's values
|
||||
472 | | //~| HELP use the corresponding method
|
||||
473 | | //~| HELP use the corresponding method
|
||||
474 | | //~| SUGGESTION for v in (*m).values_mut()
|
||||
471 | |
|
||||
472 | |
|
||||
473 | |
|
||||
474 | |
|
||||
475 | | let _v = v;
|
||||
476 | | }
|
||||
| |_____^ ...ending here
|
||||
@ -617,10 +617,10 @@ error: you seem to want to iterate on a map's keys
|
||||
|
|
||||
480 | for (k, _value) in rm {
|
||||
| _____^ starting here...
|
||||
481 | | //~^ you seem to want to iterate on a map's keys
|
||||
482 | | //~| HELP use the corresponding method
|
||||
483 | | //~| HELP use the corresponding method
|
||||
484 | | //~| SUGGESTION for k in rm.keys() {
|
||||
481 | |
|
||||
482 | |
|
||||
483 | |
|
||||
484 | |
|
||||
485 | | let _k = k;
|
||||
486 | | }
|
||||
| |_____^ ...ending here
|
||||
|
@ -3,16 +3,16 @@
|
||||
#![deny(useless_format)]
|
||||
|
||||
fn main() {
|
||||
format!("foo"); //~ERROR useless use of `format!`
|
||||
format!("foo");
|
||||
|
||||
format!("{}", "foo"); //~ERROR useless use of `format!`
|
||||
format!("{}", "foo");
|
||||
format!("{:?}", "foo"); // we only want to warn about `{}`
|
||||
format!("{:+}", "foo"); // we only want to warn about `{}`
|
||||
format!("foo {}", "bar");
|
||||
format!("{} bar", "foo");
|
||||
|
||||
let arg: String = "".to_owned();
|
||||
format!("{}", arg); //~ERROR useless use of `format!`
|
||||
format!("{}", arg);
|
||||
format!("{:?}", arg); // we only want to warn about `{}`
|
||||
format!("{:+}", arg); // we only want to warn about `{}`
|
||||
format!("foo {}", arg);
|
||||
|
@ -1,7 +1,7 @@
|
||||
error: useless use of `format!`
|
||||
--> $DIR/format.rs:6:5
|
||||
|
|
||||
6 | format!("foo"); //~ERROR useless use of `format!`
|
||||
6 | format!("foo");
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: lint level defined here
|
||||
@ -13,13 +13,13 @@ note: lint level defined here
|
||||
error: useless use of `format!`
|
||||
--> $DIR/format.rs:8:5
|
||||
|
|
||||
8 | format!("{}", "foo"); //~ERROR useless use of `format!`
|
||||
8 | format!("{}", "foo");
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: useless use of `format!`
|
||||
--> $DIR/format.rs:15:5
|
||||
|
|
||||
15 | format!("{}", arg); //~ERROR useless use of `format!`
|
||||
15 | format!("{}", arg);
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
@ -13,8 +13,8 @@ fn main() {
|
||||
// weird `else if` formatting:
|
||||
if foo() {
|
||||
} if foo() {
|
||||
//~^ ERROR this looks like an `else if` but the `else` is missing
|
||||
//~| NOTE add the missing `else` or
|
||||
|
||||
|
||||
}
|
||||
|
||||
let _ = { // if as the last expression
|
||||
@ -22,8 +22,8 @@ fn main() {
|
||||
|
||||
if foo() {
|
||||
} if foo() {
|
||||
//~^ ERROR this looks like an `else if` but the `else` is missing
|
||||
//~| NOTE add the missing `else` or
|
||||
|
||||
|
||||
}
|
||||
else {
|
||||
}
|
||||
@ -32,8 +32,8 @@ fn main() {
|
||||
let _ = { // if in the middle of a block
|
||||
if foo() {
|
||||
} if foo() {
|
||||
//~^ ERROR this looks like an `else if` but the `else` is missing
|
||||
//~| NOTE add the missing `else` or
|
||||
|
||||
|
||||
}
|
||||
else {
|
||||
}
|
||||
@ -43,15 +43,15 @@ fn main() {
|
||||
|
||||
if foo() {
|
||||
} else
|
||||
//~^ ERROR this is an `else if` but the formatting might hide it
|
||||
//~| NOTE remove the `else` or
|
||||
|
||||
|
||||
if foo() { // the span of the above error should continue here
|
||||
}
|
||||
|
||||
if foo() {
|
||||
}
|
||||
//~^ ERROR this is an `else if` but the formatting might hide it
|
||||
//~| NOTE remove the `else` or
|
||||
|
||||
|
||||
else
|
||||
if foo() { // the span of the above error should continue here
|
||||
}
|
||||
@ -81,16 +81,16 @@ fn main() {
|
||||
// weird op_eq formatting:
|
||||
let mut a = 42;
|
||||
a =- 35;
|
||||
//~^ ERROR this looks like you are trying to use `.. -= ..`, but you really are doing `.. = (- ..)`
|
||||
//~| NOTE to remove this lint, use either `-=` or `= -`
|
||||
|
||||
|
||||
a =* &191;
|
||||
//~^ ERROR this looks like you are trying to use `.. *= ..`, but you really are doing `.. = (* ..)`
|
||||
//~| NOTE to remove this lint, use either `*=` or `= *`
|
||||
|
||||
|
||||
|
||||
let mut b = true;
|
||||
b =! false;
|
||||
//~^ ERROR this looks like you are trying to use `.. != ..`, but you really are doing `.. = (! ..)`
|
||||
//~| NOTE to remove this lint, use either `!=` or `= !`
|
||||
|
||||
|
||||
|
||||
// those are ok:
|
||||
a = -35;
|
||||
@ -100,14 +100,14 @@ fn main() {
|
||||
// possible missing comma in an array
|
||||
let _ = &[
|
||||
-1, -2, -3 // <= no coma here
|
||||
//~^ ERROR possibly missing a comma here
|
||||
//~| NOTE to remove this lint, add a comma or write the expr in a single line
|
||||
|
||||
|
||||
-4, -5, -6
|
||||
];
|
||||
let _ = &[
|
||||
-1, -2, -3 // <= no coma here
|
||||
//~^ ERROR possibly missing a comma here
|
||||
//~| NOTE to remove this lint, add a comma or write the expr in a single line
|
||||
|
||||
|
||||
*4, -5, -6
|
||||
];
|
||||
|
||||
|
@ -35,8 +35,8 @@ error: this is an `else if` but the formatting might hide it
|
||||
|
|
||||
45 | } else
|
||||
| ______^ starting here...
|
||||
46 | | //~^ ERROR this is an `else if` but the formatting might hide it
|
||||
47 | | //~| NOTE remove the `else` or
|
||||
46 | |
|
||||
47 | |
|
||||
48 | | if foo() { // the span of the above error should continue here
|
||||
| |____^ ...ending here
|
||||
|
|
||||
@ -48,8 +48,8 @@ error: this is an `else if` but the formatting might hide it
|
||||
|
|
||||
52 | }
|
||||
| ______^ starting here...
|
||||
53 | | //~^ ERROR this is an `else if` but the formatting might hide it
|
||||
54 | | //~| NOTE remove the `else` or
|
||||
53 | |
|
||||
54 | |
|
||||
55 | | else
|
||||
56 | | if foo() { // the span of the above error should continue here
|
||||
| |____^ ...ending here
|
||||
|
@ -9,7 +9,7 @@
|
||||
fn good(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool) {}
|
||||
|
||||
fn bad(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()) {
|
||||
//~^ ERROR: this function has too many arguments (8/7)
|
||||
|
||||
}
|
||||
|
||||
// don't lint extern fns
|
||||
@ -18,7 +18,7 @@ extern fn extern_fn(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32,
|
||||
pub trait Foo {
|
||||
fn good(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool);
|
||||
fn bad(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ());
|
||||
//~^ ERROR: this function has too many arguments (8/7)
|
||||
|
||||
|
||||
fn ptr(p: *const u8);
|
||||
}
|
||||
@ -28,7 +28,7 @@ pub struct Bar;
|
||||
impl Bar {
|
||||
fn good_method(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool) {}
|
||||
fn bad_method(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()) {}
|
||||
//~^ ERROR: this function has too many arguments (8/7)
|
||||
|
||||
}
|
||||
|
||||
// ok, we don’t want to warn implementations
|
||||
@ -38,11 +38,11 @@ impl Foo for Bar {
|
||||
|
||||
fn ptr(p: *const u8) {
|
||||
println!("{}", unsafe { *p });
|
||||
//~^ ERROR: this public function dereferences a raw pointer but is not marked `unsafe`
|
||||
|
||||
println!("{:?}", unsafe { p.as_ref() });
|
||||
//~^ ERROR: this public function dereferences a raw pointer but is not marked `unsafe`
|
||||
|
||||
unsafe { std::ptr::read(p) };
|
||||
//~^ ERROR: this public function dereferences a raw pointer but is not marked `unsafe`
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -54,11 +54,11 @@ fn private(p: *const u8) {
|
||||
|
||||
pub fn public(p: *const u8) {
|
||||
println!("{}", unsafe { *p });
|
||||
//~^ ERROR: this public function dereferences a raw pointer but is not marked `unsafe`
|
||||
|
||||
println!("{:?}", unsafe { p.as_ref() });
|
||||
//~^ ERROR: this public function dereferences a raw pointer but is not marked `unsafe`
|
||||
|
||||
unsafe { std::ptr::read(p) };
|
||||
//~^ ERROR: this public function dereferences a raw pointer but is not marked `unsafe`
|
||||
|
||||
}
|
||||
|
||||
impl Bar {
|
||||
@ -68,11 +68,11 @@ impl Bar {
|
||||
|
||||
pub fn public(self, p: *const u8) {
|
||||
println!("{}", unsafe { *p });
|
||||
//~^ ERROR: this public function dereferences a raw pointer but is not marked `unsafe`
|
||||
|
||||
println!("{:?}", unsafe { p.as_ref() });
|
||||
//~^ ERROR: this public function dereferences a raw pointer but is not marked `unsafe`
|
||||
|
||||
unsafe { std::ptr::read(p) };
|
||||
//~^ ERROR: this public function dereferences a raw pointer but is not marked `unsafe`
|
||||
|
||||
}
|
||||
|
||||
pub fn public_ok(self, p: *const u8) {
|
||||
|
@ -3,7 +3,7 @@ error: this function has too many arguments (8/7)
|
||||
|
|
||||
11 | fn bad(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()) {
|
||||
| _^ starting here...
|
||||
12 | | //~^ ERROR: this function has too many arguments (8/7)
|
||||
12 | |
|
||||
13 | | }
|
||||
| |_^ ...ending here
|
||||
|
|
||||
|
@ -10,21 +10,21 @@ const ZERO : i64 = 0;
|
||||
fn main() {
|
||||
let x = 0;
|
||||
|
||||
x + 0; //~ERROR the operation is ineffective
|
||||
x + (1 - 1); //~ERROR the operation is ineffective
|
||||
x + 0;
|
||||
x + (1 - 1);
|
||||
x + 1;
|
||||
0 + x; //~ERROR the operation is ineffective
|
||||
0 + x;
|
||||
1 + x;
|
||||
x - ZERO; //no error, as we skip lookups (for now)
|
||||
x | (0); //~ERROR the operation is ineffective
|
||||
x | (0);
|
||||
((ZERO)) | x; //no error, as we skip lookups (for now)
|
||||
|
||||
x * 1; //~ERROR the operation is ineffective
|
||||
1 * x; //~ERROR the operation is ineffective
|
||||
x * 1;
|
||||
1 * x;
|
||||
x / ONE; //no error, as we skip lookups (for now)
|
||||
|
||||
x / 2; //no false positive
|
||||
|
||||
x & NEG_ONE; //no error, as we skip lookups (for now)
|
||||
-1 & x; //~ERROR the operation is ineffective
|
||||
-1 & x;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
error: the operation is ineffective. Consider reducing it to `x`
|
||||
--> $DIR/identity_op.rs:13:5
|
||||
|
|
||||
13 | x + 0; //~ERROR the operation is ineffective
|
||||
13 | x + 0;
|
||||
| ^^^^^
|
||||
|
|
||||
note: lint level defined here
|
||||
@ -13,37 +13,37 @@ note: lint level defined here
|
||||
error: the operation is ineffective. Consider reducing it to `x`
|
||||
--> $DIR/identity_op.rs:14:5
|
||||
|
|
||||
14 | x + (1 - 1); //~ERROR the operation is ineffective
|
||||
14 | x + (1 - 1);
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: the operation is ineffective. Consider reducing it to `x`
|
||||
--> $DIR/identity_op.rs:16:5
|
||||
|
|
||||
16 | 0 + x; //~ERROR the operation is ineffective
|
||||
16 | 0 + x;
|
||||
| ^^^^^
|
||||
|
||||
error: the operation is ineffective. Consider reducing it to `x`
|
||||
--> $DIR/identity_op.rs:19:5
|
||||
|
|
||||
19 | x | (0); //~ERROR the operation is ineffective
|
||||
19 | x | (0);
|
||||
| ^^^^^^^
|
||||
|
||||
error: the operation is ineffective. Consider reducing it to `x`
|
||||
--> $DIR/identity_op.rs:22:5
|
||||
|
|
||||
22 | x * 1; //~ERROR the operation is ineffective
|
||||
22 | x * 1;
|
||||
| ^^^^^
|
||||
|
||||
error: the operation is ineffective. Consider reducing it to `x`
|
||||
--> $DIR/identity_op.rs:23:5
|
||||
|
|
||||
23 | 1 * x; //~ERROR the operation is ineffective
|
||||
23 | 1 * x;
|
||||
| ^^^^^
|
||||
|
||||
error: the operation is ineffective. Consider reducing it to `x`
|
||||
--> $DIR/identity_op.rs:29:5
|
||||
|
|
||||
29 | -1 & x; //~ERROR the operation is ineffective
|
||||
29 | -1 & x;
|
||||
| ^^^^^^
|
||||
|
||||
error: aborting due to 7 previous errors
|
||||
|
@ -7,26 +7,26 @@
|
||||
|
||||
fn main() {
|
||||
if let Ok(_) = Ok::<i32, i32>(42) {}
|
||||
//~^ERROR redundant pattern matching, consider using `is_ok()`
|
||||
//~| HELP try this
|
||||
//~| SUGGESTION if Ok::<i32, i32>(42).is_ok() {
|
||||
|
||||
|
||||
|
||||
|
||||
if let Err(_) = Err::<i32, i32>(42) {
|
||||
//~^ERROR redundant pattern matching, consider using `is_err()`
|
||||
//~| HELP try this
|
||||
//~| SUGGESTION if Err::<i32, i32>(42).is_err() {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
if let None = None::<()> {
|
||||
//~^ERROR redundant pattern matching, consider using `is_none()`
|
||||
//~| HELP try this
|
||||
//~| SUGGESTION if None::<()>.is_none() {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
if let Some(_) = Some(42) {
|
||||
//~^ERROR redundant pattern matching, consider using `is_some()`
|
||||
//~| HELP try this
|
||||
//~| SUGGESTION if Some(42).is_some() {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
if Ok::<i32, i32>(42).is_ok() {
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user