about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--compiler/rustc_infer/src/infer/region_constraints/mod.rs2
-rw-r--r--compiler/rustc_middle/src/ty/print/pretty.rs18
-rw-r--r--compiler/rustc_middle/src/ty/structural_impls.rs2
-rw-r--r--compiler/rustc_trait_selection/src/error_reporting/infer/region.rs12
-rw-r--r--tests/ui/traits/non_lifetime_binders/placeholders-dont-outlive-static.bad.stderr8
-rw-r--r--tests/ui/traits/non_lifetime_binders/placeholders-dont-outlive-static.good.stderr8
-rw-r--r--tests/ui/traits/non_lifetime_binders/placeholders-dont-outlive-static.rs2
-rw-r--r--tests/ui/traits/non_lifetime_binders/type-match-with-late-bound.stderr25
8 files changed, 41 insertions, 36 deletions
diff --git a/compiler/rustc_infer/src/infer/region_constraints/mod.rs b/compiler/rustc_infer/src/infer/region_constraints/mod.rs
index f4cb73685d5..a1744b4df80 100644
--- a/compiler/rustc_infer/src/infer/region_constraints/mod.rs
+++ b/compiler/rustc_infer/src/infer/region_constraints/mod.rs
@@ -655,7 +655,7 @@ impl<'tcx> fmt::Display for GenericKind<'tcx> {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         match *self {
             GenericKind::Param(ref p) => write!(f, "{p}"),
-            GenericKind::Placeholder(ref p) => write!(f, "{p:?}"),
+            GenericKind::Placeholder(ref p) => write!(f, "{p}"),
             GenericKind::Alias(ref p) => write!(f, "{p}"),
         }
     }
diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs
index 9cb049cd622..d991b3126e7 100644
--- a/compiler/rustc_middle/src/ty/print/pretty.rs
+++ b/compiler/rustc_middle/src/ty/print/pretty.rs
@@ -822,13 +822,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
             ty::Alias(ty::Projection | ty::Inherent | ty::Free, ref data) => {
                 p!(print(data))
             }
