|
| 1 | +$NetBSD$ |
| 2 | + |
| 3 | +Following on from https://github.com/rust-lang/rust/issues/137630 |
| 4 | +apply patch gracefully supplied in |
| 5 | +https://github.com/beetrees/rust/commit/21f8bda79b2904c827b9d8d769a1307acfd855a1.patch |
| 6 | + |
| 7 | +Fixes cross-build for 32-bit mips on NetBSD which |
| 8 | +does not (yet?) support the f16 data type. |
| 9 | + |
| 10 | +--- src/tools/clippy/clippy_utils/src/consts.rs.orig 2025-02-17 18:17:27.000000000 +0000 |
| 11 | ++++ src/tools/clippy/clippy_utils/src/consts.rs |
| 12 | +@@ -41,14 +41,16 @@ pub enum Constant<'tcx> { |
| 13 | + Char(char), |
| 14 | + /// An integer's bit representation. |
| 15 | + Int(u128), |
| 16 | +- /// An `f16`. |
| 17 | +- F16(f16), |
| 18 | ++ /// An `f16` bitcast to a `u16`. |
| 19 | ++ // FIXME(f16_f128): use `f16` once builtins are available on all host tools platforms. |
| 20 | ++ F16(u16), |
| 21 | + /// An `f32`. |
| 22 | + F32(f32), |
| 23 | + /// An `f64`. |
| 24 | + F64(f64), |
| 25 | +- /// An `f128`. |
| 26 | +- F128(f128), |
| 27 | ++ /// An `f128` bitcast to a `u128`. |
| 28 | ++ // FIXME(f16_f128): use `f128` once builtins are available on all host tools platforms. |
| 29 | ++ F128(u128), |
| 30 | + /// `true` or `false`. |
| 31 | + Bool(bool), |
| 32 | + /// An array of constants. |
| 33 | +@@ -175,7 +177,7 @@ impl Hash for Constant<'_> { |
| 34 | + }, |
| 35 | + Self::F16(f) => { |
| 36 | + // FIXME(f16_f128): once conversions to/from `f128` are available on all platforms, |
| 37 | +- f.to_bits().hash(state); |
| 38 | ++ f.hash(state); |
| 39 | + }, |
| 40 | + Self::F32(f) => { |
| 41 | + f64::from(f).to_bits().hash(state); |
| 42 | +@@ -184,7 +186,7 @@ impl Hash for Constant<'_> { |
| 43 | + f.to_bits().hash(state); |
| 44 | + }, |
| 45 | + Self::F128(f) => { |
| 46 | +- f.to_bits().hash(state); |
| 47 | ++ f.hash(state); |
| 48 | + }, |
| 49 | + Self::Bool(b) => { |
| 50 | + b.hash(state); |
| 51 | +@@ -290,12 +292,12 @@ impl Constant<'_> { |
| 52 | + |
| 53 | + fn parse_f16(s: &str) -> Self { |
| 54 | + let f: Half = s.parse().unwrap(); |
| 55 | +- Self::F16(f16::from_bits(f.to_bits().try_into().unwrap())) |
| 56 | ++ Self::F16(f.to_bits().try_into().unwrap()) |
| 57 | + } |
| 58 | + |
| 59 | + fn parse_f128(s: &str) -> Self { |
| 60 | + let f: Quad = s.parse().unwrap(); |
| 61 | +- Self::F128(f128::from_bits(f.to_bits())) |
| 62 | ++ Self::F128(f.to_bits()) |
| 63 | + } |
| 64 | + } |
| 65 | + |
| 66 | +@@ -851,10 +853,10 @@ pub fn mir_to_const<'tcx>(tcx: TyCtxt<'t |
| 67 | + ty::Adt(adt_def, _) if adt_def.is_struct() => Some(Constant::Adt(result)), |
| 68 | + ty::Bool => Some(Constant::Bool(int == ScalarInt::TRUE)), |
| 69 | + ty::Uint(_) | ty::Int(_) => Some(Constant::Int(int.to_bits(int.size()))), |
| 70 | +- ty::Float(FloatTy::F16) => Some(Constant::F16(f16::from_bits(int.into()))), |
| 71 | ++ ty::Float(FloatTy::F16) => Some(Constant::F16(int.into())), |
| 72 | + ty::Float(FloatTy::F32) => Some(Constant::F32(f32::from_bits(int.into()))), |
| 73 | + ty::Float(FloatTy::F64) => Some(Constant::F64(f64::from_bits(int.into()))), |
| 74 | +- ty::Float(FloatTy::F128) => Some(Constant::F128(f128::from_bits(int.into()))), |
| 75 | ++ ty::Float(FloatTy::F128) => Some(Constant::F128(int.into())), |
| 76 | + ty::RawPtr(_, _) => Some(Constant::RawPtr(int.to_bits(int.size()))), |
| 77 | + _ => None, |
| 78 | + }, |
| 79 | +@@ -875,10 +877,10 @@ pub fn mir_to_const<'tcx>(tcx: TyCtxt<'t |
| 80 | + let range = alloc_range(offset + size * idx, size); |
| 81 | + let val = alloc.read_scalar(&tcx, range, /* read_provenance */ false).ok()?; |
| 82 | + res.push(match flt { |
| 83 | +- FloatTy::F16 => Constant::F16(f16::from_bits(val.to_u16().discard_err()?)), |
| 84 | ++ FloatTy::F16 => Constant::F16(val.to_u16().discard_err()?), |
| 85 | + FloatTy::F32 => Constant::F32(f32::from_bits(val.to_u32().discard_err()?)), |
| 86 | + FloatTy::F64 => Constant::F64(f64::from_bits(val.to_u64().discard_err()?)), |
| 87 | +- FloatTy::F128 => Constant::F128(f128::from_bits(val.to_u128().discard_err()?)), |
| 88 | ++ FloatTy::F128 => Constant::F128(val.to_u128().discard_err()?), |
| 89 | + }); |
| 90 | + } |
| 91 | + Some(Constant::Vec(res)) |
0 commit comments