about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2020-02-02 02:03:54 -0800
committerEsteban Küber <esteban@kuber.com.ar>2020-02-02 11:53:10 -0800
commit342db717e2aa52decc812084c31fdcbeaf03b255 (patch)
treecb595b1f61145de641e5450bb54b73785422db99
parentd216b731f61d85a5cc6cddfdd7f91628bc594b33 (diff)
downloadrust-342db717e2aa52decc812084c31fdcbeaf03b255.tar.gz
rust-342db717e2aa52decc812084c31fdcbeaf03b255.zip
Account for `?Sized` type parameter bounds
-rw-r--r--src/librustc/traits/error_reporting/suggestions.rs12
-rw-r--r--src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs2
-rw-r--r--src/test/ui/consts/too_generic_eval_ice.stderr4
-rw-r--r--src/test/ui/dst/dst-object-from-unsized-type.stderr4
-rw-r--r--src/test/ui/issues/issue-27060-2.stderr2
-rw-r--r--src/test/ui/traits/trait-suggest-where-clause.stderr4
-rw-r--r--src/test/ui/union/union-sized-field.stderr6
-rw-r--r--src/test/ui/unsized/unsized-bare-typaram.stderr4
-rw-r--r--src/test/ui/unsized/unsized-enum.stderr4
-rw-r--r--src/test/ui/unsized/unsized-enum2.stderr8
-rw-r--r--src/test/ui/unsized/unsized-inherent-impl-self-type.stderr4
-rw-r--r--src/test/ui/unsized/unsized-struct.stderr8
-rw-r--r--src/test/ui/unsized/unsized-trait-impl-self-type.stderr4
-rw-r--r--src/test/ui/unsized/unsized-trait-impl-trait-arg.stderr4
-rw-r--r--src/test/ui/unsized3.stderr36
-rw-r--r--src/test/ui/unsized5.stderr8
-rw-r--r--src/test/ui/unsized6.stderr30
-rw-r--r--src/test/ui/unsized7.stderr4
18 files changed, 76 insertions, 72 deletions
diff --git a/src/librustc/traits/error_reporting/suggestions.rs b/src/librustc/traits/error_reporting/suggestions.rs
index 72629c6a3cf..c1facd34dfe 100644
--- a/src/librustc/traits/error_reporting/suggestions.rs
+++ b/src/librustc/traits/error_reporting/suggestions.rs
@@ -145,12 +145,14 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
                     let param_name = self_ty.to_string();
                     let constraint = trait_ref.print_only_trait_path().to_string();
                     if suggest_constraining_type_param(
+                        self.tcx,
                         generics,
                         &mut err,
                         &param_name,
                         &constraint,
                         self.tcx.sess.source_map(),
                         *span,
+                        Some(trait_ref.def_id()),
                     ) {
                         return;
                     }
