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

Add ConstraintCategory::Usage for handling aggregate construction #88708

Merged
merged 1 commit into from
Sep 20, 2021

Commits on Sep 16, 2021

  1. Add ConstraintCategory::Usage for handling aggregate construction

    In some cases, we emit borrowcheck diagnostics pointing
    at a particular field expression in a struct expression
    (e.g. `MyStruct { field: my_expr }`). However, this
    behavior currently relies on us choosing the
    `ConstraintCategory::Boring` with the 'correct' span.
    When adding additional variants to `ConstraintCategory`,
    (or changing existing usages away from `ConstraintCategory::Boring`),
    the current behavior can easily get broken, since a non-boring
    constraint will get chosen over a boring one.
    
    To make the diagnostic output less fragile, this commit
    adds a `ConstraintCategory::Usage` variant. We use this variant
    for the temporary assignments created for each field of
    an aggregate we are constructing.
    
    Using this new variant, we can emit a message mentioning
    "this usage", emphasizing the fact that the error message
    is related to the specific use site (in the struct expression).
    
    This is preparation for additional work on improving NLL error messages
    (see rust-lang#57374)
    Aaron1011 committed Sep 16, 2021
    Configuration menu
    Copy the full SHA
    a41a13f View commit details
    Browse the repository at this point in the history