-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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 #54715 - oli-obk:nll_deref_promotion, r=RalfJung
- Loading branch information
Showing
3 changed files
with
59 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#![feature(nll)] | ||
|
||
const FOO: Option<&[[u8; 3]]> = Some(&[*b"foo"]); //~ ERROR temporary value dropped while borrowed | ||
|
||
use std::borrow::Cow; | ||
|
||
pub const X: [u8; 3] = *b"ABC"; | ||
pub const Y: Cow<'static, [ [u8; 3] ]> = Cow::Borrowed(&[X]); | ||
|
||
|
||
pub const Z: Cow<'static, [ [u8; 3] ]> = Cow::Borrowed(&[*b"ABC"]); | ||
//~^ ERROR temporary value dropped while borrowed | ||
|
||
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,23 @@ | ||
error[E0716]: temporary value dropped while borrowed | ||
--> $DIR/issue-54224.rs:3:39 | ||
| | ||
LL | const FOO: Option<&[[u8; 3]]> = Some(&[*b"foo"]); //~ ERROR temporary value dropped while borrowed | ||
| ^^^^^^^^^- temporary value is freed at the end of this statement | ||
| | | ||
| creates a temporary which is freed while still in use | ||
| | ||
= note: borrowed value must be valid for the static lifetime... | ||
|
||
error[E0716]: temporary value dropped while borrowed | ||
--> $DIR/issue-54224.rs:11:57 | ||
| | ||
LL | pub const Z: Cow<'static, [ [u8; 3] ]> = Cow::Borrowed(&[*b"ABC"]); | ||
| ^^^^^^^^^- temporary value is freed at the end of this statement | ||
| | | ||
| creates a temporary which is freed while still in use | ||
| | ||
= note: borrowed value must be valid for the static lifetime... | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0716`. |