NonNull
's as_ref
/ as_mut
don't have arbitrary lifetimes as stated
#80183
Labels
A-lifetimes
Area: Lifetimes / regions
A-raw-pointers
Area: raw pointers, MaybeUninit, NonNull
T-lang
Relevant to the language team, which will review and decide on the PR/issue.
T-libs-api
Relevant to the library API team, which will review and decide on the PR/issue.
The docs for
NonNull::as_ref
mention:Which makes sense, the pointer doesn't carry a lifetime with it, so we need to decide on it. However, the implementation actually looks like this (with implicit lifetimes shown for clarity):
This makes it so the reference constructed has the same lifetime as the pointer variable, which is likely not what is intended.
The same occurs for all of these methods currently:
as_ref
as_mut
Additionally, these unstable methods with
#![feature(ptr_as_uninit)]
(#75402) also have the same problem.as_uninit_slice
as_uninit_slice_mut
as_uninit_ref
as_uninit_mut
The text was updated successfully, but these errors were encountered: