Skip to content

Commit

Permalink
Move an underscore-lifetime error test to an IHLE success test
Browse files Browse the repository at this point in the history
  • Loading branch information
scottmcm committed Oct 20, 2018
1 parent faf68f4 commit ae130b0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 15 deletions.
19 changes: 19 additions & 0 deletions src/test/ui/impl-header-lifetime-elision/inherent-impl.rs
@@ -0,0 +1,19 @@
// Copyright 2017 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.

// compile-pass

struct Foo<'a>(&'a u8);

impl Foo<'_> {
fn x() {}
}

fn main() {}
Expand Up @@ -11,10 +11,6 @@
struct Foo<'a>(&'a u8);
struct Baz<'a>(&'_ &'a u8); //~ ERROR missing lifetime specifier

impl Foo<'_> { //~ ERROR missing lifetime specifier
fn x() {}
}

fn foo<'_> //~ ERROR cannot be used here
(_: Foo<'_>) {}

Expand Down
16 changes: 5 additions & 11 deletions src/test/ui/underscore-lifetime/underscore-lifetime-binders.stderr
@@ -1,11 +1,11 @@
error[E0637]: `'_` cannot be used here
--> $DIR/underscore-lifetime-binders.rs:18:8
--> $DIR/underscore-lifetime-binders.rs:14:8
|
LL | fn foo<'_> //~ ERROR cannot be used here
| ^^ `'_` is a reserved lifetime name

error[E0637]: `'_` cannot be used here
--> $DIR/underscore-lifetime-binders.rs:24:21
--> $DIR/underscore-lifetime-binders.rs:20:21
|
LL | fn meh() -> Box<for<'_> Meh<'_>> //~ ERROR cannot be used here
| ^^ `'_` is a reserved lifetime name
Expand All @@ -17,13 +17,7 @@ LL | struct Baz<'a>(&'_ &'a u8); //~ ERROR missing lifetime specifier
| ^^ expected lifetime parameter

error[E0106]: missing lifetime specifier
--> $DIR/underscore-lifetime-binders.rs:14:10
|
LL | impl Foo<'_> { //~ ERROR missing lifetime specifier
| ^^ expected lifetime parameter

error[E0106]: missing lifetime specifier
--> $DIR/underscore-lifetime-binders.rs:24:29
--> $DIR/underscore-lifetime-binders.rs:20:29
|
LL | fn meh() -> Box<for<'_> Meh<'_>> //~ ERROR cannot be used here
| ^^ expected lifetime parameter
Expand All @@ -32,14 +26,14 @@ LL | fn meh() -> Box<for<'_> Meh<'_>> //~ ERROR cannot be used here
= help: consider giving it a 'static lifetime

error[E0106]: missing lifetime specifier
--> $DIR/underscore-lifetime-binders.rs:30:35
--> $DIR/underscore-lifetime-binders.rs:26:35
|
LL | fn foo2(_: &'_ u8, y: &'_ u8) -> &'_ u8 { y } //~ ERROR missing lifetime specifier
| ^^ expected lifetime parameter
|
= help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from `_` or `y`

error: aborting due to 6 previous errors
error: aborting due to 5 previous errors

Some errors occurred: E0106, E0637.
For more information about an error, try `rustc --explain E0106`.

0 comments on commit ae130b0

Please sign in to comment.