1- //@ check-pass
1+ //@ check-fail
22//@ run-rustfix
33
44#![allow(dead_code)] // For the rustfix-ed code.
@@ -8,7 +8,7 @@ use std::ops::Deref;
88
99unsafe fn test_const(ptr: *const [u8]) {
1010 let _ = (&(*ptr))[..16];
11- //~^ WARN implicit autoref
11+ //~^ ERROR implicit autoref
1212}
1313
1414struct Test {
@@ -17,89 +17,92 @@ struct Test {
1717
1818unsafe fn test_field(ptr: *const Test) -> *const [u8] {
1919 let l = (&(*ptr).field).len();
20- //~^ WARN implicit autoref
20+ //~^ ERROR implicit autoref
2121
2222 &raw const (&(*ptr).field)[..l - 1]
23- //~^ WARN implicit autoref
23+ //~^ ERROR implicit autoref
2424}
2525
2626unsafe fn test_builtin_index(a: *mut [String]) {
2727 _ = (&(*a)[0]).len();
28- //~^ WARN implicit autoref
28+ //~^ ERROR implicit autoref
2929
3030 _ = (&(&(*a))[..1][0]).len();
31- //~^ WARN implicit autoref
32- //~^^ WARN implicit autoref
31+ //~^ ERROR implicit autoref
32+ //~^^ ERROR implicit autoref
3333}
3434
3535unsafe fn test_overloaded_deref_const(ptr: *const ManuallyDrop<Test>) {
3636 let _ = (&(*ptr)).field;
37- //~^ WARN implicit autoref
37+ //~^ ERROR implicit autoref
3838 let _ = &raw const (&(*ptr)).field;
39- //~^ WARN implicit autoref
39+ //~^ ERROR implicit autoref
4040}
4141
4242unsafe fn test_overloaded_deref_mut(ptr: *mut ManuallyDrop<Test>) {
4343 let _ = (&(*ptr)).field;
44- //~^ WARN implicit autoref
44+ //~^ ERROR implicit autoref
4545}
4646
4747unsafe fn test_double_overloaded_deref_const(ptr: *const ManuallyDrop<ManuallyDrop<Test>>) {
4848 let _ = (&(*ptr)).field;
49- //~^ WARN implicit autoref
49+ //~^ ERROR implicit autoref
5050}
5151
5252unsafe fn test_manually_overloaded_deref() {
5353 struct W<T>(T);
5454
5555 impl<T> Deref for W<T> {
5656 type Target = T;
57- fn deref(&self) -> &T { &self.0 }
57+ fn deref(&self) -> &T {
58+ &self.0
59+ }
5860 }
5961
6062 let w: W<i32> = W(5);
6163 let w = &raw const w;
6264 let _p: *const i32 = &raw const *(&**w);
63- //~^ WARN implicit autoref
65+ //~^ ERROR implicit autoref
6466}
6567
6668struct Test2 {
6769 // Derefs to `[u8]`.
68- field: &'static [u8]
70+ field: &'static [u8],
6971}
7072
7173fn test_more_manual_deref(ptr: *const Test2) -> usize {
7274 unsafe { (&(*ptr).field).len() }
73- //~^ WARN implicit autoref
75+ //~^ ERROR implicit autoref
7476}
7577
7678unsafe fn test_no_attr(ptr: *mut ManuallyDrop<u8>) {
77- ptr.write(ManuallyDrop::new(1)); // Should not warn, as `ManuallyDrop::write` is not
78- // annotated with `#[rustc_no_implicit_auto_ref]`
79+ // Should not warn, as `ManuallyDrop::write` is not
80+ // annotated with `#[rustc_no_implicit_auto_ref]`
81+ ptr.write(ManuallyDrop::new(1));
7982}
8083
8184unsafe fn test_vec_get(ptr: *mut Vec<u8>) {
8285 let _ = (&(*ptr)).get(0);
83- //~^ WARN implicit autoref
86+ //~^ ERROR implicit autoref
8487 let _ = (&(*ptr)).get_unchecked(0);
85- //~^ WARN implicit autoref
88+ //~^ ERROR implicit autoref
8689 let _ = (&mut (*ptr)).get_mut(0);
87- //~^ WARN implicit autoref
90+ //~^ ERROR implicit autoref
8891 let _ = (&mut (*ptr)).get_unchecked_mut(0);
89- //~^ WARN implicit autoref
92+ //~^ ERROR implicit autoref
9093}
9194
9295unsafe fn test_string(ptr: *mut String) {
9396 let _ = (&(*ptr)).len();
94- //~^ WARN implicit autoref
97+ //~^ ERROR implicit autoref
9598 let _ = (&(*ptr)).is_empty();
96- //~^ WARN implicit autoref
99+ //~^ ERROR implicit autoref
97100}
98101
99102unsafe fn slice_ptr_len_because_of_msrv<T>(slice: *const [T]) {
100103 let _ = (&(&(*slice))[..]).len();
101- //~^ WARN implicit autoref
102- //~^^ WARN implicit autoref
104+ //~^ ERROR implicit autoref
105+ //~^^ ERROR implicit autoref
103106}
104107
105108fn main() {}
0 commit comments