Skip to content

core::slice::Iter and core::slice::IterMut aren't NonNull-optimized #67228

Closed
@Kixunil

Description

@Kixunil

I randomly noticed that self.ptr of core::slice::Iter may never be null (also because of unconditionally calling from_raw_parts), but it's not contained in NonNull<T>, so it isn't optimized.

I double checked for compiler internal Voodoo and it confirms the lack of optimization.

I was thinking about fixing it just for fun, but it occurred to me that the current code uses assume at several places and maybe it'd be a good idea to rather add assume into NonNull::as_ptr to clean it up? Not sure, so I'm asking. (Also maybe add assume to <[T]>::as_ptr(), but that's a different topic.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: An issue proposing an enhancement or a PR with one.I-heavyIssue: Problems and improvements with respect to binary size of generated code.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions