diff options
Diffstat (limited to 'tests')
11 files changed, 217 insertions, 0 deletions
diff --git a/tests/ui/async-await/awaiting-unsized-param.drop_tracking_mir.stderr b/tests/ui/async-await/awaiting-unsized-param.drop_tracking_mir.stderr new file mode 100644 index 00000000000..02cf8310a50 --- /dev/null +++ b/tests/ui/async-await/awaiting-unsized-param.drop_tracking_mir.stderr @@ -0,0 +1,21 @@ +warning: the feature `unsized_locals` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/awaiting-unsized-param.rs:5:31 + | +LL | #![feature(unsized_fn_params, unsized_locals)] + | ^^^^^^^^^^^^^^ + | + = note: see issue #48055 <https://github.com/rust-lang/rust/issues/48055> for more information + = note: `#[warn(incomplete_features)]` on by default + +error[E0277]: the size for values of type `(dyn Future<Output = T> + Unpin + 'static)` cannot be known at compilation time + --> $DIR/awaiting-unsized-param.rs:10:17 + | +LL | async fn bug<T>(mut f: dyn Future<Output = T> + Unpin) -> T { + | ^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `(dyn Future<Output = T> + Unpin + 'static)` + = note: all values captured by value by a closure must have a statically known size + +error: aborting due to previous error; 1 warning emitted + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/async-await/awaiting-unsized-param.no_drop_tracking.stderr b/tests/ui/async-await/awaiting-unsized-param.no_drop_tracking.stderr new file mode 100644 index 00000000000..02cf8310a50 --- /dev/null +++ b/tests/ui/async-await/awaiting-unsized-param.no_drop_tracking.stderr @@ -0,0 +1,21 @@ +warning: the feature `unsized_locals` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/awaiting-unsized-param.rs:5:31 + | +LL | #![feature(unsized_fn_params, unsized_locals)] + | ^^^^^^^^^^^^^^ + | + = note: see issue #48055 <https://github.com/rust-lang/rust/issues/48055> for more information + = note: `#[warn(incomplete_features)]` on by default + +error[E0277]: the size for values of type `(dyn Future<Output = T> + Unpin + 'static)` cannot be known at compilation time + --> $DIR/awaiting-unsized-param.rs:10:17 + | +LL | async fn bug<T>(mut f: dyn Future<Output = T> + Unpin) -> T { + | ^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `(dyn Future<Output = T> + Unpin + 'static)` + = note: all values captured by value by a closure must have a statically known size + +error: aborting due to previous error; 1 warning emitted + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/async-await/awaiting-unsized-param.rs b/tests/ui/async-await/awaiting-unsized-param.rs new file mode 100644 index 00000000000..2af8723b312 --- /dev/null +++ b/tests/ui/async-await/awaiting-unsized-param.rs @@ -0,0 +1,15 @@ +// edition: 2021 +// revisions: no_drop_tracking drop_tracking_mir +// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir + +#![feature(unsized_fn_params, unsized_locals)] +//~^ WARN the feature `unsized_locals` is incomplete + +use std::future::Future; + +async fn bug<T>(mut f: dyn Future<Output = T> + Unpin) -> T { + //~^ ERROR the size for values of type `(dyn Future<Output = T> + Unpin + 'static)` cannot be known at compilation time + (&mut f).await +} + +fn main() {} diff --git a/tests/ui/async-await/unsized-across-await.drop_tracking_mir.stderr b/tests/ui/async-await/unsized-across-await.drop_tracking_mir.stderr new file mode 100644 index 00000000000..c606df8e031 --- /dev/null +++ b/tests/ui/async-await/unsized-across-await.drop_tracking_mir.stderr @@ -0,0 +1,21 @@ +warning: the feature `unsized_locals` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/unsized-across-await.rs:5:12 + | +LL | #![feature(unsized_locals)] + | ^^^^^^^^^^^^^^ + | + = note: see issue #48055 <https://github.com/rust-lang/rust/issues/48055> for more information + = note: `#[warn(incomplete_features)]` on by default + +error[E0277]: the size for values of type `dyn std::fmt::Display` cannot be known at compilation time + --> $DIR/unsized-across-await.rs:11:9 + | +LL | let _x = *x; + | ^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `dyn std::fmt::Display` + = note: all values live across `await` must have a statically known size + +error: aborting due to previous error; 1 warning emitted + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/async-await/unsized-across-await.no_drop_tracking.stderr b/tests/ui/async-await/unsized-across-await.no_drop_tracking.stderr new file mode 100644 index 00000000000..c606df8e031 --- /dev/null +++ b/tests/ui/async-await/unsized-across-await.no_drop_tracking.stderr @@ -0,0 +1,21 @@ +warning: the feature `unsized_locals` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/unsized-across-await.rs:5:12 + | +LL | #![feature(unsized_locals)] + | ^^^^^^^^^^^^^^ + | + = note: see issue #48055 <https://github.com/rust-lang/rust/issues/48055> for more information + = note: `#[warn(incomplete_features)]` on by default + +error[E0277]: the size for values of type `dyn std::fmt::Display` cannot be known at compilation time + --> $DIR/unsized-across-await.rs:11:9 + | +LL | let _x = *x; + | ^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `dyn std::fmt::Display` + = note: all values live across `await` must have a statically known size + +error: aborting due to previous error; 1 warning emitted + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/async-await/unsized-across-await.rs b/tests/ui/async-await/unsized-across-await.rs new file mode 100644 index 00000000000..9934e9db6d2 --- /dev/null +++ b/tests/ui/async-await/unsized-across-await.rs @@ -0,0 +1,18 @@ +// edition: 2021 +// revisions: no_drop_tracking drop_tracking_mir +// [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir + +#![feature(unsized_locals)] +//~^ WARN the feature `unsized_locals` is incomplete + +async fn f() {} + +async fn g(x: Box<dyn std::fmt::Display>) { + let _x = *x; + //~^ ERROR the size for values of type `dyn std::fmt::Display` cannot be known at compilation time + f().await; +} + +fn main() { + let _a = g(Box::new(5)); +} diff --git a/tests/ui/closures/capture-unsized-by-move.rs b/tests/ui/closures/capture-unsized-by-move.rs new file mode 100644 index 00000000000..1148e34ac67 --- /dev/null +++ b/tests/ui/closures/capture-unsized-by-move.rs @@ -0,0 +1,10 @@ +// compile-flags: --crate-type=lib + +#![feature(unsized_fn_params)] + +pub fn f(k: dyn std::fmt::Display) { + let k2 = move || { + k.to_string(); + //~^ ERROR the size for values of type `(dyn std::fmt::Display + 'static)` cannot be known at compilation time + }; +} diff --git a/tests/ui/closures/capture-unsized-by-move.stderr b/tests/ui/closures/capture-unsized-by-move.stderr new file mode 100644 index 00000000000..d7fafc8cadd --- /dev/null +++ b/tests/ui/closures/capture-unsized-by-move.stderr @@ -0,0 +1,14 @@ +error[E0277]: the size for values of type `(dyn std::fmt::Display + 'static)` cannot be known at compilation time + --> $DIR/capture-unsized-by-move.rs:7:9 + | +LL | let k2 = move || { + | -- this closure captures all values by move +LL | k.to_string(); + | ^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `(dyn std::fmt::Display + 'static)` + = note: all values captured by value by a closure must have a statically known size + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/closures/capture-unsized-by-ref.rs b/tests/ui/closures/capture-unsized-by-ref.rs new file mode 100644 index 00000000000..c9e4a5903d9 --- /dev/null +++ b/tests/ui/closures/capture-unsized-by-ref.rs @@ -0,0 +1,10 @@ +// build-pass +// compile-flags: --crate-type=lib + +#![feature(unsized_fn_params)] + +pub fn f(k: dyn std::fmt::Display) { + let k2 = || { + k.to_string(); + }; +} diff --git a/tests/ui/generator/unsized-across-yield.rs b/tests/ui/generator/unsized-across-yield.rs new file mode 100644 index 00000000000..876d08ac1f0 --- /dev/null +++ b/tests/ui/generator/unsized-across-yield.rs @@ -0,0 +1,34 @@ +#![feature(generator_trait)] +#![feature(generators)] +#![feature(unsized_locals)] +//~^ WARN the feature `unsized_locals` is incomplete and may not be safe to use and/or cause compiler crashes + +use std::ops::Generator; + +fn across() -> impl Generator { + move || { + let b: [u8] = *(Box::new([]) as Box<[u8]>); + //~^ ERROR the size for values of type `[u8]` cannot be known at compilation time + + yield; + + for elem in b.iter() {} + } +} + +fn capture() -> impl Generator { + let b: [u8] = *(Box::new([]) as Box<[u8]>); + move || { + println!("{:?}", &b); + //~^ ERROR the size for values of type `[u8]` cannot be known at compilation time + + yield; + + for elem in b.iter() {} + } +} + +fn main() { + across(); + capture(); +} diff --git a/tests/ui/generator/unsized-across-yield.stderr b/tests/ui/generator/unsized-across-yield.stderr new file mode 100644 index 00000000000..82375a0ec2d --- /dev/null +++ b/tests/ui/generator/unsized-across-yield.stderr @@ -0,0 +1,32 @@ +warning: the feature `unsized_locals` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/unsized-across-yield.rs:3:12 + | +LL | #![feature(unsized_locals)] + | ^^^^^^^^^^^^^^ + | + = note: see issue #48055 <https://github.com/rust-lang/rust/issues/48055> for more information + = note: `#[warn(incomplete_features)]` on by default + +error[E0277]: the size for values of type `[u8]` cannot be known at compilation time + --> $DIR/unsized-across-yield.rs:10:13 + | +LL | let b: [u8] = *(Box::new([]) as Box<[u8]>); + | ^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `[u8]` + = note: all values live across `yield` must have a statically known size + +error[E0277]: the size for values of type `[u8]` cannot be known at compilation time + --> $DIR/unsized-across-yield.rs:22:27 + | +LL | move || { + | -- this closure captures all values by move +LL | println!("{:?}", &b); + | ^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `[u8]` + = note: all values captured by value by a closure must have a statically known size + +error: aborting due to 2 previous errors; 1 warning emitted + +For more information about this error, try `rustc --explain E0277`. |
