Skip to content

Commit 5833d54

Browse files
Pretty Bound and Placeholder tys differently with Zverbose
1 parent f63ccaf commit 5833d54

File tree

3 files changed

+23
-17
lines changed

3 files changed

+23
-17
lines changed

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

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -700,12 +700,18 @@ pub trait PrettyPrinter<'tcx>:
700700
}
701701
ty::Error(_) => p!("[type error]"),
702702
ty::Param(ref param_ty) => p!(print(param_ty)),
703-
ty::Bound(debruijn, bound_ty) => match bound_ty.kind {
704-
ty::BoundTyKind::Anon(bv) => {
705-
self.pretty_print_bound_var(debruijn, ty::BoundVar::from_u32(bv))?
703+
ty::Bound(debruijn, bound_ty) => {
704+
if self.should_print_verbose() {
705+
p!(write("Bound({:?}, {:?})", debruijn, bound_ty))
706+
} else {
707+
match bound_ty.kind {
708+
ty::BoundTyKind::Anon(bv) => {
709+
self.pretty_print_bound_var(debruijn, ty::BoundVar::from_u32(bv))?
710+
}
711+
ty::BoundTyKind::Param(_, s) => p!(write("{}", s)),
712+
}
706713
}
707-
ty::BoundTyKind::Param(_, s) => p!(write("{}", s)),
708-
},
714+
}
709715
ty::Adt(def, substs) => {
710716
p!(print_def_path(def.did(), substs));
711717
}
@@ -736,8 +742,10 @@ pub trait PrettyPrinter<'tcx>:
736742
}
737743
}
738744
ty::Placeholder(placeholder) => match placeholder.name {
739-
ty::BoundTyKind::Anon(_) => p!(write("Placeholder({:?})", placeholder)),
740-
ty::BoundTyKind::Param(_, name) => p!(write("{}", name)),
745+
ty::BoundTyKind::Param(_, name) if !self.should_print_verbose() => {
746+
p!(write("{}", name))
747+
}
748+
_ => p!(write("Placeholder({:?})", placeholder)),
741749
},
742750
ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs, .. }) => {
743751
// We use verbose printing in 'NO_QUERIES' mode, to

tests/ui/nll/user-annotations/dump-fn-method.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Unit test for the "user substitutions" that are annotated on each
22
// node.
33

4-
// compile-flags:-Zverbose
5-
64
#![feature(rustc_attrs)]
75

86
// Note: we reference the names T and U in the comments below.
@@ -26,7 +24,7 @@ fn main() {
2624
let x = foo::<u32>;
2725
x(22);
2826

29-
let x = foo::<&'static u32>; //~ ERROR [&ReStatic u32]
27+
let x = foo::<&'static u32>; //~ ERROR [&'static u32]
3028
x(&22);
3129

3230
// Here: we only want the `T` to be given, the rest should be variables.
@@ -41,7 +39,7 @@ fn main() {
4139
x(&22, 44, 66);
4240

4341
// Here: all are given and we have a lifetime.
44-
let x = <u8 as Bazoom<&'static u16>>::method::<u32>; //~ ERROR [u8, &ReStatic u16, u32]
42+
let x = <u8 as Bazoom<&'static u16>>::method::<u32>; //~ ERROR [u8, &'static u16, u32]
4543
x(&22, &44, 66);
4644

4745
// Here: we want in particular that *only* the method `U`

tests/ui/nll/user-annotations/dump-fn-method.stderr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
error: user substs: UserSubsts { substs: [&ReStatic u32], user_self_ty: None }
2-
--> $DIR/dump-fn-method.rs:29:13
1+
error: user substs: UserSubsts { substs: [&'static u32], user_self_ty: None }
2+
--> $DIR/dump-fn-method.rs:27:13
33
|
44
LL | let x = foo::<&'static u32>;
55
| ^^^^^^^^^^^^^^^^^^^
66

77
error: user substs: UserSubsts { substs: [^0, u32, ^1], user_self_ty: None }
8-
--> $DIR/dump-fn-method.rs:35:13
8+
--> $DIR/dump-fn-method.rs:33:13
99
|
1010
LL | let x = <_ as Bazoom<u32>>::method::<_>;
1111
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1212

13-
error: user substs: UserSubsts { substs: [u8, &ReStatic u16, u32], user_self_ty: None }
14-
--> $DIR/dump-fn-method.rs:44:13
13+
error: user substs: UserSubsts { substs: [u8, &'static u16, u32], user_self_ty: None }
14+
--> $DIR/dump-fn-method.rs:42:13
1515
|
1616
LL | let x = <u8 as Bazoom<&'static u16>>::method::<u32>;
1717
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1818

1919
error: user substs: UserSubsts { substs: [^0, ^1, u32], user_self_ty: None }
20-
--> $DIR/dump-fn-method.rs:52:5
20+
--> $DIR/dump-fn-method.rs:50:5
2121
|
2222
LL | y.method::<u32>(44, 66);
2323
| ^^^^^^^^^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)