2019-09-19 16:57:15 -05:00
|
|
|
// This test can't work with run-rustfix because it needs two passes of test+fix
|
2023-08-24 14:32:12 -05:00
|
|
|
//@no-rustfix
|
2019-04-16 13:26:55 -05:00
|
|
|
#[warn(clippy::deref_addrof)]
|
2019-09-19 16:57:15 -05:00
|
|
|
#[allow(unused_variables, unused_mut)]
|
2019-04-16 13:26:55 -05:00
|
|
|
fn main() {
|
|
|
|
let a = 10;
|
|
|
|
|
|
|
|
//This produces a suggestion of 'let b = *&a;' which
|
|
|
|
//will trigger the 'clippy::deref_addrof' lint again
|
|
|
|
let b = **&&a;
|
2023-08-24 14:32:12 -05:00
|
|
|
//~^ ERROR: immediately dereferencing a reference
|
|
|
|
//~| NOTE: `-D clippy::deref-addrof` implied by `-D warnings`
|
2019-04-16 13:26:55 -05:00
|
|
|
|
|
|
|
{
|
|
|
|
let mut x = 10;
|
|
|
|
let y = *&mut x;
|
2023-08-24 14:32:12 -05:00
|
|
|
//~^ ERROR: immediately dereferencing a reference
|
2019-04-16 13:26:55 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
//This produces a suggestion of 'let y = *&mut x' which
|
|
|
|
//will trigger the 'clippy::deref_addrof' lint again
|
|
|
|
let mut x = 10;
|
|
|
|
let y = **&mut &mut x;
|
2023-08-24 14:32:12 -05:00
|
|
|
//~^ ERROR: immediately dereferencing a reference
|
2019-04-16 13:26:55 -05:00
|
|
|
}
|
|
|
|
}
|