Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add regression test #96667

Merged
merged 1 commit into from
May 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#![feature(type_alias_impl_trait)]

// edition:2018
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, I think this probably should be at the top of the file, I'm not sure it gets picked up by current compiletest otherwise.


use std::future::Future;

pub trait Service<Request> {
type Future: Future<Output = ()>;
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<Output = ()>;
fn call(&mut self, _: ()) -> Self::Future {
async { new() }
}
}
22 changes: 22 additions & 0 deletions src/test/ui/type-alias-impl-trait/collect_hidden_types.rs
Original file line number Diff line number Diff line change
@@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure we parse these (at least yet -- unless we already merged the compiletest PR Pietro was working on here)?

I'd rather they be at the top of the file regardless.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have many other such cases in our test suite. The comments only get ignored after the first item, possibly even allowed after use statements.


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() {}