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 member constraints pick static if no upper bounds #89056

Closed
wants to merge 2 commits into from

Commits on Sep 17, 2021

  1. make member constraints pick static if no upper bounds

    The current member constraint algorithm has a failure mode when it encounters a
    variable `'0` and the only constraint is that `':static: '0`. In that case,
    there are no upper bounds, or at least no non-trivial upper bounds.  As a
    result, we are not able to rule out any of the choices, so if you have a
    constraint like `'0 member ['a, 'b, 'static]`, where `'a` and `'b` are
    unrelated, then the algorithm gets stuck as there is no 'least choice' from
    that set.
    
    The tweak in this commit changes the algorithm so that *if* there are no upper
    bounds (and hence `'0` can get as large as desired without creating a region
    check error), it will just pick `'static`. This should only occur in cases
    where the data is flowing out from a `'static` value.
    
    This change is probably *not* right for impl Trait in let bindings, but those
    are challenging with member constraints anyway, and not currently supported.
    Furthermore, this change is not needed in a polonius-like formulation, which
    effectively permits "ad-hoc intersections" of lifetimes as the value for a
    region, and hence could give a value like `'a ^ 'b` as the resulting lifetime.
    Therefore I think there isn't forwards compat danger here. (famous last words?)
    nikomatsakis committed Sep 17, 2021
    Configuration menu
    Copy the full SHA
    b893cff View commit details
    Browse the repository at this point in the history

Commits on Sep 23, 2021

  1. Configuration menu
    Copy the full SHA
    92b2be2 View commit details
    Browse the repository at this point in the history