@@ -1652,18 +1654,26 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
 
 /// Suggest restricting a type param with a new bound.
 pub fn suggest_constraining_type_param(
+    tcx: TyCtxt<'_>,
     generics: &hir::Generics<'_>,
     err: &mut DiagnosticBuilder<'_>,
     param_name: &str,
     constraint: &str,
     source_map: &SourceMap,
     span: Span,
+    def_id: Option<DefId>,
 ) -> bool {
     let restrict_msg = "consider further restricting this bound";
     if let Some(param) =
         generics.params.iter().filter(|p| p.name.ident().as_str() == param_name).next()
     {
-        if param_name.starts_with("impl ") {
+        if def_id == tcx.lang_items().sized_trait() {
+            // Type parameters are already `Sized` by default.
+            err.span_label(
+                param.span,
+                &format!("this type parameter needs to be `{}`", constraint),
+            );
+        } else if param_name.starts_with("impl ") {
             // `impl Trait` in argument:
             // `fn foo(x: impl Trait) {}` → `fn foo(t: impl Trait + Trait2) {}`
             err.span_suggestion(
diff --git a/src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs b/src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs
index 810882d3bbd..b0b9790abb1 100644
--- a/src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs
+++ b/src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs
@@ -217,12 +217,14 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
                         tcx.hir().get_generics(tcx.closure_base_def_id(self.mir_def_id))
                     {
                         suggest_constraining_type_param(
+                            tcx,
                             generics,
                             &mut err,
                             &param.name.as_str(),
                             "Copy",
                             tcx.sess.source_map(),
                             span,
+                            None,
                         );
                     }
                 }
diff --git a/src/test/ui/consts/too_generic_eval_ice.stderr b/src/test/ui/consts/too_generic_eval_ice.stderr
index 599d1d79e75..fd68cb9c6cf 100644
--- a/src/test/ui/consts/too_generic_eval_ice.stderr
+++ b/src/test/ui/consts/too_generic_eval_ice.stderr
@@ -18,7 +18,7 @@ LL | pub struct Foo<A, B>(A, B);
    | --------------------------- required by `Foo`
 LL | 
 LL | impl<A, B> Foo<A, B> {
-   |      - help: consider restricting this bound: `A: std::marker::Sized`
+   |      - this type parameter needs to be `std::marker::Sized`
 ...
 LL |         [5; Self::HOST_SIZE] == [6; 0]
    |             ^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
@@ -33,7 +33,7 @@ LL | pub struct Foo<A, B>(A, B);
    | --------------------------- required by `Foo`
 LL | 
 LL | impl<A, B> Foo<A, B> {
-   |         - help: consider restricting this bound: `B: std::marker::Sized`
+   |         - this type parameter needs to be `std::marker::Sized`
 ...
 LL |         [5; Self::HOST_SIZE] == [6; 0]
    |             ^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
diff --git a/src/test/ui/dst/dst-object-from-unsized-type.stderr b/src/test/ui/dst/dst-object-from-unsized-type.stderr
index 40db575eabd..80d188bf2f8 100644
--- a/src/test/ui/dst/dst-object-from-unsized-type.stderr
+++ b/src/test/ui/dst/dst-object-from-unsized-type.stderr
@@ -2,7 +2,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim
   --> $DIR/dst-object-from-unsized-type.rs:8:23
    |
 LL | fn test1<T: ?Sized + Foo>(t: &T) {
-   |          -- help: consider further restricting this bound: `T: std::marker::Sized +`
+   |          - this type parameter needs to be `std::marker::Sized`
 LL |     let u: &dyn Foo = t;
    |                       ^ doesn't have a size known at compile-time
    |
@@ -14,7 +14,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim
   --> $DIR/dst-object-from-unsized-type.rs:13:23
    |
 LL | fn test2<T: ?Sized + Foo>(t: &T) {
-   |          -- help: consider further restricting this bound: `T: std::marker::Sized +`
+   |          - this type parameter needs to be `std::marker::Sized`
 LL |     let v: &dyn Foo = t as &dyn Foo;
    |                       ^ doesn't have a size known at compile-time
    |
diff --git a/src/test/ui/issues/issue-27060-2.stderr b/src/test/ui/issues/issue-27060-2.stderr
index 553041c5106..1ddea73e00a 100644
--- a/src/test/ui/issues/issue-27060-2.stderr
+++ b/src/test/ui/issues/issue-27060-2.stderr
@@ -2,7 +2,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim
   --> $DIR/issue-27060-2.rs:3:5
    |
 LL | pub struct Bad<T: ?Sized> {
-   |                -- help: consider further restricting this bound: `T: std::marker::Sized +`
+   |                - this type parameter needs to be `std::marker::Sized`
 LL |     data: T,
    |     ^^^^^^^ doesn't have a size known at compile-time
    |
diff --git a/src/test/ui/traits/trait-suggest-where-clause.stderr b/src/test/ui/traits/trait-suggest-where-clause.stderr
index 831dd439298..9680d58b8c0 100644
--- a/src/test/ui/traits/trait-suggest-where-clause.stderr
+++ b/src/test/ui/traits/trait-suggest-where-clause.stderr
@@ -2,7 +2,7 @@ error[E0277]: the size for values of type `U` cannot be known at compilation tim
   --> $DIR/trait-suggest-where-clause.rs:11:20
    |
 LL | fn check<T: Iterator, U: ?Sized>() {
-   |                       -- help: consider further restricting this bound: `U: std::marker::Sized +`
+   |                       - this type parameter needs to be `std::marker::Sized`
 LL |     // suggest a where-clause, if needed
 LL |     mem::size_of::<U>();
    |                    ^ doesn't have a size known at compile-time
@@ -19,7 +19,7 @@ error[E0277]: the size for values of type `U` cannot be known at compilation tim
   --> $DIR/trait-suggest-where-clause.rs:14:5
    |
 LL | fn check<T: Iterator, U: ?Sized>() {
-   |                       -- help: consider further restricting this bound: `U: std::marker::Sized +`
+   |                       - this type parameter needs to be `std::marker::Sized`
 ...
 LL |     mem::size_of::<Misc<U>>();
    |     ^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
diff --git a/src/test/ui/union/union-sized-field.stderr b/src/test/ui/union/union-sized-field.stderr
index c9fec1d21d1..62dacd064be 100644
--- a/src/test/ui/union/union-sized-field.stderr
+++ b/src/test/ui/union/union-sized-field.stderr
@@ -2,7 +2,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim
   --> $DIR/union-sized-field.rs:4:5
    |
 LL | union Foo<T: ?Sized> {
-   |           -- help: consider further restricting this bound: `T: std::marker::Sized +`
+   |           - this type parameter needs to be `std::marker::Sized`
 LL |     value: T,
    |     ^^^^^^^^ doesn't have a size known at compile-time
    |
@@ -14,7 +14,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim
   --> $DIR/union-sized-field.rs:9:5
    |
 LL | struct Foo2<T: ?Sized> {
-   |             -- help: consider further restricting this bound: `T: std::marker::Sized +`
+   |             - this type parameter needs to be `std::marker::Sized`
 LL |     value: T,
    |     ^^^^^^^^ doesn't have a size known at compile-time
    |
@@ -26,7 +26,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim
   --> $DIR/union-sized-field.rs:15:11
    |
 LL | enum Foo3<T: ?Sized> {
-   |           -- help: consider further restricting this bound: `T: std::marker::Sized +`
+   |           - this type parameter needs to be `std::marker::Sized`
 LL |     Value(T),
    |           ^ doesn't have a size known at compile-time
    |
diff --git a/src/test/ui/unsized/unsized-bare-typaram.stderr b/src/test/ui/unsized/unsized-bare-typaram.stderr
index bd97b0203b5..772de23e64c 100644
--- a/src/test/ui/unsized/unsized-bare-typaram.stderr
+++ b/src/test/ui/unsized/unsized-bare-typaram.stderr
@@ -4,9 +4,9 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim
 LL | fn bar<T: Sized>() { }
    |    --- - required by this bound in `bar`
 LL | fn foo<T: ?Sized>() { bar::<T>() }
-   |        --                   ^ doesn't have a size known at compile-time
+   |        -                    ^ doesn't have a size known at compile-time
    |        |
-   |        help: consider further restricting this bound: `T: std::marker::Sized +`
+   |        this type parameter needs to be `std::marker::Sized`
    |
    = help: the trait `std::marker::Sized` is not implemented for `T`
    = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
diff --git a/src/test/ui/unsized/unsized-enum.stderr b/src/test/ui/unsized/unsized-enum.stderr
index 341d3e4cc2d..88f7b1f77ae 100644
--- a/src/test/ui/unsized/unsized-enum.stderr
+++ b/src/test/ui/unsized/unsized-enum.stderr
@@ -5,9 +5,9 @@ LL | enum Foo<U> { FooSome(U), FooNone }
    | ----------- required by `Foo`
 LL | fn foo1<T>() { not_sized::<Foo<T>>() } // Hunky dory.
 LL | fn foo2<T: ?Sized>() { not_sized::<Foo<T>>() }
-   |         --                         ^^^^^^ doesn't have a size known at compile-time
+   |         -                          ^^^^^^ doesn't have a size known at compile-time
    |         |
-   |         help: consider further restricting this bound: `T: std::marker::Sized +`
+   |         this type parameter needs to be `std::marker::Sized`
    |
    = help: the trait `std::marker::Sized` is not implemented for `T`
    = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
diff --git a/src/test/ui/unsized/unsized-enum2.stderr b/src/test/ui/unsized/unsized-enum2.stderr
index e85b6d662f9..bc3b3831f32 100644
--- a/src/test/ui/unsized/unsized-enum2.stderr
+++ b/src/test/ui/unsized/unsized-enum2.stderr
@@ -2,7 +2,7 @@ error[E0277]: the size for values of type `W` cannot be known at compilation tim
   --> $DIR/unsized-enum2.rs:23:8
    |
 LL | enum E<W: ?Sized, X: ?Sized, Y: ?Sized, Z: ?Sized> {
-   |        -- help: consider further restricting this bound: `W: std::marker::Sized +`
+   |        - this type parameter needs to be `std::marker::Sized`
 LL |     // parameter
 LL |     VA(W),
    |        ^ doesn't have a size known at compile-time
@@ -15,7 +15,7 @@ error[E0277]: the size for values of type `X` cannot be known at compilation tim
   --> $DIR/unsized-enum2.rs:25:8
    |
 LL | enum E<W: ?Sized, X: ?Sized, Y: ?Sized, Z: ?Sized> {
-   |                   -- help: consider further restricting this bound: `X: std::marker::Sized +`
+   |                   - this type parameter needs to be `std::marker::Sized`
 ...
 LL |     VB{x: X},
    |        ^^^^ doesn't have a size known at compile-time
@@ -28,7 +28,7 @@ error[E0277]: the size for values of type `Y` cannot be known at compilation tim
   --> $DIR/unsized-enum2.rs:27:15
    |
 LL | enum E<W: ?Sized, X: ?Sized, Y: ?Sized, Z: ?Sized> {
-   |                              -- help: consider further restricting this bound: `Y: std::marker::Sized +`
+   |                              - this type parameter needs to be `std::marker::Sized`
 ...
 LL |     VC(isize, Y),
    |               ^ doesn't have a size known at compile-time
@@ -41,7 +41,7 @@ error[E0277]: the size for values of type `Z` cannot be known at compilation tim
   --> $DIR/unsized-enum2.rs:29:18
    |
 LL | enum E<W: ?Sized, X: ?Sized, Y: ?Sized, Z: ?Sized> {
-   |                                         -- help: consider further restricting this bound: `Z: std::marker::Sized +`
+   |                                         - this type parameter needs to be `std::marker::Sized`
 ...
 LL |     VD{u: isize, x: Z},
    |                  ^^^^ doesn't have a size known at compile-time
diff --git a/src/test/ui/unsized/unsized-inherent-impl-self-type.stderr b/src/test/ui/unsized/unsized-inherent-impl-self-type.stderr
index 280b8fd43ca..5688ae5b89a 100644
--- a/src/test/ui/unsized/unsized-inherent-impl-self-type.stderr
+++ b/src/test/ui/unsized/unsized-inherent-impl-self-type.stderr
@@ -5,9 +5,9 @@ LL | struct S5<Y>(Y);
    | ---------------- required by `S5`
 LL | 
 LL | impl<X: ?Sized> S5<X> {
-   |      --         ^^^^^ doesn't have a size known at compile-time
+   |      -          ^^^^^ doesn't have a size known at compile-time
    |      |
-   |      help: consider further restricting this bound: `X: std::marker::Sized +`
+   |      this type parameter needs to be `std::marker::Sized`
    |
    = help: the trait `std::marker::Sized` is not implemented for `X`
    = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
diff --git a/src/test/ui/unsized/unsized-struct.stderr b/src/test/ui/unsized/unsized-struct.stderr
index 2894d5d5671..653fb5c1ae8 100644
--- a/src/test/ui/unsized/unsized-struct.stderr
+++ b/src/test/ui/unsized/unsized-struct.stderr
@@ -5,9 +5,9 @@ LL | struct Foo<T> { data: T }
    | ------------- required by `Foo`
 LL | fn foo1<T>() { not_sized::<Foo<T>>() } // Hunky dory.
 LL | fn foo2<T: ?Sized>() { not_sized::<Foo<T>>() }
-   |         --                         ^^^^^^ doesn't have a size known at compile-time
+   |         -                          ^^^^^^ doesn't have a size known at compile-time
    |         |
-   |         help: consider further restricting this bound: `T: std::marker::Sized +`
+   |         this type parameter needs to be `std::marker::Sized`
    |
    = help: the trait `std::marker::Sized` is not implemented for `T`
    = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
@@ -19,9 +19,9 @@ LL | fn is_sized<T:Sized>() { }
    |    -------- - required by this bound in `is_sized`
 ...
 LL | fn bar2<T: ?Sized>() { is_sized::<Bar<T>>() }
-   |         --             ^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
+   |         -              ^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
    |         |
-   |         help: consider further restricting this bound: `T: std::marker::Sized +`
+   |         this type parameter needs to be `std::marker::Sized`
    |
    = help: within `Bar<T>`, the trait `std::marker::Sized` is not implemented for `T`
    = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
diff --git a/src/test/ui/unsized/unsized-trait-impl-self-type.stderr b/src/test/ui/unsized/unsized-trait-impl-self-type.stderr
index ba1550439c0..3597073e7e6 100644
--- a/src/test/ui/unsized/unsized-trait-impl-self-type.stderr
+++ b/src/test/ui/unsized/unsized-trait-impl-self-type.stderr
@@ -5,9 +5,9 @@ LL | struct S5<Y>(Y);
    | ---------------- required by `S5`
 LL | 
 LL | impl<X: ?Sized> T3<X> for S5<X> {
-   |      --         ^^^^^ doesn't have a size known at compile-time
+   |      -          ^^^^^ doesn't have a size known at compile-time
    |      |
-   |      help: consider further restricting this bound: `X: std::marker::Sized +`
+   |      this type parameter needs to be `std::marker::Sized`
    |
    = help: the trait `std::marker::Sized` is not implemented for `X`
    = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
diff --git a/src/test/ui/unsized/unsized-trait-impl-trait-arg.stderr b/src/test/ui/unsized/unsized-trait-impl-trait-arg.stderr
index 41371d63f9e..b37d9f9d536 100644
--- a/src/test/ui/unsized/unsized-trait-impl-trait-arg.stderr
+++ b/src/test/ui/unsized/unsized-trait-impl-trait-arg.stderr
@@ -2,9 +2,9 @@ error[E0277]: the size for values of type `X` cannot be known at compilation tim
   --> $DIR/unsized-trait-impl-trait-arg.rs:8:17
    |
 LL | impl<X: ?Sized> T2<X> for S4<X> {
-   |      --         ^^^^^ doesn't have a size known at compile-time
+   |      -          ^^^^^ doesn't have a size known at compile-time
    |      |
-   |      help: consider further restricting this bound: `X: std::marker::Sized +`
+   |      this type parameter needs to be `std::marker::Sized`
    |
    = help: the trait `std::marker::Sized` is not implemented for `X`
    = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
diff --git a/src/test/ui/unsized3.stderr b/src/test/ui/unsized3.stderr
index 0c37828229e..e97d00fc474 100644
--- a/src/test/ui/unsized3.stderr
+++ b/src/test/ui/unsized3.stderr
@@ -1,42 +1,34 @@
 error[E0277]: the size for values of type `X` cannot be known at compilation time
   --> $DIR/unsized3.rs:7:13
    |
+LL | fn f1<X: ?Sized>(x: &X) {
+   |       - this type parameter needs to be `std::marker::Sized`
 LL |     f2::<X>(x);
    |             ^ doesn't have a size known at compile-time
 ...
 LL | fn f2<X>(x: &X) {
-   |    -- - required by this bound in `f2`
+   |    -- -- help: consider relaxing the implicit `Sized` restriction: `: ?Sized`
+   |       |
+   |       required by this bound in `f2`
    |
    = help: the trait `std::marker::Sized` is not implemented for `X`
    = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
-help: consider further restricting this bound
-   |
-LL | fn f1<X: std::marker::Sized +  ?Sized>(x: &X) {
-   |       ^^^^^^^^^^^^^^^^^^^^^^^
-help: consider relaxing the implicit `Sized` restriction
-   |
-LL | fn f2<X: ?Sized>(x: &X) {
-   |        ^^^^^^^^
 
 error[E0277]: the size for values of type `X` cannot be known at compilation time
   --> $DIR/unsized3.rs:18:13
    |
+LL | fn f3<X: ?Sized + T>(x: &X) {
+   |       - this type parameter needs to be `std::marker::Sized`
 LL |     f4::<X>(x);
    |             ^ doesn't have a size known at compile-time
 ...
 LL | fn f4<X: T>(x: &X) {
-   |    -- - required by this bound in `f4`
+   |    -- -   - help: consider relaxing the implicit `Sized` restriction: `+  ?Sized`
+   |       |
+   |       required by this bound in `f4`
    |
    = help: the trait `std::marker::Sized` is not implemented for `X`
    = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
-help: consider further restricting this bound
-   |
-LL | fn f3<X: std::marker::Sized +  ?Sized + T>(x: &X) {
-   |       ^^^^^^^^^^^^^^^^^^^^^^^
-help: consider relaxing the implicit `Sized` restriction
-   |
-LL | fn f4<X: T +  ?Sized>(x: &X) {
-   |            ^^^^^^^^^
 
 error[E0277]: the size for values of type `X` cannot be known at compilation time
   --> $DIR/unsized3.rs:33:8
@@ -45,7 +37,7 @@ LL | fn f5<Y>(x: &Y) {}
    |    -- - required by this bound in `f5`
 ...
 LL | fn f8<X: ?Sized>(x1: &S<X>, x2: &S<X>) {
-   |       -- help: consider further restricting this bound: `X: std::marker::Sized +`
+   |       - this type parameter needs to be `std::marker::Sized`
 LL |     f5(x1);
    |        ^^ doesn't have a size known at compile-time
    |
@@ -57,7 +49,7 @@ error[E0277]: the size for values of type `X` cannot be known at compilation tim
   --> $DIR/unsized3.rs:40:8
    |
 LL | fn f9<X: ?Sized>(x1: Box<S<X>>) {
-   |       -- help: consider further restricting this bound: `X: std::marker::Sized +`
+   |       - this type parameter needs to be `std::marker::Sized`
 LL |     f5(&(*x1, 34));
    |        ^^^^^^^^^^ doesn't have a size known at compile-time
    |
@@ -70,7 +62,7 @@ error[E0277]: the size for values of type `X` cannot be known at compilation tim
   --> $DIR/unsized3.rs:45:9
    |
 LL | fn f10<X: ?Sized>(x1: Box<S<X>>) {
-   |        -- help: consider further restricting this bound: `X: std::marker::Sized +`
+   |        - this type parameter needs to be `std::marker::Sized`
 LL |     f5(&(32, *x1));
    |         ^^^^^^^^^ doesn't have a size known at compile-time
    |
@@ -87,7 +79,7 @@ LL | fn f5<Y>(x: &Y) {}
    |    -- - required by this bound in `f5`
 ...
 LL | fn f10<X: ?Sized>(x1: Box<S<X>>) {
-   |        -- help: consider further restricting this bound: `X: std::marker::Sized +`
+   |        - this type parameter needs to be `std::marker::Sized`
 LL |     f5(&(32, *x1));
    |        ^^^^^^^^^^ doesn't have a size known at compile-time
    |
diff --git a/src/test/ui/unsized5.stderr b/src/test/ui/unsized5.stderr
index bfd3f4aa691..de4da309791 100644
--- a/src/test/ui/unsized5.stderr
+++ b/src/test/ui/unsized5.stderr
@@ -2,7 +2,7 @@ error[E0277]: the size for values of type `X` cannot be known at compilation tim
   --> $DIR/unsized5.rs:4:5
    |
 LL | struct S1<X: ?Sized> {
-   |           -- help: consider further restricting this bound: `X: std::marker::Sized +`
+   |           - this type parameter needs to be `std::marker::Sized`
 LL |     f1: X,
    |     ^^^^^ doesn't have a size known at compile-time
    |
@@ -14,7 +14,7 @@ error[E0277]: the size for values of type `X` cannot be known at compilation tim
   --> $DIR/unsized5.rs:10:5
    |
 LL | struct S2<X: ?Sized> {
-   |           -- help: consider further restricting this bound: `X: std::marker::Sized +`
+   |           - this type parameter needs to be `std::marker::Sized`
 LL |     f: isize,
 LL |     g: X,
    |     ^^^^ doesn't have a size known at compile-time
@@ -47,7 +47,7 @@ error[E0277]: the size for values of type `X` cannot be known at compilation tim
   --> $DIR/unsized5.rs:25:8
    |
 LL | enum E<X: ?Sized> {
-   |        -- help: consider further restricting this bound: `X: std::marker::Sized +`
+   |        - this type parameter needs to be `std::marker::Sized`
 LL |     V1(X, isize),
    |        ^ doesn't have a size known at compile-time
    |
@@ -59,7 +59,7 @@ error[E0277]: the size for values of type `X` cannot be known at compilation tim
   --> $DIR/unsized5.rs:29:8
    |
 LL | enum F<X: ?Sized> {
-   |        -- help: consider further restricting this bound: `X: std::marker::Sized +`
+   |        - this type parameter needs to be `std::marker::Sized`
 LL |     V2{f1: X, f: isize},
    |        ^^^^^ doesn't have a size known at compile-time
    |
diff --git a/src/test/ui/unsized6.stderr b/src/test/ui/unsized6.stderr
index 95acd987a5a..337afd2ee7e 100644
--- a/src/test/ui/unsized6.stderr
+++ b/src/test/ui/unsized6.stderr
@@ -2,7 +2,7 @@ error[E0277]: the size for values of type `Y` cannot be known at compilation tim
   --> $DIR/unsized6.rs:9:9
    |
 LL | fn f1<W: ?Sized, X: ?Sized, Y: ?Sized, Z: ?Sized>(x: &X) {
-   |                             -- help: consider further restricting this bound: `Y: std::marker::Sized +`
+   |                             - this type parameter needs to be `std::marker::Sized`
 ...
 LL |     let y: Y;
    |         ^ doesn't have a size known at compile-time
@@ -16,7 +16,7 @@ error[E0277]: the size for values of type `X` cannot be known at compilation tim
   --> $DIR/unsized6.rs:7:12
    |
 LL | fn f1<W: ?Sized, X: ?Sized, Y: ?Sized, Z: ?Sized>(x: &X) {
-   |                  -- help: consider further restricting this bound: `X: std::marker::Sized +`
+   |                  - this type parameter needs to be `std::marker::Sized`
 LL |     let _: W; // <-- this is OK, no bindings created, no initializer.
 LL |     let _: (isize, (X, isize));
    |            ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
@@ -29,7 +29,7 @@ error[E0277]: the size for values of type `Z` cannot be known at compilation tim
   --> $DIR/unsized6.rs:11:12
    |
 LL | fn f1<W: ?Sized, X: ?Sized, Y: ?Sized, Z: ?Sized>(x: &X) {
-   |                                        -- help: consider further restricting this bound: `Z: std::marker::Sized +`
+   |                                        - this type parameter needs to be `std::marker::Sized`
 ...
 LL |     let y: (isize, (Z, usize));
    |            ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
@@ -42,7 +42,7 @@ error[E0277]: the size for values of type `X` cannot be known at compilation tim
   --> $DIR/unsized6.rs:15:9
    |
 LL | fn f2<X: ?Sized, Y: ?Sized>(x: &X) {
-   |       -- help: consider further restricting this bound: `X: std::marker::Sized +`
+   |       - this type parameter needs to be `std::marker::Sized`
 LL |     let y: X;
    |         ^ doesn't have a size known at compile-time
    |
@@ -55,7 +55,7 @@ error[E0277]: the size for values of type `Y` cannot be known at compilation tim
   --> $DIR/unsized6.rs:17:12
    |
 LL | fn f2<X: ?Sized, Y: ?Sized>(x: &X) {
-   |                  -- help: consider further restricting this bound: `Y: std::marker::Sized +`
+   |                  - this type parameter needs to be `std::marker::Sized`
 ...
 LL |     let y: (isize, (Y, isize));
    |            ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
@@ -68,7 +68,7 @@ error[E0277]: the size for values of type `X` cannot be known at compilation tim
   --> $DIR/unsized6.rs:22:9
    |
 LL | fn f3<X: ?Sized>(x1: Box<X>, x2: Box<X>, x3: Box<X>) {
-   |       -- help: consider further restricting this bound: `X: std::marker::Sized +`
+   |       - this type parameter needs to be `std::marker::Sized`
 LL |     let y: X = *x1;
    |         ^ doesn't have a size known at compile-time
    |
@@ -81,7 +81,7 @@ error[E0277]: the size for values of type `X` cannot be known at compilation tim
   --> $DIR/unsized6.rs:24:9
    |
 LL | fn f3<X: ?Sized>(x1: Box<X>, x2: Box<X>, x3: Box<X>) {
-   |       -- help: consider further restricting this bound: `X: std::marker::Sized +`
+   |       - this type parameter needs to be `std::marker::Sized`
 ...
 LL |     let y = *x2;
    |         ^ doesn't have a size known at compile-time
@@ -95,7 +95,7 @@ error[E0277]: the size for values of type `X` cannot be known at compilation tim
   --> $DIR/unsized6.rs:26:10
    |
 LL | fn f3<X: ?Sized>(x1: Box<X>, x2: Box<X>, x3: Box<X>) {
-   |       -- help: consider further restricting this bound: `X: std::marker::Sized +`
+   |       - this type parameter needs to be `std::marker::Sized`
 ...
 LL |     let (y, z) = (*x3, 4);
    |          ^ doesn't have a size known at compile-time
@@ -109,7 +109,7 @@ error[E0277]: the size for values of type `X` cannot be known at compilation tim
   --> $DIR/unsized6.rs:30:9
    |
 LL | fn f4<X: ?Sized + T>(x1: Box<X>, x2: Box<X>, x3: Box<X>) {
-   |       -- help: consider further restricting this bound: `X: std::marker::Sized +`
+   |       - this type parameter needs to be `std::marker::Sized`
 LL |     let y: X = *x1;
    |         ^ doesn't have a size known at compile-time
    |
@@ -122,7 +122,7 @@ error[E0277]: the size for values of type `X` cannot be known at compilation tim
   --> $DIR/unsized6.rs:32:9
    |
 LL | fn f4<X: ?Sized + T>(x1: Box<X>, x2: Box<X>, x3: Box<X>) {
-   |       -- help: consider further restricting this bound: `X: std::marker::Sized +`
+   |       - this type parameter needs to be `std::marker::Sized`
 ...
 LL |     let y = *x2;
    |         ^ doesn't have a size known at compile-time
@@ -136,7 +136,7 @@ error[E0277]: the size for values of type `X` cannot be known at compilation tim
   --> $DIR/unsized6.rs:34:10
    |
 LL | fn f4<X: ?Sized + T>(x1: Box<X>, x2: Box<X>, x3: Box<X>) {
-   |       -- help: consider further restricting this bound: `X: std::marker::Sized +`
+   |       - this type parameter needs to be `std::marker::Sized`
 ...
 LL |     let (y, z) = (*x3, 4);
    |          ^ doesn't have a size known at compile-time
@@ -150,9 +150,9 @@ error[E0277]: the size for values of type `X` cannot be known at compilation tim
   --> $DIR/unsized6.rs:38:18
    |
 LL | fn g1<X: ?Sized>(x: X) {}
-   |       --         ^ doesn't have a size known at compile-time
+   |       -          ^ doesn't have a size known at compile-time
    |       |
-   |       help: consider further restricting this bound: `X: std::marker::Sized +`
+   |       this type parameter needs to be `std::marker::Sized`
    |
    = help: the trait `std::marker::Sized` is not implemented for `X`
    = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
@@ -163,9 +163,9 @@ error[E0277]: the size for values of type `X` cannot be known at compilation tim
   --> $DIR/unsized6.rs:40:22
    |
 LL | fn g2<X: ?Sized + T>(x: X) {}
-   |       --             ^ doesn't have a size known at compile-time
+   |       -              ^ doesn't have a size known at compile-time
    |       |
-   |       help: consider further restricting this bound: `X: std::marker::Sized +`
+   |       this type parameter needs to be `std::marker::Sized`
    |
    = help: the trait `std::marker::Sized` is not implemented for `X`
    = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
diff --git a/src/test/ui/unsized7.stderr b/src/test/ui/unsized7.stderr
index c77503a6f87..0f71c5f6f8f 100644
--- a/src/test/ui/unsized7.stderr
+++ b/src/test/ui/unsized7.stderr
@@ -2,9 +2,9 @@ error[E0277]: the size for values of type `X` cannot be known at compilation tim
   --> $DIR/unsized7.rs:12:21
    |
 LL | impl<X: ?Sized + T> T1<X> for S3<X> {
-   |      --             ^^^^^ doesn't have a size known at compile-time
+   |      -              ^^^^^ doesn't have a size known at compile-time
    |      |
-   |      help: consider further restricting this bound: `X: std::marker::Sized +`
+   |      this type parameter needs to be `std::marker::Sized`
    |
    = help: the trait `std::marker::Sized` is not implemented for `X`
    = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>