Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppress MIR comments of FnDef and unit types #75670

Merged
merged 3 commits into from
Aug 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/librustc_middle/ty/sty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ pub enum TyKind<'tcx> {
/// After typeck, the concrete type can be found in the `types` map.
Opaque(DefId, SubstsRef<'tcx>),

/// A type parameter; for example, `T` in `fn f<T>(x: T) {}
/// A type parameter; for example, `T` in `fn f<T>(x: T) {}`.
Param(ParamTy),

/// Bound type variable, used only when preparing a trait query.
Expand Down
5 changes: 5 additions & 0 deletions src/librustc_mir/util/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,8 @@ impl Visitor<'tcx> for ExtraComments<'tcx> {
let Constant { span, user_ty, literal } = constant;
match literal.ty.kind {
ty::Int(_) | ty::Uint(_) | ty::Bool | ty::Char => {}
// Unit type
ty::Tuple(tys) if tys.is_empty() => {}
_ => {
self.push("mir::Constant");
self.push(&format!("+ span: {}", self.tcx.sess.source_map().span_to_string(*span)));
Expand All @@ -405,6 +407,9 @@ impl Visitor<'tcx> for ExtraComments<'tcx> {
let ty::Const { ty, val, .. } = constant;
match ty.kind {
ty::Int(_) | ty::Uint(_) | ty::Bool | ty::Char => {}
// Unit type
ty::Tuple(tys) if tys.is_empty() => {}
ty::FnDef(..) => {}
_ => {
self.push("ty::Const");
self.push(&format!("+ ty: {:?}", ty));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,12 +287,6 @@ fn address_of_reborrow() -> () {
FakeRead(ForLet, _47); // scope 13 at $DIR/address-of.rs:36:9: 36:10
AscribeUserType(_47, o, UserTypeProjection { base: UserType(29), projs: [] }); // scope 13 at $DIR/address-of.rs:36:12: 36:22
_0 = const (); // scope 0 at $DIR/address-of.rs:3:26: 37:2
// ty::Const
// + ty: ()
// + val: Value(Scalar(<ZST>))
// mir::Constant
// + span: $DIR/address-of.rs:3:26: 37:2
// + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
StorageDead(_47); // scope 13 at $DIR/address-of.rs:37:1: 37:2
StorageDead(_45); // scope 12 at $DIR/address-of.rs:37:1: 37:2
StorageDead(_44); // scope 11 at $DIR/address-of.rs:37:1: 37:2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,6 @@ fn borrow_and_cast(_1: i32) -> () {
FakeRead(ForLet, _6); // scope 2 at $DIR/address-of.rs:44:9: 44:10
StorageDead(_7); // scope 2 at $DIR/address-of.rs:44:31: 44:32
_0 = const (); // scope 0 at $DIR/address-of.rs:41:32: 45:2
// ty::Const
// + ty: ()
// + val: Value(Scalar(<ZST>))
// mir::Constant
// + span: $DIR/address-of.rs:41:32: 45:2
// + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
StorageDead(_6); // scope 2 at $DIR/address-of.rs:45:1: 45:2
StorageDead(_4); // scope 1 at $DIR/address-of.rs:45:1: 45:2
StorageDead(_2); // scope 0 at $DIR/address-of.rs:45:1: 45:2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ fn main() -> () {
StorageLive(_6); // scope 4 at $DIR/array-index-is-temporary.rs:16:25: 16:26
_6 = _3; // scope 4 at $DIR/array-index-is-temporary.rs:16:25: 16:26
_5 = const foo(move _6) -> bb1; // scope 4 at $DIR/array-index-is-temporary.rs:16:21: 16:27
// ty::Const
// + ty: unsafe fn(*mut usize) -> u32 {foo}
// + val: Value(Scalar(<ZST>))
// mir::Constant
// + span: $DIR/array-index-is-temporary.rs:16:21: 16:24
// + literal: Const { ty: unsafe fn(*mut usize) -> u32 {foo}, val: Value(Scalar(<ZST>)) }
Expand All @@ -59,12 +56,6 @@ fn main() -> () {
StorageDead(_5); // scope 3 at $DIR/array-index-is-temporary.rs:16:28: 16:29
StorageDead(_7); // scope 3 at $DIR/array-index-is-temporary.rs:16:29: 16:30
_0 = const (); // scope 0 at $DIR/array-index-is-temporary.rs:12:11: 17:2
// ty::Const
// + ty: ()
// + val: Value(Scalar(<ZST>))
// mir::Constant
// + span: $DIR/array-index-is-temporary.rs:12:11: 17:2
// + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
StorageDead(_3); // scope 2 at $DIR/array-index-is-temporary.rs:17:1: 17:2
StorageDead(_2); // scope 1 at $DIR/array-index-is-temporary.rs:17:1: 17:2
StorageDead(_1); // scope 0 at $DIR/array-index-is-temporary.rs:17:1: 17:2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ fn main() -> () {
StorageLive(_6); // scope 4 at $DIR/array-index-is-temporary.rs:16:25: 16:26
_6 = _3; // scope 4 at $DIR/array-index-is-temporary.rs:16:25: 16:26
_5 = const foo(move _6) -> bb1; // scope 4 at $DIR/array-index-is-temporary.rs:16:21: 16:27
// ty::Const
// + ty: unsafe fn(*mut usize) -> u32 {foo}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exact type of functions can sometimes be useful.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type is still shown right below (though we should probably cut out the val part of the literal field as it's useless for zsts.

// + val: Value(Scalar(<ZST>))
// mir::Constant
// + span: $DIR/array-index-is-temporary.rs:16:21: 16:24
// + literal: Const { ty: unsafe fn(*mut usize) -> u32 {foo}, val: Value(Scalar(<ZST>)) }
Expand All @@ -59,12 +56,6 @@ fn main() -> () {
StorageDead(_5); // scope 3 at $DIR/array-index-is-temporary.rs:16:28: 16:29
StorageDead(_7); // scope 3 at $DIR/array-index-is-temporary.rs:16:29: 16:30
_0 = const (); // scope 0 at $DIR/array-index-is-temporary.rs:12:11: 17:2
// ty::Const
// + ty: ()
// + val: Value(Scalar(<ZST>))
// mir::Constant
// + span: $DIR/array-index-is-temporary.rs:12:11: 17:2
// + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
StorageDead(_3); // scope 2 at $DIR/array-index-is-temporary.rs:17:1: 17:2
StorageDead(_2); // scope 1 at $DIR/array-index-is-temporary.rs:17:1: 17:2
StorageDead(_1); // scope 0 at $DIR/array-index-is-temporary.rs:17:1: 17:2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,6 @@ fn main() -> () {
bb6: {
StorageDead(_6); // scope 4 at $DIR/basic_assignment.rs:23:19: 23:20
_0 = const (); // scope 0 at $DIR/basic_assignment.rs:10:11: 24:2
// ty::Const
// + ty: ()
// + val: Value(Scalar(<ZST>))
// mir::Constant
// + span: $DIR/basic_assignment.rs:10:11: 24:2
// + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
drop(_5) -> [return: bb7, unwind: bb3]; // scope 3 at $DIR/basic_assignment.rs:24:1: 24:2
}

Expand Down
12 changes: 0 additions & 12 deletions src/test/mir-opt/box_expr.main.ElaborateDrops.before.mir
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ fn main() -> () {
StorageLive(_2); // scope 0 at $DIR/box_expr.rs:7:13: 7:25
_2 = Box(S); // scope 0 at $DIR/box_expr.rs:7:13: 7:25
(*_2) = const S::new() -> [return: bb2, unwind: bb3]; // scope 0 at $DIR/box_expr.rs:7:17: 7:25
// ty::Const
// + ty: fn() -> S {S::new}
// + val: Value(Scalar(<ZST>))
// mir::Constant
// + span: $DIR/box_expr.rs:7:17: 7:23
// + literal: Const { ty: fn() -> S {S::new}, val: Value(Scalar(<ZST>)) }
Expand All @@ -42,9 +39,6 @@ fn main() -> () {
StorageLive(_4); // scope 1 at $DIR/box_expr.rs:8:10: 8:11
_4 = move _1; // scope 1 at $DIR/box_expr.rs:8:10: 8:11
_3 = const std::mem::drop::<std::boxed::Box<S>>(move _4) -> [return: bb5, unwind: bb7]; // scope 1 at $DIR/box_expr.rs:8:5: 8:12
// ty::Const
// + ty: fn(std::boxed::Box<S>) {std::mem::drop::<std::boxed::Box<S>>}
// + val: Value(Scalar(<ZST>))
// mir::Constant
// + span: $DIR/box_expr.rs:8:5: 8:9
// + literal: Const { ty: fn(std::boxed::Box<S>) {std::mem::drop::<std::boxed::Box<S>>}, val: Value(Scalar(<ZST>)) }
Expand All @@ -54,12 +48,6 @@ fn main() -> () {
StorageDead(_4); // scope 1 at $DIR/box_expr.rs:8:11: 8:12
StorageDead(_3); // scope 1 at $DIR/box_expr.rs:8:12: 8:13
_0 = const (); // scope 0 at $DIR/box_expr.rs:6:11: 9:2
// ty::Const
// + ty: ()
// + val: Value(Scalar(<ZST>))
// mir::Constant
// + span: $DIR/box_expr.rs:6:11: 9:2
// + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
drop(_1) -> bb8; // scope 0 at $DIR/box_expr.rs:9:1: 9:2
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ fn main() -> () {
StorageLive(_2); // scope 1 at $DIR/byte_slice.rs:6:9: 6:10
_2 = [const 5_u8, const 120_u8]; // scope 1 at $DIR/byte_slice.rs:6:13: 6:24
_0 = const (); // scope 0 at $DIR/byte_slice.rs:4:11: 7:2
// ty::Const
// + ty: ()
// + val: Value(Scalar(<ZST>))
// mir::Constant
// + span: $DIR/byte_slice.rs:4:11: 7:2
// + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
StorageDead(_2); // scope 1 at $DIR/byte_slice.rs:7:1: 7:2
StorageDead(_1); // scope 0 at $DIR/byte_slice.rs:7:1: 7:2
return; // scope 0 at $DIR/byte_slice.rs:7:2: 7:2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@ fn main() -> () {
StorageDead(_2); // scope 0 at $DIR/const_allocation.rs:8:8: 8:9
StorageDead(_1); // scope 0 at $DIR/const_allocation.rs:8:8: 8:9
_0 = const (); // scope 0 at $DIR/const_allocation.rs:7:11: 9:2
// ty::Const
// + ty: ()
// + val: Value(Scalar(<ZST>))
// mir::Constant
// + span: $DIR/const_allocation.rs:7:11: 9:2
// + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
return; // scope 0 at $DIR/const_allocation.rs:9:2: 9:2
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@ fn main() -> () {
StorageDead(_2); // scope 0 at $DIR/const_allocation.rs:8:8: 8:9
StorageDead(_1); // scope 0 at $DIR/const_allocation.rs:8:8: 8:9
_0 = const (); // scope 0 at $DIR/const_allocation.rs:7:11: 9:2
// ty::Const
// + ty: ()
// + val: Value(Scalar(<ZST>))
// mir::Constant
// + span: $DIR/const_allocation.rs:7:11: 9:2
// + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
return; // scope 0 at $DIR/const_allocation.rs:9:2: 9:2
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@ fn main() -> () {
StorageDead(_2); // scope 0 at $DIR/const_allocation2.rs:5:8: 5:9
StorageDead(_1); // scope 0 at $DIR/const_allocation2.rs:5:8: 5:9
_0 = const (); // scope 0 at $DIR/const_allocation2.rs:4:11: 6:2
// ty::Const
// + ty: ()
// + val: Value(Scalar(<ZST>))
// mir::Constant
// + span: $DIR/const_allocation2.rs:4:11: 6:2
// + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
return; // scope 0 at $DIR/const_allocation2.rs:6:2: 6:2
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@ fn main() -> () {
StorageDead(_2); // scope 0 at $DIR/const_allocation2.rs:5:8: 5:9
StorageDead(_1); // scope 0 at $DIR/const_allocation2.rs:5:8: 5:9
_0 = const (); // scope 0 at $DIR/const_allocation2.rs:4:11: 6:2
// ty::Const
// + ty: ()
// + val: Value(Scalar(<ZST>))
// mir::Constant
// + span: $DIR/const_allocation2.rs:4:11: 6:2
// + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
return; // scope 0 at $DIR/const_allocation2.rs:6:2: 6:2
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@ fn main() -> () {
StorageDead(_2); // scope 0 at $DIR/const_allocation3.rs:5:8: 5:9
StorageDead(_1); // scope 0 at $DIR/const_allocation3.rs:5:8: 5:9
_0 = const (); // scope 0 at $DIR/const_allocation3.rs:4:11: 6:2
// ty::Const
// + ty: ()
// + val: Value(Scalar(<ZST>))
// mir::Constant
// + span: $DIR/const_allocation3.rs:4:11: 6:2
// + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
return; // scope 0 at $DIR/const_allocation3.rs:6:2: 6:2
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@ fn main() -> () {
StorageDead(_2); // scope 0 at $DIR/const_allocation3.rs:5:8: 5:9
StorageDead(_1); // scope 0 at $DIR/const_allocation3.rs:5:8: 5:9
_0 = const (); // scope 0 at $DIR/const_allocation3.rs:4:11: 6:2
// ty::Const
// + ty: ()
// + val: Value(Scalar(<ZST>))
// mir::Constant
// + span: $DIR/const_allocation3.rs:4:11: 6:2
// + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
return; // scope 0 at $DIR/const_allocation3.rs:6:2: 6:2
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@
+ _2 = &(*_6); // scope 0 at $DIR/const-promotion-extern-static.rs:9:31: 9:35
_1 = move _2 as &[&i32] (Pointer(Unsize)); // scope 0 at $DIR/const-promotion-extern-static.rs:9:31: 9:35
_0 = const core::slice::<impl [&i32]>::as_ptr(move _1) -> [return: bb2, unwind: bb1]; // scope 0 at $DIR/const-promotion-extern-static.rs:9:31: 9:44
// ty::Const
// + ty: for<'r> fn(&'r [&i32]) -> *const &i32 {core::slice::<impl [&i32]>::as_ptr}
// + val: Value(Scalar(<ZST>))
// mir::Constant
// + span: $DIR/const-promotion-extern-static.rs:9:36: 9:42
// + literal: Const { ty: for<'r> fn(&'r [&i32]) -> *const &i32 {core::slice::<impl [&i32]>::as_ptr}, val: Value(Scalar(<ZST>)) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@
+ _2 = &(*_6); // scope 0 at $DIR/const-promotion-extern-static.rs:13:31: 13:46
_1 = move _2 as &[&i32] (Pointer(Unsize)); // scope 0 at $DIR/const-promotion-extern-static.rs:13:31: 13:46
_0 = const core::slice::<impl [&i32]>::as_ptr(move _1) -> [return: bb2, unwind: bb1]; // scope 0 at $DIR/const-promotion-extern-static.rs:13:31: 13:55
// ty::Const
// + ty: for<'r> fn(&'r [&i32]) -> *const &i32 {core::slice::<impl [&i32]>::as_ptr}
// + val: Value(Scalar(<ZST>))
// mir::Constant
// + span: $DIR/const-promotion-extern-static.rs:13:47: 13:53
// + literal: Const { ty: for<'r> fn(&'r [&i32]) -> *const &i32 {core::slice::<impl [&i32]>::as_ptr}, val: Value(Scalar(<ZST>)) }
Expand Down
6 changes: 0 additions & 6 deletions src/test/mir-opt/const_prop/aggregate.main.ConstProp.diff
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@
StorageDead(_2); // scope 0 at $DIR/aggregate.rs:5:27: 5:28
StorageDead(_3); // scope 0 at $DIR/aggregate.rs:5:28: 5:29
_0 = const (); // scope 0 at $DIR/aggregate.rs:4:11: 6:2
// ty::Const
// + ty: ()
// + val: Value(Scalar(<ZST>))
// mir::Constant
// + span: $DIR/aggregate.rs:4:11: 6:2
// + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
StorageDead(_1); // scope 0 at $DIR/aggregate.rs:6:1: 6:2
return; // scope 0 at $DIR/aggregate.rs:6:2: 6:2
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@
StorageDead(_3); // scope 0 at $DIR/array_index.rs:5:33: 5:34
StorageDead(_2); // scope 0 at $DIR/array_index.rs:5:33: 5:34
_0 = const (); // scope 0 at $DIR/array_index.rs:4:11: 6:2
// ty::Const
// + ty: ()
// + val: Value(Scalar(<ZST>))
// mir::Constant
// + span: $DIR/array_index.rs:4:11: 6:2
// + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
StorageDead(_1); // scope 0 at $DIR/array_index.rs:6:1: 6:2
return; // scope 0 at $DIR/array_index.rs:6:2: 6:2
}
Expand Down
Loading