about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorAustin Lasher <austinlasher@gmail.com>2020-08-15 13:04:18 -0400
committerAustin Lasher <austinlasher@gmail.com>2020-08-17 17:18:23 -0400
commitbf1c024f99d8218102e4dfc5cdaa4d8ae1af2e51 (patch)
tree9f3374c7655b06570e6efc52a7dd99414c37bf39 /src
parent33c96b4d9782cf6364e47cb2c904e66b06c22bb4 (diff)
downloadrust-bf1c024f99d8218102e4dfc5cdaa4d8ae1af2e51.tar.gz
rust-bf1c024f99d8218102e4dfc5cdaa4d8ae1af2e51.zip
Suppress verbose MIR comments for trivial types
Diffstat (limited to 'src')
-rw-r--r--src/librustc_mir/util/pretty.rs26
1 files 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) {