Skip to content

rustc doesn't check nested WFness if it's in a higher-ranked predicate #104

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

Open
compiler-errors opened this issue Apr 8, 2024 · 2 comments

Comments

@compiler-errors
Copy link
Member

compiler-errors commented Apr 8, 2024

rust-lang/rust#122501 (comment)

This will probably end up complicating implied bounds computation in binders?

@compiler-errors
Copy link
Member Author

Minimal I think:

trait Bound {}

struct W<'a, T: Bound>(&'a T);

fn wf<T>() where for<'a> W<'a, T>: Sized {}

We should recurse on W<'a, T> and see T: Bound must hold, but we don't even recurse on the self arg of the predicate because the trait has escaping bound vars.

@jackh726
Copy link
Member

That regression list sucks. I think this is something we should consider slowly moving towards error (or at least deny-by-default) by starting with a warn-by-default lint.

I'm also curious if there's a good MCVE for things that are so "obvious" as the example above. This modification, for example, is pretty clear what the problem is when trying to call wf:

use std::fmt::Debug;

trait Bound {}

struct W<'a, T: Bound>(&'a T);

fn wf<T>() where for<'a> W<'a, T>: Debug {}

fn main() {
    wf::<u32>();
}

But, I could imagine that we can have move subtle things we don't check in e.g. super trait bounds. These could be good candidates to also move towards erroring quicker.

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

2 participants