Reduce special casing in the const pretty printer
This commit is contained in:
parent
e22ddfd80d
commit
b837e71732
@ -937,7 +937,6 @@ pub trait PrettyPrinter<'tcx>:
|
||||
// Bool
|
||||
(Scalar::Raw { data: 0, .. }, ty::Bool) => p!(write("false")),
|
||||
(Scalar::Raw { data: 1, .. }, ty::Bool) => p!(write("true")),
|
||||
(Scalar::Raw { data, .. }, ty::Bool) => p!(write("{}_bool", data)),
|
||||
// Float
|
||||
(Scalar::Raw { data, .. }, ty::Float(ast::FloatTy::F32)) => {
|
||||
p!(write("{}f32", Single::from_bits(data)))
|
||||
@ -975,14 +974,9 @@ pub trait PrettyPrinter<'tcx>:
|
||||
Some(c) => p!(write("{:?}", c)),
|
||||
None => p!(write("{}_char", data)),
|
||||
},
|
||||
// References and pointers
|
||||
(Scalar::Raw { data: 0, .. }, ty::RawPtr(_)) => p!(write("{{null pointer}}")),
|
||||
// This is UB, but we still print it
|
||||
(Scalar::Raw { data: 0, .. }, ty::Ref(_, ty, _)) => {
|
||||
p!(write("{{null reference to "), print(ty), write("}}"))
|
||||
}
|
||||
(Scalar::Raw { data, .. }, ty::Ref(..)) | (Scalar::Raw { data, .. }, ty::RawPtr(_)) => {
|
||||
p!(write("0x{:x}", data))
|
||||
// Raw pointers
|
||||
(Scalar::Raw { data, .. }, ty::RawPtr(_)) => {
|
||||
p!(write("{{0x{:x} as ", data), print(ty), write("}}"))
|
||||
}
|
||||
(Scalar::Ptr(ptr), ty::FnPtr(_)) => {
|
||||
let instance = {
|
||||
|
@ -10,12 +10,12 @@ error[E0308]: mismatched types
|
||||
--> $DIR/raw-ptr-const-param.rs:7:40
|
||||
|
|
||||
LL | let _: Const<{ 15 as *const _ }> = Const::<{ 10 as *const _ }>;
|
||||
| ------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `0xf`, found `0xa`
|
||||
| ------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `{0xf as *const u32}`, found `{0xa as *const u32}`
|
||||
| |
|
||||
| expected due to this
|
||||
|
|
||||
= note: expected struct `Const<0xf>`
|
||||
found struct `Const<0xa>`
|
||||
= note: expected struct `Const<{0xf as *const u32}>`
|
||||
found struct `Const<{0xa as *const u32}>`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user