diff options
| author | bors <bors@rust-lang.org> | 2022-04-08 10:41:10 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-04-08 10:41:10 +0000 |
| commit | e4f5b15b8832334eca2c0bd3929eb3969f1d166d (patch) | |
| tree | 9b5684d1a1da8238910873984b75fa03e1bf0c4a /src/test | |
| parent | 1a4b9a85634c17a60e8802307510c300a35a4b9b (diff) | |
| parent | 7b285d09e9e4ccf8273cc03dba28e8a428e6084e (diff) | |
Auto merge of #95798 - Dylan-DPC:rollup-51hx1wl, r=Dylan-DPC
Rollup of 7 pull requests
Successful merges:
- #95102 (Add known-bug for #95034)
- #95579 (Add `<[[T; N]]>::flatten{_mut}`)
- #95634 (Mailmap update)
- #95705 (Promote x86_64-unknown-none target to Tier 2 and distribute build artifacts)
- #95761 (Kickstart the inner usage of `macro_metavar_expr`)
- #95782 (Windows: Increase a pipe's buffer capacity to 64kb)
- #95791 (hide an #[allow] directive from the Arc::new_cyclic doc example)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/ui/hrtb/issue-94034.rs | 96 | ||||
| -rw-r--r-- | src/test/ui/hrtb/issue-94034.stderr | 1 |
2 files changed, 97 insertions, 0 deletions
diff --git a/src/test/ui/hrtb/issue-94034.rs b/src/test/ui/hrtb/issue-94034.rs new file mode 100644 index 00000000000..5239e5db11c --- /dev/null +++ b/src/test/ui/hrtb/issue-94034.rs @@ -0,0 +1,96 @@ +// known-bug +// failure-status: 101 +// compile-flags: --edition=2021 --crate-type=lib +// rustc-env:RUST_BACKTRACE=0 + +// normalize-stderr-test "thread 'rustc' panicked.*" -> "thread 'rustc' panicked" +// normalize-stderr-test "note:.*RUST_BACKTRACE=1.*\n" -> "" +// normalize-stderr-test "\nerror: internal compiler error.*\n\n" -> "" +// normalize-stderr-test "note:.*unexpectedly panicked.*\n\n" -> "" +// normalize-stderr-test "note: we would appreciate a bug report.*\n\n" -> "" +// normalize-stderr-test "note: compiler flags.*\n\n" -> "" +// normalize-stderr-test "note: rustc.*running on.*\n\n" -> "" +// normalize-stderr-test "query stack during panic:\n" -> "" +// normalize-stderr-test "we're just showing a limited slice of the query stack\n" -> "" +// normalize-stderr-test "end of query stack\n" -> "" +// normalize-stderr-test "#.*\n" -> "" + +// This should not ICE. + +use std::{ + future::Future, + marker::PhantomData, + pin::Pin, + task::{Context, Poll}, +}; + +mod object { + use super::*; + + pub trait Object<'a> { + type Error; + type Future: Future<Output = Self>; + fn create() -> Self::Future; + } + + impl<'a> Object<'a> for u8 { + type Error = (); + type Future = Pin<Box<dyn Future<Output = Self>>>; + fn create() -> Self::Future { + unimplemented!() + } + } + + impl<'a, E, A: Object<'a, Error = E>> Object<'a> for (A,) { + type Error = (); + type Future = CustomFut<'a, E, A>; + fn create() -> Self::Future { + unimplemented!() + } + } + + pub struct CustomFut<'f, E, A: Object<'f, Error = E>> { + ph: PhantomData<(A::Future,)>, + } + + impl<'f, E, A: Object<'f, Error = E>> Future for CustomFut<'f, E, A> { + type Output = (A,); + fn poll(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Self::Output> { + unimplemented!() + } + } +} + +mod async_fn { + use super::*; + + pub trait AsyncFn { + type Future: Future<Output = ()>; + fn call(&self) -> Self::Future; + } + + impl<F, Fut> AsyncFn for F + where + F: Fn() -> Fut, + Fut: Future<Output = ()>, + { + type Future = Fut; + fn call(&self) -> Self::Future { + (self)() + } + } +} + +pub async fn test() { + use self::{async_fn::AsyncFn, object::Object}; + + async fn create<T: Object<'static>>() { + T::create().await; + } + + async fn call_async_fn(inner: impl AsyncFn) { + inner.call().await; + } + + call_async_fn(create::<(u8,)>).await; +} diff --git a/src/test/ui/hrtb/issue-94034.stderr b/src/test/ui/hrtb/issue-94034.stderr new file mode 100644 index 00000000000..1d8329142fc --- /dev/null +++ b/src/test/ui/hrtb/issue-94034.stderr @@ -0,0 +1 @@ +thread 'rustc' panicked |
