diff options
| author | dswij <dswijj@gmail.com> | 2023-06-23 02:53:34 +0800 |
|---|---|---|
| committer | dswij <dswijj@gmail.com> | 2023-06-25 21:32:02 +0800 |
| commit | 91351ef48676638101ee24bba3403e8cf81d510c (patch) | |
| tree | 87a99aa73a0414cda7d0c078858685f4ee83b4be /tests | |
| parent | 7b9b1277009c407010298bd2f195f83af31fd06b (diff) | |
| download | rust-91351ef48676638101ee24bba3403e8cf81d510c.tar.gz rust-91351ef48676638101ee24bba3403e8cf81d510c.zip | |
Add test for futures with HRTB
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/higher-ranked/trait-bounds/future.classic.stderr | 6 | ||||
| -rw-r--r-- | tests/ui/higher-ranked/trait-bounds/future.rs | 38 |
2 files changed, 44 insertions, 0 deletions
diff --git a/tests/ui/higher-ranked/trait-bounds/future.classic.stderr b/tests/ui/higher-ranked/trait-bounds/future.classic.stderr new file mode 100644 index 00000000000..33c0f7173a1 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/future.classic.stderr @@ -0,0 +1,6 @@ +error: the compiler unexpectedly panicked. this is a bug. + +query stack during panic: +#0 [evaluate_obligation] evaluating trait selection obligation `for<'a> [async fn body@$DIR/future.rs:32:35: 34:2]: core::future::future::Future` +#1 [codegen_select_candidate] computing candidate for `<strlen as Trait>` +end of query stack diff --git a/tests/ui/higher-ranked/trait-bounds/future.rs b/tests/ui/higher-ranked/trait-bounds/future.rs new file mode 100644 index 00000000000..da7ee034329 --- /dev/null +++ b/tests/ui/higher-ranked/trait-bounds/future.rs @@ -0,0 +1,38 @@ +// ignore-tidy-linelength +// edition:2021 +// revisions: classic next +//[next] compile-flags: -Ztrait-solver=next +//[next] check-pass +//[classic] known-bug: #112347 +//[classic] build-fail +//[classic] failure-status: 101 +//[classic] normalize-stderr-test "note: .*\n\n" -> "" +//[classic] normalize-stderr-test "thread 'rustc' panicked.*\n" -> "" +//[classic] normalize-stderr-test "(error: internal compiler error: [^:]+):\d+:\d+: " -> "$1:LL:CC: " +//[classic] rustc-env:RUST_BACKTRACE=0 + +#![feature(unboxed_closures)] + +use std::future::Future; + +trait Trait { + fn func(&self, _: &str); +} + +impl<T> Trait for T +where + for<'a> T: Fn<(&'a str,)> + Send + Sync, + for<'a> <T as FnOnce<(&'a str,)>>::Output: Future<Output = usize> + Send, +{ + fn func(&self, _: &str) { + println!("hello!"); + } +} + +async fn strlen(x: &str) -> usize { + x.len() +} + +fn main() { + strlen.func("hi"); +} |
