-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #54802 - davidtwco:issue-53040, r=pnkfelix
[nll] better error message when returning refs to upvars Fixes #53040. r? @nikomatsakis
- Loading branch information
Showing
12 changed files
with
214 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,13 @@ | ||
error: unsatisfied lifetime constraints | ||
error: captured variable cannot escape `FnMut` closure body | ||
--> $DIR/issue-40510-1.rs:18:9 | ||
| | ||
LL | || { | ||
| -- | ||
| || | ||
| |return type of closure is &'2 mut std::boxed::Box<()> | ||
| lifetime `'1` represents this closure's body | ||
| - inferred to be a `FnMut` closure | ||
LL | &mut x | ||
| ^^^^^^ returning this value requires that `'1` must outlive `'2` | ||
| ^^^^^^ returns a reference to a captured variable which escapes the closure body | ||
| | ||
= note: closure implements `FnMut`, so references to captured variables can't escape the closure | ||
= note: `FnMut` closures only have access to their captured variables while they are executing... | ||
= note: ...therefore, they cannot allow references to captured variables to escape | ||
|
||
error: aborting due to previous error | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,15 @@ | ||
error: unsatisfied lifetime constraints | ||
error: captured variable cannot escape `FnMut` closure body | ||
--> $DIR/issue-40510-3.rs:18:9 | ||
| | ||
LL | || { | ||
| -- | ||
| || | ||
| |return type of closure is [closure@$DIR/issue-40510-3.rs:18:9: 20:10 x:&'2 mut std::vec::Vec<()>] | ||
| lifetime `'1` represents this closure's body | ||
| - inferred to be a `FnMut` closure | ||
LL | / || { | ||
LL | | x.push(()) | ||
LL | | } | ||
| |_________^ returning this value requires that `'1` must outlive `'2` | ||
| |_________^ returns a closure that contains a reference to a captured variable, which then escapes the closure body | ||
| | ||
= note: closure implements `FnMut`, so references to captured variables can't escape the closure | ||
= note: `FnMut` closures only have access to their captured variables while they are executing... | ||
= note: ...therefore, they cannot allow references to captured variables to escape | ||
|
||
error: aborting due to previous error | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,15 @@ | ||
error: unsatisfied lifetime constraints | ||
error: captured variable cannot escape `FnMut` closure body | ||
--> $DIR/issue-49824.rs:22:9 | ||
| | ||
LL | || { | ||
| -- | ||
| || | ||
| |return type of closure is [closure@$DIR/issue-49824.rs:22:9: 24:10 x:&'2 mut i32] | ||
| lifetime `'1` represents this closure's body | ||
| - inferred to be a `FnMut` closure | ||
LL | / || { | ||
LL | | let _y = &mut x; | ||
LL | | } | ||
| |_________^ returning this value requires that `'1` must outlive `'2` | ||
| |_________^ returns a closure that contains a reference to a captured variable, which then escapes the closure body | ||
| | ||
= note: closure implements `FnMut`, so references to captured variables can't escape the closure | ||
= note: `FnMut` closures only have access to their captured variables while they are executing... | ||
= note: ...therefore, they cannot allow references to captured variables to escape | ||
|
||
error: aborting due to previous error | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
#![feature(nll)] | ||
|
||
fn main() { | ||
let mut v: Vec<()> = Vec::new(); | ||
|| &mut v; | ||
} |
Oops, something went wrong.