2023-08-24 14:32:12 -05:00
|
|
|
|
2019-03-07 00:21:41 -06: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.
|
|
|
|
|
|
|
|
#![feature(custom_inner_attributes)]
|
2022-11-21 13:34:47 -06:00
|
|
|
#![feature(closure_lifetime_binder)]
|
2019-03-07 00:21:41 -06:00
|
|
|
#![rustfmt::skip]
|
|
|
|
|
|
|
|
#![deny(clippy::unused_unit)]
|
2019-08-24 14:42:39 -05:00
|
|
|
#![allow(dead_code)]
|
2021-01-02 09:29:43 -06:00
|
|
|
#![allow(clippy::from_over_into)]
|
2019-03-07 00:21:41 -06:00
|
|
|
|
|
|
|
struct Unitter;
|
|
|
|
impl Unitter {
|
|
|
|
#[allow(clippy::no_effect)]
|
2020-11-05 07:29:48 -06:00
|
|
|
pub fn get_unit<F: Fn(), G>(&self, f: F, _g: G)
|
|
|
|
where G: Fn() {
|
|
|
|
let _y: &dyn Fn() = &f;
|
2019-03-07 00:21:41 -06:00
|
|
|
(); // this should not lint, as it's not in return type position
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Into<()> for Unitter {
|
|
|
|
#[rustfmt::skip]
|
2020-11-05 07:29:48 -06:00
|
|
|
fn into(self) {
|
2019-03-07 00:21:41 -06:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-17 10:36:26 -05:00
|
|
|
trait Trait {
|
2020-11-05 07:29:48 -06:00
|
|
|
fn redundant<F: FnOnce(), G, H>(&self, _f: F, _g: G, _h: H)
|
2020-05-17 10:36:26 -05:00
|
|
|
where
|
2020-11-05 07:29:48 -06:00
|
|
|
G: FnMut(),
|
|
|
|
H: Fn();
|
2020-05-17 10:36:26 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Trait for Unitter {
|
2020-11-05 07:29:48 -06:00
|
|
|
fn redundant<F: FnOnce(), G, H>(&self, _f: F, _g: G, _h: H)
|
2020-05-17 10:36:26 -05:00
|
|
|
where
|
2020-11-05 07:29:48 -06:00
|
|
|
G: FnMut(),
|
|
|
|
H: Fn() {}
|
2020-05-17 10:36:26 -05:00
|
|
|
}
|
|
|
|
|
2020-11-05 07:29:48 -06:00
|
|
|
fn return_unit() { }
|
2019-03-07 00:21:41 -06:00
|
|
|
|
|
|
|
#[allow(clippy::needless_return)]
|
|
|
|
#[allow(clippy::never_loop)]
|
2019-10-02 15:48:19 -05:00
|
|
|
#[allow(clippy::unit_cmp)]
|
2019-03-07 00:21:41 -06:00
|
|
|
fn main() {
|
|
|
|
let u = Unitter;
|
|
|
|
assert_eq!(u.get_unit(|| {}, return_unit), u.into());
|
|
|
|
return_unit();
|
|
|
|
loop {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2019-08-24 14:42:39 -05: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-11-05 07:29:48 -06:00
|
|
|
|
|
|
|
#[rustfmt::skip]
|
|
|
|
fn test(){}
|
|
|
|
|
|
|
|
#[rustfmt::skip]
|
|
|
|
fn test2(){}
|
|
|
|
|
|
|
|
#[rustfmt::skip]
|
|
|
|
fn test3(){}
|
2021-05-06 04:51:22 -05:00
|
|
|
|
|
|
|
fn macro_expr() {
|
|
|
|
macro_rules! e {
|
|
|
|
() => (());
|
|
|
|
}
|
|
|
|
e!()
|
|
|
|
}
|
2022-11-21 13:34:47 -06:00
|
|
|
|
|
|
|
mod issue9748 {
|
|
|
|
fn main() {
|
|
|
|
let _ = for<'a> |_: &'a u32| -> () {};
|
|
|
|
}
|
|
|
|
}
|
2024-02-27 08:25:18 -06:00
|
|
|
|
|
|
|
mod issue9949 {
|
|
|
|
fn main() {
|
|
|
|
#[doc = "documentation"]
|
|
|
|
()
|
|
|
|
}
|
|
|
|
}
|