mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-28 19:27:30 +03:00
Add test for temporary lifetime extension in Self() syntax.
This commit is contained in:
@@ -7,6 +7,17 @@ fn temp() -> String {
|
||||
#[derive(Debug)]
|
||||
struct X<'a>(&'a String);
|
||||
|
||||
trait T<'a> {
|
||||
const A: X<'a>;
|
||||
const B: X<'a>;
|
||||
}
|
||||
|
||||
impl<'a> T<'a> for X<'a> {
|
||||
// Check both Self() and X() syntax:
|
||||
const A: X<'a> = Self(&String::new());
|
||||
const B: X<'a> = X(&String::new());
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let a = &temp();
|
||||
let b = Some(&temp());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
error[E0716]: temporary value dropped while borrowed
|
||||
--> $DIR/temporary-lifetime-extension-tuple-ctor.rs:23:19
|
||||
--> $DIR/temporary-lifetime-extension-tuple-ctor.rs:34:19
|
||||
|
|
||||
LL | let g = some(&temp());
|
||||
| ^^^^^^ - temporary value is freed at the end of this statement
|
||||
|
||||
Reference in New Issue
Block a user