Skip to content

Commit 24bdc6d

Browse files
committed
Auto merge of #86240 - tmiasko:verbose-generator-witness, r=jackh726
Pretty print generator witness only in `-Zverbose` mode In release build of deeply-nested-async benchmark the size of `no-opt.bc` file is reduced from 46MB to 62kB. Helps with #84873, where in one of reported test cases the size of `no-opt.bc` file is reduced from 2.3GB to 799kB.
2 parents da7ada5 + 06ca736 commit 24bdc6d

11 files changed

+29
-29
lines changed

compiler/rustc_middle/src/ty/print/pretty.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -685,10 +685,10 @@ pub trait PrettyPrinter<'tcx>:
685685
self = self.comma_sep(substs.as_generator().upvar_tys())?;
686686
}
687687
p!(")");
688-
}
689688

690-
if substs.as_generator().is_valid() {
691-
p!(" ", print(substs.as_generator().witness()));
689+
if substs.as_generator().is_valid() {
690+
p!(" ", print(substs.as_generator().witness()));
691+
}
692692
}
693693

694694
p!("]")

src/test/mir-opt/generator_drop_cleanup.main-{closure#0}.generator_drop.0.mir

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
},
1515
} */
1616

17-
fn main::{closure#0}(_1: *mut [generator@$DIR/generator-drop-cleanup.rs:10:15: 13:6 {String, ()}]) -> () {
17+
fn main::{closure#0}(_1: *mut [generator@$DIR/generator-drop-cleanup.rs:10:15: 13:6]) -> () {
1818
let mut _0: (); // return place in scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 13:6
1919
let mut _2: (); // in scope 0 at $DIR/generator-drop-cleanup.rs:10:15: 13:6
2020
let _3: std::string::String; // in scope 0 at $DIR/generator-drop-cleanup.rs:11:13: 11:15

src/test/mir-opt/generator_storage_dead_unwind.main-{closure#0}.StateTransform.before.mir

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// MIR for `main::{closure#0}` before StateTransform
22

3-
fn main::{closure#0}(_1: [generator@$DIR/generator-storage-dead-unwind.rs:22:16: 28:6 {Foo, Bar, ()}], _2: ()) -> ()
3+
fn main::{closure#0}(_1: [generator@$DIR/generator-storage-dead-unwind.rs:22:16: 28:6], _2: ()) -> ()
44
yields ()
55
{
66
let mut _0: (); // return place in scope 0 at $DIR/generator-storage-dead-unwind.rs:22:19: 22:19

src/test/mir-opt/generator_tiny.main-{closure#0}.generator_resume.0.mir

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
storage_conflicts: BitMatrix(0x0) {},
1111
} */
1212

13-
fn main::{closure#0}(_1: Pin<&mut [generator@$DIR/generator-tiny.rs:19:16: 25:6 {u8, HasDrop, ()}]>, _2: u8) -> GeneratorState<(), ()> {
13+
fn main::{closure#0}(_1: Pin<&mut [generator@$DIR/generator-tiny.rs:19:16: 25:6]>, _2: u8) -> GeneratorState<(), ()> {
1414
debug _x => _10; // in scope 0 at $DIR/generator-tiny.rs:19:17: 19:19
1515
let mut _0: std::ops::GeneratorState<(), ()>; // return place in scope 0 at $DIR/generator-tiny.rs:19:16: 25:6
1616
let _3: HasDrop; // in scope 0 at $DIR/generator-tiny.rs:20:13: 20:15
@@ -27,7 +27,7 @@ fn main::{closure#0}(_1: Pin<&mut [generator@$DIR/generator-tiny.rs:19:16: 25:6
2727
}
2828

2929
bb0: {
30-
_11 = discriminant((*(_1.0: &mut [generator@$DIR/generator-tiny.rs:19:16: 25:6 {u8, HasDrop, ()}]))); // scope 0 at $DIR/generator-tiny.rs:19:16: 25:6
30+
_11 = discriminant((*(_1.0: &mut [generator@$DIR/generator-tiny.rs:19:16: 25:6]))); // scope 0 at $DIR/generator-tiny.rs:19:16: 25:6
3131
switchInt(move _11) -> [0_u32: bb1, 3_u32: bb5, otherwise: bb6]; // scope 0 at $DIR/generator-tiny.rs:19:16: 25:6
3232
}
3333

@@ -43,7 +43,7 @@ fn main::{closure#0}(_1: Pin<&mut [generator@$DIR/generator-tiny.rs:19:16: 25:6
4343
StorageLive(_7); // scope 1 at $DIR/generator-tiny.rs:22:13: 22:18
4444
((_0 as Yielded).0: ()) = move _7; // scope 1 at $DIR/generator-tiny.rs:22:13: 22:18
4545
discriminant(_0) = 0; // scope 1 at $DIR/generator-tiny.rs:22:13: 22:18
46-
discriminant((*(_1.0: &mut [generator@$DIR/generator-tiny.rs:19:16: 25:6 {u8, HasDrop, ()}]))) = 3; // scope 1 at $DIR/generator-tiny.rs:22:13: 22:18
46+
discriminant((*(_1.0: &mut [generator@$DIR/generator-tiny.rs:19:16: 25:6]))) = 3; // scope 1 at $DIR/generator-tiny.rs:22:13: 22:18
4747
return; // scope 1 at $DIR/generator-tiny.rs:22:13: 22:18
4848
}
4949

src/test/mir-opt/inline/inline_generator.main.Inline.diff

+8-8
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
}
1414
+ scope 2 (inlined g) { // at $DIR/inline-generator.rs:9:28: 9:31
1515
+ }
16-
+ scope 3 (inlined Pin::<&mut [generator@$DIR/inline-generator.rs:15:5: 15:41 {bool, i32}]>::new) { // at $DIR/inline-generator.rs:9:14: 9:32
16+
+ scope 3 (inlined Pin::<&mut [generator@$DIR/inline-generator.rs:15:5: 15:41]>::new) { // at $DIR/inline-generator.rs:9:14: 9:32
1717
+ debug pointer => _3; // in scope 3 at $DIR/inline-generator.rs:9:14: 9:32
18-
+ let mut _5: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41 {bool, i32}]; // in scope 3 at $DIR/inline-generator.rs:9:14: 9:32
18+
+ let mut _5: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41]; // in scope 3 at $DIR/inline-generator.rs:9:14: 9:32
1919
+ scope 4 {
20-
+ scope 5 (inlined Pin::<&mut [generator@$DIR/inline-generator.rs:15:5: 15:41 {bool, i32}]>::new_unchecked) { // at $DIR/inline-generator.rs:9:14: 9:32
20+
+ scope 5 (inlined Pin::<&mut [generator@$DIR/inline-generator.rs:15:5: 15:41]>::new_unchecked) { // at $DIR/inline-generator.rs:9:14: 9:32
2121
+ debug pointer => _5; // in scope 5 at $DIR/inline-generator.rs:9:14: 9:32
22-
+ let mut _6: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41 {bool, i32}]; // in scope 5 at $DIR/inline-generator.rs:9:14: 9:32
22+
+ let mut _6: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41]; // in scope 5 at $DIR/inline-generator.rs:9:14: 9:32
2323
+ }
2424
+ }
2525
+ }
@@ -58,7 +58,7 @@
5858
+ _5 = move _3; // scope 4 at $DIR/inline-generator.rs:9:14: 9:32
5959
+ StorageLive(_6); // scope 5 at $DIR/inline-generator.rs:9:14: 9:32
6060
+ _6 = move _5; // scope 5 at $DIR/inline-generator.rs:9:14: 9:32
61-
+ (_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41 {bool, i32}]) = move _6; // scope 5 at $DIR/inline-generator.rs:9:14: 9:32
61+
+ (_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41]) = move _6; // scope 5 at $DIR/inline-generator.rs:9:14: 9:32
6262
+ StorageDead(_6); // scope 5 at $DIR/inline-generator.rs:9:14: 9:32
6363
+ StorageDead(_5); // scope 4 at $DIR/inline-generator.rs:9:14: 9:32
6464
StorageDead(_3); // scope 0 at $DIR/inline-generator.rs:9:31: 9:32
@@ -71,7 +71,7 @@
7171
+ StorageLive(_10); // scope 0 at $DIR/inline-generator.rs:9:14: 9:46
7272
+ StorageLive(_11); // scope 0 at $DIR/inline-generator.rs:9:14: 9:46
7373
+ StorageLive(_12); // scope 0 at $DIR/inline-generator.rs:9:14: 9:46
74-
+ _12 = discriminant((*(_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41 {bool, i32}]))); // scope 6 at $DIR/inline-generator.rs:9:14: 9:46
74+
+ _12 = discriminant((*(_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41]))); // scope 6 at $DIR/inline-generator.rs:9:14: 9:46
7575
+ switchInt(move _12) -> [0_u32: bb3, 1_u32: bb8, 3_u32: bb7, otherwise: bb9]; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46
7676
}
7777

