diff options
| author | Dylan DPC <dylan.dpc@gmail.com> | 2021-04-19 22:00:10 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-19 22:00:10 +0200 |
| commit | 349fae3a32cfcb650f252104bb5c88ee32d9bebf (patch) | |
| tree | cf8f2f18e679b72ece157fe7a559ef9f7933763b /src | |
| parent | 761243572e8ed83368f9bdcc7e0198ef1bea3a66 (diff) | |
| parent | a8193ca4c3204d6d8aafadab80ff5c6b284aa76e (diff) | |
| download | rust-349fae3a32cfcb650f252104bb5c88ee32d9bebf.tar.gz rust-349fae3a32cfcb650f252104bb5c88ee32d9bebf.zip | |
Rollup merge of #84313 - lcnr:sized-err-msg, r=petrochenkov
fix suggestion for unsized function parameters taken from `@fasterthanlime's` article https://fasterthanli.me/articles/whats-in-the-box
Diffstat (limited to 'src')
24 files changed, 58 insertions, 30 deletions
diff --git a/src/test/ui/error-codes/E0277.stderr b/src/test/ui/error-codes/E0277.stderr index 1f54af4d154..dea0bb259f5 100644 --- a/src/test/ui/error-codes/E0277.stderr +++ b/src/test/ui/error-codes/E0277.stderr @@ -9,8 +9,8 @@ LL | fn f(p: Path) { } = help: unsized fn params are gated as an unstable feature help: function arguments must have a statically known size, borrowed types always have a known size | -LL | fn f(&p: Path) { } - | ^ +LL | fn f(p: &Path) { } + | ^ error[E0277]: the trait bound `i32: Foo` is not satisfied --> $DIR/E0277.rs:15:15 diff --git a/src/test/ui/feature-gates/feature-gate-unsized_fn_params.stderr b/src/test/ui/feature-gates/feature-gate-unsized_fn_params.stderr index 71acbb174ac..3631a03938a 100644 --- a/src/test/ui/feature-gates/feature-gate-unsized_fn_params.stderr +++ b/src/test/ui/feature-gates/feature-gate-unsized_fn_params.stderr @@ -8,8 +8,8 @@ LL | fn foo(x: dyn Foo) { = help: unsized fn params are gated as an unstable feature help: function arguments must have a statically known size, borrowed types always have a known size | -LL | fn foo(&x: dyn Foo) { - | ^ +LL | fn foo(x: &dyn Foo) { + | ^ error[E0277]: the size for values of type `(dyn Foo + 'static)` cannot be known at compilation time --> $DIR/feature-gate-unsized_fn_params.rs:24:5 diff --git a/src/test/ui/feature-gates/feature-gate-unsized_locals.stderr b/src/test/ui/feature-gates/feature-gate-unsized_locals.stderr index 52254220872..0919c2f3a1e 100644 --- a/src/test/ui/feature-gates/feature-gate-unsized_locals.stderr +++ b/src/test/ui/feature-gates/feature-gate-unsized_locals.stderr @@ -8,8 +8,8 @@ LL | fn f(f: dyn FnOnce()) {} = help: unsized fn params are gated as an unstable feature help: function arguments must have a statically known size, borrowed types always have a known size | -LL | fn f(&f: dyn FnOnce()) {} - | ^ +LL | fn f(f: &dyn FnOnce()) {} + | ^ error: aborting due to previous error diff --git a/src/test/ui/issues/issue-5883.rs b/src/test/ui/issues/issue-5883.rs index 0de53502397..82866b35557 100644 --- a/src/test/ui/issues/issue-5883.rs +++ b/src/test/ui/issues/issue-5883.rs @@ -4,9 +4,9 @@ struct Struct { r: dyn A + 'static } -fn new_struct(r: dyn A + 'static) - -> Struct { //~^ ERROR the size for values of type - //~^ ERROR the size for values of type +fn new_struct( + r: dyn A + 'static //~ ERROR the size for values of type +) -> Struct { //~ ERROR the size for values of type Struct { r: r } } diff --git a/src/test/ui/issues/issue-5883.stderr b/src/test/ui/issues/issue-5883.stderr index 48879eb798f..de598a70ee0 100644 --- a/src/test/ui/issues/issue-5883.stderr +++ b/src/test/ui/issues/issue-5883.stderr @@ -1,22 +1,21 @@ error[E0277]: the size for values of type `(dyn A + 'static)` cannot be known at compilation time - --> $DIR/issue-5883.rs:7:15 + --> $DIR/issue-5883.rs:8:5 | -LL | fn new_struct(r: dyn A + 'static) - | ^ doesn't have a size known at compile-time +LL | r: dyn A + 'static + | ^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `(dyn A + 'static)` = help: unsized fn params are gated as an unstable feature help: function arguments must have a statically known size, borrowed types always have a known size | -LL | fn new_struct(&r: dyn A + 'static) - | ^ +LL | r: &dyn A + 'static + | ^ error[E0277]: the size for values of type `(dyn A + 'static)` cannot be known at compilation time - --> $DIR/issue-5883.rs:8:8 + --> $DIR/issue-5883.rs:9:6 | -LL | -> Struct { - | ^^^^^^ doesn't have a size known at compile-time -LL | +LL | ) -> Struct { + | ^^^^^^ doesn't have a size known at compile-time LL | Struct { r: r } | --------------- this returned value is of type `Struct` | diff --git a/src/test/ui/resolve/issue-5035-2.stderr b/src/test/ui/resolve/issue-5035-2.stderr index b2084a7a426..e94877fded7 100644 --- a/src/test/ui/resolve/issue-5035-2.stderr +++ b/src/test/ui/resolve/issue-5035-2.stderr @@ -8,8 +8,8 @@ LL | fn foo(_x: K) {} = help: unsized fn params are gated as an unstable feature help: function arguments must have a statically known size, borrowed types always have a known size | -LL | fn foo(&_x: K) {} - | ^ +LL | fn foo(_x: &K) {} + | ^ error: aborting due to previous error diff --git a/src/test/ui/suggestions/path-by-value.stderr b/src/test/ui/suggestions/path-by-value.stderr index 19fc3406ccf..5919a6f7492 100644 --- a/src/test/ui/suggestions/path-by-value.stderr +++ b/src/test/ui/suggestions/path-by-value.stderr @@ -9,8 +9,8 @@ LL | fn f(p: Path) { } = help: unsized fn params are gated as an unstable feature help: function arguments must have a statically known size, borrowed types always have a known size | -LL | fn f(&p: Path) { } - | ^ +LL | fn f(p: &Path) { } + | ^ error: aborting due to previous error diff --git a/src/test/ui/traits/bound/not-on-bare-trait.stderr b/src/test/ui/traits/bound/not-on-bare-trait.stderr index e7fc0fa5ec0..b8ae88ace02 100644 --- a/src/test/ui/traits/bound/not-on-bare-trait.stderr +++ b/src/test/ui/traits/bound/not-on-bare-trait.stderr @@ -16,8 +16,8 @@ LL | fn foo(_x: Foo + Send) { = help: unsized fn params are gated as an unstable feature help: function arguments must have a statically known size, borrowed types always have a known size | -LL | fn foo(&_x: Foo + Send) { - | ^ +LL | fn foo(_x: &Foo + Send) { + | ^ error: aborting due to previous error; 1 warning emitted diff --git a/src/test/ui/unsized/unsized-fn-arg.fixed b/src/test/ui/unsized/unsized-fn-arg.fixed new file mode 100644 index 00000000000..2c686c6c2b2 --- /dev/null +++ b/src/test/ui/unsized/unsized-fn-arg.fixed @@ -0,0 +1,6 @@ +// run-rustfix +#![crate_type="lib"] +#![allow(unused)] + +fn f<T: ?Sized>(t: &T) {} +//~^ ERROR the size for values of type `T` cannot be known at compilation time diff --git a/src/test/ui/unsized/unsized-fn-arg.rs b/src/test/ui/unsized/unsized-fn-arg.rs new file mode 100644 index 00000000000..9fc08bd6d3e --- /dev/null +++ b/src/test/ui/unsized/unsized-fn-arg.rs @@ -0,0 +1,6 @@ +// run-rustfix +#![crate_type="lib"] +#![allow(unused)] + +fn f<T: ?Sized>(t: T) {} +//~^ ERROR the size for values of type `T` cannot be known at compilation time diff --git a/src/test/ui/unsized/unsized-fn-arg.stderr b/src/test/ui/unsized/unsized-fn-arg.stderr new file mode 100644 index 00000000000..6b802ddf542 --- /dev/null +++ b/src/test/ui/unsized/unsized-fn-arg.stderr @@ -0,0 +1,17 @@ +error[E0277]: the size for values of type `T` cannot be known at compilation time + --> $DIR/unsized-fn-arg.rs:5:17 + | +LL | fn f<T: ?Sized>(t: T) {} + | - ^ doesn't have a size known at compile-time + | | + | this type parameter needs to be `std::marker::Sized` + | + = help: unsized fn params are gated as an unstable feature +help: function arguments must have a statically known size, borrowed types always have a known size + | +LL | fn f<T: ?Sized>(t: &T) {} + | ^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/unsized-tuple-impls.rs b/src/test/ui/unsized/unsized-tuple-impls.rs index 5e385f33bee..5e385f33bee 100644 --- a/src/test/ui/unsized-tuple-impls.rs +++ b/src/test/ui/unsized/unsized-tuple-impls.rs diff --git a/src/test/ui/unsized.rs b/src/test/ui/unsized/unsized.rs index 54304834d4b..54304834d4b 100644 --- a/src/test/ui/unsized.rs +++ b/src/test/ui/unsized/unsized.rs diff --git a/src/test/ui/unsized2.rs b/src/test/ui/unsized/unsized2.rs index be4406399fd..be4406399fd 100644 --- a/src/test/ui/unsized2.rs +++ b/src/test/ui/unsized/unsized2.rs diff --git a/src/test/ui/unsized3-rpass.rs b/src/test/ui/unsized/unsized3-rpass.rs index 65efbd6b520..65efbd6b520 100644 --- a/src/test/ui/unsized3-rpass.rs +++ b/src/test/ui/unsized/unsized3-rpass.rs diff --git a/src/test/ui/unsized3.rs b/src/test/ui/unsized/unsized3.rs index f5b5d025931..f5b5d025931 100644 --- a/src/test/ui/unsized3.rs +++ b/src/test/ui/unsized/unsized3.rs diff --git a/src/test/ui/unsized3.stderr b/src/test/ui/unsized/unsized3.stderr index bd36008aca0..bd36008aca0 100644 --- a/src/test/ui/unsized3.stderr +++ b/src/test/ui/unsized/unsized3.stderr diff --git a/src/test/ui/unsized5.rs b/src/test/ui/unsized/unsized5.rs index befd2244d97..befd2244d97 100644 --- a/src/test/ui/unsized5.rs +++ b/src/test/ui/unsized/unsized5.rs diff --git a/src/test/ui/unsized5.stderr b/src/test/ui/unsized/unsized5.stderr index 0bfd4565529..0bfd4565529 100644 --- a/src/test/ui/unsized5.stderr +++ b/src/test/ui/unsized/unsized5.stderr diff --git a/src/test/ui/unsized6.rs b/src/test/ui/unsized/unsized6.rs index 79133554d54..79133554d54 100644 --- a/src/test/ui/unsized6.rs +++ b/src/test/ui/unsized/unsized6.rs diff --git a/src/test/ui/unsized6.stderr b/src/test/ui/unsized/unsized6.stderr index f9f7877d542..8e5734dffb1 100644 --- a/src/test/ui/unsized6.stderr +++ b/src/test/ui/unsized/unsized6.stderr @@ -135,8 +135,8 @@ LL | fn g1<X: ?Sized>(x: X) {} = help: unsized fn params are gated as an unstable feature help: function arguments must have a statically known size, borrowed types always have a known size | -LL | fn g1<X: ?Sized>(&x: X) {} - | ^ +LL | fn g1<X: ?Sized>(x: &X) {} + | ^ error[E0277]: the size for values of type `X` cannot be known at compilation time --> $DIR/unsized6.rs:40:22 @@ -149,8 +149,8 @@ LL | fn g2<X: ?Sized + T>(x: X) {} = help: unsized fn params are gated as an unstable feature help: function arguments must have a statically known size, borrowed types always have a known size | -LL | fn g2<X: ?Sized + T>(&x: X) {} - | ^ +LL | fn g2<X: ?Sized + T>(x: &X) {} + | ^ error: aborting due to 13 previous errors diff --git a/src/test/ui/unsized7.rs b/src/test/ui/unsized/unsized7.rs index 422a784814e..422a784814e 100644 --- a/src/test/ui/unsized7.rs +++ b/src/test/ui/unsized/unsized7.rs diff --git a/src/test/ui/unsized7.stderr b/src/test/ui/unsized/unsized7.stderr index 7dbddd4ed24..7dbddd4ed24 100644 --- a/src/test/ui/unsized7.stderr +++ b/src/test/ui/unsized/unsized7.stderr diff --git a/src/tools/clippy/tests/ui/crashes/ice-6251.stderr b/src/tools/clippy/tests/ui/crashes/ice-6251.stderr index 9a7cf4b0919..8498c040780 100644 --- a/src/tools/clippy/tests/ui/crashes/ice-6251.stderr +++ b/src/tools/clippy/tests/ui/crashes/ice-6251.stderr @@ -16,8 +16,8 @@ LL | fn bug<T>() -> impl Iterator<Item = [(); { |x: [u8]| x }]> { = help: unsized fn params are gated as an unstable feature help: function arguments must have a statically known size, borrowed types always have a known size | -LL | fn bug<T>() -> impl Iterator<Item = [(); { |&x: [u8]| x }]> { - | ^ +LL | fn bug<T>() -> impl Iterator<Item = [(); { |x: &[u8]| x }]> { + | ^ error[E0277]: the size for values of type `[u8]` cannot be known at compilation time --> $DIR/ice-6251.rs:4:54 |
