Skip to content

rocket regression: rigid alias don't require trait to hold #177

@compiler-errors

Description

@compiler-errors
Member

https://crater-reports.s3.amazonaws.com/pr-133502-1/try%23fa8e241660363f48d64b66b05eea58c93ab828fb/reg/rocket-0.5.1/log.txt

Minimized:

use std::{future::Future, pin::Pin};

pub trait FromRequest<'r> {
    type Assoc;
    fn from_request() -> Pin<Box<dyn Future<Output = Self::Assoc> + Send>>;
}

fn from_request<'r, T: FromRequest<'r>>() -> Pin<Box<dyn Future<Output = ()> + Send>> {
    Box::pin(async move {
        T::from_request().await;
    })
}

Activity

compiler-errors

compiler-errors commented on Apr 11, 2025

@compiler-errors
Author
compiler-errors

compiler-errors commented on Apr 11, 2025

@compiler-errors
MemberAuthor

Has to do with the leak check and higher ranked trait bounds b/c of coroutine witness erasure.

I think we're somewhat unnecessarily requiring that dyn Future<Output = Self::Assoc> + Send implements all of its bounds in order for it to implement Send.

Proving the coroutine is Send requires proving (dyn Future<Output = <T as FromRequest<'!0>>::Assoc> + Send): Send. Note that '!0 is some higher ranked lifetime due to coroutine lifetime erasure.

Checking this goal goes through assemble_object_bound_candidates -> probe_and_consider_object_bound_candidate, which equates the self type with itself. That emits an alias-relate goal <T as FromRequest<'!0>>::Assoc == <T as FromRequest<'!0>>::Assoc, which ends up normalizing <T as FromRequest<'!0>>::Assoc, which is rigid, which ends up checking T: FromRequest<'!0> for alias wf.

Since all we know is that T: FromRequest<'r> from the param-env, we end up failing (I believe due to the leak check here).

compiler-errors

compiler-errors commented on Apr 13, 2025

@compiler-errors
MemberAuthor

The reason this doesn't fail in the old solver is b/c we don't check that rigid projections implement their trait goal, lol.

compiler-errors

compiler-errors commented on Apr 13, 2025

@compiler-errors
MemberAuthor

I'm curious to know exactly what the fallout of this is in the old solver: rust-lang/rust#139763

added
from-craterA regression found via a crater run, not part of our test suite
on Apr 14, 2025
moved this from unknown to in progress in -Znext-solver=globallyon Apr 16, 2025
added a commit that references this issue on Apr 16, 2025
c594a88
added a commit that references this issue on Apr 17, 2025
moved this from in progress to done in -Znext-solver=globallyon Apr 17, 2025
closed this as completedby moving to done in -Znext-solver=globallyon Apr 17, 2025
changed the title [-]rocket regression[/-] [+]rocket regression: rigid alias don't require trait to hold[/+] on Apr 17, 2025

1 remaining item

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

from-craterA regression found via a crater run, not part of our test suite

Type

No type

Projects

Status

done

Milestone

No milestone

Relationships

None yet

    Development

    Participants

    @compiler-errors@lcnr

    Issue actions

      rocket regression: rigid alias don't require trait to hold · Issue #177 · rust-lang/trait-system-refactor-initiative