fork/rust
git clone https://git.julia.blue/fork/rust
3bcad65fbf6
master
1 2 3// The output for humans should just highlight the whole span without showing 4// the suggested replacement, but we also want to test that suggested 5// replacement only removes one set of parentheses, rather than naïvely 6// stripping away any starting or ending parenthesis characters—hence this 7// test of the JSON error format. 8 9#![feature(custom_inner_attributes)] 10#![feature(closure_lifetime_binder)] 11#![rustfmt::skip] 12 13#![deny(clippy::unused_unit)] 14#![allow(dead_code)] 15#![allow(clippy::from_over_into)] 16 17struct Unitter; 18impl Unitter { 19 #[allow(clippy::no_effect)] 20 pub fn get_unit<F: Fn(), G>(&self, f: F, _g: G) 21 where G: Fn() { 22 let _y: &dyn Fn() = &f; 23 (); // this should not lint, as it's not in return type position 24 } 25} 26 27impl Into<()> for Unitter { 28 #[rustfmt::skip] 29 fn into(self) { 30 31 } 32} 33 34trait Trait { 35 fn redundant<F: FnOnce(), G, H>(&self, _f: F, _g: G, _h: H) 36 where 37 G: FnMut(), 38 H: Fn(); 39} 40 41impl Trait for Unitter { 42 fn redundant<F: FnOnce(), G, H>(&self, _f: F, _g: G, _h: H) 43 where 44 G: FnMut(), 45 H: Fn() {} 46} 47 48fn return_unit() { } 49 50#[allow(clippy::needless_return)] 51#[allow(clippy::never_loop)] 52#[allow(clippy::unit_cmp)] 53fn main() { 54 let u = Unitter; 55 assert_eq!(u.get_unit(|| {}, return_unit), u.into()); 56 return_unit(); 57 loop { 58 break; 59 } 60 return; 61} 62 63// https://github.com/rust-lang/rust-clippy/issues/4076 64fn foo() { 65 macro_rules! foo { 66 (recv($r:expr) -> $res:pat => $body:expr) => { 67 $body 68 } 69 } 70 71 foo! { 72 recv(rx) -> _x => () 73 } 74} 75 76#[rustfmt::skip] 77fn test(){} 78 79#[rustfmt::skip] 80fn test2(){} 81 82#[rustfmt::skip] 83fn test3(){} 84 85fn macro_expr() { 86 macro_rules! e { 87 () => (()); 88 } 89 e!() 90} 91 92mod issue9748 { 93 fn main() { 94 let _ = for<'a> |_: &'a u32| -> () {}; 95 } 96}