Merge remote-tracking branch 'origin/master' into gen

This commit is contained in:
Alex Crichton 2017-08-17 13:23:20 -07:00
commit 4b5f330c70
90 changed files with 288 additions and 172 deletions

View file

@ -11,10 +11,12 @@
// Test lifetimes are linked properly when we take reference
// to interior.
fn id<T>(x: T) -> T { x }
struct Foo(isize);
fn foo<'a>() -> &'a isize {
let &Foo(ref x) = &Foo(3); //~ ERROR borrowed value does not live long enough
let &Foo(ref x) = &id(Foo(3)); //~ ERROR borrowed value does not live long enough
x
}

View file

@ -10,7 +10,9 @@
// This file must never have a trailing newline
fn id<T>(x: T) -> T { x }
fn main() {
let x = Some(3);
let y = x.as_ref().unwrap_or(&5); //~ ERROR: borrowed value does not live long enough
let y = x.as_ref().unwrap_or(&id(5)); //~ ERROR: borrowed value does not live long enough
}

View file

@ -10,9 +10,11 @@
#![feature(fn_traits)]
fn id<T>(x: T) -> T { x }
pub fn foo<'a, F: Fn(&'a ())>(bar: F) {
bar.call((
&(), //~ ERROR borrowed value does not live long enough
&id(()), //~ ERROR borrowed value does not live long enough
));
}
fn main() {}

View file

