Skip to content

items/union example triggers float literal compatibility lint #563

Closed

Description

@kyrias

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,
        }
    }
}

Activity

  1. changed the title [-]items/union example triggers rust-lang/rust#41620[/-] [+]items/union example triggers float literal compatibility lint[/+] on Apr 13, 2019
  2. added
    C-bugIncorrect statements, terminology, or rendering issues
    on Apr 13, 2019
  3. added a commit that references this issue on Sep 26, 2019
    b18ea92
  4. added a commit that references this issue on Aug 25, 2020
    e08c49f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugIncorrect statements, terminology, or rendering issues

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions