forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#89501 - Aaron1011:escaping-name-regions, r=…
…davidtwco Note specific regions involved in 'borrowed data escapes' error Fixes rust-lang#67007 Currently, a 'borrowed data escapes' error does not mention the specific lifetime involved (except indirectly through a suggestion about adding a lifetime bound). We now explain the specific lifetime relationship that failed to hold, which improves otherwise vague error messages.
- Loading branch information
Showing
18 changed files
with
209 additions
and
39 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
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Regression test for issue #67007 | ||
// Ensures that we show information about the specific regions involved | ||
|
||
#![feature(nll)] | ||
|
||
// Covariant over 'a, invariant over 'tcx | ||
struct FnCtxt<'a, 'tcx: 'a>(&'a (), *mut &'tcx ()); | ||
|
||
impl<'a, 'tcx> FnCtxt<'a, 'tcx> { | ||
fn use_it(&self, _: &'tcx ()) {} | ||
} | ||
|
||
struct Consumer<'tcx>(&'tcx ()); | ||
|
||
impl<'tcx> Consumer<'tcx> { | ||
fn bad_method<'a>(&self, fcx: &FnCtxt<'a, 'tcx>) { | ||
let other = self.use_fcx(fcx); //~ ERROR borrowed data | ||
fcx.use_it(other); | ||
} | ||
|
||
fn use_fcx<'a>(&self, _: &FnCtxt<'a, 'tcx>) -> &'a () { | ||
&() | ||
} | ||
} | ||
|
||
fn main() {} |
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,21 @@ | ||
error[E0521]: borrowed data escapes outside of associated function | ||
--> $DIR/issue-67007-escaping-data.rs:17:21 | ||
| | ||
LL | impl<'tcx> Consumer<'tcx> { | ||
| ---- lifetime `'tcx` defined here | ||
LL | fn bad_method<'a>(&self, fcx: &FnCtxt<'a, 'tcx>) { | ||
| -- ----- --- `fcx` is a reference that is only valid in the associated function body | ||
| | | | ||
| | `self` declared here, outside of the associated function body | ||
| lifetime `'a` defined here | ||
LL | let other = self.use_fcx(fcx); | ||
| ^^^^^^^^^^^^^^^^^ | ||
| | | ||
| `fcx` escapes the associated function body here | ||
| argument requires that `'a` must outlive `'tcx` | ||
| | ||
= help: consider adding the following bound: `'a: 'tcx` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0521`. |
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
Oops, something went wrong.