Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 4717cf2

Browse files
committedAug 18, 2020
Auto merge of #75566 - alasher:master, r=oli-obk
Suppress verbose MIR comments for trivial types Addresses #74508 This is my first contribution to the Rust project! Please let me know if anything needs revising, I'm happy to make changes.
2 parents 515c9fa + 28ac141 commit 4717cf2

File tree

132 files changed

+48
-3687
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

132 files changed

+48
-3687
lines changed
 

‎src/librustc_mir/util/pretty.rs

Lines changed: 18 additions & 8 deletions
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) {

‎src/test/mir-opt/address_of.address_of_reborrow.SimplifyCfg-initial.after.mir

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -129,23 +129,11 @@ fn address_of_reborrow() -> () {
129129
StorageLive(_1); // scope 0 at $DIR/address-of.rs:4:9: 4:10
130130
StorageLive(_2); // scope 0 at $DIR/address-of.rs:4:14: 4:21
131131
_2 = [const 0_i32; 10]; // scope 0 at $DIR/address-of.rs:4:14: 4:21
132-
// ty::Const
133-
// + ty: i32
134-
// + val: Value(Scalar(0x00000000))
135-
// mir::Constant
136-
// + span: $DIR/address-of.rs:4:15: 4:16
137-
// + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) }
138132
_1 = &_2; // scope 0 at $DIR/address-of.rs:4:13: 4:21
139133
FakeRead(ForLet, _1); // scope 0 at $DIR/address-of.rs:4:9: 4:10
140134
StorageLive(_3); // scope 1 at $DIR/address-of.rs:5:9: 5:14
141135
StorageLive(_4); // scope 1 at $DIR/address-of.rs:5:22: 5:29
142136
_4 = [const 0_i32; 10]; // scope 1 at $DIR/address-of.rs:5:22: 5:29
143-
// ty::Const
144-
// + ty: i32
145-
// + val: Value(Scalar(0x00000000))
146-
// mir::Constant
147-
// + span: $DIR/address-of.rs:5:23: 5:24
148-
// + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) }
149137
_3 = &mut _4; // scope 1 at $DIR/address-of.rs:5:17: 5:29
150138
FakeRead(ForLet, _3); // scope 1 at $DIR/address-of.rs:5:9: 5:14
151139
StorageLive(_5); // scope 2 at $DIR/address-of.rs:7:5: 7:18

0 commit comments

Comments
 (0)
Please sign in to comment.