diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-02-22 12:16:34 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-02-22 12:16:34 +0100 |
| commit | e3814629c4aaff5813ad35b2e52f00cfa006eef5 (patch) | |
| tree | ca623c9abfcce814d85e0c6ac5a69e3b5c61fafe /compiler | |
| parent | 396910a66473b6891983b778621dfbd3ac1593b4 (diff) | |
| parent | fb1ee8764f4d6ba78c1ad1803a34a0a2d2b0bf93 (diff) | |
| download | rust-e3814629c4aaff5813ad35b2e52f00cfa006eef5.tar.gz rust-e3814629c4aaff5813ad35b2e52f00cfa006eef5.zip | |
Rollup merge of #94246 - RalfJung:hex, r=oli-obk
ScalarMaybeUninit is explicitly hexadecimal in its formatting This makes `ScalarMaybeUninit` consistent with `Scalar` after the changes in https://github.com/rust-lang/rust/pull/94189. r? ``@oli-obk``
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/operand.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/validity.rs | 10 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/mir/interpret/value.rs | 2 |
3 files changed, 8 insertions, 8 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/operand.rs b/compiler/rustc_const_eval/src/interpret/operand.rs index 60e915a7eee..bc4dca4c146 100644 --- a/compiler/rustc_const_eval/src/interpret/operand.rs +++ b/compiler/rustc_const_eval/src/interpret/operand.rs @@ -142,11 +142,11 @@ impl<Tag: Provenance> std::fmt::Display for ImmTy<'_, Tag> { p(cx, s, ty)?; return Ok(()); } - write!(f, "{}: {}", s, self.layout.ty) + write!(f, "{:x}: {}", s, self.layout.ty) } Immediate::ScalarPair(a, b) => { // FIXME(oli-obk): at least print tuples and slices nicely - write!(f, "({}, {}): {}", a, b, self.layout.ty,) + write!(f, "({:x}, {:x}): {}", a, b, self.layout.ty,) } } }) diff --git a/compiler/rustc_const_eval/src/interpret/validity.rs b/compiler/rustc_const_eval/src/interpret/validity.rs index 19c6449078d..54e29299e6c 100644 --- a/compiler/rustc_const_eval/src/interpret/validity.rs +++ b/compiler/rustc_const_eval/src/interpret/validity.rs @@ -503,7 +503,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, ' value.to_bool(), self.path, err_ub!(InvalidBool(..)) | err_ub!(InvalidUninitBytes(None)) => - { "{}", value } expected { "a boolean" }, + { "{:x}", value } expected { "a boolean" }, ); Ok(true) } @@ -513,7 +513,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, ' value.to_char(), self.path, err_ub!(InvalidChar(..)) | err_ub!(InvalidUninitBytes(None)) => - { "{}", value } expected { "a valid unicode scalar value (in `0..=0x10FFFF` but not in `0xD800..=0xDFFF`)" }, + { "{:x}", value } expected { "a valid unicode scalar value (in `0..=0x10FFFF` but not in `0xD800..=0xDFFF`)" }, ); Ok(true) } @@ -526,7 +526,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, ' let is_bits = value.check_init().map_or(false, |v| v.try_to_int().is_ok()); if !is_bits { throw_validation_failure!(self.path, - { "{}", value } expected { "initialized plain (non-pointer) bytes" } + { "{:x}", value } expected { "initialized plain (non-pointer) bytes" } ) } } @@ -580,7 +580,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, ' err_ub!(DanglingIntPointer(..)) | err_ub!(InvalidFunctionPointer(..)) | err_ub!(InvalidUninitBytes(None)) => - { "{}", value } expected { "a function pointer" }, + { "{:x}", value } expected { "a function pointer" }, ); // FIXME: Check if the signature matches Ok(true) @@ -632,7 +632,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, ' let value = try_validation!( value.check_init(), self.path, - err_ub!(InvalidUninitBytes(None)) => { "{}", value } + err_ub!(InvalidUninitBytes(None)) => { "{:x}", value } expected { "something {}", wrapping_range_format(valid_range, max_value) }, ); let bits = match value.try_to_int() { diff --git a/compiler/rustc_middle/src/mir/interpret/value.rs b/compiler/rustc_middle/src/mir/interpret/value.rs index acf7847de54..c8ddc4edc8a 100644 --- a/compiler/rustc_middle/src/mir/interpret/value.rs +++ b/compiler/rustc_middle/src/mir/interpret/value.rs @@ -498,7 +498,7 @@ impl<Tag: Provenance> fmt::Debug for ScalarMaybeUninit<Tag> { } } -impl<Tag: Provenance> fmt::Display for ScalarMaybeUninit<Tag> { +impl<Tag: Provenance> fmt::LowerHex for ScalarMaybeUninit<Tag> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { ScalarMaybeUninit::Uninit => write!(f, "uninitialized bytes"), |
