Skip to content

Commit 411e645

Browse files
committed
adjust how closure/generator types and rvalues are printed
1 parent 5ede940 commit 411e645

File tree

192 files changed

+477
-477
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

192 files changed

+477
-477
lines changed

compiler/rustc_infer/src/infer/error_reporting/mod.rs

Lines changed: 1 addition & 1 deletion
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)

compiler/rustc_middle/src/mir/mod.rs

Lines changed: 3 additions & 3 deletions
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

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@ pub trait PrettyPrinter<'tcx>:
797797
}
798798
ty::Str => p!("str"),
799799
ty::Generator(did, args, movability) => {
800-
p!(write("["));
800+
p!(write("{{"));
801801
let generator_kind = self.tcx().generator_kind(did).unwrap();
802802
let should_print_movability =
803803
self.should_print_verbose() || generator_kind == hir::GeneratorKind::Gen;
@@ -838,13 +838,13 @@ pub trait PrettyPrinter<'tcx>:
838838
}
839839
}
840840

841-
p!("]")
841+
p!("}}")
842842
}
843843
ty::GeneratorWitness(types) => {
844844
p!(in_binder(&types));
845845
}
846846
ty::GeneratorWitnessMIR(did, args) => {
847-
p!(write("["));
847+
p!(write("{{"));
848848
if !self.tcx().sess.verbose() {
849849
p!("generator witness");
850850
// FIXME(eddyb) should use `def_span`.
@@ -863,10 +863,10 @@ pub trait PrettyPrinter<'tcx>:
863863
p!(print_def_path(did, args));
864864
}
865865

866-
p!("]")
866+
p!("}}")
867867
}
868868
ty::Closure(did, args) => {
869-
p!(write("["));
869+
p!(write("{{"));
870870
if !self.should_print_verbose() {
871871
p!(write("closure"));
872872
// FIXME(eddyb) should use `def_span`.
@@ -906,7 +906,7 @@ pub trait PrettyPrinter<'tcx>:
906906
p!(")");
907907
}
908908
}
909-
p!("]");
909+
p!("}}");
910910
}
911911
ty::Array(ty, sz) => p!("[", print(ty), "; ", print(sz), "]"),
912912
ty::Slice(ty) => p!("[", print(ty), "]"),
@@ -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()

compiler/rustc_middle/src/ty/sty.rs

Lines changed: 1 addition & 1 deletion
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<[[email protected]:4:20]>` returns true
2539+
/// Example: `Option<{[email protected]:4:20}>` returns true
25402540
pub fn contains_closure(self) -> bool {
25412541
struct ContainsClosureVisitor;
25422542

src/tools/clippy/tests/ui/box_default.fixed

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ fn main() {
3636
issue_10381();
3737

3838
// `Box::<Option<_>>::default()` would be valid here, but not `Box::default()` or
39-
// `Box::<Option<[closure@...]>::default()`
39+
// `Box::<Option<{closure@...}>::default()`
4040
//
4141
// Would have a suggestion after https://github.com/rust-lang/rust/blob/fdd030127cc68afec44a8d3f6341525dd34e50ae/compiler/rustc_middle/src/ty/diagnostics.rs#L554-L563
4242
let mut unnameable = Box::new(Option::default());

src/tools/clippy/tests/ui/box_default.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ fn main() {
3636
issue_10381();
3737

3838
// `Box::<Option<_>>::default()` would be valid here, but not `Box::default()` or
39-
// `Box::<Option<[closure@...]>::default()`
39+
// `Box::<Option<{closure@...}>::default()`
4040
//
4141
// Would have a suggestion after https://github.com/rust-lang/rust/blob/fdd030127cc68afec44a8d3f6341525dd34e50ae/compiler/rustc_middle/src/ty/diagnostics.rs#L554-L563
4242
let mut unnameable = Box::new(Option::default());

src/tools/clippy/tests/ui/crashes/ice-6251.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ LL | fn bug<T>() -> impl Iterator<Item = [(); { |x: [u8]| x }]> {
2727
| ^^^^^^^^^^^ expected `usize`, found closure
2828
|
2929
= note: expected type `usize`
30-
found closure `[closure@$DIR/ice-6251.rs:4:44: 4:53]`
30+
found closure `{closure@$DIR/ice-6251.rs:4:44: 4:53}`
3131

3232
error: aborting due to 3 previous errors
3333

src/tools/miri/tests/fail/both_borrows/newtype_pair_retagging.stack.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ note: inside closure
2424
|
2525
LL | || drop(Box::from_raw(ptr)),
2626
| ^^^^^^^^^^^^^^^^^^
27-
note: inside `dealloc_while_running::<[closure@$DIR/newtype_pair_retagging.rs:LL:CC]>`
27+
note: inside `dealloc_while_running::<{closure@$DIR/newtype_pair_retagging.rs:LL:CC}>`
2828
--> $DIR/newtype_pair_retagging.rs:LL:CC
2929
|
3030
LL | dealloc();

src/tools/miri/tests/fail/both_borrows/newtype_pair_retagging.tree.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ note: inside closure
3535
|
3636
LL | || drop(Box::from_raw(ptr)),
3737
| ^^^^^^^^^^^^^^^^^^^^^^^^
38-
note: inside `dealloc_while_running::<[closure@$DIR/newtype_pair_retagging.rs:LL:CC]>`
38+
note: inside `dealloc_while_running::<{closure@$DIR/newtype_pair_retagging.rs:LL:CC}>`
3939
--> $DIR/newtype_pair_retagging.rs:LL:CC
4040
|
4141
LL | dealloc();

src/tools/miri/tests/fail/both_borrows/newtype_retagging.stack.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ note: inside closure
2424
|
2525
LL | || drop(Box::from_raw(ptr)),
2626
| ^^^^^^^^^^^^^^^^^^
27-
note: inside `dealloc_while_running::<[closure@$DIR/newtype_retagging.rs:LL:CC]>`
27+
note: inside `dealloc_while_running::<{closure@$DIR/newtype_retagging.rs:LL:CC}>`
2828
--> $DIR/newtype_retagging.rs:LL:CC
2929
|
3030
LL | dealloc();

0 commit comments

Comments
 (0)