-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Can Weak be null? #114517
Copy link
Copy link
Open
Labels
A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and toolsT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.T-opsemRelevant to the opsem teamRelevant to the opsem team
Metadata
Metadata
Assignees
Labels
A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and toolsT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.T-opsemRelevant to the opsem teamRelevant to the opsem team
Type
Fields
Give feedbackNo fields configured for issues without a type.
There is a discrepancy between the docs of
Weakand its implementation, originally found by @Urgau in #114494 (comment) .On one hand, the docs of Weak::as_ptr state:
On the other hand, the implementation of
WeakusesNonNull:rust/library/alloc/src/rc.rs
Lines 2681 to 2693 in 1cabb8e
From what I know, it is okay for
NonNullpointers 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::Weakas well asalloc::rc::Weak.