2019-09-19 21:57:15 +00:00
|
|
|
// This test can't work with run-rustfix because it needs two passes of test+fix
|
2023-08-24 19:32:12 +00:00
|
|
|
//@no-rustfix
|
2019-04-16 18:26:55 +00:00
|
|
|
#[warn(clippy::deref_addrof)]
|
2019-09-19 21:57:15 +00:00
|
|
|
#[allow(unused_variables, unused_mut)]
|
2019-04-16 18:26:55 +00: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 19:32:12 +00:00
|
|
|
//~^ ERROR: immediately dereferencing a reference
|
|
|
|
//~| NOTE: `-D clippy::deref-addrof` implied by `-D warnings`
|
2019-04-16 18:26:55 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
let mut x = 10;
|
|
|
|
let y = *&mut x;
|
2023-08-24 19:32:12 +00:00
|
|
|
//~^ ERROR: immediately dereferencing a reference
|
2019-04-16 18:26:55 +00: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 19:32:12 +00:00
|
|
|
//~^ ERROR: immediately dereferencing a reference
|
2019-04-16 18:26:55 +00:00
|
|
|
}
|
|
|
|
}
|