@ -8,9 +8,11 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn id<T>(x: T) -> T { x }
const FOO: usize = 3;
fn foo() -> &'static usize { &FOO }
fn foo() -> &'static usize { &id(FOO) }
//~^ ERROR: borrowed value does not live long enough
fn main() {

View file

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Regression test for issue #27591.
// Regression test for issue #27592.
fn write<'a, F: ::std::ops::FnOnce()->::std::fmt::Arguments<'a> + 'a>(fcn: F) {
use std::fmt::Write;
@ -23,7 +23,7 @@ impl ::std::fmt::Write for Stream {
}
fn main() {
write(|| format_args!("{}", "Hello world"));
write(|| format_args!("{}", String::from("Hello world")));
//~^ ERROR borrowed value does not live long enough
//~| ERROR borrowed value does not live long enough
}

View file

@ -12,6 +12,8 @@
// are treated as rvalues and their lifetime is not bounded to
// the static scope.
fn id<T>(x: T) -> T { x }
struct Test;
enum MyEnum {
@ -19,12 +21,14 @@ enum MyEnum {
}
fn structLifetime<'a>() -> &'a Test {
let testValue = &Test; //~ ERROR borrowed value does not live long enough
let testValue = &id(Test);
//~^ ERROR borrowed value does not live long enough
testValue
}
fn variantLifetime<'a>() -> &'a MyEnum {
let testValue = &MyEnum::Variant1; //~ ERROR borrowed value does not live long enough
let testValue = &id(MyEnum::Variant1);
//~^ ERROR borrowed value does not live long enough
testValue
}

View file

@ -8,8 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn id<T>(x: T) -> T { x }
fn f(_x: &isize) -> &isize {
return &3; //~ ERROR borrowed value does not live long enough
return &id(3); //~ ERROR borrowed value does not live long enough
}
fn main() {

View file

@ -8,13 +8,15 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn id<T>(x: T) -> T { x }
fn foo(cond: bool) {
// Here we will infer a type that uses the
// region of the if stmt then block:
let mut x;
if cond {
x = &3; //~ ERROR borrowed value does not live long enough
x = &id(3); //~ ERROR borrowed value does not live long enough
assert_eq!(*x, 3);
}
}

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn id<T>(x: T) -> T { x }
struct StateMachineIter<'a> {
statefn: &'a StateMachineFunc<'a>
}
@ -23,19 +25,19 @@ impl<'a> Iterator for StateMachineIter<'a> {
}
fn state1(self_: &mut StateMachineIter) -> Option<&'static str> {
self_.statefn = &(state2 as StateMachineFunc);
self_.statefn = &id(state2 as StateMachineFunc);
//~^ ERROR borrowed value does not live long enough
return Some("state1");
}
fn state2(self_: &mut StateMachineIter) -> Option<(&'static str)> {
self_.statefn = &(state3 as StateMachineFunc);
self_.statefn = &id(state3 as StateMachineFunc);
//~^ ERROR borrowed value does not live long enough
return Some("state2");
}
fn state3(self_: &mut StateMachineIter) -> Option<(&'static str)> {
self_.statefn = &(finished as StateMachineFunc);
self_.statefn = &id(finished as StateMachineFunc);
//~^ ERROR borrowed value does not live long enough
return Some("state3");
}
@ -46,7 +48,8 @@ fn finished(_: &mut StateMachineIter) -> Option<(&'static str)> {
fn state_iter() -> StateMachineIter<'static> {
StateMachineIter {
statefn: &(state1 as StateMachineFunc) //~ ERROR borrowed value does not live long enough
statefn: &id(state1 as StateMachineFunc)
//~^ ERROR borrowed value does not live long enough
}
}

View file

@ -10,11 +10,13 @@
#![feature(box_syntax)]
fn id<T>(x: T) -> T { x }
fn f<T:'static>(_: T) {}
fn main() {
let x: Box<_> = box 3;
f(x);
let x = &3; //~ ERROR borrowed value does not live long enough
let x = &id(3); //~ ERROR borrowed value does not live long enough
f(x);
}

View file

@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(rvalue_static_promotion)]
#[allow(unused_variables)]
fn main() {
let x: &'static u32 = &42;

View file

@ -8,8 +8,25 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[allow(unused_variables)]
fn main() {
let x: &'static u32 = &42; //~ error: does not live long enough
let y: &'static Option<u32> = &None; //~ error: does not live long enough
#![feature(conservative_impl_trait)]
pub fn g() -> impl Iterator<Item=u8> {
Some(1u8).into_iter()
}
pub fn h() -> (impl Iterator<Item=u8>) {
Some(1u8).into_iter()
}
pub fn i() -> impl Iterator<Item=u8> + 'static {
Some(1u8).into_iter()
}
pub fn j() -> impl Iterator<Item=u8> + Clone {
Some(1u8).into_iter()
}
// @has issue_43869/fn.g.html
// @has issue_43869/fn.h.html
// @has issue_43869/fn.i.html
// @has issue_43869/fn.j.html

View file

@ -5,6 +5,7 @@ error[E0599]: no method named `f` found for type `{integer}` in the current scop
| ^
|
= note: found the following associated functions; to be used as methods, functions must have a `self` parameter
= help: try with `{integer}::f`
note: candidate #1 is defined in the trait `issue_41652_b::Tr`
--> $DIR/auxiliary/issue_41652_b.rs:14:5
|

View file

@ -9,7 +9,7 @@
// except according to those terms.
fn f() {
let x = [1].iter();
let x = vec![1].iter();
}
fn main() {

View file

@ -1,14 +1,15 @@
error[E0597]: borrowed value does not live long enough
--> $DIR/borrowck-let-suggestion.rs:12:23
--> $DIR/borrowck-let-suggestion.rs:12:27
|
12 | let x = [1].iter();
| --- ^ temporary value dropped here while still borrowed
12 | let x = vec![1].iter();
| ------- ^ temporary value dropped here while still borrowed
| |
| temporary value created here
13 | }
| - temporary value needs to live until here
|
= note: consider using a `let` binding to increase its lifetime
= note: this error originates in a macro outside of the current crate
error: aborting due to previous error

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn id<T>(x: T) -> T { x }
fn f() {
let old = ['o']; // statement 0
let mut v1 = Vec::new(); // statement 1
@ -21,7 +23,7 @@ fn f() {
let mut v3 = Vec::new(); // statement 5
v3.push(&'x'); // statement 6
v3.push(&id('x')); // statement 6
//~^ ERROR borrowed value does not live long enough
//~| NOTE temporary value created here
//~| NOTE temporary value only lives until here
@ -31,7 +33,7 @@ fn f() {
let mut v4 = Vec::new(); // (sub) statement 0
v4.push(&'y');
v4.push(&id('y'));
//~^ ERROR borrowed value does not live long enough
//~| NOTE temporary value created here
//~| NOTE temporary value only lives until here
@ -42,7 +44,7 @@ fn f() {
let mut v5 = Vec::new(); // statement 8
v5.push(&'z');
v5.push(&id('z'));
//~^ ERROR borrowed value does not live long enough
//~| NOTE temporary value created here
//~| NOTE temporary value only lives until here

View file

@ -1,49 +1,49 @@
error[E0597]: `young[..]` does not live long enough
--> $DIR/borrowck-let-suggestion-suffixes.rs:52:1
--> $DIR/borrowck-let-suggestion-suffixes.rs:54:1
|
19 | v2.push(&young[0]); // statement 4
21 | v2.push(&young[0]); // statement 4
| -------- borrow occurs here
...
52 | }
54 | }
| ^ `young[..]` dropped here while still borrowed
|
= note: values in a scope are dropped in the opposite order they are created
error[E0597]: borrowed value does not live long enough
--> $DIR/borrowck-let-suggestion-suffixes.rs:24:18
--> $DIR/borrowck-let-suggestion-suffixes.rs:26:22
|
24 | v3.push(&'x'); // statement 6
| --- ^ temporary value dropped here while still borrowed
26 | v3.push(&id('x')); // statement 6
| ------- ^ temporary value dropped here while still borrowed
| |
| temporary value created here
...
52 | }
54 | }
| - temporary value needs to live until here
|
= note: consider using a `let` binding to increase its lifetime
error[E0597]: borrowed value does not live long enough
--> $DIR/borrowck-let-suggestion-suffixes.rs:34:22
--> $DIR/borrowck-let-suggestion-suffixes.rs:36:26
|
34 | v4.push(&'y');
| --- ^ temporary value dropped here while still borrowed
36 | v4.push(&id('y'));
| ------- ^ temporary value dropped here while still borrowed
| |
| temporary value created here
...
40 | } // (statement 7)
42 | } // (statement 7)
| - temporary value needs to live until here
|
= note: consider using a `let` binding to increase its lifetime
error[E0597]: borrowed value does not live long enough
--> $DIR/borrowck-let-suggestion-suffixes.rs:45:18
--> $DIR/borrowck-let-suggestion-suffixes.rs:47:22
|
45 | v5.push(&'z');
| --- ^ temporary value dropped here while still borrowed
47 | v5.push(&id('z'));
| ------- ^ temporary value dropped here while still borrowed
| |
| temporary value created here
...
52 | }
54 | }
| - temporary value needs to live until here
|
= note: consider using a `let` binding to increase its lifetime

