diff --git a/src/librustc/traits/error_reporting/suggestions.rs b/src/librustc/traits/error_reporting/suggestions.rs index 72629c6a3cffa..c1facd34dfee5 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, ¶m_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, ) -> 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 810882d3bbdb8..b0b9790abb12a 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, ¶m.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 599d1d79e7555..fd68cb9c6cf85 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); | --------------------------- required by `Foo` LL | LL | impl Foo { - | - 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); | --------------------------- required by `Foo` LL | LL | impl Foo { - | - 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 40db575eabd38..80d188bf2f89b 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: &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: &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 553041c5106c5..1ddea73e00ae0 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 { - | -- 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 831dd439298d9..9680d58b8c0c7 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() { - | -- 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::(); | ^ 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() { - | -- help: consider further restricting this bound: `U: std::marker::Sized +` + | - this type parameter needs to be `std::marker::Sized` ... LL | mem::size_of::>(); | ^^^^^^^^^^^^^^^^^^^^^^^ 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 c9fec1d21d152..62dacd064bed0 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 { - | -- 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 { - | -- 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 { - | -- 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 bd97b0203b510..772de23e64cf0 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() { } | --- - required by this bound in `bar` LL | fn foo() { bar::() } - | -- ^ 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 diff --git a/src/test/ui/unsized/unsized-enum.stderr b/src/test/ui/unsized/unsized-enum.stderr index 341d3e4cc2df2..88f7b1f77aee0 100644 --- a/src/test/ui/unsized/unsized-enum.stderr +++ b/src/test/ui/unsized/unsized-enum.stderr @@ -5,9 +5,9 @@ LL | enum Foo { FooSome(U), FooNone } | ----------- required by `Foo` LL | fn foo1() { not_sized::>() } // Hunky dory. LL | fn foo2() { not_sized::>() } - | -- ^^^^^^ 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 diff --git a/src/test/ui/unsized/unsized-enum2.stderr b/src/test/ui/unsized/unsized-enum2.stderr index e85b6d662f9d5..bc3b3831f3269 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 { - | -- 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 { - | -- 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 { - | -- 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 { - | -- 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 280b8fd43cab0..5688ae5b89a04 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); | ---------------- required by `S5` LL | LL | impl S5 { - | -- ^^^^^ 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 diff --git a/src/test/ui/unsized/unsized-struct.stderr b/src/test/ui/unsized/unsized-struct.stderr index 2894d5d56710d..653fb5c1ae8dc 100644 --- a/src/test/ui/unsized/unsized-struct.stderr +++ b/src/test/ui/unsized/unsized-struct.stderr @@ -5,9 +5,9 @@ LL | struct Foo { data: T } | ------------- required by `Foo` LL | fn foo1() { not_sized::>() } // Hunky dory. LL | fn foo2() { not_sized::>() } - | -- ^^^^^^ 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 @@ -19,9 +19,9 @@ LL | fn is_sized() { } | -------- - required by this bound in `is_sized` ... LL | fn bar2() { is_sized::>() } - | -- ^^^^^^^^^^^^^^^^^^ 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`, the trait `std::marker::Sized` is not implemented for `T` = note: to learn more, visit 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 ba1550439c0d9..3597073e7e6c6 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); | ---------------- required by `S5` LL | LL | impl T3 for S5 { - | -- ^^^^^ 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 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 41371d63f9e53..b37d9f9d5369e 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 T2 for S4 { - | -- ^^^^^ 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 diff --git a/src/test/ui/unsized3.stderr b/src/test/ui/unsized3.stderr index 0c37828229e34..e97d00fc4741d 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: &X) { + | - this type parameter needs to be `std::marker::Sized` LL | f2::(x); | ^ doesn't have a size known at compile-time ... LL | fn f2(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 -help: consider further restricting this bound - | -LL | fn f1(x: &X) { - | ^^^^^^^^^^^^^^^^^^^^^^^ -help: consider relaxing the implicit `Sized` restriction - | -LL | fn f2(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: &X) { + | - this type parameter needs to be `std::marker::Sized` LL | f4::(x); | ^ doesn't have a size known at compile-time ... LL | fn f4(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 -help: consider further restricting this bound - | -LL | fn f3(x: &X) { - | ^^^^^^^^^^^^^^^^^^^^^^^ -help: consider relaxing the implicit `Sized` restriction - | -LL | fn f4(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(x: &Y) {} | -- - required by this bound in `f5` ... LL | fn f8(x1: &S, x2: &S) { - | -- 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(x1: Box>) { - | -- 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(x1: Box>) { - | -- 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(x: &Y) {} | -- - required by this bound in `f5` ... LL | fn f10(x1: Box>) { - | -- 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 bfd3f4aa691eb..de4da309791c0 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 { - | -- 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 { - | -- 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 { - | -- 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 { - | -- 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 95acd987a5a27..337afd2ee7e10 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(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(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(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: &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: &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(x1: Box, x2: Box, x3: Box) { - | -- 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(x1: Box, x2: Box, x3: Box) { - | -- 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(x1: Box, x2: Box, x3: Box) { - | -- 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(x1: Box, x2: Box, x3: Box) { - | -- 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(x1: Box, x2: Box, x3: Box) { - | -- 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(x1: Box, x2: Box, x3: Box) { - | -- 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: 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 @@ -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: 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 diff --git a/src/test/ui/unsized7.stderr b/src/test/ui/unsized7.stderr index c77503a6f87aa..0f71c5f6f8fe6 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 T1 for S3 { - | -- ^^^^^ 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