Skip to content

two phase borrows: ensure reservations are limited to assignments to temps #46746

Closed
@pnkfelix

Description

@pnkfelix

Spawned off of #46537 (comment)

@arielb1 put its simply:

However, it's probably a wise idea to limit reservations to assignments to temporaries. I don't think
MIR construction ever does anything else, but you shouldn't be able to do this:

let mut a = 0;
let mut b = 0;
let mut x: &mut u32 = &mut a;
let y = &mut x;
*y = &mut b; // this borrow should be active
// look at me, no use of `*y`, but:
use(x, &b); // should be illegal

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-NLLArea: Non-lexical lifetimes (NLL)

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions