Skip to content

Rust doesn't use niche in reference (or pointer) to slice #132235

Open
@VorfeedCanal

Description

@VorfeedCanal

From reddit thread: why can't rust optimize the size of Option<Option<&str>>?

Indeed, in spite of the fact that &str doesn't all use more than half of possible bit sequences (top bit of 2nd word is always zero, plus first word can not be zero) only Option<&str> is optimized

Would it make sense to teach compiler about that niche or is it prevented by some deeper issue?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-layoutArea: Memory layout of typesC-optimizationCategory: An issue highlighting optimization opportunities or PRs implementing suchE-needs-designThis issue needs exploration and design to see how and if we can fix/implement itT-compilerRelevant to the compiler 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