Skip to content

fieldless FRU can be used on non-struct-like structs #27831

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
arielb1 opened this issue Aug 14, 2015 · 2 comments
Closed

fieldless FRU can be used on non-struct-like structs #27831

arielb1 opened this issue Aug 14, 2015 · 2 comments

Comments

@arielb1
Copy link
Contributor

arielb1 commented Aug 14, 2015

STR

struct Foo(u32);

fn main() {
    let x = Foo(42);
    let _ = Foo { ..x };
}

Result

This compiles and runs.

Expected

This shouldn't compile.

@alexcrichton alexcrichton added final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. I-nominated and removed final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. labels Aug 14, 2015
@alexcrichton
Copy link
Member

Nominating

@arielb1
Copy link
Contributor Author

arielb1 commented Aug 14, 2015

This issue also occurs in patterns, but there's also the additional issue of Ty-aliases being too transparent (instantiate_path):

struct Foo<T> { x: T }
type Ty = Foo<u32>;
fn main() {
    match (Foo { x: () }) { Ty::<()> { x } => {} }
}

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

No branches or pull requests

2 participants