Skip to content

Commit 5fff382

Browse files
committed
Auto merge of #75670 - lzutao:suppress-mir-fndef-ty, r=oli-obk
Suppress MIR comments of FnDef and unit types An expansion of #75566. Comments of FnDef MIR constant already contain `ty::Contains` comments.
2 parents 1a22a0f + 86cf461 commit 5fff382

File tree

132 files changed

+45
-1311
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

+45
-1311
lines changed

src/librustc_middle/ty/sty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ pub enum TyKind<'tcx> {
185185
/// After typeck, the concrete type can be found in the `types` map.
186186
Opaque(DefId, SubstsRef<'tcx>),
187187

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

191191
/// Bound type variable, used only when preparing a trait query.

src/librustc_mir/util/pretty.rs

+5
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,8 @@ impl Visitor<'tcx> for ExtraComments<'tcx> {
389389
let Constant { span, user_ty, literal } = constant;
390390
match literal.ty.kind {
391391
ty::Int(_) | ty::Uint(_) | ty::Bool | ty::Char => {}
392+
// Unit type
393+
ty::Tuple(tys) if tys.is_empty() => {}
392394
_ => {
393395
self.push("mir::Constant");
394396
self.push(&format!("+ span: {}", self.tcx.sess.source_map().span_to_string(*span)));
@@ -405,6 +407,9 @@ impl Visitor<'tcx> for ExtraComments<'tcx> {
405407
let ty::Const { ty, val, .. } = constant;
406408
match ty.kind {
407409
ty::Int(_) | ty::Uint(_) | ty::Bool | ty::Char => {}
410+
// Unit type
411+
ty::Tuple(tys) if tys.is_empty() => {}
412+
ty::FnDef(..) => {}
408413
_ => {
409414
self.push("ty::Const");
410415
self.push(&format!("+ ty: {:?}", ty));

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

-6
Original file line numberDiff line numberDiff line change
@@ -287,12 +287,6 @@ fn address_of_reborrow() -> () {
287287
FakeRead(ForLet, _47); // scope 13 at $DIR/address-of.rs:36:9: 36:10
288288
AscribeUserType(_47, o, UserTypeProjection { base: UserType(29), projs: [] }); // scope 13 at $DIR/address-of.rs:36:12: 36:22
289289
_0 = const (); // scope 0 at $DIR/address-of.rs:3:26: 37:2
290-
// ty::Const
291-
// + ty: ()
292-
// + val: Value(Scalar(<ZST>))
293-
// mir::Constant
294-
// + span: $DIR/address-of.rs:3:26: 37:2
295-
// + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
296290
StorageDead(_47); // scope 13 at $DIR/address-of.rs:37:1: 37:2
297291
StorageDead(_45); // scope 12 at $DIR/address-of.rs:37:1: 37:2
298292
StorageDead(_44); // scope 11 at $DIR/address-of.rs:37:1: 37:2

src/test/mir-opt/address_of.borrow_and_cast.SimplifyCfg-initial.after.mir

-6
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,6 @@ fn borrow_and_cast(_1: i32) -> () {
3939
FakeRead(ForLet, _6); // scope 2 at $DIR/address-of.rs:44:9: 44:10
4040
StorageDead(_7); // scope 2 at $DIR/address-of.rs:44:31: 44:32
4141
_0 = const (); // scope 0 at $DIR/address-of.rs:41:32: 45:2
42-
// ty::Const
43-
// + ty: ()
44-
// + val: Value(Scalar(<ZST>))
45-
// mir::Constant
46-
// + span: $DIR/address-of.rs:41:32: 45:2
47-
// + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
4842
StorageDead(_6); // scope 2 at $DIR/address-of.rs:45:1: 45:2
4943
StorageDead(_4); // scope 1 at $DIR/address-of.rs:45:1: 45:2
5044
StorageDead(_2); // scope 0 at $DIR/address-of.rs:45:1: 45:2

src/test/mir-opt/array_index_is_temporary.main.SimplifyCfg-elaborate-drops.after.mir.32bit

-9
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ fn main() -> () {
3737
StorageLive(_6); // scope 4 at $DIR/array-index-is-temporary.rs:16:25: 16:26
3838
_6 = _3; // scope 4 at $DIR/array-index-is-temporary.rs:16:25: 16:26
3939
_5 = const foo(move _6) -> bb1; // scope 4 at $DIR/array-index-is-temporary.rs:16:21: 16:27
40-
// ty::Const
41-
// + ty: unsafe fn(*mut usize) -> u32 {foo}
42-
// + val: Value(Scalar(<ZST>))
4340
// mir::Constant
4441
// + span: $DIR/array-index-is-temporary.rs:16:21: 16:24
4542
// + literal: Const { ty: unsafe fn(*mut usize) -> u32 {foo}, val: Value(Scalar(<ZST>)) }
@@ -59,12 +56,6 @@ fn main() -> () {
5956
StorageDead(_5); // scope 3 at $DIR/array-index-is-temporary.rs:16:28: 16:29
6057
StorageDead(_7); // scope 3 at $DIR/array-index-is-temporary.rs:16:29: 16:30
6158
_0 = const (); // scope 0 at $DIR/array-index-is-temporary.rs:12:11: 17:2
62-
// ty::Const
63-
// + ty: ()
64-
// + val: Value(Scalar(<ZST>))
65-
// mir::Constant
66-
// + span: $DIR/array-index-is-temporary.rs:12:11: 17:2
67-
// + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
6859
StorageDead(_3); // scope 2 at $DIR/array-index-is-temporary.rs:17:1: 17:2
6960
StorageDead(_2); // scope 1 at $DIR/array-index-is-temporary.rs:17:1: 17:2
7061
StorageDead(_1); // scope 0 at $DIR/array-index-is-temporary.rs:17:1: 17:2

src/test/mir-opt/array_index_is_temporary.main.SimplifyCfg-elaborate-drops.after.mir.64bit

-9
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ fn main() -> () {
3737
StorageLive(_6); // scope 4 at $DIR/array-index-is-temporary.rs:16:25: 16:26
3838
_6 = _3; // scope 4 at $DIR/array-index-is-temporary.rs:16:25: 16:26
3939
_5 = const foo(move _6) -> bb1; // scope 4 at $DIR/array-index-is-temporary.rs:16:21: 16:27
40-
// ty::Const
41-
// + ty: unsafe fn(*mut usize) -> u32 {foo}
42-
// + val: Value(Scalar(<ZST>))
4340
// mir::Constant
4441
// + span: $DIR/array-index-is-temporary.rs:16:21: 16:24
4542
// + literal: Const { ty: unsafe fn(*mut usize) -> u32 {foo}, val: Value(Scalar(<ZST>)) }
@@ -59,12 +56,6 @@ fn main() -> () {
5956
StorageDead(_5); // scope 3 at $DIR/array-index-is-temporary.rs:16:28: 16:29
6057
StorageDead(_7); // scope 3 at $DIR/array-index-is-temporary.rs:16:29: 16:30
6158
_0 = const (); // scope 0 at $DIR/array-index-is-temporary.rs:12:11: 17:2
62-
// ty::Const
63-
// + ty: ()
64-
// + val: Value(Scalar(<ZST>))
65-
// mir::Constant
66-
// + span: $DIR/array-index-is-temporary.rs:12:11: 17:2
67-
// + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
6859
StorageDead(_3); // scope 2 at $DIR/array-index-is-temporary.rs:17:1: 17:2
6960
StorageDead(_2); // scope 1 at $DIR/array-index-is-temporary.rs:17:1: 17:2
7061
StorageDead(_1); // scope 0 at $DIR/array-index-is-temporary.rs:17:1: 17:2

src/test/mir-opt/basic_assignment.main.SimplifyCfg-initial.after.mir

-6
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,6 @@ fn main() -> () {
6767
bb6: {
6868
StorageDead(_6); // scope 4 at $DIR/basic_assignment.rs:23:19: 23:20
6969
_0 = const (); // scope 0 at $DIR/basic_assignment.rs:10:11: 24:2
70-
// ty::Const
71-
// + ty: ()
72-
// + val: Value(Scalar(<ZST>))
73-
// mir::Constant
74-
// + span: $DIR/basic_assignment.rs:10:11: 24:2
75-
// + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
7670
drop(_5) -> [return: bb7, unwind: bb3]; // scope 3 at $DIR/basic_assignment.rs:24:1: 24:2
7771
}
7872

src/test/mir-opt/box_expr.main.ElaborateDrops.before.mir

-12
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ fn main() -> () {
1515
StorageLive(_2); // scope 0 at $DIR/box_expr.rs:7:13: 7:25
1616
_2 = Box(S); // scope 0 at $DIR/box_expr.rs:7:13: 7:25
1717
(*_2) = const S::new() -> [return: bb2, unwind: bb3]; // scope 0 at $DIR/box_expr.rs:7:17: 7:25
18-
// ty::Const
19-
// + ty: fn() -> S {S::new}
20-
// + val: Value(Scalar(<ZST>))
2118
// mir::Constant
2219
// + span: $DIR/box_expr.rs:7:17: 7:23
2320
// + literal: Const { ty: fn() -> S {S::new}, val: Value(Scalar(<ZST>)) }
@@ -42,9 +39,6 @@ fn main() -> () {
4239
StorageLive(_4); // scope 1 at $DIR/box_expr.rs:8:10: 8:11
4340
_4 = move _1; // scope 1 at $DIR/box_expr.rs:8:10: 8:11
4441
_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
45-
// ty::Const
46-
// + ty: fn(std::boxed::Box<S>) {std::mem::drop::<std::boxed::Box<S>>}
47-
// + val: Value(Scalar(<ZST>))
4842
// mir::Constant
4943
// + span: $DIR/box_expr.rs:8:5: 8:9
5044
// + literal: Const { ty: fn(std::boxed::Box<S>) {std::mem::drop::<std::boxed::Box<S>>}, val: Value(Scalar(<ZST>)) }
@@ -54,12 +48,6 @@ fn main() -> () {
5448
StorageDead(_4); // scope 1 at $DIR/box_expr.rs:8:11: 8:12
5549
StorageDead(_3); // scope 1 at $DIR/box_expr.rs:8:12: 8:13
5650
_0 = const (); // scope 0 at $DIR/box_expr.rs:6:11: 9:2
57-
// ty::Const
58-
// + ty: ()
59-
// + val: Value(Scalar(<ZST>))
60-
// mir::Constant
61-
// + span: $DIR/box_expr.rs:6:11: 9:2
62-
// + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
6351
drop(_1) -> bb8; // scope 0 at $DIR/box_expr.rs:9:1: 9:2
6452
}
6553

src/test/mir-opt/byte_slice.main.SimplifyCfg-elaborate-drops.after.mir

-6
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,6 @@ fn main() -> () {
2323
StorageLive(_2); // scope 1 at $DIR/byte_slice.rs:6:9: 6:10
2424
_2 = [const 5_u8, const 120_u8]; // scope 1 at $DIR/byte_slice.rs:6:13: 6:24
2525
_0 = const (); // scope 0 at $DIR/byte_slice.rs:4:11: 7:2
26-
// ty::Const
27-
// + ty: ()
28-
// + val: Value(Scalar(<ZST>))
29-
// mir::Constant
30-
// + span: $DIR/byte_slice.rs:4:11: 7:2
31-
// + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
3226
StorageDead(_2); // scope 1 at $DIR/byte_slice.rs:7:1: 7:2
3327
StorageDead(_1); // scope 0 at $DIR/byte_slice.rs:7:1: 7:2
3428
return; // scope 0 at $DIR/byte_slice.rs:7:2: 7:2

src/test/mir-opt/const_allocation.main.ConstProp.after.mir.32bit

-6
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,6 @@ fn main() -> () {
1919
StorageDead(_2); // scope 0 at $DIR/const_allocation.rs:8:8: 8:9
2020
StorageDead(_1); // scope 0 at $DIR/const_allocation.rs:8:8: 8:9
2121
_0 = const (); // scope 0 at $DIR/const_allocation.rs:7:11: 9:2
22-
// ty::Const
23-
// + ty: ()
24-
// + val: Value(Scalar(<ZST>))
25-
// mir::Constant
26-
// + span: $DIR/const_allocation.rs:7:11: 9:2
27-
// + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
2822
return; // scope 0 at $DIR/const_allocation.rs:9:2: 9:2
2923
}
3024
}

src/test/mir-opt/const_allocation.main.ConstProp.after.mir.64bit

-6
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,6 @@ fn main() -> () {
1919
StorageDead(_2); // scope 0 at $DIR/const_allocation.rs:8:8: 8:9
2020
StorageDead(_1); // scope 0 at $DIR/const_allocation.rs:8:8: 8:9
2121
_0 = const (); // scope 0 at $DIR/const_allocation.rs:7:11: 9:2
22-
// ty::Const
23-
// + ty: ()
24-
// + val: Value(Scalar(<ZST>))
25-
// mir::Constant
26-
// + span: $DIR/const_allocation.rs:7:11: 9:2
27-
// + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
2822
return; // scope 0 at $DIR/const_allocation.rs:9:2: 9:2
2923
}
3024
}

src/test/mir-opt/const_allocation2.main.ConstProp.after.mir.32bit

-6
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,6 @@ fn main() -> () {
1919
StorageDead(_2); // scope 0 at $DIR/const_allocation2.rs:5:8: 5:9
2020
StorageDead(_1); // scope 0 at $DIR/const_allocation2.rs:5:8: 5:9
2121
_0 = const (); // scope 0 at $DIR/const_allocation2.rs:4:11: 6:2
22-
// ty::Const
23-
// + ty: ()
24-
// + val: Value(Scalar(<ZST>))
25-
// mir::Constant
26-
// + span: $DIR/const_allocation2.rs:4:11: 6:2
27-
// + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
2822
return; // scope 0 at $DIR/const_allocation2.rs:6:2: 6:2
2923
}
3024
}

src/test/mir-opt/const_allocation2.main.ConstProp.after.mir.64bit

-6
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,6 @@ fn main() -> () {
1919
StorageDead(_2); // scope 0 at $DIR/const_allocation2.rs:5:8: 5:9
2020
StorageDead(_1); // scope 0 at $DIR/const_allocation2.rs:5:8: 5:9
2121
_0 = const (); // scope 0 at $DIR/const_allocation2.rs:4:11: 6:2
22-
// ty::Const
23-
// + ty: ()
24-
// + val: Value(Scalar(<ZST>))
25-
// mir::Constant
26-
// + span: $DIR/const_allocation2.rs:4:11: 6:2
27-
// + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
2822
return; // scope 0 at $DIR/const_allocation2.rs:6:2: 6:2
2923
}
3024
}

src/test/mir-opt/const_allocation3.main.ConstProp.after.mir.32bit

-6
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,6 @@ fn main() -> () {
1919
StorageDead(_2); // scope 0 at $DIR/const_allocation3.rs:5:8: 5:9
2020
StorageDead(_1); // scope 0 at $DIR/const_allocation3.rs:5:8: 5:9
2121
_0 = const (); // scope 0 at $DIR/const_allocation3.rs:4:11: 6:2
22-
// ty::Const
23-
// + ty: ()
24-
// + val: Value(Scalar(<ZST>))
25-
// mir::Constant
26-
// + span: $DIR/const_allocation3.rs:4:11: 6:2
27-
// + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
2822
return; // scope 0 at $DIR/const_allocation3.rs:6:2: 6:2
2923
}
3024
}

src/test/mir-opt/const_allocation3.main.ConstProp.after.mir.64bit

-6
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,6 @@ fn main() -> () {
1919
StorageDead(_2); // scope 0 at $DIR/const_allocation3.rs:5:8: 5:9
2020
StorageDead(_1); // scope 0 at $DIR/const_allocation3.rs:5:8: 5:9
2121
_0 = const (); // scope 0 at $DIR/const_allocation3.rs:4:11: 6:2
22-
// ty::Const
23-
// + ty: ()
24-
// + val: Value(Scalar(<ZST>))
25-
// mir::Constant
26-
// + span: $DIR/const_allocation3.rs:4:11: 6:2
27-
// + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
2822
return; // scope 0 at $DIR/const_allocation3.rs:6:2: 6:2
2923
}
3024
}

src/test/mir-opt/const_promotion_extern_static.BAR.PromoteTemps.diff

-3
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@
3434
+ _2 = &(*_6); // scope 0 at $DIR/const-promotion-extern-static.rs:9:31: 9:35
3535
_1 = move _2 as &[&i32] (Pointer(Unsize)); // scope 0 at $DIR/const-promotion-extern-static.rs:9:31: 9:35
3636
_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
37-
// ty::Const
38-
// + ty: for<'r> fn(&'r [&i32]) -> *const &i32 {core::slice::<impl [&i32]>::as_ptr}
39-
// + val: Value(Scalar(<ZST>))
4037
// mir::Constant
4138
// + span: $DIR/const-promotion-extern-static.rs:9:36: 9:42
4239
// + literal: Const { ty: for<'r> fn(&'r [&i32]) -> *const &i32 {core::slice::<impl [&i32]>::as_ptr}, val: Value(Scalar(<ZST>)) }

src/test/mir-opt/const_promotion_extern_static.FOO.PromoteTemps.diff

-3
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@
3636
+ _2 = &(*_6); // scope 0 at $DIR/const-promotion-extern-static.rs:13:31: 13:46
3737
_1 = move _2 as &[&i32] (Pointer(Unsize)); // scope 0 at $DIR/const-promotion-extern-static.rs:13:31: 13:46
3838
_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
39-
// ty::Const
40-
// + ty: for<'r> fn(&'r [&i32]) -> *const &i32 {core::slice::<impl [&i32]>::as_ptr}
41-
// + val: Value(Scalar(<ZST>))
4239
// mir::Constant
4340
// + span: $DIR/const-promotion-extern-static.rs:13:47: 13:53
4441
// + literal: Const { ty: for<'r> fn(&'r [&i32]) -> *const &i32 {core::slice::<impl [&i32]>::as_ptr}, val: Value(Scalar(<ZST>)) }

src/test/mir-opt/const_prop/aggregate.main.ConstProp.diff

-6
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,6 @@
2424
StorageDead(_2); // scope 0 at $DIR/aggregate.rs:5:27: 5:28
2525
StorageDead(_3); // scope 0 at $DIR/aggregate.rs:5:28: 5:29
2626
_0 = const (); // scope 0 at $DIR/aggregate.rs:4:11: 6:2
27-
// ty::Const
28-
// + ty: ()
29-
// + val: Value(Scalar(<ZST>))
30-
// mir::Constant
31-
// + span: $DIR/aggregate.rs:4:11: 6:2
32-
// + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
3327
StorageDead(_1); // scope 0 at $DIR/aggregate.rs:6:1: 6:2
3428
return; // scope 0 at $DIR/aggregate.rs:6:2: 6:2
3529
}

src/test/mir-opt/const_prop/array_index.main.ConstProp.diff.32bit

-6
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,6 @@
3131
StorageDead(_3); // scope 0 at $DIR/array_index.rs:5:33: 5:34
3232
StorageDead(_2); // scope 0 at $DIR/array_index.rs:5:33: 5:34
3333
_0 = const (); // scope 0 at $DIR/array_index.rs:4:11: 6:2
34-
// ty::Const
35-
// + ty: ()
36-
// + val: Value(Scalar(<ZST>))
37-
// mir::Constant
38-
// + span: $DIR/array_index.rs:4:11: 6:2
39-
// + literal: Const { ty: (), val: Value(Scalar(<ZST>)) }
4034
StorageDead(_1); // scope 0 at $DIR/array_index.rs:6:1: 6:2
4135
return; // scope 0 at $DIR/array_index.rs:6:2: 6:2
4236
}

0 commit comments

Comments
 (0)