From 4abcf28d2baaf53afe810e75ddfbfa8eff72c863 Mon Sep 17 00:00:00 2001 From: gaurikholkar Date: Thu, 29 Jun 2017 14:13:53 -0700 Subject: adding compile-fail test --- src/test/compile-fail/E0495.rs | 23 +++++++++++++++++ ...turn-one-existing-name-if-else-using-closure.rs | 24 ------------------ ...-one-existing-name-if-else-using-closure.stderr | 29 ---------------------- 3 files changed, 23 insertions(+), 53 deletions(-) create mode 100644 src/test/compile-fail/E0495.rs delete mode 100644 src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-closure.rs delete mode 100644 src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-closure.stderr diff --git a/src/test/compile-fail/E0495.rs b/src/test/compile-fail/E0495.rs new file mode 100644 index 00000000000..e47c4d7199c --- /dev/null +++ b/src/test/compile-fail/E0495.rs @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// FIXME - This test gives different results on different machines. +fn invoke<'a, F>(x: &'a i32, f: F) -> &'a i32 +where F: FnOnce(&'a i32, &i32) -> &'a i32 +{ + let y = 22; + f(x, &y) +} + +fn foo<'a>(x: &'a i32) { //~ ERROR E0495 + invoke(&x, |a, b| if a > b { a } else { b }); +} + +fn main() {} diff --git a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-closure.rs b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-closure.rs deleted file mode 100644 index faf4fe547bf..00000000000 --- a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-closure.rs +++ /dev/null @@ -1,24 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn invoke<'a, F>(x: &'a i32, f: F) -> &'a i32 -where F: FnOnce(&'a i32, &i32) -> &'a i32 -{ - let y = 22; - f(x, &y) -} - -fn foo<'a>(x: &'a i32) { - invoke(&x, |a, b| if a > b { a } else { b }); -} - -fn main() { -} - diff --git a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-closure.stderr b/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-closure.stderr deleted file mode 100644 index 20104afae51..00000000000 --- a/src/test/ui/lifetime-errors/ex1-return-one-existing-name-if-else-using-closure.stderr +++ /dev/null @@ -1,29 +0,0 @@ -error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements - --> $DIR/ex1-return-one-existing-name-if-else-using-closure.rs:19:5 - | -19 | invoke(&x, |a, b| if a > b { a } else { b }); - | ^^^^^^ - | -note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on the body at 19:16... - --> $DIR/ex1-return-one-existing-name-if-else-using-closure.rs:19:16 - | -19 | invoke(&x, |a, b| if a > b { a } else { b }); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...so that reference does not outlive borrowed content - --> $DIR/ex1-return-one-existing-name-if-else-using-closure.rs:19:45 - | -19 | invoke(&x, |a, b| if a > b { a } else { b }); - | ^ -note: but, the lifetime must be valid for the expression at 19:5... - --> $DIR/ex1-return-one-existing-name-if-else-using-closure.rs:19:5 - | -19 | invoke(&x, |a, b| if a > b { a } else { b }); - | ^^^^^^ -note: ...so that a type/lifetime parameter is in scope here - --> $DIR/ex1-return-one-existing-name-if-else-using-closure.rs:19:5 - | -19 | invoke(&x, |a, b| if a > b { a } else { b }); - | ^^^^^^ - -error: aborting due to previous error(s) - -- cgit 1.4.1-3-g733a5