Skip to content

Commit bf1c024

Browse files
committed
Suppress verbose MIR comments for trivial types
1 parent 33c96b4 commit bf1c024

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

src/librustc_mir/util/pretty.rs

+18-8
Original file line numberDiff line numberDiff line change
@@ -387,20 +387,30 @@ impl Visitor<'tcx> for ExtraComments<'tcx> {
387387
fn visit_constant(&mut self, constant: &Constant<'tcx>, location: Location) {
388388
self.super_constant(constant, location);
389389
let Constant { span, user_ty, literal } = constant;
390-
self.push("mir::Constant");
391-
self.push(&format!("+ span: {}", self.tcx.sess.source_map().span_to_string(*span)));
392-
if let Some(user_ty) = user_ty {
393-
self.push(&format!("+ user_ty: {:?}", user_ty));
390+
match literal.ty.kind {
391+
ty::Int(_) | ty::Uint(_) | ty::Bool | ty::Char => {}
392+
_ => {
393+
self.push("mir::Constant");
394+
self.push(&format!("+ span: {}", self.tcx.sess.source_map().span_to_string(*span)));
395+
if let Some(user_ty) = user_ty {
396+
self.push(&format!("+ user_ty: {:?}", user_ty));
397+
}
398+
self.push(&format!("+ literal: {:?}", literal));
399+
}
394400
}
395-
self.push(&format!("+ literal: {:?}", literal));
396401
}
397402

398403
fn visit_const(&mut self, constant: &&'tcx ty::Const<'tcx>, _: Location) {
399404
self.super_const(constant);
400405
let ty::Const { ty, val, .. } = constant;
401-
self.push("ty::Const");
402-
self.push(&format!("+ ty: {:?}", ty));
403-
self.push(&format!("+ val: {:?}", val));
406+
match ty.kind {
407+
ty::Int(_) | ty::Uint(_) | ty::Bool | ty::Char => {}
408+
_ => {
409+
self.push("ty::Const");
410+
self.push(&format!("+ ty: {:?}", ty));
411+
self.push(&format!("+ val: {:?}", val));
412+
}
413+
}
404414
}
405415

406416
fn visit_rvalue(&mut self, rvalue: &Rvalue<'tcx>, location: Location) {

0 commit comments

Comments
 (0)