]> git.lizzy.rs Git - rust.git/commit
Rollup merge of #72598 - Aaron1011:feature/fnmut-capture-span, r=nikomatsakis
authorRalf Jung <post@ralfj.de>
Mon, 15 Jun 2020 07:57:28 +0000 (09:57 +0200)
committerGitHub <noreply@github.com>
Mon, 15 Jun 2020 07:57:28 +0000 (09:57 +0200)
commit5193c5d60881e19afdfbab98cbc7ba6b7607ee18
tree548621e4e5e97d37bff0f91e704cc6d53f6ab0e8
parente6510babc786469075f76db94fedfe651072bf25
parent9cee22c1a401ace6dd8633335b131c47a37d7bac
Rollup merge of #72598 - Aaron1011:feature/fnmut-capture-span, r=nikomatsakis

Display information about captured variable in `FnMut` error

Fixes #69446

When we encounter a region error involving an `FnMut` closure, we
display a specialized error message. However, we currently do not
tell the user which upvar was captured. This makes it difficult to
determine the cause of the error, especially when the closure is large.

This commit records marks constraints involving closure upvars
with `ConstraintCategory::ClosureUpvar`. When we decide to 'blame'
a `ConstraintCategory::Return`, we additionall store
the captured upvar if we found a `ConstraintCategory::ClosureUpvar` in
the path.

When generating an error message, we point to relevant spans if we have
closure upvar information available. We further customize the message if
an `async` closure is being returned, to make it clear that the captured
variable is being returned indirectly.
src/librustc_middle/mir/query.rs
src/librustc_mir/borrow_check/diagnostics/conflict_errors.rs
src/librustc_mir/borrow_check/diagnostics/region_errors.rs
src/librustc_mir/borrow_check/mod.rs
src/librustc_mir/borrow_check/nll.rs
src/librustc_mir/borrow_check/type_check/mod.rs