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
118 lines
2.3 KiB
Rust
118 lines
2.3 KiB
Rust
// aux-build: proc_macro_with_span.rs
|
|
#![warn(clippy::single_match_else)]
|
|
#![allow(clippy::needless_return, clippy::no_effect, clippy::uninlined_format_args)]
|
|
|
|
extern crate proc_macro_with_span;
|
|
use proc_macro_with_span::with_span;
|
|
|
|
enum ExprNode {
|
|
ExprAddrOf,
|
|
Butterflies,
|
|
Unicorns,
|
|
}
|
|
|
|
static NODE: ExprNode = ExprNode::Unicorns;
|
|
|
|
fn unwrap_addr() -> Option<&'static ExprNode> {
|
|
let _ = match ExprNode::Butterflies {
|
|
ExprNode::ExprAddrOf => Some(&NODE),
|
|
_ => {
|
|
let x = 5;
|
|
None
|
|
},
|
|
};
|
|
|
|
// Don't lint
|
|
with_span!(span match ExprNode::Butterflies {
|
|
ExprNode::ExprAddrOf => Some(&NODE),
|
|
_ => {
|
|
let x = 5;
|
|
None
|
|
},
|
|
})
|
|
}
|
|
|
|
macro_rules! unwrap_addr {
|
|
($expression:expr) => {
|
|
match $expression {
|
|
ExprNode::ExprAddrOf => Some(&NODE),
|
|
_ => {
|
|
let x = 5;
|
|
None
|
|
},
|
|
}
|
|
};
|
|
}
|
|
|
|
#[rustfmt::skip]
|
|
fn main() {
|
|
unwrap_addr!(ExprNode::Unicorns);
|
|
|
|
//
|
|
// don't lint single exprs/statements
|
|
//
|
|
|
|
// don't lint here
|
|
match Some(1) {
|
|
Some(a) => println!("${:?}", a),
|
|
None => return,
|
|
}
|
|
|
|
// don't lint here
|
|
match Some(1) {
|
|
Some(a) => println!("${:?}", a),
|
|
None => {
|
|
return
|
|
},
|
|
}
|
|
|
|
// don't lint here
|
|
match Some(1) {
|
|
Some(a) => println!("${:?}", a),
|
|
None => {
|
|
return;
|
|
},
|
|
}
|
|
|
|
//
|
|
// lint multiple exprs/statements "else" blocks
|
|
//
|
|
|
|
// lint here
|
|
match Some(1) {
|
|
Some(a) => println!("${:?}", a),
|
|
None => {
|
|
println!("else block");
|
|
return
|
|
},
|
|
}
|
|
|
|
// lint here
|
|
match Some(1) {
|
|
Some(a) => println!("${:?}", a),
|
|
None => {
|
|
println!("else block");
|
|
return;
|
|
},
|
|
}
|
|
|
|
// lint here
|
|
use std::convert::Infallible;
|
|
match Result::<i32, Infallible>::Ok(1) {
|
|
Ok(a) => println!("${:?}", a),
|
|
Err(_) => {
|
|
println!("else block");
|
|
return;
|
|
}
|
|
}
|
|
|
|
use std::borrow::Cow;
|
|
match Cow::from("moo") {
|
|
Cow::Owned(a) => println!("${:?}", a),
|
|
Cow::Borrowed(_) => {
|
|
println!("else block");
|
|
return;
|
|
}
|
|
}
|
|
}
|