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

Make reproducing test(s) for failing to generalize program clauses #614

Open
nathanwhit opened this issue Sep 28, 2020 · 2 comments
Open

Comments

@nathanwhit
Copy link
Member

If program clauses are not properly generalized it can cause issues in the recursive solver. This was the cause of the recent breakage in rust-analyzer. We should have a test that covers this to prevent future issues.

Discussed briefly here.

bors added a commit that referenced this issue Dec 10, 2020
Pass canonical goals to program clauses code in SLG solver

It seemed like we were leaning towards this solution in the [design meeting](https://rust-lang.zulipchat.com/#narrow/stream/144729-wg-traits/topic/meeting.202020-09-22), and it turned out (assuming these changes are right) to be pretty straightforward.

Closes #568.

This should stop seeing issues related to failing to generalize program clauses pop up, but I'm only going to cc #614 since I'd like some tests maybe.
@detrumi
Copy link
Member

detrumi commented Jan 15, 2021

Minimal example:

fn main() {
    foo(|a: u32| {});
}

fn foo<F>(f: F)
where
    F: Send,
{
}

Trying to fit this in a test is tricky though, as the problem triggers with this goal:

Implemented({closure:ClosureId(0)}<for<0> Safe () [?0 := Uint(U32), ?1 := ^1.0]>: Send)

The syntax has changed slightly since (old debug formatting here), but this is a TyKind::Closure with the substitution being a FnPointer (for<0> Safe () [?0 := Uint(U32), ?1 := ^1.0]).

I don't think there's currently a way to trigger closure substitutions in chalk tests. My attempts so far:

test! {
        program {
            #[lang(fn_once)]
            trait FnOnce<Args> {
                type Output;
            }

            #[auto] trait Send { }

            fn foo<F>(f: F) -> ()
                where F: Send;

            closure bar(self, a: u32) {}
        }

        goal {
            <bar as FnOnce<(foo<(bar, u32)>)>>: Send // Not valid test syntax
        } yields {
            "Unique"
        }
    }

Similar goals like bar: Send or fn(bar): Send don't trigger the problem.

@flodiebold
Copy link
Member

Yes, I've had similar problems reproducing problems with closures from RA. Maybe the closure support in the test harness needs to be more flexible somehow. I've usually been able to reproduce the problems by just modeling the closure as a normal struct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants