Skip to content

Optimisations based on lifetimes #231

Open
@Diggsey

Description

@Diggsey

I think the answer to this is fairly obvious, but I couldn't see it stated anywhere. Is it the case that lifetimes are only relevant for determining whether code is safe and not whether it is valid? In other words, lifetimes (or incorrect lifetimes) can never cause UB by themselves.

Furthermore, the compiler can never optimise something based on eg. the knowledge that a reference has 'static lifetime, and transmuting between different lifetimes is always OK as long as the stacked borrows rules are followed at runtime.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-supportCategory: Supporting a user to solve a concrete problem

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions