diff --git a/bindgen-tests/tests/expectations/tests/infinite-macro.rs b/bindgen-tests/tests/expectations/tests/infinite-macro.rs index f19879fb17..cf2b32f0ed 100644 --- a/bindgen-tests/tests/expectations/tests/infinite-macro.rs +++ b/bindgen-tests/tests/expectations/tests/infinite-macro.rs @@ -1,3 +1,7 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -pub const INFINITY: f64 = f64::INFINITY; -pub const NAN: f64 = f64::NAN; +pub const INFINITY: f64 = f64::INFINITY as _; +pub const NEG_INFINITY: f64 = f64::NEG_INFINITY as _; +pub const NAN: f64 = f64::NAN as _; +pub const F32_INFINITY: f32 = f64::INFINITY as _; +pub const F32_NEG_INFINITY: f32 = f64::NEG_INFINITY as _; +pub const F32_NAN: f32 = f64::NAN as _; diff --git a/bindgen-tests/tests/headers/infinite-macro.h b/bindgen-tests/tests/headers/infinite-macro.h deleted file mode 100644 index ab352c5785..0000000000 --- a/bindgen-tests/tests/headers/infinite-macro.h +++ /dev/null @@ -1,2 +0,0 @@ -#define INFINITY (1.0f/0.0f) -#define NAN (0.0f/0.0f) diff --git a/bindgen-tests/tests/headers/infinite-macro.hpp b/bindgen-tests/tests/headers/infinite-macro.hpp new file mode 100644 index 0000000000..32c8b61911 --- /dev/null +++ b/bindgen-tests/tests/headers/infinite-macro.hpp @@ -0,0 +1,7 @@ +#define INFINITY (1.0f/0.0f) +#define NEG_INFINITY (-1.0f/0.0f) +#define NAN (0.0f/0.0f) + +static const float F32_INFINITY = 1.0f / 0.0f; +static const float F32_NEG_INFINITY = -1.0f / 0.0f; +static const float F32_NAN = 0.0f / 0.0f; diff --git a/bindgen/codegen/helpers.rs b/bindgen/codegen/helpers.rs index 49928cce3a..9b86ba47b0 100644 --- a/bindgen/codegen/helpers.rs +++ b/bindgen/codegen/helpers.rs @@ -320,14 +320,14 @@ pub(crate) mod ast_ty { } if f.is_nan() { - return Ok(quote! { f64::NAN }); + return Ok(quote! { f64::NAN as _ }); } if f.is_infinite() { let tokens = if f.is_sign_positive() { - quote! { f64::INFINITY } + quote! { f64::INFINITY as _ } } else { - quote! { f64::NEG_INFINITY } + quote! { f64::NEG_INFINITY as _ } }; return Ok(tokens); }