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

librustc: Make Copy opt-in. #17864

Closed
wants to merge 1 commit into from
Closed

Commits on Dec 5, 2014

  1. librustc: Make Copy opt-in.

    This change makes the compiler no longer infer whether types (structures
    and enumerations) implement the `Copy` trait (and thus are implicitly
    copyable). Rather, you must implement `Copy` yourself via `impl Copy for
    MyType {}`.
    
    A new warning has been added, `missing_copy_implementations`, to warn
    you if a non-generic public type has been added that could have
    implemented `Copy` but didn't.
    
    This breaks code like:
    
        #[deriving(Show)]
        struct Point2D {
            x: int,
            y: int,
        }
    
        fn main() {
            let mypoint = Point2D {
                x: 1,
                y: 1,
            };
            let otherpoint = mypoint;
            println!("{}{}", mypoint, otherpoint);
        }
    
    Change this code to:
    
        #[deriving(Show)]
        struct Point2D {
            x: int,
            y: int,
        }
    
        impl Copy for Point2D {}
    
        fn main() {
            let mypoint = Point2D {
                x: 1,
                y: 1,
            };
            let otherpoint = mypoint;
            println!("{}{}", mypoint, otherpoint);
        }
    
    This is the backwards-incompatible part of rust-lang#13231.
    
    Part of RFC rust-lang#3.
    
    [breaking-change]
    pcwalton committed Dec 5, 2014
    3 Configuration menu
    Copy the full SHA
    5859dc1 View commit details
    Browse the repository at this point in the history