2019-03-07 06:21:41 +00:00
|
|
|
// run-rustfix
|
2018-09-27 17:10:20 +00:00
|
|
|
|
|
|
|
// The output for humans should just highlight the whole span without showing
|
|
|
|
// the suggested replacement, but we also want to test that suggested
|
|
|
|
// replacement only removes one set of parentheses, rather than naïvely
|
|
|
|
// stripping away any starting or ending parenthesis characters—hence this
|
|
|
|
// test of the JSON error format.
|
|
|
|
|
2019-03-07 06:13:59 +00:00
|
|
|
#![feature(custom_inner_attributes)]
|
|
|
|
#![rustfmt::skip]
|
2018-09-27 17:10:20 +00:00
|
|
|
|
2019-03-07 06:21:41 +00:00
|
|
|
#![deny(clippy::unused_unit)]
|
2019-08-24 19:42:39 +00:00
|
|
|
#![allow(dead_code)]
|
2020-12-19 14:49:42 +00:00
|
|
|
#![allow(clippy::from_over_into)]
|
2019-03-07 06:21:41 +00:00
|
|
|
|
2018-09-27 17:10:20 +00:00
|
|
|
struct Unitter;
|
|
|
|
impl Unitter {
|
2019-03-07 06:21:41 +00:00
|
|
|
#[allow(clippy::no_effect)]
|
2020-05-12 23:04:16 +00:00
|
|
|
pub fn get_unit<F: Fn() -> (), G>(&self, f: F, _g: G) -> ()
|
2018-09-27 17:10:20 +00:00
|
|
|
where G: Fn() -> () {
|
2019-05-30 06:23:47 +00:00
|
|
|
let _y: &dyn Fn() -> () = &f;
|
2018-09-27 17:10:20 +00:00
|
|
|
(); // this should not lint, as it's not in return type position
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Into<()> for Unitter {
|
2018-12-08 17:56:59 +00:00
|
|
|
#[rustfmt::skip]
|
2018-09-27 17:10:20 +00:00
|
|
|
fn into(self) -> () {
|
|
|
|
()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-12 23:04:16 +00:00
|
|
|
trait Trait {
|
|
|
|
fn redundant<F: FnOnce() -> (), G, H>(&self, _f: F, _g: G, _h: H)
|
|
|
|
where
|
|
|
|
G: FnMut() -> (),
|
|
|
|
H: Fn() -> ();
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Trait for Unitter {
|
|
|
|
fn redundant<F: FnOnce() -> (), G, H>(&self, _f: F, _g: G, _h: H)
|
|
|
|
where
|
|
|
|
G: FnMut() -> (),
|
|
|
|
H: Fn() -> () {}
|
|
|
|
}
|
|
|
|
|
2018-09-27 17:10:20 +00:00
|
|
|
fn return_unit() -> () { () }
|
|
|
|
|
2019-03-07 06:21:41 +00:00
|
|
|
#[allow(clippy::needless_return)]
|
|
|
|
#[allow(clippy::never_loop)]
|
2019-10-02 20:48:19 +00:00
|
|
|
#[allow(clippy::unit_cmp)]
|
2018-09-27 17:10:20 +00:00
|
|
|
fn main() {
|
|
|
|
let u = Unitter;
|
|
|
|
assert_eq!(u.get_unit(|| {}, return_unit), u.into());
|
|
|
|
return_unit();
|
|
|
|
loop {
|
|
|
|
break();
|
|
|
|
}
|
|
|
|
return();
|
|
|
|
}
|
2019-08-24 19:42:39 +00:00
|
|
|
|
|
|
|
// https://github.com/rust-lang/rust-clippy/issues/4076
|
|
|
|
fn foo() {
|
|
|
|
macro_rules! foo {
|
|
|
|
(recv($r:expr) -> $res:pat => $body:expr) => {
|
|
|
|
$body
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
foo! {
|
|
|
|
recv(rx) -> _x => ()
|
|
|
|
}
|
|
|
|
}
|
2020-10-27 14:18:08 +00:00
|
|
|
|
|
|
|
#[rustfmt::skip]
|
|
|
|
fn test()->(){}
|
|
|
|
|
|
|
|
#[rustfmt::skip]
|
|
|
|
fn test2() ->(){}
|
|
|
|
|
|
|
|
#[rustfmt::skip]
|
|
|
|
fn test3()-> (){}
|