diff options
| author | bors <bors@rust-lang.org> | 2017-01-26 17:42:52 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-01-26 17:42:52 +0000 |
| commit | 8430042a49bbd49bbb4fbc54f457feb5fb614f56 (patch) | |
| tree | a5fb7095092902f3168b86d671f0813d1228eaa4 /src/test | |
| parent | 491b978822a56f23acf9ba46f90861958bc1e36c (diff) | |
| parent | 82a280597d967dc3ec8686f160a0afea4ad45837 (diff) | |
| download | rust-8430042a49bbd49bbb4fbc54f457feb5fb614f56.tar.gz rust-8430042a49bbd49bbb4fbc54f457feb5fb614f56.zip | |
Auto merge of #39066 - arielb1:lifetime-extension-test, r=nikomatsakis
End temporary lifetimes being extended by `let X: &_` hints cc #39283 r? @nikomatsakis
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/compile-fail/issue-36082.rs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/test/compile-fail/issue-36082.rs b/src/test/compile-fail/issue-36082.rs new file mode 100644 index 00000000000..cec4b2d15dc --- /dev/null +++ b/src/test/compile-fail/issue-36082.rs @@ -0,0 +1,27 @@ +// Copyright 2016 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. + +use std::cell::RefCell; + +fn main() { + let mut r = 0; + let s = 0; + let x = RefCell::new((&mut r,s)); + + let val: &_ = x.borrow().0; + //~^ WARNING this temporary used to live longer - see issue #39283 + //~^^ ERROR borrowed value does not live long enough + //~| temporary value dropped here while still borrowed + //~| temporary value created here + //~| consider using a `let` binding to increase its lifetime + //~| before rustc 1.16, this temporary lived longer - see issue #39283 + println!("{}", val); +} +//~^ temporary value needs to live until here |