@@ -115,7 +115,7 @@
115115
+ StorageDead(_9); // scope 6 at $DIR/inline-generator.rs:9:14: 9:46
116116
+ ((_1 as Yielded).0: i32) = move _8; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46
117117
+ discriminant(_1) = 0; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46
118-
+ discriminant((*(_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41 {bool, i32}]))) = 3; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46
118+
+ discriminant((*(_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41]))) = 3; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46
119119
+ goto -> bb1; // scope 0 at $DIR/inline-generator.rs:15:11: 15:39
120120
+ }
121121
+
@@ -125,7 +125,7 @@
125125
+ StorageDead(_8); // scope 6 at $DIR/inline-generator.rs:9:14: 9:46
126126
+ ((_1 as Complete).0: bool) = move _10; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46
127127
+ discriminant(_1) = 1; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46
128-
+ discriminant((*(_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41 {bool, i32}]))) = 1; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46
128+
+ discriminant((*(_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41]))) = 1; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46
129129
+ goto -> bb1; // scope 0 at $DIR/inline-generator.rs:15:41: 15:41
130130
+ }
131131
+

src/test/ui/async-await/issue-68112.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ LL | require_send(send_fut);
4141
|
4242
= help: the trait `Sync` is not implemented for `RefCell<i32>`
4343
= note: required because of the requirements on the impl of `Send` for `Arc<RefCell<i32>>`
44-
= note: required because it appears within the type `[static generator@$DIR/issue-68112.rs:47:31: 47:36 {}]`
45-
= note: required because it appears within the type `from_generator::GenFuture<[static generator@$DIR/issue-68112.rs:47:31: 47:36 {}]>`
44+
= note: required because it appears within the type `[static generator@$DIR/issue-68112.rs:47:31: 47:36]`
45+
= note: required because it appears within the type `from_generator::GenFuture<[static generator@$DIR/issue-68112.rs:47:31: 47:36]>`
4646
= note: required because it appears within the type `impl Future`
4747
= note: required because it appears within the type `impl Future`
4848
= note: required because it appears within the type `impl Future`
4949
= note: required because it appears within the type `{ResumeTy, impl Future, (), i32, Ready<i32>}`
50-
= note: required because it appears within the type `[static generator@$DIR/issue-68112.rs:55:26: 59:6 {ResumeTy, impl Future, (), i32, Ready<i32>}]`
51-
= note: required because it appears within the type `from_generator::GenFuture<[static generator@$DIR/issue-68112.rs:55:26: 59:6 {ResumeTy, impl Future, (), i32, Ready<i32>}]>`
50+
= note: required because it appears within the type `[static generator@$DIR/issue-68112.rs:55:26: 59:6]`
51+
= note: required because it appears within the type `from_generator::GenFuture<[static generator@$DIR/issue-68112.rs:55:26: 59:6]>`
5252
= note: required because it appears within the type `impl Future`
5353

