Skip to content

Commit 6f3706e

Browse files
Pretty placeholders using their names
1 parent ec40b1a commit 6f3706e

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

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

+4-1
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,10 @@ pub trait PrettyPrinter<'tcx>:
735735
p!(print(data))
736736
}
737737
}
738-
ty::Placeholder(placeholder) => p!(write("Placeholder({:?})", placeholder)),
738+
ty::Placeholder(placeholder) => match placeholder.name {
739+
ty::BoundTyKind::Anon(_) => p!(write("Placeholder({:?})", placeholder)),
740+
ty::BoundTyKind::Param(_, name) => p!(write("{}", name)),
741+
},
739742
ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs, .. }) => {
740743
// We use verbose printing in 'NO_QUERIES' mode, to
741744
// avoid needing to call `predicates_of`. This should

tests/ui/traits/non_lifetime_binders/bad-sized-cond.rs

+2
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,6 @@ fn main() {
1818
//~^ ERROR the size for values of type `V` cannot be known at compilation time
1919

2020
bar();
21+
//~^ ERROR the size for values of type `V` cannot be known at compilation time
22+
//~| ERROR `V` is not an iterator
2123
}

tests/ui/traits/non_lifetime_binders/bad-sized-cond.stderr

+5-5
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ LL | where
2323
LL | for<V> V: Sized,
2424
| ^^^^^ required by this bound in `foo`
2525

26-
error[E0277]: the size for values of type `Placeholder(Placeholder { universe: U3, name: Param(DefId(0:6 ~ bad_sized_cond[9450]::bar::V), "V") })` cannot be known at compilation time
26+
error[E0277]: the size for values of type `V` cannot be known at compilation time
2727
--> $DIR/bad-sized-cond.rs:20:5
2828
|
2929
LL | bar();
3030
| ^^^ doesn't have a size known at compile-time
3131
|
32-
= help: the trait `Sized` is not implemented for `Placeholder(Placeholder { universe: U3, name: Param(DefId(0:6 ~ bad_sized_cond[9450]::bar::V), "V") })`
32+
= help: the trait `Sized` is not implemented for `V`
3333
= note: required for `V` to implement `IntoIterator`
3434
note: required by a bound in `bar`
3535
--> $DIR/bad-sized-cond.rs:12:15
@@ -40,13 +40,13 @@ LL | where
4040
LL | for<V> V: IntoIterator,
4141
| ^^^^^^^^^^^^ required by this bound in `bar`
4242

43-
error[E0277]: `Placeholder(Placeholder { universe: U3, name: Param(DefId(0:6 ~ bad_sized_cond[9450]::bar::V), "V") })` is not an iterator
43+
error[E0277]: `V` is not an iterator
4444
--> $DIR/bad-sized-cond.rs:20:5
4545
|
4646
LL | bar();
47-
| ^^^ `Placeholder(Placeholder { universe: U3, name: Param(DefId(0:6 ~ bad_sized_cond[9450]::bar::V), "V") })` is not an iterator
47+
| ^^^ `V` is not an iterator
4848
|
49-
= help: the trait `Iterator` is not implemented for `Placeholder(Placeholder { universe: U3, name: Param(DefId(0:6 ~ bad_sized_cond[9450]::bar::V), "V") })`
49+
= help: the trait `Iterator` is not implemented for `V`
5050
= note: required for `V` to implement `IntoIterator`
5151
note: required by a bound in `bar`
5252
--> $DIR/bad-sized-cond.rs:12:15

0 commit comments

Comments
 (0)