Skip to content

Struct literal constructors don't check type parameters on typedefs #15875

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

Closed
pcwalton opened this issue Jul 21, 2014 · 1 comment
Closed

Struct literal constructors don't check type parameters on typedefs #15875

pcwalton opened this issue Jul 21, 2014 · 1 comment
Labels
A-type-system Area: Type system

Comments

@pcwalton
Copy link
Contributor

I believe this compiles but shouldn't:

struct MyStruct<T> {
    x: T,
}
type OtherStruct = MyStruct<bool>;
let s = OtherStruct {
    x: 1,
};

Nominating for 1.0, P-backcompat-lang.

@mukilan
Copy link
Contributor

mukilan commented Jul 22, 2014

Even this compiles while it shouldn't:

struct MyStruct<T> {
    x: T,
}

let s = MyStruct::<bool> {
    x: 1,
};

pcwalton added a commit to pcwalton/rust that referenced this issue Jul 24, 2014
This breaks code like:

    struct Point<T> {
        x: T,
        y: T,
    }

    let pt = Point::<bool> {
        x: 1,
        y: 2,
    };

Change this code to not contain a type error. For example:

    let pt = Point::<int> {
        x: 1,
        y: 2,
    };

Closes rust-lang#9620.
Closes rust-lang#15875.

[breaking-change]
bors added a commit to rust-lang-ci/rust that referenced this issue Nov 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-type-system Area: Type system
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants