Skip to content

Lang: Stabilize usage of rustc_nonnull_optimization_guaranteed on -1 #97122

Closed
@joshtriplett

Description

@joshtriplett

I/O Safety (#87074) uses types which are repr(transparent) wrappers around file descriptors or sockets, and which have a niche at -1 which is an invalid fd/socket. Those types use rustc_nonnull_optimization_guaranteed, which together with the niche, allows using things like Option<OwnedFd> in FFI.

(The attribute remains unstable, and is misnamed at this point since it shouldn't say "nonnull"; it should be something like rustc_niche_optimization_guaranteed, but that shouldn't block this issue.)

Before stabilizing those types, we'd like to confirm T-lang consensus that we have no objections to exposing a type with a guaranteed non-zero niche (in this case, a guaranteed niche at -1). This commits us to continuing to provide some mechanism (even if perma-unstable) for declaring non-zero niches and allowing their use in FFI.

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-langRelevant to the language teamdisposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.finished-final-comment-periodThe final comment period is finished for this PR / Issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions