Open
Description
The following code:
unsafe fn slice_ptr_len_because_of_msrv<T>(slice: *const [T]) -> usize {
unsafe { (*slice)[..].len() }
}
gives the two following warnings
warning: implicit autoref creates a reference to the dereference of a raw pointer
--> src/main.rs:2:14
|
2 | unsafe { (*slice)[..].len() }
| ^^^^^^^^^^^^^^^^^^
|
= note: creating a reference requires the pointer target to be valid and imposes aliasing requirements
= note: `#[warn(dangerous_implicit_autorefs)]` on by default
help: try using a raw pointer method instead; or if this reference is intentional, make it explicit
|
2 | unsafe { (&(*slice)[..]).len() }
| ++ +
warning: implicit autoref creates a reference to the dereference of a raw pointer
--> src/main.rs:2:14
|
2 | unsafe { (*slice)[..].len() }
| ^^^^^^^^^^^^
|
= note: creating a reference requires the pointer target to be valid and imposes aliasing requirements
help: try using a raw pointer method instead; or if this reference is intentional, make it explicit
|
2 | unsafe { (&(*slice))[..].len() }
| ++ +
I the first warning is quite a duplicate of the second one, and its suggestion is also wrong, as (&(*slice)[..]).len()
would still trigger the warning.