fork/rust
git clone https://git.julia.blue/fork/rust
3bcad65fbf6
master
1//@aux-build:proc_macros.rs 2 3#![allow(clippy::return_self_not_must_use, clippy::useless_vec)] 4#![warn(clippy::deref_addrof)] 5 6extern crate proc_macros; 7use proc_macros::inline_macros; 8 9fn get_number() -> usize { 10 10 11} 12 13fn get_reference(n: &usize) -> &usize { 14 n 15} 16 17#[allow(clippy::double_parens)] 18#[allow(unused_variables, unused_parens)] 19fn main() { 20 let a = 10; 21 let aref = &a; 22 23 let b = a; 24 25 let b = get_number(); 26 27 let b = *get_reference(&a); 28 29 let bytes: Vec<usize> = vec![1, 2, 3, 4]; 30 let b = bytes[1..2][0]; 31 32 //This produces a suggestion of 'let b = (a);' which 33 //will trigger the 'unused_parens' lint 34 let b = (a); 35 36 let b = a; 37 38 #[rustfmt::skip] 39 let b = a; 40 41 let b = &a; 42 43 let b = *aref; 44 45 let _ = unsafe { *core::ptr::addr_of!(a) }; 46} 47 48#[derive(Copy, Clone)] 49pub struct S; 50#[inline_macros] 51impl S { 52 pub fn f(&self) -> &Self { 53 inline!($(@expr self)) 54 } 55 #[allow(unused_mut)] // mut will be unused, once the macro is fixed 56 pub fn f_mut(mut self) -> Self { 57 inline!($(@expr self)) 58 } 59}