Commit 31b97f7
committed
Auto merge of #55069 - matthewjasper:explain-free-region-liveness, r=nikomatsakis
[NLL] Use new region infer errors when explaining borrows
Use the new free region infer errors for explaining borrows
This gives at least some explanation for why a borrow is expected to
last for a certain free region. Also:
* Reports E0373: "closure may outlive the current function" with NLL.
* Special cases the case of returning a reference to (or value referencing) a local variable or temporary (E0515).
* Special case assigning a reference to a local variable in a closure to a captured variable. (E0521)
Closes #51026 - `regions-nested-fns-2.rs` isn't changed to that diagnostic, since that would not be the correct error here.
Closes #51169
cc #53882 - The error is (IMO) better now, but it could be better when we trace lifetimes in these error messages.
r? @nikomatsakis cc @pnkfelixFile tree
138 files changed
+1938
-1836
lines changed- src
- librustc_mir
- borrow_check
- nll
- explain_borrow
- region_infer
- error_reporting
- type_check
- util
- librustc
- ich
- mir
- test/ui
- borrowck
- consts
- const-eval
- min_const_fn
- dropck
- dst
- generator
- issues
- nll
- closure-requirements
- relate_tys
- user-annotations
- regions
- span
- static
- traits
- unboxed-closures
- wf
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
138 files changed
+1938
-1836
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
557 | 557 | | |
558 | 558 | | |
559 | 559 | | |
| 560 | + | |
| 561 | + | |
560 | 562 | | |
561 | 563 | | |
562 | 564 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2725 | 2725 | | |
2726 | 2726 | | |
2727 | 2727 | | |
| 2728 | + | |
| 2729 | + | |
2728 | 2730 | | |
2729 | 2731 | | |
2730 | 2732 | | |
| |||
0 commit comments