rust-lang / rust-bindgen

Automatically generates Rust FFI bindings to C (and some C++) libraries.
https://rust-lang.github.io/rust-bindgen/
BSD 3-Clause "New" or "Revised" License
4.23k stars 679 forks source link

Generated INFINITY & NEG_ INFINITY are invalid in Rust 1.79 #2853

Open gabiganam opened 1 week ago

gabiganam commented 1 week ago

Input C/C++ Header

#define POSITIVE_INFINITE (1.0/0.0)
#define NEGATIVE_INFINITE (-1.0/0.0)

Actual Results

pub const POSITIVE_INFINITE: f64 = ::std::f64::INFINITY;
pub const NEGATIVE_INFINITE: f64 = ::std::f64::NEG_INFINITY;

Expected Results

pub const POSITIVE_INFINITE: f64 = f64::INFINITY;
pub const NEGATIVE_INFINITE: f64 = f64::NEG_INFINITY;

Due to new lint rule: https://rust-lang.github.io/rust-clippy/master/index.html#/legacy_numeric_constants

Source code seems to be: https://github.com/rust-lang/rust-bindgen/blob/cf9b02f57cc6138f60b4d35a5ff109b433dd8238/bindgen/codegen/helpers.rs#L325