Skip to content

Stacked Borrows: asserting uniqueness too early? Should we allow the optimizer to add spurious stores? #133

Open
@RalfJung

Description

@RalfJung

We have seen a few cases in libstd where the rule that just creating a mutable reference already asserts uniqueness is a problem:

In some cases, even just creating a shared ref is an issue, as it conflicts with a recently created mutable ref:

So maybe we assert uniqueness to aggressively here? Maybe mutable references should only become unique on first write, or so? I am not sure what that would look like though. (In principle this could also happen with shared references but I have not seen that.)

I'll use this issue to collect such cases.

However, there are also cases where people want the extra UB to get more optimizations:

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-SB-vs-TBTopic: Design questions where SB and TB are opposite sides of the design axisA-aliasing-modelTopic: Related to the aliasing model (e.g. Stacked/Tree Borrows)C-open-questionCategory: An open question that we should revisitS-pending-designStatus: Resolving this issue requires addressing some open design questions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions