mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
Add test for futures with HRTB
This commit is contained in:
parent
7b9b127700
commit
91351ef486
@ -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
|
38
tests/ui/higher-ranked/trait-bounds/future.rs
Normal file
38
tests/ui/higher-ranked/trait-bounds/future.rs
Normal file
@ -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");
|
||||
}
|
Loading…
Reference in New Issue
Block a user