about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2017-01-27 22:13:41 +0000
committerbors <bors@rust-lang.org>2017-01-27 22:13:41 +0000
commit154c202afb256c379b7d454ec0244da69eaa2ced (patch)
treef31d24ce9e30da7a0c7261132a3cec0e43ec0a38 /src/test
parent62a72586775fc0bfe38f4e43bf3aca52a31c6921 (diff)
parenta2735c02493d816835a19249dd258e0c678530d0 (diff)
downloadrust-154c202afb256c379b7d454ec0244da69eaa2ced.tar.gz
rust-154c202afb256c379b7d454ec0244da69eaa2ced.zip
Auto merge of #37057 - brson:nosuggest, r=nikomatsakis
rustc: Remove all "consider using an explicit lifetime parameter" suggestions

These give so many incorrect suggestions that having them is
detrimental to the user experience. The compiler should not be
suggesting changes to the code that are wrong - it is infuriating: not
only is the compiler telling you that _you don't understand_ borrowing,
_the compiler itself_ appears to not understand borrowing. It does not
inspire confidence.

r? @nikomatsakis
Diffstat (limited to 'src/test')
-rw-r--r--src/test/compile-fail/issue-13058.rs1
-rw-r--r--src/test/compile-fail/lifetime-inference-give-expl-lifetime-param-2.rs36
-rw-r--r--src/test/compile-fail/lifetime-inference-give-expl-lifetime-param-3.rs32
-rw-r--r--src/test/compile-fail/lifetime-inference-give-expl-lifetime-param.rs57
-rw-r--r--src/test/ui/lifetimes/consider-using-explicit-lifetime.rs28
-rw-r--r--src/test/ui/lifetimes/consider-using-explicit-lifetime.stderr25
6 files changed, 0 insertions, 179 deletions
diff --git a/src/test/compile-fail/issue-13058.rs b/src/test/compile-fail/issue-13058.rs
index de578257e46..408c6d411de 100644
--- a/src/test/compile-fail/issue-13058.rs
+++ b/src/test/compile-fail/issue-13058.rs
@@ -20,7 +20,6 @@ impl<'r> Itble<'r, usize, Range<usize>> for (usize, usize) {
 }
 
 fn check<'r, I: Iterator<Item=usize>, T: Itble<'r, usize, I>>(cont: &T) -> bool
