From 52de679c193c249d771d84fdaa1cce0bf70404a4 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Tue, 3 May 2022 09:50:17 +0000 Subject: [PATCH] Add regression test --- .../auxiliary/collect_hidden_types.rs | 21 ++++++++++++++++++ .../collect_hidden_types.rs | 22 +++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 src/test/ui/type-alias-impl-trait/auxiliary/collect_hidden_types.rs create mode 100644 src/test/ui/type-alias-impl-trait/collect_hidden_types.rs diff --git a/src/test/ui/type-alias-impl-trait/auxiliary/collect_hidden_types.rs b/src/test/ui/type-alias-impl-trait/auxiliary/collect_hidden_types.rs new file mode 100644 index 0000000000000..75d20a6fef9fe --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/auxiliary/collect_hidden_types.rs @@ -0,0 +1,21 @@ +#![feature(type_alias_impl_trait)] + +// edition:2018 + +use std::future::Future; + +pub trait Service { + type Future: Future; + fn call(&mut self, req: Request) -> Self::Future; +} + +// NOTE: the pub(crate) here is critical +pub(crate) fn new() -> () {} + +pub struct A; +impl Service<()> for A { + type Future = impl Future; + fn call(&mut self, _: ()) -> Self::Future { + async { new() } + } +} diff --git a/src/test/ui/type-alias-impl-trait/collect_hidden_types.rs b/src/test/ui/type-alias-impl-trait/collect_hidden_types.rs new file mode 100644 index 0000000000000..e78f178e464eb --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/collect_hidden_types.rs @@ -0,0 +1,22 @@ +// aux-build:collect_hidden_types.rs +use collect_hidden_types::Service; +use std::future::Future; +use std::pin::Pin; +use std::task::Context; + +// build-pass + +// edition:2018 + +extern crate collect_hidden_types; + +fn broken(mut a: collect_hidden_types::A, cx: &mut Context<'_>) { + let mut fut = a.call(()); + let _ = unsafe { Pin::new_unchecked(&mut fut) }.poll(cx); +} + +pub async fn meeb(cx: &mut Context<'_>) { + broken(collect_hidden_types::A, cx); +} + +fn main() {}