Skip to content

NLL Diagnostic Review 3: Unions not reinitialized after assignment into field #55651

Closed
@davidtwco

Description

@davidtwco

@pnkfelix's review comments:

ui/borrowck/borrowck-union-move-assign.nll.stderr rejecting sound uses of unions; it reports 3 errors when only one expected. We should make a run-pass test from the two cases we expect to accept.

For the record, here's the relevant part of the test in question (play):

#![feature(untagged_unions)]
struct A;
struct B;
union U {
    a: A,
    b: B,
}
fn main() {
    unsafe {
        {
            let mut u = U { a: A };
            let _a = u.a;
            u.a = A;
            let _a = u.a; // OK
        }
        {
            let mut u = U { a: A };
            let _a = u.a;
            u.b = B;
            let _a = u.a; // OK
        }
    }
}

Metadata

Metadata

Assignees

Labels

A-NLLArea: Non-lexical lifetimes (NLL)NLL-completeWorking towards the "valid code works" goalNLL-diagnosticsWorking towards the "diagnostic parity" goalP-highHigh priority

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions