summaryrefslogtreecommitdiffstats
path: root/tests/ui/async-await/return-type-notation
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
commit9835e2ae736235810b4ea1c162ca5e65c547e770 (patch)
tree3fcebf40ed70e581d776a8a4c65923e8ec20e026 /tests/ui/async-await/return-type-notation
parentReleasing progress-linux version 1.70.0+dfsg2-1~progress7.99u1. (diff)
downloadrustc-9835e2ae736235810b4ea1c162ca5e65c547e770.tar.xz
rustc-9835e2ae736235810b4ea1c162ca5e65c547e770.zip
Merging upstream version 1.71.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/async-await/return-type-notation')
-rw-r--r--tests/ui/async-await/return-type-notation/issue-110963-early.rs48
-rw-r--r--tests/ui/async-await/return-type-notation/issue-110963-early.stderr37
-rw-r--r--tests/ui/async-await/return-type-notation/issue-110963-late.rs49
-rw-r--r--tests/ui/async-await/return-type-notation/issue-110963-late.stderr11
-rw-r--r--tests/ui/async-await/return-type-notation/super-method-bound-ambig.rs32
-rw-r--r--tests/ui/async-await/return-type-notation/super-method-bound-ambig.stderr19
-rw-r--r--tests/ui/async-await/return-type-notation/super-method-bound.rs25
-rw-r--r--tests/ui/async-await/return-type-notation/super-method-bound.stderr11
-rw-r--r--tests/ui/async-await/return-type-notation/supertrait-bound.rs11
-rw-r--r--tests/ui/async-await/return-type-notation/supertrait-bound.stderr11
10 files changed, 254 insertions, 0 deletions
diff --git a/tests/ui/async-await/return-type-notation/issue-110963-early.rs b/tests/ui/async-await/return-type-notation/issue-110963-early.rs
new file mode 100644
index 000000000..0ecbca5c1
--- /dev/null
+++ b/tests/ui/async-await/return-type-notation/issue-110963-early.rs
@@ -0,0 +1,48 @@
+// edition: 2021
+// known-bug: #110963
+
+#![feature(return_type_notation)]
+#![feature(async_fn_in_trait)]
+
+trait HealthCheck {
+ async fn check<'a: 'a>(&'a mut self) -> bool;
+}
+
+async fn do_health_check_par<HC>(hc: HC)
+where
+ HC: HealthCheck<check(): Send> + Send + 'static,
+{
+ spawn(async move {
+ let mut hc = hc;
+ if !hc.check().await {
+ log_health_check_failure().await;
+ }
+ });
+}
+
+async fn log_health_check_failure() {}
+
+fn main() {}
+
+// Fake tokio spawn
+
+use std::future::Future;
+use std::pin::Pin;
+use std::task::{Context, Poll};
+
+fn spawn<F>(future: F) -> JoinHandle
+where
+ F: Future + Send + 'static,
+ F::Output: Send + 'static,
+{
+ loop {}
+}
+
+struct JoinHandle;
+
+impl Future for JoinHandle {
+ type Output = ();
+ fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
+ loop {}
+ }
+}
diff --git a/tests/ui/async-await/return-type-notation/issue-110963-early.stderr b/tests/ui/async-await/return-type-notation/issue-110963-early.stderr
new file mode 100644
index 000000000..33e22dec3
--- /dev/null
+++ b/tests/ui/async-await/return-type-notation/issue-110963-early.stderr
@@ -0,0 +1,37 @@
+warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes
+ --> $DIR/issue-110963-early.rs:4:12
+ |
+LL | #![feature(return_type_notation)]
+ | ^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information
+ = note: `#[warn(incomplete_features)]` on by default
+
+error: higher-ranked lifetime error
+ --> $DIR/issue-110963-early.rs:15:5
+ |
+LL | / spawn(async move {
+LL | | let mut hc = hc;
+LL | | if !hc.check().await {
+LL | | log_health_check_failure().await;
+LL | | }
+LL | | });
+ | |______^
+ |
+ = note: could not prove `[async block@$DIR/issue-110963-early.rs:15:11: 20:6]: Send`
+
+error: higher-ranked lifetime error
+ --> $DIR/issue-110963-early.rs:15:5
+ |
+LL | / spawn(async move {
+LL | | let mut hc = hc;
+LL | | if !hc.check().await {
+LL | | log_health_check_failure().await;
+LL | | }
+LL | | });
+ | |______^
+ |
+ = note: could not prove `[async block@$DIR/issue-110963-early.rs:15:11: 20:6]: Send`
+
+error: aborting due to 2 previous errors; 1 warning emitted
+
diff --git a/tests/ui/async-await/return-type-notation/issue-110963-late.rs b/tests/ui/async-await/return-type-notation/issue-110963-late.rs
new file mode 100644
index 000000000..17b5d775d
--- /dev/null
+++ b/tests/ui/async-await/return-type-notation/issue-110963-late.rs
@@ -0,0 +1,49 @@
+// edition: 2021
+// check-pass
+
+#![feature(return_type_notation)]
+//~^ WARN the feature `return_type_notation` is incomplete
+#![feature(async_fn_in_trait)]
+
+trait HealthCheck {
+ async fn check(&mut self) -> bool;
+}
+
+async fn do_health_check_par<HC>(hc: HC)
+where
+ HC: HealthCheck<check(): Send> + Send + 'static,
+{
+ spawn(async move {
+ let mut hc = hc;
+ if !hc.check().await {
+ log_health_check_failure().await;
+ }
+ });
+}
+
+async fn log_health_check_failure() {}
+
+fn main() {}
+
+// Fake tokio spawn
+
+use std::future::Future;
+use std::pin::Pin;
+use std::task::{Context, Poll};
+
+fn spawn<F>(future: F) -> JoinHandle
+where
+ F: Future + Send + 'static,
+ F::Output: Send + 'static,
+{
+ loop {}
+}
+
+struct JoinHandle;
+
+impl Future for JoinHandle {
+ type Output = ();
+ fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
+ loop {}
+ }
+}
diff --git a/tests/ui/async-await/return-type-notation/issue-110963-late.stderr b/tests/ui/async-await/return-type-notation/issue-110963-late.stderr
new file mode 100644
index 000000000..9c6966537
--- /dev/null
+++ b/tests/ui/async-await/return-type-notation/issue-110963-late.stderr
@@ -0,0 +1,11 @@
+warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes
+ --> $DIR/issue-110963-late.rs:4:12
+ |
+LL | #![feature(return_type_notation)]
+ | ^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information
+ = note: `#[warn(incomplete_features)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/async-await/return-type-notation/super-method-bound-ambig.rs b/tests/ui/async-await/return-type-notation/super-method-bound-ambig.rs
new file mode 100644
index 000000000..028e526b5
--- /dev/null
+++ b/tests/ui/async-await/return-type-notation/super-method-bound-ambig.rs
@@ -0,0 +1,32 @@
+// edition:2021
+
+#![feature(async_fn_in_trait, return_type_notation)]
+//~^ WARN the feature `return_type_notation` is incomplete
+
+trait Super1<'a> {
+ async fn test();
+}
+impl Super1<'_> for () {
+ async fn test() {}
+}
+
+trait Super2 {
+ async fn test();
+}
+impl Super2 for () {
+ async fn test() {}
+}
+
+trait Foo: for<'a> Super1<'a> + Super2 {}
+impl Foo for () {}
+
+fn test<T>()
+where
+ T: Foo<test(): Send>,
+ //~^ ERROR ambiguous associated function `test` for `Foo`
+{
+}
+
+fn main() {
+ test::<()>();
+}
diff --git a/tests/ui/async-await/return-type-notation/super-method-bound-ambig.stderr b/tests/ui/async-await/return-type-notation/super-method-bound-ambig.stderr
new file mode 100644
index 000000000..5bc8dbde4
--- /dev/null
+++ b/tests/ui/async-await/return-type-notation/super-method-bound-ambig.stderr
@@ -0,0 +1,19 @@
+warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes
+ --> $DIR/super-method-bound-ambig.rs:3:31
+ |
+LL | #![feature(async_fn_in_trait, return_type_notation)]
+ | ^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information
+ = note: `#[warn(incomplete_features)]` on by default
+
+error: ambiguous associated function `test` for `Foo`
+ --> $DIR/super-method-bound-ambig.rs:25:12
+ |
+LL | T: Foo<test(): Send>,
+ | ^^^^^^^^^^^^
+ |
+ = note: `test` is declared in two supertraits: `Super2` and `Super1<'a>`
+
+error: aborting due to previous error; 1 warning emitted
+
diff --git a/tests/ui/async-await/return-type-notation/super-method-bound.rs b/tests/ui/async-await/return-type-notation/super-method-bound.rs
new file mode 100644
index 000000000..58ea3578d
--- /dev/null
+++ b/tests/ui/async-await/return-type-notation/super-method-bound.rs
@@ -0,0 +1,25 @@
+// edition:2021
+// check-pass
+
+#![feature(async_fn_in_trait, return_type_notation)]
+//~^ WARN the feature `return_type_notation` is incomplete
+
+trait Super<'a> {
+ async fn test();
+}
+impl Super<'_> for () {
+ async fn test() {}
+}
+
+trait Foo: for<'a> Super<'a> {}
+impl Foo for () {}
+
+fn test<T>()
+where
+ T: Foo<test(): Send>,
+{
+}
+
+fn main() {
+ test::<()>();
+}
diff --git a/tests/ui/async-await/return-type-notation/super-method-bound.stderr b/tests/ui/async-await/return-type-notation/super-method-bound.stderr
new file mode 100644
index 000000000..ac0668d3c
--- /dev/null
+++ b/tests/ui/async-await/return-type-notation/super-method-bound.stderr
@@ -0,0 +1,11 @@
+warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes
+ --> $DIR/super-method-bound.rs:4:31
+ |
+LL | #![feature(async_fn_in_trait, return_type_notation)]
+ | ^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information
+ = note: `#[warn(incomplete_features)]` on by default
+
+warning: 1 warning emitted
+
diff --git a/tests/ui/async-await/return-type-notation/supertrait-bound.rs b/tests/ui/async-await/return-type-notation/supertrait-bound.rs
new file mode 100644
index 000000000..19bcfe304
--- /dev/null
+++ b/tests/ui/async-await/return-type-notation/supertrait-bound.rs
@@ -0,0 +1,11 @@
+// check-pass
+
+#![feature(return_position_impl_trait_in_trait, return_type_notation)]
+//~^ WARN the feature `return_type_notation` is incomplete and may not be safe to use
+
+trait IntFactory {
+ fn stream(&self) -> impl Iterator<Item = i32>;
+}
+trait SendIntFactory: IntFactory<stream(): Send> + Send {}
+
+fn main() {}
diff --git a/tests/ui/async-await/return-type-notation/supertrait-bound.stderr b/tests/ui/async-await/return-type-notation/supertrait-bound.stderr
new file mode 100644
index 000000000..c8cec4946
--- /dev/null
+++ b/tests/ui/async-await/return-type-notation/supertrait-bound.stderr
@@ -0,0 +1,11 @@
+warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes
+ --> $DIR/supertrait-bound.rs:3:49
+ |
+LL | #![feature(return_position_impl_trait_in_trait, return_type_notation)]
+ | ^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information
+ = note: `#[warn(incomplete_features)]` on by default
+
+warning: 1 warning emitted
+