Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

borrowck: Prevent partial reinitialization of uninitialized structures #22079

Closed
wants to merge 2 commits into from

Commits on Feb 8, 2015

  1. librustc: Forbid partial reinitialization of uninitialized structures or

    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]
    pcwalton authored and Ryman committed Feb 8, 2015
    Configuration menu
    Copy the full SHA
    fa761f0 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    dda79e9 View commit details
    Browse the repository at this point in the history