-//~^ HELP as shown: fn check<'r, I: Iterator<Item = usize>, T: Itble<'r, usize, I>>(cont: &'r T)
 {
     let cont_iter = cont.iter();
 //~^ ERROR cannot infer an appropriate lifetime for autoref due to conflicting requirements
diff --git a/src/test/compile-fail/lifetime-inference-give-expl-lifetime-param-2.rs b/src/test/compile-fail/lifetime-inference-give-expl-lifetime-param-2.rs
deleted file mode 100644
index d2d0dbf3e98..00000000000
--- a/src/test/compile-fail/lifetime-inference-give-expl-lifetime-param-2.rs
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright 2014 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.
-
-// ignore-tidy-linelength
-
-use std::ops::Range;
-
-trait Itble<'r, T, I: Iterator<Item=T>> { fn iter(&'r self) -> I; }
-
-impl<'r> Itble<'r, usize, Range<usize>> for (usize, usize) {
-    fn iter(&'r self) -> Range<usize> {
-        let &(min, max) = self;
-        min..max
-    }
-}
-
-fn check<'r, I: Iterator<Item=usize>, T: Itble<'r, usize, I>>(cont: &T) -> bool {
-//~^ HELP: consider using an explicit lifetime parameter as shown: fn check<'r, I: Iterator<Item = usize>, T: Itble<'r, usize, I>>(cont: &'r T)
-    let cont_iter = cont.iter(); //~ ERROR: cannot infer
-    let result = cont_iter.fold(Some(0), |state, val| {
-        state.map_or(None, |mask| {
-            let bit = 1 << val;
-            if mask & bit == 0 {Some(mask|bit)} else {None}
-        })
-    });
-    result.is_some()
-}
-
-fn main() {}
diff --git a/src/test/compile-fail/lifetime-inference-give-expl-lifetime-param-3.rs b/src/test/compile-fail/lifetime-inference-give-expl-lifetime-param-3.rs
deleted file mode 100644
index 6b22d434804..00000000000
--- a/src/test/compile-fail/lifetime-inference-give-expl-lifetime-param-3.rs
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright 2014 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.
-
-// ignore-tidy-linelength
-
-use std::marker::PhantomData;
-
-struct Bar<'x, 'y, 'z> { bar: &'y i32, baz: i32, marker: PhantomData<(&'x(),&'y(),&'z())> }
-fn bar1<'a>(x: &Bar) -> (&'a i32, &'a i32, &'a i32) {
-    //~^ HELP consider using an explicit lifetime parameter as shown: fn bar1<'b, 'c, 'a>(x: &'a Bar<'b, 'a, 'c>) -> (&'a i32, &'a i32, &'a i32)
-    (x.bar, &x.baz, &x.baz)
-    //~^ ERROR E0312
-    //~| ERROR cannot infer
-    //~| ERROR cannot infer
-}
-
-fn bar2<'a, 'b, 'c>(x: &Bar<'a, 'b, 'c>) -> (&'a i32, &'a i32, &'a i32) {
-    //~^ HELP: consider using an explicit lifetime parameter as shown: fn bar2<'a, 'c>(x: &'a Bar<'a, 'a, 'c>) -> (&'a i32, &'a i32, &'a i32)
-    (x.bar, &x.baz, &x.baz)
-    //~^ ERROR E0312
-    //~| ERROR cannot infer
-    //~| ERROR cannot infer
-}
-
-fn main() { }
diff --git a/src/test/compile-fail/lifetime-inference-give-expl-lifetime-param.rs b/src/test/compile-fail/lifetime-inference-give-expl-lifetime-param.rs
deleted file mode 100644
index 4323929e2e3..00000000000
--- a/src/test/compile-fail/lifetime-inference-give-expl-lifetime-param.rs
+++ /dev/null
@@ -1,57 +0,0 @@
-// Copyright 2014 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.
-
-// ignore-tidy-linelength
-
-use std::marker::PhantomData;
-
-struct Foo<'x> { bar: isize, marker: PhantomData<&'x ()> }
-fn foo1<'a>(x: &Foo) -> &'a isize {
-//~^ HELP: consider using an explicit lifetime parameter as shown: fn foo1<'a>(x: &'a Foo) -> &'a isize
-    &x.bar //~ ERROR: cannot infer
-}
-
-fn foo2<'a, 'b>(x: &'a Foo) -> &'b isize {
-//~^ HELP: consider using an explicit lifetime parameter as shown: fn foo2<'a>(x: &'a Foo) -> &'a isize
-    &x.bar //~ ERROR: cannot infer
-}
-
-fn foo3<'a>(x: &Foo) -> (&'a isize, &'a isize) {
-//~^ HELP: consider using an explicit lifetime parameter as shown: fn foo3<'a>(x: &'a Foo) -> (&'a isize, &'a isize)
-    (&x.bar, &x.bar) //~ ERROR: cannot infer
-    //~^ ERROR: cannot infer
-}
-
-fn foo4<'a, 'b>(x: &'a Foo) -> (&'b isize, &'a isize, &'b isize) {
-//~^ HELP: consider using an explicit lifetime parameter as shown: fn foo4<'a>(x: &'a Foo) -> (&'a isize, &'a isize, &'a isize)
-    (&x.bar, &x.bar, &x.bar) //~ ERROR: cannot infer
-    //~^ ERROR: cannot infer
-}
-
-struct Cat<'x, T> { cat: &'x isize, t: T }
-struct Dog<'y> { dog: &'y isize }
-
-fn cat2<'x, 'y>(x: Cat<'x, Dog<'y>>) -> &'x isize {
-    //~^ HELP consider using an explicit lifetime parameter as shown: fn cat2<'x>(x: Cat<'x, Dog<'x>>) -> &'x isize
-    x.t.dog //~ ERROR E0312
-}
-
-struct Baz<'x> {
-    bar: &'x isize
-}
-
-impl<'a> Baz<'a> {
-    fn baz2<'b>(&self, x: &isize) -> (&'b isize, &'b isize) {
-        (self.bar, x) //~ ERROR E0312
-        //~^ ERROR E0312
-    }
-}
-
-fn main() {}
diff --git a/src/test/ui/lifetimes/consider-using-explicit-lifetime.rs b/src/test/ui/lifetimes/consider-using-explicit-lifetime.rs
deleted file mode 100644
index 603f55af465..00000000000
--- a/src/test/ui/lifetimes/consider-using-explicit-lifetime.rs
+++ /dev/null
@@ -1,28 +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 <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::str::FromStr;
-
-pub struct Foo<'a> {
-    field: &'a str,
-}
-
-impl<'a> Foo<'a> {
-    fn bar(path: &str) -> Result<Self, ()> {
-        Ok(Foo { field: path })
-    }
-}
-
-impl<'a> FromStr for Foo<'a> {
-    type Err = ();
-    fn from_str(path: &str) -> Result<Self, ()> {
-        Ok(Foo { field: path })
-    }
-}
diff --git a/src/test/ui/lifetimes/consider-using-explicit-lifetime.stderr b/src/test/ui/lifetimes/consider-using-explicit-lifetime.stderr
deleted file mode 100644
index 153aaa07833..00000000000
--- a/src/test/ui/lifetimes/consider-using-explicit-lifetime.stderr
+++ /dev/null
@@ -1,25 +0,0 @@
-error: main function not found
-
-error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
-  --> $DIR/consider-using-explicit-lifetime.rs:19:12
-   |
-19 |         Ok(Foo { field: path })
-   |            ^^^
-
-error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
-  --> $DIR/consider-using-explicit-lifetime.rs:26:12
-   |
-26 |         Ok(Foo { field: path })
-   |            ^^^
-   |
-help: consider using an explicit lifetime parameter as shown: fn from_str(path: &'a str) -> Result<Self, ()>
-  --> $DIR/consider-using-explicit-lifetime.rs:25:5
-   |
-25 |       fn from_str(path: &str) -> Result<Self, ()> {
-   |  _____^ starting here...
-26 | |         Ok(Foo { field: path })
-27 | |     }
-   | |_____^ ...ending here
-
-error: aborting due to 2 previous errors
-