diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:20:39 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:20:39 +0000 |
commit | 1376c5a617be5c25655d0d7cb63e3beaa5a6e026 (patch) | |
tree | 3bb8d61aee02bc7a15eab3f36e3b921afc2075d0 /compiler/rustc_serialize | |
parent | Releasing progress-linux version 1.69.0+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.tar.xz rustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.zip |
Merging upstream version 1.70.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'compiler/rustc_serialize')
-rw-r--r-- | compiler/rustc_serialize/Cargo.toml | 2 | ||||
-rw-r--r-- | compiler/rustc_serialize/src/opaque.rs | 36 | ||||
-rw-r--r-- | compiler/rustc_serialize/src/serialize.rs | 16 | ||||
-rw-r--r-- | compiler/rustc_serialize/tests/opaque.rs | 32 |
4 files changed, 15 insertions, 71 deletions
diff --git a/compiler/rustc_serialize/Cargo.toml b/compiler/rustc_serialize/Cargo.toml index c04465719..e4dbb8a63 100644 --- a/compiler/rustc_serialize/Cargo.toml +++ b/compiler/rustc_serialize/Cargo.toml @@ -4,7 +4,7 @@ version = "0.0.0" edition = "2021" [dependencies] -indexmap = "1.9.1" +indexmap = "1.9.3" smallvec = { version = "1.8.1", features = ["union", "may_dangle"] } thin-vec = "0.2.12" diff --git a/compiler/rustc_serialize/src/opaque.rs b/compiler/rustc_serialize/src/opaque.rs index 0e0ebc79e..53e5c8967 100644 --- a/compiler/rustc_serialize/src/opaque.rs +++ b/compiler/rustc_serialize/src/opaque.rs @@ -123,18 +123,6 @@ impl Encoder for MemEncoder { } #[inline] - fn emit_f64(&mut self, v: f64) { - let as_u64: u64 = v.to_bits(); - self.emit_u64(as_u64); - } - - #[inline] - fn emit_f32(&mut self, v: f32) { - let as_u32: u32 = v.to_bits(); - self.emit_u32(as_u32); - } - - #[inline] fn emit_char(&mut self, v: char) { self.emit_u32(v as u32); } @@ -501,18 +489,6 @@ impl Encoder for FileEncoder { } #[inline] - fn emit_f64(&mut self, v: f64) { - let as_u64: u64 = v.to_bits(); - self.emit_u64(as_u64); - } - - #[inline] - fn emit_f32(&mut self, v: f32) { - let as_u32: u32 = v.to_bits(); - self.emit_u32(as_u32); - } - - #[inline] fn emit_char(&mut self, v: char) { self.emit_u32(v as u32); } @@ -643,18 +619,6 @@ impl<'a> Decoder for MemDecoder<'a> { } #[inline] - fn read_f64(&mut self) -> f64 { - let bits = self.read_u64(); - f64::from_bits(bits) - } - - #[inline] - fn read_f32(&mut self) -> f32 { - let bits = self.read_u32(); - f32::from_bits(bits) - } - - #[inline] fn read_char(&mut self) -> char { let bits = self.read_u32(); std::char::from_u32(bits).unwrap() diff --git a/compiler/rustc_serialize/src/serialize.rs b/compiler/rustc_serialize/src/serialize.rs index 567fe0610..527abc237 100644 --- a/compiler/rustc_serialize/src/serialize.rs +++ b/compiler/rustc_serialize/src/serialize.rs @@ -22,6 +22,11 @@ use std::sync::Arc; /// be processed or ignored, whichever is appropriate. Then they should provide /// a `finish` method that finishes up encoding. If the encoder is fallible, /// `finish` should return a `Result` that indicates success or failure. +/// +/// This current does not support `f32` nor `f64`, as they're not needed in any +/// serialized data structures. That could be changed, but consider whether it +/// really makes sense to store floating-point values at all. +/// (If you need it, revert <https://github.com/rust-lang/rust/pull/109984>.) pub trait Encoder { // Primitive types: fn emit_usize(&mut self, v: usize); @@ -37,8 +42,6 @@ pub trait Encoder { fn emit_i16(&mut self, v: i16); fn emit_i8(&mut self, v: i8); fn emit_bool(&mut self, v: bool); - fn emit_f64(&mut self, v: f64); - fn emit_f32(&mut self, v: f32); fn emit_char(&mut self, v: char); fn emit_str(&mut self, v: &str); fn emit_raw_bytes(&mut self, s: &[u8]); @@ -58,6 +61,11 @@ pub trait Encoder { // top-level invocation would also just panic on failure. Switching to // infallibility made things faster and lots of code a little simpler and more // concise. +/// +/// This current does not support `f32` nor `f64`, as they're not needed in any +/// serialized data structures. That could be changed, but consider whether it +/// really makes sense to store floating-point values at all. +/// (If you need it, revert <https://github.com/rust-lang/rust/pull/109984>.) pub trait Decoder { // Primitive types: fn read_usize(&mut self) -> usize; @@ -73,8 +81,6 @@ pub trait Decoder { fn read_i16(&mut self) -> i16; fn read_i8(&mut self) -> i8; fn read_bool(&mut self) -> bool; - fn read_f64(&mut self) -> f64; - fn read_f32(&mut self) -> f32; fn read_char(&mut self) -> char; fn read_str(&mut self) -> &str; fn read_raw_bytes(&mut self, len: usize) -> &[u8]; @@ -143,8 +149,6 @@ direct_serialize_impls! { i64 emit_i64 read_i64, i128 emit_i128 read_i128, - f32 emit_f32 read_f32, - f64 emit_f64 read_f64, bool emit_bool read_bool, char emit_char read_char } diff --git a/compiler/rustc_serialize/tests/opaque.rs b/compiler/rustc_serialize/tests/opaque.rs index 3a695d071..5e7dd18aa 100644 --- a/compiler/rustc_serialize/tests/opaque.rs +++ b/compiler/rustc_serialize/tests/opaque.rs @@ -22,8 +22,6 @@ struct Struct { l: char, m: String, - n: f32, - o: f64, p: bool, q: Option<u32>, } @@ -120,24 +118,6 @@ fn test_bool() { } #[test] -fn test_f32() { - let mut vec = vec![]; - for i in -100..100 { - vec.push((i as f32) / 3.0); - } - check_round_trip(vec); -} - -#[test] -fn test_f64() { - let mut vec = vec![]; - for i in -100..100 { - vec.push((i as f64) / 3.0); - } - check_round_trip(vec); -} - -#[test] fn test_char() { let vec = vec!['a', 'b', 'c', 'd', 'A', 'X', ' ', '#', 'Ö', 'Ä', 'µ', '€']; check_round_trip(vec); @@ -200,8 +180,6 @@ fn test_struct() { l: 'x', m: "abc".to_string(), - n: 20.5, - o: 21.5, p: false, q: None, }]); @@ -222,8 +200,6 @@ fn test_struct() { l: 'y', m: "def".to_string(), - n: -20.5, - o: -21.5, p: true, q: Some(1234567), }]); @@ -232,7 +208,7 @@ fn test_struct() { #[derive(PartialEq, Clone, Debug, Encodable, Decodable)] enum Enum { Variant1, - Variant2(usize, f32), + Variant2(usize, u32), Variant3 { a: i32, b: char, c: bool }, } @@ -240,7 +216,7 @@ enum Enum { fn test_enum() { check_round_trip(vec![ Enum::Variant1, - Enum::Variant2(1, 2.5), + Enum::Variant2(1, 25), Enum::Variant3 { a: 3, b: 'b', c: false }, Enum::Variant3 { a: -4, b: 'f', c: true }, ]); @@ -269,8 +245,8 @@ fn test_hash_map() { #[test] fn test_tuples() { - check_round_trip(vec![('x', (), false, 0.5f32)]); - check_round_trip(vec![(9i8, 10u16, 1.5f64)]); + check_round_trip(vec![('x', (), false, 5u32)]); + check_round_trip(vec![(9i8, 10u16, 15i64)]); check_round_trip(vec![(-12i16, 11u8, 12usize)]); check_round_trip(vec![(1234567isize, 100000000000000u64, 99999999999999i64)]); check_round_trip(vec![(String::new(), "some string".to_string())]); |