diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:03:36 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:03:36 +0000 |
commit | 17d40c6057c88f4c432b0d7bac88e1b84cb7e67f (patch) | |
tree | 3f66c4a5918660bb8a758ab6cda5ff8ee4f6cdcd /src/test/ui/dyn-star | |
parent | Adding upstream version 1.64.0+dfsg1. (diff) | |
download | rustc-upstream/1.65.0+dfsg1.tar.xz rustc-upstream/1.65.0+dfsg1.zip |
Adding upstream version 1.65.0+dfsg1.upstream/1.65.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | src/test/ui/dyn-star/const.rs | 14 | ||||
-rw-r--r-- | src/test/ui/dyn-star/drop.rs | 23 | ||||
-rw-r--r-- | src/test/ui/dyn-star/drop.run.stdout | 1 | ||||
-rw-r--r-- | src/test/ui/dyn-star/error.rs | 13 | ||||
-rw-r--r-- | src/test/ui/dyn-star/error.stderr | 9 | ||||
-rw-r--r-- | src/test/ui/dyn-star/feature-gate-dyn_star.rs | 9 | ||||
-rw-r--r-- | src/test/ui/dyn-star/feature-gate-dyn_star.stderr | 12 | ||||
-rw-r--r-- | src/test/ui/dyn-star/make-dyn-star.rs | 13 | ||||
-rw-r--r-- | src/test/ui/dyn-star/method.rs | 26 | ||||
-rw-r--r-- | src/test/ui/dyn-star/syntax.rs | 11 |
10 files changed, 131 insertions, 0 deletions
diff --git a/src/test/ui/dyn-star/const.rs b/src/test/ui/dyn-star/const.rs new file mode 100644 index 000000000..e49caf649 --- /dev/null +++ b/src/test/ui/dyn-star/const.rs @@ -0,0 +1,14 @@ +// run-pass +#![feature(dyn_star)] +#![allow(unused, incomplete_features)] + +use std::fmt::Debug; + +fn make_dyn_star() { + let i = 42usize; + let dyn_i: dyn* Debug = i as dyn* Debug; +} + +fn main() { + make_dyn_star(); +} diff --git a/src/test/ui/dyn-star/drop.rs b/src/test/ui/dyn-star/drop.rs new file mode 100644 index 000000000..46b232f3d --- /dev/null +++ b/src/test/ui/dyn-star/drop.rs @@ -0,0 +1,23 @@ +// run-pass +// check-run-results +#![feature(dyn_star)] +#![allow(incomplete_features)] + +use std::fmt::Debug; + +#[derive(Debug)] +struct Foo(usize); + +impl Drop for Foo { + fn drop(&mut self) { + println!("destructor called"); + } +} + +fn make_dyn_star(i: Foo) { + let _dyn_i: dyn* Debug = i as dyn* Debug; +} + +fn main() { + make_dyn_star(Foo(42)); +} diff --git a/src/test/ui/dyn-star/drop.run.stdout b/src/test/ui/dyn-star/drop.run.stdout new file mode 100644 index 000000000..dadb33ccf --- /dev/null +++ b/src/test/ui/dyn-star/drop.run.stdout @@ -0,0 +1 @@ +destructor called diff --git a/src/test/ui/dyn-star/error.rs b/src/test/ui/dyn-star/error.rs new file mode 100644 index 000000000..33eff80a5 --- /dev/null +++ b/src/test/ui/dyn-star/error.rs @@ -0,0 +1,13 @@ +#![feature(dyn_star)] +#![allow(incomplete_features)] + +use std::fmt::Debug; + +trait Foo {} + +fn make_dyn_star() { + let i = 42; + let dyn_i: dyn* Foo = i as dyn* Foo; //~ ERROR trait bound `{integer}: Foo` is not satisfied +} + +fn main() {} diff --git a/src/test/ui/dyn-star/error.stderr b/src/test/ui/dyn-star/error.stderr new file mode 100644 index 000000000..d612ccc63 --- /dev/null +++ b/src/test/ui/dyn-star/error.stderr @@ -0,0 +1,9 @@ +error[E0277]: the trait bound `{integer}: Foo` is not satisfied + --> $DIR/error.rs:10:27 + | +LL | let dyn_i: dyn* Foo = i as dyn* Foo; + | ^ the trait `Foo` is not implemented for `{integer}` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/dyn-star/feature-gate-dyn_star.rs b/src/test/ui/dyn-star/feature-gate-dyn_star.rs new file mode 100644 index 000000000..4756661cf --- /dev/null +++ b/src/test/ui/dyn-star/feature-gate-dyn_star.rs @@ -0,0 +1,9 @@ +// Feature gate test for dyn_star + +/// dyn* is not necessarily the final surface syntax (if we have one at all), +/// but for now we will support it to aid in writing tests independently. +pub fn dyn_star_parameter(_: &dyn* Send) { + //~^ dyn* trait objects are unstable +} + +fn main() {} diff --git a/src/test/ui/dyn-star/feature-gate-dyn_star.stderr b/src/test/ui/dyn-star/feature-gate-dyn_star.stderr new file mode 100644 index 000000000..2767e9478 --- /dev/null +++ b/src/test/ui/dyn-star/feature-gate-dyn_star.stderr @@ -0,0 +1,12 @@ +error[E0658]: dyn* trait objects are unstable + --> $DIR/feature-gate-dyn_star.rs:5:31 + | +LL | pub fn dyn_star_parameter(_: &dyn* Send) { + | ^^^^^^^^^ + | + = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information + = help: add `#![feature(dyn_star)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/dyn-star/make-dyn-star.rs b/src/test/ui/dyn-star/make-dyn-star.rs new file mode 100644 index 000000000..708ffa25d --- /dev/null +++ b/src/test/ui/dyn-star/make-dyn-star.rs @@ -0,0 +1,13 @@ +// run-pass +#![feature(dyn_star)] +#![allow(incomplete_features)] + +use std::fmt::Debug; + +fn make_dyn_star(i: usize) { + let _dyn_i: dyn* Debug = i as dyn* Debug; +} + +fn main() { + make_dyn_star(42); +} diff --git a/src/test/ui/dyn-star/method.rs b/src/test/ui/dyn-star/method.rs new file mode 100644 index 000000000..d04958ca2 --- /dev/null +++ b/src/test/ui/dyn-star/method.rs @@ -0,0 +1,26 @@ +// run-pass +#![feature(dyn_star)] +#![allow(incomplete_features)] + +trait Foo { + fn get(&self) -> usize; +} + +impl Foo for usize { + fn get(&self) -> usize { + *self + } +} + +fn invoke_dyn_star(i: dyn* Foo) -> usize { + i.get() +} + +fn make_and_invoke_dyn_star(i: usize) -> usize { + let dyn_i: dyn* Foo = i as dyn* Foo; + invoke_dyn_star(dyn_i) +} + +fn main() { + println!("{}", make_and_invoke_dyn_star(42)); +} diff --git a/src/test/ui/dyn-star/syntax.rs b/src/test/ui/dyn-star/syntax.rs new file mode 100644 index 000000000..618c72562 --- /dev/null +++ b/src/test/ui/dyn-star/syntax.rs @@ -0,0 +1,11 @@ +// Make sure we can parse the `dyn* Trait` syntax +// +// check-pass + +#![feature(dyn_star)] +#![allow(incomplete_features)] + +pub fn dyn_star_parameter(_: dyn* Send) { +} + +fn main() {} |