Skip to content

Commit

Permalink
Pretty placeholders using their names
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed Feb 18, 2023
1 parent ec40b1a commit 6f3706e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
5 changes: 4 additions & 1 deletion compiler/rustc_middle/src/ty/print/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,10 @@ pub trait PrettyPrinter<'tcx>:
p!(print(data))
}
}
ty::Placeholder(placeholder) => p!(write("Placeholder({:?})", placeholder)),
ty::Placeholder(placeholder) => match placeholder.name {
ty::BoundTyKind::Anon(_) => p!(write("Placeholder({:?})", placeholder)),
ty::BoundTyKind::Param(_, name) => p!(write("{}", name)),
},
ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs, .. }) => {
// We use verbose printing in 'NO_QUERIES' mode, to
// avoid needing to call `predicates_of`. This should
Expand Down
2 changes: 2 additions & 0 deletions tests/ui/traits/non_lifetime_binders/bad-sized-cond.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ fn main() {
//~^ ERROR the size for values of type `V` cannot be known at compilation time

bar();
//~^ ERROR the size for values of type `V` cannot be known at compilation time
//~| ERROR `V` is not an iterator
}
10 changes: 5 additions & 5 deletions tests/ui/traits/non_lifetime_binders/bad-sized-cond.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ LL | where
LL | for<V> V: Sized,
| ^^^^^ required by this bound in `foo`

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

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

0 comments on commit 6f3706e

Please sign in to comment.