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