Skip to content

Commit 31b97f7

Browse files
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 @pnkfelix
2 parents 66910ba + 2a3969a commit 31b97f7

File tree

138 files changed

+1938
-1836
lines changed

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

src/librustc/ich/impls_mir.rs

+2
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,8 @@ impl_stable_hash_for!(struct mir::ClosureOutlivesRequirement<'tcx> {
557557

558558
impl_stable_hash_for!(enum mir::ConstraintCategory {
559559
Return,
560+
UseAsConst,
561+
UseAsStatic,
560562
TypeAnnotation,
561563
Cast,
562564
ClosureBounds,

src/librustc/mir/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -2725,6 +2725,8 @@ pub struct ClosureOutlivesRequirement<'tcx> {
27252725
#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)]
27262726
pub enum ConstraintCategory {
27272727
Return,
2728+
UseAsConst,
2729+
UseAsStatic,
27282730
TypeAnnotation,
27292731
Cast,
27302732

0 commit comments

Comments
 (0)