mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-28 15:41:10 +00:00
eb3970285b
In order to switch `clippy::uninlined_format_args` from pedantic to style, all existing tests must not raise a warning. I did not want to change the actual tests, so this is a relatively minor change that: * add `#![allow(clippy::uninlined_format_args)]` where needed * normalizes all allow/deny/warn attributes * all allow attributes are grouped together * sorted alphabetically * the `clippy::*` attributes are listed separate from the other ones. * deny and warn attributes are listed before the allowed ones changelog: none
73 lines
1.5 KiB
Rust
73 lines
1.5 KiB
Rust
#![warn(clippy::for_loops_over_fallibles)]
|
|
#![allow(clippy::uninlined_format_args)]
|
|
|
|
fn for_loops_over_fallibles() {
|
|
let option = Some(1);
|
|
let mut result = option.ok_or("x not found");
|
|
let v = vec![0, 1, 2];
|
|
|
|
// check over an `Option`
|
|
for x in option {
|
|
println!("{}", x);
|
|
}
|
|
|
|
// check over an `Option`
|
|
for x in option.iter() {
|
|
println!("{}", x);
|
|
}
|
|
|
|
// check over a `Result`
|
|
for x in result {
|
|
println!("{}", x);
|
|
}
|
|
|
|
// check over a `Result`
|
|
for x in result.iter_mut() {
|
|
println!("{}", x);
|
|
}
|
|
|
|
// check over a `Result`
|
|
for x in result.into_iter() {
|
|
println!("{}", x);
|
|
}
|
|
|
|
for x in option.ok_or("x not found") {
|
|
println!("{}", x);
|
|
}
|
|
|
|
// make sure LOOP_OVER_NEXT lint takes clippy::precedence when next() is the last call
|
|
// in the chain
|
|
for x in v.iter().next() {
|
|
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)) {
|
|
println!("{}", x);
|
|
}
|
|
|
|
for x in v.iter().next().ok_or("x not found") {
|
|
println!("{}", x);
|
|
}
|
|
|
|
// check for false positives
|
|
|
|
// for loop false positive
|
|
for x in v {
|
|
println!("{}", x);
|
|
}
|
|
|
|
// while let false positive for Option
|
|
while let Some(x) = option {
|
|
println!("{}", x);
|
|
break;
|
|
}
|
|
|
|
// while let false positive for Result
|
|
while let Ok(x) = result {
|
|
println!("{}", x);
|
|
break;
|
|
}
|
|
}
|
|
|
|
fn main() {}
|