-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Regression in Beta/Nightly: implementation of Trait
is not general enough
#106630
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
searched nightlies: from nightly-2022-10-29 to nightly-2022-12-10 bisected with cargo-bisect-rustc v0.6.5Host triple: x86_64-unknown-linux-gnu cargo bisect-rustc --access=github --start=1.66.0 --end=2022-12-10 -- build -p=gotham_examples_handlers_simple_async_handlers_await @rustbot label +regression-from-stable-to-beta -regression-untriaged |
@albertlarsan68 The rollup can itself be checked with these artifacts. I'm pretty sure it's going to be #105255 again. |
It is in fact #105255 that makes this error, cc @cjgillot @compiler-errors |
WG-prioritization assigning priority (Zulip discussion). @rustbot label -I-prioritize +P-high T-compiler |
I think we still would like an mcve and regression test to be added. Lowering priority since this was reverted. |
Here's a smaller version that fails to compile on mod gotham {
use std::future::Future;
pub struct State;
pub trait IntoResponse {}
pub struct Response;
impl IntoResponse for Response {}
mod private {
use super::*;
pub trait HandlerMarker {}
pub trait AsyncHandlerFn<'a> {
type Res;
}
impl<'a, Fut, R, F> AsyncHandlerFn<'a> for F
where
F: FnOnce(&'a mut State) -> Fut,
Fut: Future<Output = R> + Send + 'a
{
type Res = R;
}
impl<F, R> HandlerMarker for F
where
R: IntoResponse + 'static,
for<'a> F: AsyncHandlerFn<'a, Res = R> + Send
{
}
}
pub fn to_async_borrowing<F>(handler: F)
where
F: private::HandlerMarker
{
_ = handler;
}
}
use gotham::*;
async fn sleep_handler(_: &mut State) -> impl IntoResponse {
Response
}
fn main() {
to_async_borrowing(sleep_handler);
} |
Untagging as a regression since I believe we expect this to already be fixed on beta + nightly as of #106759 (and its backport). |
I managed to get the code that triggers the regression even shorter: use std::future::Future;
trait AsyncCallback<'a> {
type Out;
}
impl<'a, Fut, T, F> AsyncCallback<'a> for F
where
F: FnOnce(&'a mut ()) -> Fut,
Fut: Future<Output = T> + Send + 'a,
{
type Out = T;
}
trait CallbackMarker {}
impl<F, T> CallbackMarker for F
where
T: 'static,
for<'a> F: AsyncCallback<'a, Out = T> + Send,
{
}
fn do_sth<F: CallbackMarker>(_: F) {}
async fn callback(_: &mut ()) -> impl Send {}
fn main() {
do_sth(callback);
} Do you want me to create a PR that adds a test for this code? If so, is there some guide on how to add regression tests? |
Triage: this has got a MCVE.
@msrd0 I'm not an experienced compiler dev but I believe you simply add a test case file to |
…trochenkov Add regression test for rust-lang#106630 This PR adds a regression test for rust-lang#106630. I was unsure where exactly to place the test or how to test it locally so please let me know if I should change something.
…iaskrgr Rollup of 5 pull requests Successful merges: - rust-lang#119331 (rustdoc-search: count path edits with separate edit limit) - rust-lang#119359 (Simplify Parser::ident_or_error) - rust-lang#119376 (Add regression test for rust-lang#106630) - rust-lang#119379 (Update `parse_seq` doc) - rust-lang#119380 (Don't suggest writing a bodyless arm if the pattern can never be a never pattern) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#119376 - msrd0:regression-test-106630, r=petrochenkov Add regression test for rust-lang#106630 This PR adds a regression test for rust-lang#106630. I was unsure where exactly to place the test or how to test it locally so please let me know if I should change something.
Code
I tried this code:
https://github.com/gotham-rs/gotham/tree/3da82b63e36db81f73f0d88b7610a3979c62289a/examples/handlers/simple_async_handlers_await
I expected to see this happen: Code compiles (as it does on stable: https://github.com/gotham-rs/gotham/actions/runs/3873554934/jobs/6603712754)
Instead, this happened: Code fails to compile (on beta: https://github.com/gotham-rs/gotham/actions/runs/3873554934/jobs/6603712995 and nightly: https://github.com/gotham-rs/gotham/actions/runs/3873554934/jobs/6603713263)
Version it worked on
It most recently worked on: 1.66.0 (69f9c33 2022-12-12)
Version with regression
1.67.0-beta.6 (51b0345 2022-12-31) and rustc 1.68.0-nightly (cc47b06 2023-01-08)
@rustbot modify labels: +regression-from-stable-to-beta
The text was updated successfully, but these errors were encountered: