Skip to content

Conversation

@pnkfelix
Copy link
Contributor

borrowck: Prevent partial reinitialization of uninitialized structures

This is a pnkfelix-swiped squash of #22079, which was a rebase and revision of #18963

Fixes #18571.

Ryman and others added 2 commits February 12, 2015 13:55
enumerations that implement the `Drop` trait.

This breaks code like:

    struct Struct {
        f: String,
        g: String,
    }

    impl Drop for Struct { ... }

    fn main() {
        let x = Struct { ... };
        drop(x);
        x.f = ...;
    }

Change this code to not create partially-initialized structures. For
example:

    struct Struct {
        f: String,
        g: String,
    }

    impl Drop for Struct { ... }

    fn main() {
        let x = Struct { ... };
        drop(x);
        x = Struct {
            f: ...,
            g: ...,
        }
    }

Closes rust-lang#18571.

[breaking-change]

----

(Joint authorship by pcwalton and Ryman; thanks all!)
@rust-highfive
Copy link
Contributor

r? @eddyb

(rust_highfive has picked a reviewer for you, use r? to override)

@pnkfelix
Copy link
Contributor Author

@bors r+ 6cc3b00

bors added a commit that referenced this pull request Feb 13, 2015
borrowck: Prevent partial reinitialization of uninitialized structures

This is a pnkfelix-swiped squash of #22079, which was a rebase and revision of #18963

Fixes #18571.
@bors
Copy link
Collaborator

bors commented Feb 13, 2015

⌛ Testing commit 6cc3b00 with merge ba2efe9...

@bors
Copy link
Collaborator

bors commented Feb 13, 2015

@bors bors merged commit 6cc3b00 into rust-lang:master Feb 13, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Undetected use after move

5 participants