1 #![warn(clippy::semicolon_if_nothing_returned)] 2 #![allow(clippy::redundant_closure)] 3 #![feature(label_break_value)] 4 get_unit()5fn get_unit() {} 6 7 // the functions below trigger the lint main()8fn main() { 9 println!("Hello") 10 } 11 hello()12fn hello() { 13 get_unit() 14 } 15 basic101(x: i32)16fn basic101(x: i32) { 17 let y: i32; 18 y = x + 1 19 } 20 21 #[rustfmt::skip] closure_error()22fn closure_error() { 23 let _d = || { 24 hello() 25 }; 26 } 27 28 #[rustfmt::skip] unsafe_checks_error()29fn unsafe_checks_error() { 30 use std::mem::MaybeUninit; 31 use std::ptr; 32 33 let mut s = MaybeUninit::<String>::uninit(); 34 let _d = || unsafe { 35 ptr::drop_in_place(s.as_mut_ptr()) 36 }; 37 } 38 39 // this is fine print_sum(a: i32, b: i32)40fn print_sum(a: i32, b: i32) { 41 println!("{}", a + b); 42 assert_eq!(true, false); 43 } 44 foo(x: i32)45fn foo(x: i32) { 46 let y: i32; 47 if x < 1 { 48 y = 4; 49 } else { 50 y = 5; 51 } 52 } 53 bar(x: i32)54fn bar(x: i32) { 55 let y: i32; 56 match x { 57 1 => y = 4, 58 _ => y = 32, 59 } 60 } 61 foobar(x: i32)62fn foobar(x: i32) { 63 let y: i32; 64 'label: { 65 y = x + 1; 66 } 67 } 68 loop_test(x: i32)69fn loop_test(x: i32) { 70 let y: i32; 71 for &ext in &["stdout", "stderr", "fixed"] { 72 println!("{}", ext); 73 } 74 } 75 closure()76fn closure() { 77 let _d = || hello(); 78 } 79 80 #[rustfmt::skip] closure_block()81fn closure_block() { 82 let _d = || { hello() }; 83 } 84 some_unsafe_op()85unsafe fn some_unsafe_op() {} some_other_unsafe_fn()86unsafe fn some_other_unsafe_fn() {} 87 do_something()88fn do_something() { 89 unsafe { some_unsafe_op() }; 90 91 unsafe { some_other_unsafe_fn() }; 92 } 93 unsafe_checks()94fn unsafe_checks() { 95 use std::mem::MaybeUninit; 96 use std::ptr; 97 98 let mut s = MaybeUninit::<String>::uninit(); 99 let _d = || unsafe { ptr::drop_in_place(s.as_mut_ptr()) }; 100 } 101 102 // Issue #7768 103 #[rustfmt::skip] macro_with_semicolon()104fn macro_with_semicolon() { 105 macro_rules! repro { 106 () => { 107 while false { 108 } 109 }; 110 } 111 repro!(); 112 } 113