Prepare mir::Constant for ty::Const only supporting valtrees

This commit is contained in:
Oli Scherer
2021-03-08 16:18:03 +00:00
parent 3ecde6f5db
commit 3127a9c60f
38 changed files with 369 additions and 153 deletions

View File

@@ -439,7 +439,7 @@ impl Visitor<'tcx> for ExtraComments<'tcx> {
fn visit_constant(&mut self, constant: &Constant<'tcx>, location: Location) {
self.super_constant(constant, location);
let Constant { span, user_ty, literal } = constant;
match literal.ty.kind() {
match literal.ty().kind() {
ty::Int(_) | ty::Uint(_) | ty::Bool | ty::Char => {}
// Unit type
ty::Tuple(tys) if tys.is_empty() => {}
@@ -449,7 +449,12 @@ impl Visitor<'tcx> for ExtraComments<'tcx> {
if let Some(user_ty) = user_ty {
self.push(&format!("+ user_ty: {:?}", user_ty));
}
self.push(&format!("+ literal: {:?}", literal));
match literal {
ConstantSource::Ty(literal) => self.push(&format!("+ literal: {:?}", literal)),
ConstantSource::Val(val, ty) => {
self.push(&format!("+ literal: {:?}, {}", val, ty))
}
}
}
}
}