Skip to content

Commit 4a7791d

Browse files
committed
implicit_unsafe_autorefs: make the lint warn by default
1 parent e1c0b69 commit 4a7791d

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

compiler/rustc_lint/src/implicit_unsafe_autorefs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ declare_lint! {
4343
/// }
4444
/// ```
4545
pub IMPLICIT_UNSAFE_AUTOREFS,
46-
Deny,
46+
Warn,
4747
"implicit reference to a dereference of a raw pointer"
4848
}
4949

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1+
// check-pass
12
// run-rustfix
23
use std::ptr::{addr_of, addr_of_mut};
34

45
unsafe fn _test_mut(ptr: *mut [u8]) -> *mut [u8] {
56
addr_of_mut!((&mut (*ptr))[..16])
6-
//~^ error: implicit auto-ref creates a reference to a dereference of a raw pointer
7+
//~^ warn: implicit auto-ref creates a reference to a dereference of a raw pointer
78
}
89

910
unsafe fn _test_const(ptr: *const [u8]) -> *const [u8] {
1011
addr_of!((&(*ptr))[..16])
11-
//~^ error: implicit auto-ref creates a reference to a dereference of a raw pointer
12+
//~^ warn: implicit auto-ref creates a reference to a dereference of a raw pointer
1213
}
1314

1415
fn main() {}
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1+
// check-pass
12
// run-rustfix
23
use std::ptr::{addr_of, addr_of_mut};
34

45
unsafe fn _test_mut(ptr: *mut [u8]) -> *mut [u8] {
56
addr_of_mut!((*ptr)[..16])
6-
//~^ error: implicit auto-ref creates a reference to a dereference of a raw pointer
7+
//~^ warn: implicit auto-ref creates a reference to a dereference of a raw pointer
78
}
89

910
unsafe fn _test_const(ptr: *const [u8]) -> *const [u8] {
1011
addr_of!((*ptr)[..16])
11-
//~^ error: implicit auto-ref creates a reference to a dereference of a raw pointer
12+
//~^ warn: implicit auto-ref creates a reference to a dereference of a raw pointer
1213
}
1314

1415
fn main() {}
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
error: implicit auto-ref creates a reference to a dereference of a raw pointer
2-
--> $DIR/implicit_unsafe_autorefs.rs:5:18
1+
warning: implicit auto-ref creates a reference to a dereference of a raw pointer
2+
--> $DIR/implicit_unsafe_autorefs.rs:6:18
33
|
44
LL | addr_of_mut!((*ptr)[..16])
55
| ^^^^^^
66
|
77
= note: creating a reference requires the pointer to be valid and imposes aliasing requirements
8-
= note: `#[deny(implicit_unsafe_autorefs)]` on by default
8+
= note: `#[warn(implicit_unsafe_autorefs)]` on by default
99
help: try using a raw pointer method instead; or if this reference is intentional, make it explicit
1010
|
1111
LL | addr_of_mut!((&mut (*ptr))[..16])
1212
| +++++ +
1313

14-
error: implicit auto-ref creates a reference to a dereference of a raw pointer
15-
--> $DIR/implicit_unsafe_autorefs.rs:10:14
14+
warning: implicit auto-ref creates a reference to a dereference of a raw pointer
15+
--> $DIR/implicit_unsafe_autorefs.rs:11:14
1616
|
1717
LL | addr_of!((*ptr)[..16])
1818
| ^^^^^^
@@ -23,5 +23,5 @@ help: try using a raw pointer method instead; or if this reference is intentiona
2323
LL | addr_of!((&(*ptr))[..16])
2424
| ++ +
2525

26-
error: aborting due to 2 previous errors
26+
warning: 2 warnings emitted
2727

0 commit comments

Comments
 (0)