Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make explain borrow work for Universal lifetimes
- Loading branch information
1 parent
834e392
commit ff7dca5
Showing
14 changed files
with
127 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright 2018 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. | ||
|
||
// compile-flags: -Znll-dump-cause | ||
|
||
#![feature(nll)] | ||
#![allow(warnings)] | ||
|
||
fn foo<'a>(x: &'a (u32,)) -> &'a u32 { | ||
let v = 22; | ||
&v | ||
//~^ ERROR `v` does not live long enough [E0597] | ||
} | ||
|
||
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,18 @@ | ||
error[E0597]: `v` does not live long enough | ||
--> $DIR/borrowed-universal-error-2.rs:18:5 | ||
| | ||
LL | &v | ||
| ^^ borrowed value does not live long enough | ||
LL | //~^ ERROR `v` does not live long enough [E0597] | ||
LL | } | ||
| - borrowed value only lives until here | ||
| | ||
note: borrowed value must be valid for the lifetime 'a as defined on the function body at 16:1... | ||
--> $DIR/borrowed-universal-error-2.rs:16:1 | ||
| | ||
LL | fn foo<'a>(x: &'a (u32,)) -> &'a u32 { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|
||
If you want more information on this error, try using "rustc --explain E0597" |
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 @@ | ||
// Copyright 2018 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. | ||
|
||
// compile-flags: -Znll-dump-cause | ||
|
||
#![feature(nll)] | ||
#![allow(warnings)] | ||
|
||
fn gimme(x: &(u32,)) -> &u32 { | ||
&x.0 | ||
} | ||
|
||
fn foo<'a>(x: &'a (u32,)) -> &'a u32 { | ||
let v = 22; | ||
gimme(&(v,)) | ||
//~^ ERROR borrowed value does not live long enough [E0597] | ||
} | ||
|
||
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,18 @@ | ||
error[E0597]: borrowed value does not live long enough | ||
--> $DIR/borrowed-universal-error.rs:22:12 | ||
| | ||
LL | gimme(&(v,)) | ||
| ^^^^ temporary value does not live long enough | ||
LL | //~^ ERROR borrowed value does not live long enough [E0597] | ||
LL | } | ||
| - temporary value only lives until here | ||
| | ||
note: borrowed value must be valid for the lifetime 'a as defined on the function body at 20:1... | ||
--> $DIR/borrowed-universal-error.rs:20:1 | ||
| | ||
LL | fn foo<'a>(x: &'a (u32,)) -> &'a u32 { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|
||
If you want more information on this error, try using "rustc --explain E0597" |
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