From bf1c024f99d8218102e4dfc5cdaa4d8ae1af2e51 Mon Sep 17 00:00:00 2001 From: Austin Lasher Date: Sat, 15 Aug 2020 13:04:18 -0400 Subject: [PATCH] Suppress verbose MIR comments for trivial types --- src/librustc_mir/util/pretty.rs | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/librustc_mir/util/pretty.rs b/src/librustc_mir/util/pretty.rs index c3dbac08ed8..0294a7cd7af 100644 --- a/src/librustc_mir/util/pretty.rs +++ b/src/librustc_mir/util/pretty.rs @@ -387,20 +387,30 @@ 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; - self.push("mir::Constant"); - self.push(&format!("+ span: {}", self.tcx.sess.source_map().span_to_string(*span))); - if let Some(user_ty) = user_ty { - self.push(&format!("+ user_ty: {:?}", user_ty)); + match literal.ty.kind { + ty::Int(_) | ty::Uint(_) | ty::Bool | ty::Char => {} + _ => { + self.push("mir::Constant"); + self.push(&format!("+ span: {}", self.tcx.sess.source_map().span_to_string(*span))); + if let Some(user_ty) = user_ty { + self.push(&format!("+ user_ty: {:?}", user_ty)); + } + self.push(&format!("+ literal: {:?}", literal)); + } } - self.push(&format!("+ literal: {:?}", literal)); } fn visit_const(&mut self, constant: &&'tcx ty::Const<'tcx>, _: Location) { self.super_const(constant); let ty::Const { ty, val, .. } = constant; - self.push("ty::Const"); - self.push(&format!("+ ty: {:?}", ty)); - self.push(&format!("+ val: {:?}", val)); + match ty.kind { + ty::Int(_) | ty::Uint(_) | ty::Bool | ty::Char => {} + _ => { + self.push("ty::Const"); + self.push(&format!("+ ty: {:?}", ty)); + self.push(&format!("+ val: {:?}", val)); + } + } } fn visit_rvalue(&mut self, rvalue: &Rvalue<'tcx>, location: Location) {