View file

@ -8,9 +8,11 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
fn id<T>(x: T) -> T { x }
fn main() {
let v = vec![
&3
&id(3)
];
for &&x in &v {

View file

@ -1,12 +1,12 @@
error[E0597]: borrowed value does not live long enough
--> $DIR/issue-15480.rs:14:6
--> $DIR/issue-15480.rs:16:6
|
13 | &3
| - temporary value created here
14 | ];
15 | &id(3)
| ----- temporary value created here
16 | ];
| ^ temporary value dropped here while still borrowed
...
19 | }
21 | }
| - temporary value needs to live until here
|
= note: consider using a `let` binding to increase its lifetime

View file

@ -5,6 +5,7 @@ error[E0599]: no method named `f9` found for type `usize` in the current scope
| ^^
|
= note: found the following associated functions; to be used as methods, functions must have a `self` parameter
= help: try with `usize::f9`
note: candidate #1 is defined in the trait `CtxtFn`
--> $DIR/issue-7575.rs:16:5
|
@ -36,6 +37,7 @@ error[E0599]: no method named `fff` found for type `Myisize` in the current scop
| ^^^
|
= note: found the following associated functions; to be used as methods, functions must have a `self` parameter
= help: try with `Myisize::fff`
note: candidate #1 is defined in an impl for the type `Myisize`
--> $DIR/issue-7575.rs:51:5
|
@ -51,6 +53,7 @@ error[E0599]: no method named `is_str` found for type `T` in the current scope
| ^^^^^^
|
= note: found the following associated functions; to be used as methods, functions must have a `self` parameter
= help: try with `T::is_str`
note: candidate #1 is defined in the trait `ManyImplTrait`
--> $DIR/issue-7575.rs:57:5
|

View file

@ -10,6 +10,8 @@
#![feature(box_syntax)]
fn id<T>(x: T) -> T { x }
trait Foo { }
impl<'a> Foo for &'a isize { }
@ -17,7 +19,7 @@ impl<'a> Foo for &'a isize { }
fn main() {
let blah;
{
let ss: &isize = &1;
let ss: &isize = &id(1);
blah = box ss as Box<Foo>;
}
}

View file

@ -1,12 +1,12 @@
error[E0597]: borrowed value does not live long enough
--> $DIR/regions-close-over-borrowed-ref-in-obj.rs:22:5
--> $DIR/regions-close-over-borrowed-ref-in-obj.rs:24:5
|
20 | let ss: &isize = &1;
| - temporary value created here
21 | blah = box ss as Box<Foo>;
22 | }
22 | let ss: &isize = &id(1);
| ----- temporary value created here
23 | blah = box ss as Box<Foo>;
24 | }
| ^ temporary value dropped here while still borrowed
23 | }
25 | }
| - temporary value needs to live until here
error: aborting due to previous error

View file

@ -13,7 +13,7 @@
fn main() {
let y;
{
let x: &[isize] = &[1, 2, 3, 4, 5];
let x: &[isize] = &vec![1, 2, 3, 4, 5];
y = &x[1..];
}
}

View file

@ -1,13 +1,15 @@
error[E0597]: borrowed value does not live long enough
--> $DIR/slice-borrow.rs:18:5
|
16 | let x: &[isize] = &[1, 2, 3, 4, 5];
| --------------- temporary value created here
16 | let x: &[isize] = &vec![1, 2, 3, 4, 5];
| ------------------- temporary value created here
17 | y = &x[1..];
18 | }
| ^ temporary value dropped here while still borrowed
19 | }
| - temporary value needs to live until here
|
= note: this error originates in a macro outside of the current crate
error: aborting due to previous error