]> git.lizzy.rs Git - rust.git/blob - tests/ui/unused_unit.fixed
Auto merge of #4314 - chansuke:add-negation-to-is_empty, r=flip1995
[rust.git] / tests / ui / unused_unit.fixed
1 // run-rustfix
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 #![rustfmt::skip]
11
12 #![deny(clippy::unused_unit)]
13
14 struct Unitter;
15 impl Unitter {
16     // try to disorient the lint with multiple unit returns and newlines
17     #[allow(clippy::no_effect)]
18     pub fn get_unit<F: Fn() -> (), G>(&self, f: F, _g: G) 
19     where G: Fn() -> () {
20         let _y: &dyn Fn() -> () = &f;
21         (); // this should not lint, as it's not in return type position
22     }
23 }
24
25 impl Into<()> for Unitter {
26     #[rustfmt::skip]
27     fn into(self)  {
28         
29     }
30 }
31
32 fn return_unit()  {  }
33
34 #[allow(clippy::needless_return)]
35 #[allow(clippy::never_loop)]
36 fn main() {
37     let u = Unitter;
38     assert_eq!(u.get_unit(|| {}, return_unit), u.into());
39     return_unit();
40     loop {
41         break;
42     }
43     return;
44 }