about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2023-02-17 21:21:27 +0000
committerMichael Goulet <michael@errs.io>2023-02-18 19:49:40 +0000
commit6f3706ea71a89a431acf7f84573b87c2ac98b0c7 (patch)
treef368516dae7ea14d2f5a75fa30e57bbbc679bd87
parentec40b1a3938ea0f7ae27b4bffe62bd41dc8015af (diff)
downloadrust-6f3706ea71a89a431acf7f84573b87c2ac98b0c7.tar.gz
rust-6f3706ea71a89a431acf7f84573b87c2ac98b0c7.zip
Pretty placeholders using their names
-rw-r--r--compiler/rustc_middle/src/ty/print/pretty.rs5
-rw-r--r--tests/ui/traits/non_lifetime_binders/bad-sized-cond.rs2
-rw-r--r--tests/ui/traits/non_lifetime_binders/bad-sized-cond.stderr10
3 files changed, 11 insertions, 6 deletions
diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs
index 1e59983583b..a101127104d 100644
--- a/compiler/rustc_middle/src/ty/print/pretty.rs
+++ b/compiler/rustc_middle/src/ty/print/pretty.rs
@@ -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
diff --git a/tests/ui/traits/non_lifetime_binders/bad-sized-cond.rs b/tests/ui/traits/non_lifetime_binders/bad-sized-cond.rs
index 3128e0f3138..dfc800c8e7e 100644
--- a/tests/ui/traits/non_lifetime_binders/bad-sized-cond.rs
+++ b/tests/ui/traits/non_lifetime_binders/bad-sized-cond.rs
@@ -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
 }
diff --git a/tests/ui/traits/non_lifetime_binders/bad-sized-cond.stderr b/tests/ui/traits/non_lifetime_binders/bad-sized-cond.stderr
index 3af115d897d..6480e490e8b 100644
--- a/tests/ui/traits/non_lifetime_binders/bad-sized-cond.stderr
+++ b/tests/ui/traits/non_lifetime_binders/bad-sized-cond.stderr
@@ -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
@@ -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