Description
There is a discrepancy between the docs of Weak
and its implementation, originally found by @Urgau in #114494 (comment) .
On one hand, the docs of Weak::as_ptr state:
The pointer is valid only if there are some strong references. The pointer may be dangling, unaligned or even null otherwise.
On the other hand, the implementation of Weak
uses NonNull
:
Lines 2681 to 2693 in 1cabb8e
From what I know, it is okay for NonNull
pointers to be dangling or unaligned, but, staying true to their name, they are never allowed to be null pointers.
I think this discrepancy should be resolved, but I wonder, which way? Should the docs be adjusted, or the implementation?
The issue exists both with alloc::sync::Weak
as well as alloc::rc::Weak
.