Skip to content

Commit d9d80be

Browse files
committed
adjust how closure/generator types are printed
1 parent 5ede940 commit d9d80be

12 files changed

+14
-14
lines changed

Diff for: compiler/rustc_infer/src/infer/error_reporting/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1616,7 +1616,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
16161616
// | expected `()`, found closure
16171617
// |
16181618
// = note: expected unit type `()`
1619-
// found closure `[closure@$DIR/issue-20862.rs:2:5: 2:14 x:_]`
1619+
// found closure `{closure@$DIR/issue-20862.rs:2:5: 2:14 x:_}`
16201620
//
16211621
// Also ignore opaque `Future`s that come from async fns.
16221622
if !self.ignore_span.overlaps(span)

Diff for: compiler/rustc_middle/src/mir/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -2174,11 +2174,11 @@ impl<'tcx> Debug for Rvalue<'tcx> {
21742174
AggregateKind::Closure(def_id, args) => ty::tls::with(|tcx| {
21752175
let name = if tcx.sess.opts.unstable_opts.span_free_formats {
21762176
let args = tcx.lift(args).unwrap();
2177-
format!("[closure@{}]", tcx.def_path_str_with_args(def_id, args),)
2177+
format!("{{closure@{}}}", tcx.def_path_str_with_args(def_id, args),)
21782178
} else {
21792179
let span = tcx.def_span(def_id);
21802180
format!(
2181-
"[closure@{}]",
2181+
"{{closure@{}}}",
21822182
tcx.sess.source_map().span_to_diagnostic_string(span)
21832183
)
21842184
};
@@ -2202,7 +2202,7 @@ impl<'tcx> Debug for Rvalue<'tcx> {
22022202
}),
22032203

22042204
AggregateKind::Generator(def_id, _, _) => ty::tls::with(|tcx| {
2205-
let name = format!("[generator@{:?}]", tcx.def_span(def_id));
2205+
let name = format!("{{generator@{:?}}}", tcx.def_span(def_id));
22062206
let mut struct_fmt = fmt.debug_struct(&name);
22072207

22082208
// FIXME(project-rfc-2229#48): This should be a list of capture names/places

Diff for: compiler/rustc_middle/src/ty/print/pretty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1063,7 +1063,7 @@ pub trait PrettyPrinter<'tcx>:
10631063
}
10641064

10651065
for (assoc_item_def_id, term) in assoc_items {
1066-
// Skip printing `<[generator@] as Generator<_>>::Return` from async blocks,
1066+
// Skip printing `<{generator@} as Generator<_>>::Return` from async blocks,
10671067
// unless we can find out what generator return type it comes from.
10681068
let term = if let Some(ty) = term.skip_binder().ty()
10691069
&& let ty::Alias(ty::Projection, proj) = ty.kind()

Diff for: compiler/rustc_middle/src/ty/sty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2536,7 +2536,7 @@ impl<'tcx> Ty<'tcx> {
25362536

25372537
/// Checks whether a type recursively contains any closure
25382538
///
2539-
/// Example: `Option<[closure@file.rs:4:20]>` returns true
2539+
/// Example: `Option<{closure@file.rs:4:20}>` returns true
25402540
pub fn contains_closure(self) -> bool {
25412541
struct ContainsClosureVisitor;
25422542

Diff for: tests/mir-opt/inline/inline_closure.foo.Inline.after.mir

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ fn foo(_1: T, _2: i32) -> i32 {
2121

2222
bb0: {
2323
StorageLive(_3);
24-
_3 = [closure@foo::<T>::{closure#0}];
24+
_3 = {closure@foo::<T>::{closure#0}};
2525
StorageLive(_4);
2626
_4 = &_3;
2727
StorageLive(_5);

Diff for: tests/mir-opt/inline/inline_closure_borrows_arg.foo.Inline.after.mir

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ fn foo(_1: T, _2: &i32) -> i32 {
2424

2525
bb0: {
2626
StorageLive(_3);
27-
_3 = [closure@foo::<T>::{closure#0}];
27+
_3 = {closure@foo::<T>::{closure#0}};
2828
StorageLive(_4);
2929
_4 = &_3;
3030
StorageLive(_5);

Diff for: tests/mir-opt/inline/inline_closure_captures.foo.Inline.after.mir

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ fn foo(_1: T, _2: i32) -> (i32, T) {
3030
_4 = &_2;
3131
StorageLive(_5);
3232
_5 = &_1;
33-
_3 = [closure@foo::<T>::{closure#0}] { q: move _4, t: move _5 };
33+
_3 = {closure@foo::<T>::{closure#0}} { q: move _4, t: move _5 };
3434
StorageDead(_5);
3535
StorageDead(_4);
3636
StorageLive(_6);

Diff for: tests/mir-opt/inline/inline_generator.main.Inline.panic-abort.diff

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
- }
4040
-
4141
- bb1: {
42-
+ _4 = [generator@$DIR/inline_generator.rs:16:5: 16:8 (#0)];
42+
+ _4 = {generator@$DIR/inline_generator.rs:16:5: 16:8 (#0)};
4343
_3 = &mut _4;
4444
- _2 = Pin::<&mut [generator@$DIR/inline_generator.rs:16:5: 16:8]>::new(move _3) -> [return: bb2, unwind unreachable];
4545
- }

Diff for: tests/mir-opt/inline/inline_generator.main.Inline.panic-unwind.diff

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
- }
4040
-
4141
- bb1: {
42-
+ _4 = [generator@$DIR/inline_generator.rs:16:5: 16:8 (#0)];
42+
+ _4 = {generator@$DIR/inline_generator.rs:16:5: 16:8 (#0)};
4343
_3 = &mut _4;
4444
- _2 = Pin::<&mut [generator@$DIR/inline_generator.rs:16:5: 16:8]>::new(move _3) -> [return: bb2, unwind: bb4];
4545
- }

Diff for: tests/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ fn main() -> () {
1919

2020
bb0: {
2121
StorageLive(_1);
22-
_1 = [closure@$DIR/issue_76997_inline_scopes_parenting.rs:5:13: 5:16];
22+
_1 = {closure@$DIR/issue_76997_inline_scopes_parenting.rs:5:13: 5:16};
2323
StorageLive(_2);
2424
_2 = &_1;
2525
StorageLive(_3);

Diff for: tests/mir-opt/retag.main.SimplifyCfg-elaborate-drops.after.panic-abort.mir

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ fn main() -> () {
103103
StorageDead(_2);
104104
StorageLive(_13);
105105
StorageLive(_14);
106-
_14 = [closure@main::{closure#0}];
106+
_14 = {closure@main::{closure#0}};
107107
Retag(_14);
108108
_13 = move _14 as for<'a> fn(&'a i32) -> &'a i32 (PointerCoercion(ClosureFnPointer(Normal)));
109109
StorageDead(_14);

Diff for: tests/mir-opt/retag.main.SimplifyCfg-elaborate-drops.after.panic-unwind.mir

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ fn main() -> () {
103103
StorageDead(_2);
104104
StorageLive(_13);
105105
StorageLive(_14);
106-
_14 = [closure@main::{closure#0}];
106+
_14 = {closure@main::{closure#0}};
107107
Retag(_14);
108108
_13 = move _14 as for<'a> fn(&'a i32) -> &'a i32 (PointerCoercion(ClosureFnPointer(Normal)));
109109
StorageDead(_14);

0 commit comments

Comments
 (0)