Skip to content

Commit 4dcab72

Browse files
committed
add test for *&[a, b,...]`
1 parent 76856ff commit 4dcab72

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

tests/ui/deref_addrof.fixed

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ fn main() {
4343
let b = *aref;
4444

4545
let _ = unsafe { *core::ptr::addr_of!(a) };
46+
47+
// do NOT lint for array as sematic differences with/out `*&`.
48+
let _repeat = [0; 64];
49+
let _arr = [0, 1, 2, 3, 4];
4650
}
4751

4852
#[derive(Copy, Clone)]

tests/ui/deref_addrof.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ fn main() {
4343
let b = **&aref;
4444

4545
let _ = unsafe { *core::ptr::addr_of!(a) };
46+
47+
// do NOT lint for array as sematic differences with/out `*&`.
48+
let _repeat = *&[0; 64];
49+
let _arr = *&[0, 1, 2, 3, 4];
4650
}
4751

4852
#[derive(Copy, Clone)]

tests/ui/deref_addrof.stderr

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,20 +50,32 @@ LL | let b = **&aref;
5050
| ^^^^^^ help: try: `aref`
5151

5252
error: immediately dereferencing a reference
53-
--> tests/ui/deref_addrof.rs:53:17
53+
--> tests/ui/deref_addrof.rs:48:19
54+
|
55+
LL | let _repeat = *&[0; 64];
56+
| ^^^^^^^^^ help: try: `[0; 64]`
57+
58+
error: immediately dereferencing a reference
59+
--> tests/ui/deref_addrof.rs:49:16
60+
|
61+
LL | let _arr = *&[0, 1, 2, 3, 4];
62+
| ^^^^^^^^^^^^^^^^^ help: try: `[0, 1, 2, 3, 4]`
63+
64+
error: immediately dereferencing a reference
65+
--> tests/ui/deref_addrof.rs:57:17
5466
|
5567
LL | inline!(*& $(@expr self))
5668
| ^^^^^^^^^^^^^^^^ help: try: `$(@expr self)`
5769
|
5870
= note: this error originates in the macro `__inline_mac_impl` (in Nightly builds, run with -Z macro-backtrace for more info)
5971

6072
error: immediately dereferencing a reference
61-
--> tests/ui/deref_addrof.rs:57:17
73+
--> tests/ui/deref_addrof.rs:61:17
6274
|
6375
LL | inline!(*&mut $(@expr self))
6476
| ^^^^^^^^^^^^^^^^^^^ help: try: `$(@expr self)`
6577
|
6678
= note: this error originates in the macro `__inline_mac_impl` (in Nightly builds, run with -Z macro-backtrace for more info)
6779

68-
error: aborting due to 10 previous errors
80+
error: aborting due to 12 previous errors
6981

0 commit comments

Comments
 (0)