5454
error: aborting due to 3 previous errors

src/test/ui/async-await/issues/issue-67893.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ LL | pub async fn run() {
1414
|
1515
= help: within `impl Future`, the trait `Send` is not implemented for `MutexGuard<'_, ()>`
1616
= note: required because it appears within the type `for<'r, 's, 't0, 't1, 't2, 't3> {ResumeTy, Arc<Mutex<()>>, &'r Mutex<()>, Result<MutexGuard<'s, ()>, PoisonError<MutexGuard<'t0, ()>>>, &'t1 MutexGuard<'t2, ()>, MutexGuard<'t3, ()>, (), impl Future}`
17-
= note: required because it appears within the type `[static generator@run::{closure#0} for<'r, 's, 't0, 't1, 't2, 't3> {ResumeTy, Arc<Mutex<()>>, &'r Mutex<()>, Result<MutexGuard<'s, ()>, PoisonError<MutexGuard<'t0, ()>>>, &'t1 MutexGuard<'t2, ()>, MutexGuard<'t3, ()>, (), impl Future}]`
18-
= note: required because it appears within the type `from_generator::GenFuture<[static generator@run::{closure#0} for<'r, 's, 't0, 't1, 't2, 't3> {ResumeTy, Arc<Mutex<()>>, &'r Mutex<()>, Result<MutexGuard<'s, ()>, PoisonError<MutexGuard<'t0, ()>>>, &'t1 MutexGuard<'t2, ()>, MutexGuard<'t3, ()>, (), impl Future}]>`
17+
= note: required because it appears within the type `[static generator@run::{closure#0}]`
18+
= note: required because it appears within the type `from_generator::GenFuture<[static generator@run::{closure#0}]>`
1919
= note: required because it appears within the type `impl Future`
2020
= note: required because it appears within the type `impl Future`
2121

src/test/ui/generator/issue-68112.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ LL | require_send(send_gen);
2929
|
3030
= help: the trait `Sync` is not implemented for `RefCell<i32>`
3131
= note: required because of the requirements on the impl of `Send` for `Arc<RefCell<i32>>`
32-
= note: required because it appears within the type `[generator@$DIR/issue-68112.rs:38:5: 41:6 {()}]`
32+
= note: required because it appears within the type `[generator@$DIR/issue-68112.rs:38:5: 41:6]`
3333
= note: required because it appears within the type `impl Generator`
3434
= note: required because it appears within the type `impl Generator`
3535
= note: required because it appears within the type `{impl Generator, ()}`
36-
= note: required because it appears within the type `[generator@$DIR/issue-68112.rs:48:20: 51:6 {impl Generator, ()}]`
36+
= note: required because it appears within the type `[generator@$DIR/issue-68112.rs:48:20: 51:6]`
3737

3838
error: aborting due to 2 previous errors
3939

src/test/ui/generator/not-send-sync.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ LL | assert_send(|| {
99
|
1010
= help: the trait `Sync` is not implemented for `Cell<i32>`
1111
= note: required because of the requirements on the impl of `Send` for `&Cell<i32>`
12-
= note: required because it appears within the type `[generator@$DIR/not-send-sync.rs:16:17: 20:6 _]`
12+
= note: required because it appears within the type `[generator@$DIR/not-send-sync.rs:16:17: 20:6]`
1313

1414
error: generator cannot be shared between threads safely
1515
--> $DIR/not-send-sync.rs:9:5
@@ -20,7 +20,7 @@ LL | fn assert_sync<T: Sync>(_: T) {}
2020
LL | assert_sync(|| {
2121
| ^^^^^^^^^^^ generator is not `Sync`
2222
|
23-
= help: within `[generator@$DIR/not-send-sync.rs:9:17: 13:6 {Cell<i32>, ()}]`, the trait `Sync` is not implemented for `Cell<i32>`
23+
= help: within `[generator@$DIR/not-send-sync.rs:9:17: 13:6]`, the trait `Sync` is not implemented for `Cell<i32>`
2424
note: generator is not `Sync` as this value is used across a yield
2525
--> $DIR/not-send-sync.rs:12:9
2626
|

src/test/ui/impl-trait/recursive-impl-trait-type-indirect.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ LL | / move || {
9595
LL | | yield;
9696
LL | | x;
9797
LL | | }
98-
| |_____- returning here with type `[generator@$DIR/recursive-impl-trait-type-indirect.rs:61:5: 64:6 {()}]`
98+
| |_____- returning here with type `[generator@$DIR/recursive-impl-trait-type-indirect.rs:61:5: 64:6]`
9999

100100
error[E0720]: cannot resolve opaque type
101101
--> $DIR/recursive-impl-trait-type-indirect.rs:67:35
@@ -117,7 +117,7 @@ LL | | let x = generator_hold();
117117
LL | | yield;
118118
LL | | x;
119119
LL | | }
120-
| |_____- returning here with type `[generator@$DIR/recursive-impl-trait-type-indirect.rs:74:5: 78:6 {impl Sized, ()}]`
120+
| |_____- returning here with type `[generator@$DIR/recursive-impl-trait-type-indirect.rs:74:5: 78:6]`
121121

122122
error[E0720]: cannot resolve opaque type
123123
--> $DIR/recursive-impl-trait-type-indirect.rs:86:26

src/test/ui/suggestions/unnamable-types.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ error: missing type for `const` item
5555
LL | const G = || -> i32 { yield 0; return 1; };
5656
| ^
5757
|
58-
note: however, the inferred type `[generator@$DIR/unnamable-types.rs:37:11: 37:43 {i32, ()}]` cannot be named
58+
note: however, the inferred type `[generator@$DIR/unnamable-types.rs:37:11: 37:43]` cannot be named
5959
--> $DIR/unnamable-types.rs:37:11
6060
|
6161
LL | const G = || -> i32 { yield 0; return 1; };

0 commit comments

Comments
 (0)