Skip to content

Suppress MIR comments on unit type constants #75730

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

Closed
wants to merge 3 commits into from
Closed
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
4 changes: 4 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,8 @@ 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() => {}
_ => {
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 @@ -59,12 +59,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 @@ -59,12 +59,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
6 changes: 0 additions & 6 deletions src/test/mir-opt/box_expr.main.ElaborateDrops.before.mir
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,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
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
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
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,6 @@
+ _2 = Div(const 1_i32, const 0_i32); // scope 1 at $DIR/bad_op_div_by_zero.rs:5:14: 5:19
StorageDead(_3); // scope 1 at $DIR/bad_op_div_by_zero.rs:5:18: 5:19
_0 = const (); // scope 0 at $DIR/bad_op_div_by_zero.rs:3:11: 6:2
// ty::Const
// + ty: ()
// + val: Value(Scalar(<ZST>))
// mir::Constant
// + span: $DIR/bad_op_div_by_zero.rs:3:11: 6:2
// + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
StorageDead(_2); // scope 1 at $DIR/bad_op_div_by_zero.rs:6:1: 6:2
StorageDead(_1); // scope 0 at $DIR/bad_op_div_by_zero.rs:6:1: 6:2
return; // scope 0 at $DIR/bad_op_div_by_zero.rs:6:2: 6:2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,6 @@
+ _2 = Rem(const 1_i32, const 0_i32); // scope 1 at $DIR/bad_op_mod_by_zero.rs:5:14: 5:19
StorageDead(_3); // scope 1 at $DIR/bad_op_mod_by_zero.rs:5:18: 5:19
_0 = const (); // scope 0 at $DIR/bad_op_mod_by_zero.rs:3:11: 6:2
// ty::Const
// + ty: ()
// + val: Value(Scalar(<ZST>))
// mir::Constant
// + span: $DIR/bad_op_mod_by_zero.rs:3:11: 6:2
// + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
StorageDead(_2); // scope 1 at $DIR/bad_op_mod_by_zero.rs:6:1: 6:2
StorageDead(_1); // scope 0 at $DIR/bad_op_mod_by_zero.rs:6:1: 6:2
return; // scope 0 at $DIR/bad_op_mod_by_zero.rs:6:2: 6:2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,6 @@
_5 = (*_1)[_6]; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:7:18: 7:25
StorageDead(_6); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:7:25: 7:26
_0 = const (); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:6:5: 8:6
// ty::Const
// + ty: ()
// + val: Value(Scalar(<ZST>))
// mir::Constant
// + span: $DIR/bad_op_unsafe_oob_for_slices.rs:6:5: 8:6
// + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
StorageDead(_5); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:8:5: 8:6
StorageDead(_1); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:9:1: 9:2
return; // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:9:2: 9:2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,6 @@
_5 = (*_1)[_6]; // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:7:18: 7:25
StorageDead(_6); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:7:25: 7:26
_0 = const (); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:6:5: 8:6
// ty::Const
// + ty: ()
// + val: Value(Scalar(<ZST>))
// mir::Constant
// + span: $DIR/bad_op_unsafe_oob_for_slices.rs:6:5: 8:6
// + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
StorageDead(_5); // scope 2 at $DIR/bad_op_unsafe_oob_for_slices.rs:8:5: 8:6
StorageDead(_1); // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:9:1: 9:2
return; // scope 0 at $DIR/bad_op_unsafe_oob_for_slices.rs:9:2: 9:2
Expand Down
Loading