Skip to content

items/union example triggers float literal compatibility lint #563

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
kyrias opened this issue Apr 13, 2019 · 0 comments · Fixed by #683
Closed

items/union example triggers float literal compatibility lint #563

kyrias opened this issue Apr 13, 2019 · 0 comments · Fixed by #683
Labels
C-bug Incorrect statements, terminology, or rendering issues

Comments

@kyrias
Copy link

kyrias commented Apr 13, 2019

The unions section has an example matching on a float literal, which triggers the rust-lang/rust#41620 compatibility lint:

#[repr(u32)]
enum Tag { I, F }

#[repr(C)]
union U {
    i: i32,
    f: f32,
}

#[repr(C)]
struct Value {
    tag: Tag,
    u: U,
}

fn is_zero(v: Value) -> bool {
    unsafe {
        match v {
            Value { tag: I, u: U { i: 0 } } => true,
            Value { tag: F, u: U { f: 0.0 } } => true,
            _ => false,
        }
    }
}
@kyrias kyrias changed the title items/union example triggers rust-lang/rust#41620 items/union example triggers float literal compatibility lint Apr 13, 2019
@Centril Centril added the C-bug Incorrect statements, terminology, or rendering issues label Apr 13, 2019
pnkfelix added a commit to pnkfelix/reference that referenced this issue Sep 26, 2019
Havvy pushed a commit to Havvy/reference that referenced this issue Aug 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Incorrect statements, terminology, or rendering issues
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants