Skip to content

Commit 10d205b

Browse files
committed
more test
1 parent 630be51 commit 10d205b

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

tests/ui/needless_deref.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ mod should_lint {
1010
}
1111
}
1212

13-
mod should_not_lint {
13+
// this mod explains why we should not lint `&mut &* (&T)`
14+
mod should_not_lint1 {
1415
fn foo(x: &mut &u32) {
1516
*x = &1;
1617
}
@@ -24,3 +25,14 @@ mod should_not_lint {
2425
assert_eq!(*x, 1);
2526
}
2627
}
28+
29+
// this mod explains why we should not lint `& &* (&T)`
30+
mod should_not_lint2 {
31+
fn foo() {
32+
let x = &12;
33+
let addr_x = &x as *const _ as usize;
34+
let addr_y = &&*x as *const _ as usize; // assert ok
35+
// let addr_y = &x as *const _ as usize; // assert fail
36+
assert_ne!(addr_x, addr_y);
37+
}
38+
}

0 commit comments

Comments
 (0)