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
This commit is contained in:
bors 2017-01-27 22:13:41 +00:00
commit 154c202afb
7 changed files with 4 additions and 893 deletions

View file

@ -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 })
}
}

View file

@ -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