-            ty::Placeholder(placeholder) => match placeholder.bound.kind {
-                ty::BoundTyKind::Anon => p!(write("{placeholder:?}")),
-                ty::BoundTyKind::Param(def_id) => match self.should_print_verbose() {
-                    true => p!(write("{:?}", ty.kind())),
-                    false => p!(write("{}", self.tcx().item_name(def_id))),
-                },
-            },
+            ty::Placeholder(placeholder) => p!(print(placeholder)),
             ty::Alias(ty::Opaque, ty::AliasTy { def_id, args, .. }) => {
                 // We use verbose printing in 'NO_QUERIES' mode, to
                 // avoid needing to call `predicates_of`. This should
@@ -3373,6 +3367,16 @@ define_print_and_forward_display! {
         p!(write("{}", self.name))
     }
 
+    ty::PlaceholderType {
+        match self.bound.kind {
+            ty::BoundTyKind::Anon => p!(write("{self:?}")),
+            ty::BoundTyKind::Param(def_id) => match cx.should_print_verbose() {
+                true => p!(write("{self:?}")),
+                false => p!(write("{}", cx.tcx().item_name(def_id))),
+            },
+        }
+    }
+
     ty::ParamConst {
         p!(write("{}", self.name))
     }
diff --git a/compiler/rustc_middle/src/ty/structural_impls.rs b/compiler/rustc_middle/src/ty/structural_impls.rs
index 049f85ed651..af9c98bd87d 100644
--- a/compiler/rustc_middle/src/ty/structural_impls.rs
+++ b/compiler/rustc_middle/src/ty/structural_impls.rs
@@ -272,7 +272,6 @@ TrivialTypeTraversalImpls! {
     crate::ty::BoundVar,
     crate::ty::InferConst,
     crate::ty::Placeholder<crate::ty::BoundRegion>,
-    crate::ty::Placeholder<crate::ty::BoundTy>,
     crate::ty::Placeholder<ty::BoundVar>,
     crate::ty::UserTypeAnnotationIndex,
     crate::ty::ValTree<'tcx>,
@@ -303,6 +302,7 @@ TrivialTypeTraversalAndLiftImpls! {
     // tidy-alphabetical-start
     crate::ty::ParamConst,
     crate::ty::ParamTy,
+    crate::ty::Placeholder<crate::ty::BoundTy>,
     crate::ty::instance::ReifyReason,
     rustc_hir::def_id::DefId,
     // tidy-alphabetical-end
diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/region.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/region.rs
index f9de3e96d79..72f08777f9d 100644
--- a/compiler/rustc_trait_selection/src/error_reporting/infer/region.rs
+++ b/compiler/rustc_trait_selection/src/error_reporting/infer/region.rs
@@ -713,14 +713,14 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
         }
 
         let labeled_user_string = match bound_kind {
-            GenericKind::Param(ref p) => format!("the parameter type `{p}`"),
-            GenericKind::Placeholder(ref p) => format!("the placeholder type `{p:?}`"),
-            GenericKind::Alias(ref p) => match p.kind(self.tcx) {
+            GenericKind::Param(_) => format!("the parameter type `{bound_kind}`"),
+            GenericKind::Placeholder(_) => format!("the placeholder type `{bound_kind}`"),
+            GenericKind::Alias(p) => match p.kind(self.tcx) {
                 ty::Projection | ty::Inherent => {
-                    format!("the associated type `{p}`")
+                    format!("the associated type `{bound_kind}`")
                 }
-                ty::Free => format!("the type alias `{p}`"),
-                ty::Opaque => format!("the opaque type `{p}`"),
+                ty::Free => format!("the type alias `{bound_kind}`"),
+                ty::Opaque => format!("the opaque type `{bound_kind}`"),
             },
         };
 
diff --git a/tests/ui/traits/non_lifetime_binders/placeholders-dont-outlive-static.bad.stderr b/tests/ui/traits/non_lifetime_binders/placeholders-dont-outlive-static.bad.stderr
index 7dd383b1e7a..d51927aaa34 100644
--- a/tests/ui/traits/non_lifetime_binders/placeholders-dont-outlive-static.bad.stderr
+++ b/tests/ui/traits/non_lifetime_binders/placeholders-dont-outlive-static.bad.stderr
@@ -7,19 +7,19 @@ LL | #![feature(non_lifetime_binders)]
    = note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information
    = note: `#[warn(incomplete_features)]` on by default
 
-error[E0310]: the placeholder type `!1_"T"` may not live long enough
+error[E0310]: the placeholder type `T` may not live long enough
   --> $DIR/placeholders-dont-outlive-static.rs:13:5
    |
 LL |     foo();
    |     ^^^^^
    |     |
-   |     the placeholder type `!1_"T"` must be valid for the static lifetime...
+   |     the placeholder type `T` must be valid for the static lifetime...
    |     ...so that the type `T` will meet its required lifetime bounds
    |
 help: consider adding an explicit lifetime bound
    |
-LL | fn bad() where !1_"T": 'static {
-   |          +++++++++++++++++++++
+LL | fn bad() where T: 'static {
+   |          ++++++++++++++++
 
 error: aborting due to 1 previous error; 1 warning emitted
 
diff --git a/tests/ui/traits/non_lifetime_binders/placeholders-dont-outlive-static.good.stderr b/tests/ui/traits/non_lifetime_binders/placeholders-dont-outlive-static.good.stderr
index b4f00978ada..bc1a1992399 100644
--- a/tests/ui/traits/non_lifetime_binders/placeholders-dont-outlive-static.good.stderr
+++ b/tests/ui/traits/non_lifetime_binders/placeholders-dont-outlive-static.good.stderr
@@ -7,19 +7,19 @@ LL | #![feature(non_lifetime_binders)]
    = note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information
    = note: `#[warn(incomplete_features)]` on by default
 
-error[E0310]: the placeholder type `!1_"T"` may not live long enough
+error[E0310]: the placeholder type `T` may not live long enough
   --> $DIR/placeholders-dont-outlive-static.rs:19:5
    |
 LL |     foo();
    |     ^^^^^
    |     |
-   |     the placeholder type `!1_"T"` must be valid for the static lifetime...
+   |     the placeholder type `T` must be valid for the static lifetime...
    |     ...so that the type `T` will meet its required lifetime bounds
    |
 help: consider adding an explicit lifetime bound
    |
-LL | fn good() where for<T> T: 'static, !1_"T": 'static {
-   |                                  +++++++++++++++++
+LL | fn good() where for<T> T: 'static, T: 'static {
+   |                                  ++++++++++++
 
 error: aborting due to 1 previous error; 1 warning emitted
 
diff --git a/tests/ui/traits/non_lifetime_binders/placeholders-dont-outlive-static.rs b/tests/ui/traits/non_lifetime_binders/placeholders-dont-outlive-static.rs
index e87863ab251..3133d6aeedc 100644
--- a/tests/ui/traits/non_lifetime_binders/placeholders-dont-outlive-static.rs
+++ b/tests/ui/traits/non_lifetime_binders/placeholders-dont-outlive-static.rs
@@ -11,7 +11,7 @@ fn foo() where for<T> T: 'static {}
 #[cfg(bad)]
 fn bad() {
     foo();
-    //[bad]~^ ERROR the placeholder type `!1_"T"` may not live long enough
+    //[bad]~^ ERROR the placeholder type `T` may not live long enough
 }
 
 #[cfg(good)]
diff --git a/tests/ui/traits/non_lifetime_binders/type-match-with-late-bound.stderr b/tests/ui/traits/non_lifetime_binders/type-match-with-late-bound.stderr
index 9d54675c260..15902bf16de 100644
--- a/tests/ui/traits/non_lifetime_binders/type-match-with-late-bound.stderr
+++ b/tests/ui/traits/non_lifetime_binders/type-match-with-late-bound.stderr
@@ -7,11 +7,11 @@ LL | #![feature(non_lifetime_binders)]
    = note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information
    = note: `#[warn(incomplete_features)]` on by default
 
-error[E0309]: the placeholder type `!1_"F"` may not live long enough
+error[E0309]: the placeholder type `F` may not live long enough
   --> $DIR/type-match-with-late-bound.rs:8:1
    |
 LL |   async fn walk2<'a, T: 'a>(_: T)
-   |   ^              -- the placeholder type `!1_"F"` must be valid for the lifetime `'a` as defined here...
+   |   ^              -- the placeholder type `F` must be valid for the lifetime `'a` as defined here...
    |  _|
    | |
 LL | | where
@@ -25,36 +25,37 @@ LL |     for<F> F: 'a,
    |               ^^
 help: consider adding an explicit lifetime bound
    |
-LL |     for<F> F: 'a, !1_"F": 'a
-   |                   ++++++++++
+LL |     for<F> F: 'a, F: 'a
+   |                   +++++
 
-error[E0309]: the placeholder type `!1_"F"` may not live long enough
+error[E0309]: the placeholder type `F` may not live long enough
   --> $DIR/type-match-with-late-bound.rs:11:1
    |
 LL | async fn walk2<'a, T: 'a>(_: T)
-   |                -- the placeholder type `!1_"F"` must be valid for the lifetime `'a` as defined here...
+   |                -- the placeholder type `F` must be valid for the lifetime `'a` as defined here...
 ...
 LL | {}
    | ^^ ...so that the type `F` will meet its required lifetime bounds
    |
 help: consider adding an explicit lifetime bound
    |
-LL |     for<F> F: 'a, !1_"F": 'a
-   |                   ++++++++++
+LL |     for<F> F: 'a, F: 'a
+   |                   +++++
 
-error[E0309]: the placeholder type `!2_"F"` may not live long enough
+error[E0309]: the placeholder type `F` may not live long enough
   --> $DIR/type-match-with-late-bound.rs:11:1
    |
 LL | async fn walk2<'a, T: 'a>(_: T)
-   |                -- the placeholder type `!2_"F"` must be valid for the lifetime `'a` as defined here...
+   |                -- the placeholder type `F` must be valid for the lifetime `'a` as defined here...
 ...
 LL | {}
    | ^^ ...so that the type `F` will meet its required lifetime bounds
    |
+   = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
 help: consider adding an explicit lifetime bound
    |
-LL |     for<F> F: 'a, !2_"F": 'a
-   |                   ++++++++++
+LL |     for<F> F: 'a, F: 'a
+   |                   +++++
 
 error: aborting due to 3 previous errors; 1 warning emitted