1
Fork 0

Auto merge of #54778 - scottmcm:stabilize-ihle, r=pnkfelix

Stabilize impl_header_lifetime_elision in 2015

~~This is currently blocked on https://github.com/rust-lang/rust/issues/54902; it should be good after that~~

It's already stable in 2018; this finishes the stabilization.

FCP completed (https://github.com/rust-lang/rust/issues/15872#issuecomment-417953153), proposal (https://github.com/rust-lang/rust/issues/15872#issuecomment-412759783).

Tracking issue: https://github.com/rust-lang/rust/issues/15872
Usage examples (from libcore): https://github.com/rust-lang/rust/pull/54687
This commit is contained in:
bors 2018-10-23 04:05:50 +00:00
commit d570b36cd9
41 changed files with 156 additions and 264 deletions

View file

@ -87,7 +87,7 @@
#![feature(doc_spotlight)] #![feature(doc_spotlight)]
#![feature(extern_types)] #![feature(extern_types)]
#![feature(fundamental)] #![feature(fundamental)]
#![feature(impl_header_lifetime_elision)] #![cfg_attr(stage0, feature(impl_header_lifetime_elision))]
#![feature(intrinsics)] #![feature(intrinsics)]
#![feature(lang_items)] #![feature(lang_items)]
#![feature(link_llvm_intrinsics)] #![feature(link_llvm_intrinsics)]

View file

@ -19,7 +19,7 @@
#![feature(flt2dec)] #![feature(flt2dec)]
#![feature(fmt_internals)] #![feature(fmt_internals)]
#![feature(hashmap_internals)] #![feature(hashmap_internals)]
#![feature(impl_header_lifetime_elision)] #![cfg_attr(stage0, feature(impl_header_lifetime_elision))]
#![feature(pattern)] #![feature(pattern)]
#![feature(range_is_empty)] #![feature(range_is_empty)]
#![feature(raw)] #![feature(raw)]

View file

@ -125,9 +125,8 @@ pub struct LoweringContext<'a> {
// Whether or not in-band lifetimes are being collected. This is used to // Whether or not in-band lifetimes are being collected. This is used to
// indicate whether or not we're in a place where new lifetimes will result // indicate whether or not we're in a place where new lifetimes will result
// in in-band lifetime definitions, such a function or an impl header. // in in-band lifetime definitions, such a function or an impl header,
// This will always be false unless the `in_band_lifetimes` or // including implicit lifetimes from `impl_header_lifetime_elision`.
// `impl_header_lifetime_elision` feature is enabled.
is_collecting_in_band_lifetimes: bool, is_collecting_in_band_lifetimes: bool,
// Currently in-scope lifetimes defined in impl headers, fn headers, or HRTB. // Currently in-scope lifetimes defined in impl headers, fn headers, or HRTB.
@ -709,12 +708,8 @@ impl<'a> LoweringContext<'a> {
assert!(self.lifetimes_to_define.is_empty()); assert!(self.lifetimes_to_define.is_empty());
let old_anonymous_lifetime_mode = self.anonymous_lifetime_mode; let old_anonymous_lifetime_mode = self.anonymous_lifetime_mode;
if self.sess.features_untracked().impl_header_lifetime_elision {
self.anonymous_lifetime_mode = anonymous_lifetime_mode; self.anonymous_lifetime_mode = anonymous_lifetime_mode;
self.is_collecting_in_band_lifetimes = true; self.is_collecting_in_band_lifetimes = true;
} else if self.sess.features_untracked().in_band_lifetimes {
self.is_collecting_in_band_lifetimes = true;
}
let (in_band_ty_params, res) = f(self); let (in_band_ty_params, res) = f(self);

View file

@ -67,7 +67,7 @@
#![feature(step_trait)] #![feature(step_trait)]
#![feature(integer_atomics)] #![feature(integer_atomics)]
#![feature(test)] #![feature(test)]
#![feature(impl_header_lifetime_elision)] #![cfg_attr(stage0, feature(impl_header_lifetime_elision))]
#![feature(in_band_lifetimes)] #![feature(in_band_lifetimes)]
#![feature(macro_at_most_once_rep)] #![feature(macro_at_most_once_rep)]
#![feature(crate_visibility_modifier)] #![feature(crate_visibility_modifier)]

View file

@ -21,7 +21,7 @@
html_root_url = "https://doc.rust-lang.org/nightly/")] html_root_url = "https://doc.rust-lang.org/nightly/")]
#![feature(in_band_lifetimes)] #![feature(in_band_lifetimes)]
#![feature(impl_header_lifetime_elision)] #![cfg_attr(stage0, feature(impl_header_lifetime_elision))]
#![feature(unboxed_closures)] #![feature(unboxed_closures)]
#![feature(fn_traits)] #![feature(fn_traits)]
#![feature(unsize)] #![feature(unsize)]

View file

@ -16,7 +16,7 @@ Rust MIR: a lowered representation of Rust. Also: an experiment!
#![feature(nll)] #![feature(nll)]
#![feature(in_band_lifetimes)] #![feature(in_band_lifetimes)]
#![feature(impl_header_lifetime_elision)] #![cfg_attr(stage0, feature(impl_header_lifetime_elision))]
#![feature(slice_patterns)] #![feature(slice_patterns)]
#![feature(slice_sort_by_cached_key)] #![feature(slice_sort_by_cached_key)]
#![feature(box_patterns)] #![feature(box_patterns)]

View file

@ -375,14 +375,14 @@ and likely to change in the future.
E0705: r##" E0705: r##"
A `#![feature]` attribute was declared for a feature that is stable in A `#![feature]` attribute was declared for a feature that is stable in
the current edition. the current edition, but not in all editions.
Erroneous code example: Erroneous code example:
```ignore (limited to a warning during 2018 edition development) ```ignore (limited to a warning during 2018 edition development)
#![feature(rust_2018_preview)] #![feature(rust_2018_preview)]
#![feature(impl_header_lifetime_elision)] // error: the feature #![feature(test_2018_feature)] // error: the feature
// `impl_header_lifetime_elision` is // `test_2018_feature` is
// included in the Rust 2018 edition // included in the Rust 2018 edition
``` ```

View file

@ -462,9 +462,8 @@ declare_features! (
(active, abi_amdgpu_kernel, "1.29.0", Some(51575), None), (active, abi_amdgpu_kernel, "1.29.0", Some(51575), None),
// impl<I:Iterator> Iterator for &mut Iterator // Perma-unstable; added for testing E0705
// impl Debug for Foo<'_> (active, test_2018_feature, "1.31.0", Some(0), Some(Edition::Edition2018)),
(active, impl_header_lifetime_elision, "1.30.0", Some(15872), Some(Edition::Edition2018)),
// Support for arbitrary delimited token streams in non-macro attributes // Support for arbitrary delimited token streams in non-macro attributes
(active, unrestricted_attribute_tokens, "1.30.0", Some(44690), None), (active, unrestricted_attribute_tokens, "1.30.0", Some(44690), None),
@ -684,6 +683,9 @@ declare_features! (
(accepted, min_const_fn, "1.31.0", Some(53555), None), (accepted, min_const_fn, "1.31.0", Some(53555), None),
// Scoped lints // Scoped lints
(accepted, tool_lints, "1.31.0", Some(44690), None), (accepted, tool_lints, "1.31.0", Some(44690), None),
// impl<I:Iterator> Iterator for &mut Iterator
// impl Debug for Foo<'_>
(accepted, impl_header_lifetime_elision, "1.31.0", Some(15872), None),
); );
// If you change this, please modify src/doc/unstable-book as well. You must // If you change this, please modify src/doc/unstable-book as well. You must

View file

@ -10,8 +10,11 @@
// compile-pass // compile-pass
#![feature(impl_header_lifetime_elision)] // This is a stub feature that doesn't control anything, so to make tidy happy,
//~^ WARN the feature `impl_header_lifetime_elision` is included in the Rust 2018 edition // gate-test-test_2018_feature
#![feature(test_2018_feature)]
//~^ WARN the feature `test_2018_feature` is included in the Rust 2018 edition
#![feature(rust_2018_preview)] #![feature(rust_2018_preview)]
fn main() {} fn main() {}

View file

@ -1,6 +1,6 @@
warning[E0705]: the feature `impl_header_lifetime_elision` is included in the Rust 2018 edition warning[E0705]: the feature `test_2018_feature` is included in the Rust 2018 edition
--> $DIR/E0705.rs:13:12 --> $DIR/E0705.rs:16:12
| |
LL | #![feature(impl_header_lifetime_elision)] LL | #![feature(test_2018_feature)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^

View file

@ -1,15 +0,0 @@
error[E0106]: missing lifetime specifier
--> $DIR/feature-gate-impl_header_lifetime_elision-with-in_band.rs:18:22
|
LL | impl MyTrait<'a> for &u32 { }
| ^ expected lifetime parameter
error[E0106]: missing lifetime specifier
--> $DIR/feature-gate-impl_header_lifetime_elision-with-in_band.rs:24:23
|
LL | impl MarkerTrait for &'_ MyStruct { }
| ^^ expected lifetime parameter
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0106`.

View file

@ -1,15 +0,0 @@
error[E0106]: missing lifetime specifier
--> $DIR/feature-gate-impl_header_lifetime_elision.rs:15:26
|
LL | impl<'a> MyTrait<'a> for &u32 { }
| ^ expected lifetime parameter
error[E0106]: missing lifetime specifier
--> $DIR/feature-gate-impl_header_lifetime_elision.rs:18:18
|
LL | impl<'a> MyTrait<'_> for &'a f32 { }
| ^^ expected lifetime parameter
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0106`.

View file

@ -10,9 +10,6 @@
#![allow(warnings)] #![allow(warnings)]
// Make sure this related feature didn't accidentally enable this
#![feature(impl_header_lifetime_elision)]
fn foo(x: &'x u8) -> &'x u8 { x } fn foo(x: &'x u8) -> &'x u8 { x }
//~^ ERROR use of undeclared lifetime name //~^ ERROR use of undeclared lifetime name
//~^^ ERROR use of undeclared lifetime name //~^^ ERROR use of undeclared lifetime name

View file

@ -1,101 +1,101 @@
error[E0261]: use of undeclared lifetime name `'x` error[E0261]: use of undeclared lifetime name `'x`
--> $DIR/feature-gate-in_band_lifetimes.rs:16:12 --> $DIR/feature-gate-in_band_lifetimes.rs:13:12
| |
LL | fn foo(x: &'x u8) -> &'x u8 { x } LL | fn foo(x: &'x u8) -> &'x u8 { x }
| ^^ undeclared lifetime | ^^ undeclared lifetime
error[E0261]: use of undeclared lifetime name `'x` error[E0261]: use of undeclared lifetime name `'x`
--> $DIR/feature-gate-in_band_lifetimes.rs:16:23 --> $DIR/feature-gate-in_band_lifetimes.rs:13:23
| |
LL | fn foo(x: &'x u8) -> &'x u8 { x } LL | fn foo(x: &'x u8) -> &'x u8 { x }
| ^^ undeclared lifetime | ^^ undeclared lifetime
error[E0261]: use of undeclared lifetime name `'b` error[E0261]: use of undeclared lifetime name `'b`
--> $DIR/feature-gate-in_band_lifetimes.rs:28:12 --> $DIR/feature-gate-in_band_lifetimes.rs:25:12
| |
LL | impl<'a> X<'b> { LL | impl<'a> X<'b> {
| ^^ undeclared lifetime | ^^ undeclared lifetime
error[E0261]: use of undeclared lifetime name `'b` error[E0261]: use of undeclared lifetime name `'b`
--> $DIR/feature-gate-in_band_lifetimes.rs:30:27 --> $DIR/feature-gate-in_band_lifetimes.rs:27:27
| |
LL | fn inner_2(&self) -> &'b u8 { LL | fn inner_2(&self) -> &'b u8 {
| ^^ undeclared lifetime | ^^ undeclared lifetime
error[E0261]: use of undeclared lifetime name `'b` error[E0261]: use of undeclared lifetime name `'b`
--> $DIR/feature-gate-in_band_lifetimes.rs:36:8 --> $DIR/feature-gate-in_band_lifetimes.rs:33:8
| |
LL | impl X<'b> { LL | impl X<'b> {
| ^^ undeclared lifetime | ^^ undeclared lifetime
error[E0261]: use of undeclared lifetime name `'b` error[E0261]: use of undeclared lifetime name `'b`
--> $DIR/feature-gate-in_band_lifetimes.rs:38:27 --> $DIR/feature-gate-in_band_lifetimes.rs:35:27
| |
LL | fn inner_3(&self) -> &'b u8 { LL | fn inner_3(&self) -> &'b u8 {
| ^^ undeclared lifetime | ^^ undeclared lifetime
error[E0261]: use of undeclared lifetime name `'a` error[E0261]: use of undeclared lifetime name `'a`
--> $DIR/feature-gate-in_band_lifetimes.rs:46:9 --> $DIR/feature-gate-in_band_lifetimes.rs:43:9
| |
LL | impl Y<&'a u8> { LL | impl Y<&'a u8> {
| ^^ undeclared lifetime | ^^ undeclared lifetime
error[E0261]: use of undeclared lifetime name `'a` error[E0261]: use of undeclared lifetime name `'a`
--> $DIR/feature-gate-in_band_lifetimes.rs:48:25 --> $DIR/feature-gate-in_band_lifetimes.rs:45:25
| |
LL | fn inner(&self) -> &'a u8 { LL | fn inner(&self) -> &'a u8 {
| ^^ undeclared lifetime | ^^ undeclared lifetime
error[E0261]: use of undeclared lifetime name `'b` error[E0261]: use of undeclared lifetime name `'b`
--> $DIR/feature-gate-in_band_lifetimes.rs:56:27 --> $DIR/feature-gate-in_band_lifetimes.rs:53:27
| |
LL | fn any_lifetime() -> &'b u8; LL | fn any_lifetime() -> &'b u8;
| ^^ undeclared lifetime | ^^ undeclared lifetime
error[E0261]: use of undeclared lifetime name `'b` error[E0261]: use of undeclared lifetime name `'b`
--> $DIR/feature-gate-in_band_lifetimes.rs:58:27 --> $DIR/feature-gate-in_band_lifetimes.rs:55:27
| |
LL | fn borrowed_lifetime(&'b self) -> &'b u8; LL | fn borrowed_lifetime(&'b self) -> &'b u8;
| ^^ undeclared lifetime | ^^ undeclared lifetime
error[E0261]: use of undeclared lifetime name `'b` error[E0261]: use of undeclared lifetime name `'b`
--> $DIR/feature-gate-in_band_lifetimes.rs:58:40 --> $DIR/feature-gate-in_band_lifetimes.rs:55:40
| |
LL | fn borrowed_lifetime(&'b self) -> &'b u8; LL | fn borrowed_lifetime(&'b self) -> &'b u8;
| ^^ undeclared lifetime | ^^ undeclared lifetime
error[E0261]: use of undeclared lifetime name `'a` error[E0261]: use of undeclared lifetime name `'a`
--> $DIR/feature-gate-in_band_lifetimes.rs:63:14 --> $DIR/feature-gate-in_band_lifetimes.rs:60:14
| |
LL | impl MyTrait<'a> for Y<&'a u8> { LL | impl MyTrait<'a> for Y<&'a u8> {
| ^^ undeclared lifetime | ^^ undeclared lifetime
error[E0261]: use of undeclared lifetime name `'a` error[E0261]: use of undeclared lifetime name `'a`
--> $DIR/feature-gate-in_band_lifetimes.rs:63:25 --> $DIR/feature-gate-in_band_lifetimes.rs:60:25
| |
LL | impl MyTrait<'a> for Y<&'a u8> { LL | impl MyTrait<'a> for Y<&'a u8> {
| ^^ undeclared lifetime | ^^ undeclared lifetime
error[E0261]: use of undeclared lifetime name `'a` error[E0261]: use of undeclared lifetime name `'a`
--> $DIR/feature-gate-in_band_lifetimes.rs:66:31 --> $DIR/feature-gate-in_band_lifetimes.rs:63:31
| |
LL | fn my_lifetime(&self) -> &'a u8 { self.0 } LL | fn my_lifetime(&self) -> &'a u8 { self.0 }
| ^^ undeclared lifetime | ^^ undeclared lifetime
error[E0261]: use of undeclared lifetime name `'b` error[E0261]: use of undeclared lifetime name `'b`
--> $DIR/feature-gate-in_band_lifetimes.rs:68:27 --> $DIR/feature-gate-in_band_lifetimes.rs:65:27
| |
LL | fn any_lifetime() -> &'b u8 { &0 } LL | fn any_lifetime() -> &'b u8 { &0 }
| ^^ undeclared lifetime | ^^ undeclared lifetime
error[E0261]: use of undeclared lifetime name `'b` error[E0261]: use of undeclared lifetime name `'b`
--> $DIR/feature-gate-in_band_lifetimes.rs:70:27 --> $DIR/feature-gate-in_band_lifetimes.rs:67:27
| |
LL | fn borrowed_lifetime(&'b self) -> &'b u8 { &*self.0 } LL | fn borrowed_lifetime(&'b self) -> &'b u8 { &*self.0 }
| ^^ undeclared lifetime | ^^ undeclared lifetime
error[E0261]: use of undeclared lifetime name `'b` error[E0261]: use of undeclared lifetime name `'b`
--> $DIR/feature-gate-in_band_lifetimes.rs:70:40 --> $DIR/feature-gate-in_band_lifetimes.rs:67:40
| |
LL | fn borrowed_lifetime(&'b self) -> &'b u8 { &*self.0 } LL | fn borrowed_lifetime(&'b self) -> &'b u8 { &*self.0 }
| ^^ undeclared lifetime | ^^ undeclared lifetime

View file

@ -13,8 +13,6 @@
#![allow(warnings)] #![allow(warnings)]
#![feature(impl_header_lifetime_elision)]
trait MyTrait { trait MyTrait {
type Output; type Output;
} }

View file

@ -1,11 +1,11 @@
error[E0106]: missing lifetime specifier error[E0106]: missing lifetime specifier
--> $DIR/assoc-type.rs:23:19 --> $DIR/assoc-type.rs:21:19
| |
LL | type Output = &i32; LL | type Output = &i32;
| ^ expected lifetime parameter | ^ expected lifetime parameter
error[E0106]: missing lifetime specifier error[E0106]: missing lifetime specifier
--> $DIR/assoc-type.rs:28:20 --> $DIR/assoc-type.rs:26:20
| |
LL | type Output = &'_ i32; LL | type Output = &'_ i32;
| ^^ expected lifetime parameter | ^^ expected lifetime parameter

View file

@ -13,8 +13,6 @@
#![allow(warnings)] #![allow(warnings)]
#![feature(impl_header_lifetime_elision)]
use std::fmt::Debug; use std::fmt::Debug;
// Equivalent to `Box<dyn Debug + 'static>`: // Equivalent to `Box<dyn Debug + 'static>`:

View file

@ -1,11 +1,11 @@
error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
--> $DIR/dyn-trait.rs:32:16 --> $DIR/dyn-trait.rs:30:16
| |
LL | static_val(x); //~ ERROR cannot infer LL | static_val(x); //~ ERROR cannot infer
| ^ | ^
| |
note: first, the lifetime cannot outlive the lifetime 'a as defined on the function body at 31:26... note: first, the lifetime cannot outlive the lifetime 'a as defined on the function body at 29:26...
--> $DIR/dyn-trait.rs:31:26 --> $DIR/dyn-trait.rs:29:26
| |
LL | fn with_dyn_debug_static<'a>(x: Box<dyn Debug + 'a>) { LL | fn with_dyn_debug_static<'a>(x: Box<dyn Debug + 'a>) {
| ^^ | ^^

View file

@ -12,8 +12,6 @@
#![allow(warnings)] #![allow(warnings)]
#![feature(impl_header_lifetime_elision)]
// This works for functions... // This works for functions...
fn foo<'a>(x: &str, y: &'a str) {} fn foo<'a>(x: &str, y: &'a str) {}

View file

@ -8,14 +8,12 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
#![allow(warnings)] // compile-pass
trait MyTrait<'a> { } struct Foo<'a>(&'a u8);
impl<'a> MyTrait<'a> for &u32 { } impl Foo<'_> {
//~^ ERROR missing lifetime specifier fn x() {}
}
impl<'a> MyTrait<'_> for &'a f32 { }
//~^ ERROR missing lifetime specifier
fn main() {} fn main() {}

View file

@ -9,8 +9,6 @@
// except according to those terms. // except according to those terms.
#![allow(warnings)] #![allow(warnings)]
#![feature(impl_header_lifetime_elision)]
trait MyTrait { } trait MyTrait { }
struct Foo<'a> { x: &'a u32 } struct Foo<'a> { x: &'a u32 }

View file

@ -1,5 +1,5 @@
error[E0106]: missing lifetime specifier error[E0106]: missing lifetime specifier
--> $DIR/path-elided.rs:18:18 --> $DIR/path-elided.rs:16:18
| |
LL | impl MyTrait for Foo { LL | impl MyTrait for Foo {
| ^^^ expected lifetime parameter | ^^^ expected lifetime parameter

View file

@ -14,8 +14,6 @@
#![allow(warnings)] #![allow(warnings)]
#![feature(impl_header_lifetime_elision)]
trait MyTrait { } trait MyTrait { }
struct Foo<'a> { x: &'a u32 } struct Foo<'a> { x: &'a u32 }

View file

@ -14,8 +14,6 @@
#![allow(warnings)] #![allow(warnings)]
#![feature(impl_header_lifetime_elision)]
trait MyTrait { } trait MyTrait { }
impl MyTrait for &i32 { impl MyTrait for &i32 {

View file

@ -9,8 +9,6 @@
// except according to those terms. // except according to those terms.
#![allow(warnings)] #![allow(warnings)]
#![feature(impl_header_lifetime_elision)]
trait MyTrait<'a> { } trait MyTrait<'a> { }
impl MyTrait for u32 { impl MyTrait for u32 {

View file

@ -1,5 +1,5 @@
error[E0106]: missing lifetime specifier error[E0106]: missing lifetime specifier
--> $DIR/trait-elided.rs:16:6 --> $DIR/trait-elided.rs:14:6
| |
LL | impl MyTrait for u32 { LL | impl MyTrait for u32 {
| ^^^^^^^ expected lifetime parameter | ^^^^^^^ expected lifetime parameter

View file

@ -15,8 +15,6 @@
#![allow(warnings)] #![allow(warnings)]
#![feature(impl_header_lifetime_elision)]
trait MyTrait<'a> { } trait MyTrait<'a> { }
// This is equivalent to `MyTrait<'a> for &'b i32`, which is proven by // This is equivalent to `MyTrait<'a> for &'b i32`, which is proven by

View file

@ -1,4 +1,4 @@
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at // file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT. // http://rust-lang.org/COPYRIGHT.
// //
@ -8,20 +8,19 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
#![allow(warnings)] #[derive(Debug)]
struct Pair<T, V> (T, V);
// Make sure this related feature didn't accidentally enable this impl Pair<
#![feature(in_band_lifetimes)] &str,
isize
> {
fn say(self: &Pair<&str, isize>) {
println!("{:?}", self);
}
}
trait MyTrait<'a> { } fn main() {
let result = &Pair("shane", 1);
impl MyTrait<'a> for &u32 { } result.say();
//~^ ERROR missing lifetime specifier }
struct MyStruct;
trait MarkerTrait {}
impl MarkerTrait for &'_ MyStruct { }
//~^ ERROR missing lifetime specifier
fn main() {}

View file

@ -0,0 +1,45 @@
error[E0308]: mismatched method receiver
--> $DIR/issue-17905-2.rs:18:18
|
LL | fn say(self: &Pair<&str, isize>) {
| ^^^^^^^^^^^^^^^^^^ lifetime mismatch
|
= note: expected type `Pair<&'_ str, _>`
found type `Pair<&str, _>`
note: the anonymous lifetime #2 defined on the method body at 18:5...
--> $DIR/issue-17905-2.rs:18:5
|
LL | / fn say(self: &Pair<&str, isize>) {
LL | | println!("{:?}", self);
LL | | }
| |_____^
note: ...does not necessarily outlive the lifetime '_ as defined on the impl at 15:5
--> $DIR/issue-17905-2.rs:15:5
|
LL | &str,
| ^
error[E0308]: mismatched method receiver
--> $DIR/issue-17905-2.rs:18:18
|
LL | fn say(self: &Pair<&str, isize>) {
| ^^^^^^^^^^^^^^^^^^ lifetime mismatch
|
= note: expected type `Pair<&'_ str, _>`
found type `Pair<&str, _>`
note: the lifetime '_ as defined on the impl at 15:5...
--> $DIR/issue-17905-2.rs:15:5
|
LL | &str,
| ^
note: ...does not necessarily outlive the anonymous lifetime #2 defined on the method body at 18:5
--> $DIR/issue-17905-2.rs:18:5
|
LL | / fn say(self: &Pair<&str, isize>) {
LL | | println!("{:?}", self);
LL | | }
| |_____^
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0308`.

View file

@ -8,15 +8,17 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
// run-pass
#[derive(Debug)] #[derive(Debug)]
struct Pair<T, V> (T, V); struct Pair<T, V> (T, V);
impl Pair< impl Pair<
&str, //~ ERROR missing lifetime specifier &str,
isize isize
> { > {
fn say(self: &Pair<&str, isize>) { fn say(&self) {
println!("{}", self); println!("{:?}", self);
} }
} }

View file

@ -1,9 +0,0 @@
error[E0106]: missing lifetime specifier
--> $DIR/issue-17905.rs:15:5
|
LL | &str, //~ ERROR missing lifetime specifier
| ^ expected lifetime parameter
error: aborting due to previous error
For more information about this error, try `rustc --explain E0106`.

View file

@ -1,33 +0,0 @@
// Copyright 2015 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
// pretty-expanded FIXME #23616
#![feature(fn_traits, unboxed_closures)]
#[allow(dead_code)]
struct Foo;
impl<'a> Fn<(&'a (),)> for Foo {
extern "rust-call" fn call(&self, (_,): (&(),)) {}
}
impl<'a> FnMut<(&'a (),)> for Foo {
extern "rust-call" fn call_mut(&mut self, (_,): (&(),)) {}
}
impl<'a> FnOnce<(&'a (),)> for Foo {
type Output = ();
extern "rust-call" fn call_once(self, (_,): (&(),)) {}
}
fn main() {}

View file

@ -8,10 +8,25 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
#![feature(unboxed_closures)] // compile-pass
#![feature(fn_traits, unboxed_closures)]
#[allow(dead_code)]
struct Foo; struct Foo;
impl Fn<(&(),)> for Foo { } //~ ERROR missing lifetime specifier impl Fn<(&(),)> for Foo {
extern "rust-call" fn call(&self, (_,): (&(),)) {}
}
impl FnMut<(&(),)> for Foo {
extern "rust-call" fn call_mut(&mut self, (_,): (&(),)) {}
}
impl FnOnce<(&(),)> for Foo {
type Output = ();
extern "rust-call" fn call_once(self, (_,): (&(),)) {}
}
fn main() {} fn main() {}

View file

@ -1,9 +0,0 @@
error[E0106]: missing lifetime specifier
--> $DIR/issue-19982.rs:15:10
|
LL | impl Fn<(&(),)> for Foo { } //~ ERROR missing lifetime specifier
| ^ expected lifetime parameter
error: aborting due to previous error
For more information about this error, try `rustc --explain E0106`.

View file

@ -10,7 +10,6 @@
#![feature(nll)] #![feature(nll)]
#![feature(in_band_lifetimes)] #![feature(in_band_lifetimes)]
#![feature(impl_header_lifetime_elision)]
struct Foo<'a, 'b> { struct Foo<'a, 'b> {
x: &'a u32, x: &'a u32,

View file

@ -1,5 +1,5 @@
error: unsatisfied lifetime constraints error: unsatisfied lifetime constraints
--> $DIR/issue-52742.rs:26:9 --> $DIR/issue-52742.rs:25:9
| |
LL | fn take_bar(&mut self, b: Bar<'_>) { LL | fn take_bar(&mut self, b: Bar<'_>) {
| --------- -- let's call this `'1` | --------- -- let's call this `'1`

View file

@ -1,46 +0,0 @@
error[E0637]: `'_` cannot be used here
--> $DIR/in-binder.rs:12:6
|
LL | impl<'_> IceCube<'_> {}
| ^^ `'_` is a reserved lifetime name
error[E0637]: `'_` cannot be used here
--> $DIR/in-binder.rs:17:15
|
LL | struct Struct<'_> {
| ^^ `'_` is a reserved lifetime name
error[E0637]: `'_` cannot be used here
--> $DIR/in-binder.rs:23:11
|
LL | enum Enum<'_> {
| ^^ `'_` is a reserved lifetime name
error[E0637]: `'_` cannot be used here
--> $DIR/in-binder.rs:29:13
|
LL | union Union<'_> {
| ^^ `'_` is a reserved lifetime name
error[E0637]: `'_` cannot be used here
--> $DIR/in-binder.rs:35:13
|
LL | trait Trait<'_> {
| ^^ `'_` is a reserved lifetime name
error[E0637]: `'_` cannot be used here
--> $DIR/in-binder.rs:40:8
|
LL | fn foo<'_>() {
| ^^ `'_` is a reserved lifetime name
error[E0106]: missing lifetime specifier
--> $DIR/in-binder.rs:12:18
|
LL | impl<'_> IceCube<'_> {}
| ^^ expected lifetime parameter
error: aborting due to 7 previous errors
Some errors occurred: E0106, E0637.
For more information about an error, try `rustc --explain E0106`.

View file

@ -2,44 +2,34 @@
// //
// Regression test for #52098. // Regression test for #52098.
// revisions: Rust2015 Rust2018
//[Rust2018] edition:2018
struct IceCube<'a> { struct IceCube<'a> {
v: Vec<&'a char> v: Vec<&'a char>
} }
impl<'_> IceCube<'_> {} impl<'_> IceCube<'_> {}
//[Rust2015]~^ ERROR `'_` cannot be used here //~^ ERROR `'_` cannot be used here
//[Rust2015]~| ERROR missing lifetime specifier
//[Rust2018]~^^^ ERROR `'_` cannot be used here
struct Struct<'_> { struct Struct<'_> {
//[Rust2015]~^ ERROR `'_` cannot be used here //~^ ERROR `'_` cannot be used here
//[Rust2018]~^^ ERROR `'_` cannot be used here
v: Vec<&'static char> v: Vec<&'static char>
} }
enum Enum<'_> { enum Enum<'_> {
//[Rust2015]~^ ERROR `'_` cannot be used here //~^ ERROR `'_` cannot be used here
//[Rust2018]~^^ ERROR `'_` cannot be used here
Variant Variant
} }
union Union<'_> { union Union<'_> {
//[Rust2015]~^ ERROR `'_` cannot be used here //~^ ERROR `'_` cannot be used here
//[Rust2018]~^^ ERROR `'_` cannot be used here
a: u32 a: u32
} }
trait Trait<'_> { trait Trait<'_> {
//[Rust2015]~^ ERROR `'_` cannot be used here //~^ ERROR `'_` cannot be used here
//[Rust2018]~^^ ERROR `'_` cannot be used here
} }
fn foo<'_>() { fn foo<'_>() {
//[Rust2015]~^ ERROR `'_` cannot be used here //~^ ERROR `'_` cannot be used here
//[Rust2018]~^^ ERROR `'_` cannot be used here
} }
fn main() {} fn main() {}

View file

@ -1,35 +1,35 @@
error[E0637]: `'_` cannot be used here error[E0637]: `'_` cannot be used here
--> $DIR/in-binder.rs:12:6 --> $DIR/in-binder.rs:9:6
| |
LL | impl<'_> IceCube<'_> {} LL | impl<'_> IceCube<'_> {}
| ^^ `'_` is a reserved lifetime name | ^^ `'_` is a reserved lifetime name
error[E0637]: `'_` cannot be used here error[E0637]: `'_` cannot be used here
--> $DIR/in-binder.rs:17:15 --> $DIR/in-binder.rs:12:15
| |
LL | struct Struct<'_> { LL | struct Struct<'_> {
| ^^ `'_` is a reserved lifetime name | ^^ `'_` is a reserved lifetime name
error[E0637]: `'_` cannot be used here error[E0637]: `'_` cannot be used here
--> $DIR/in-binder.rs:23:11 --> $DIR/in-binder.rs:17:11
| |
LL | enum Enum<'_> { LL | enum Enum<'_> {
| ^^ `'_` is a reserved lifetime name | ^^ `'_` is a reserved lifetime name
error[E0637]: `'_` cannot be used here error[E0637]: `'_` cannot be used here
--> $DIR/in-binder.rs:29:13 --> $DIR/in-binder.rs:22:13
| |
LL | union Union<'_> { LL | union Union<'_> {
| ^^ `'_` is a reserved lifetime name | ^^ `'_` is a reserved lifetime name
error[E0637]: `'_` cannot be used here error[E0637]: `'_` cannot be used here
--> $DIR/in-binder.rs:35:13 --> $DIR/in-binder.rs:27:13
| |
LL | trait Trait<'_> { LL | trait Trait<'_> {
| ^^ `'_` is a reserved lifetime name | ^^ `'_` is a reserved lifetime name
error[E0637]: `'_` cannot be used here error[E0637]: `'_` cannot be used here
--> $DIR/in-binder.rs:40:8 --> $DIR/in-binder.rs:31:8
| |
LL | fn foo<'_>() { LL | fn foo<'_>() {
| ^^ `'_` is a reserved lifetime name | ^^ `'_` is a reserved lifetime name

View file

@ -11,10 +11,6 @@
struct Foo<'a>(&'a u8); struct Foo<'a>(&'a u8);
struct Baz<'a>(&'_ &'a u8); //~ ERROR missing lifetime specifier struct Baz<'a>(&'_ &'a u8); //~ ERROR missing lifetime specifier
impl Foo<'_> { //~ ERROR missing lifetime specifier
fn x() {}
}
fn foo<'_> //~ ERROR cannot be used here fn foo<'_> //~ ERROR cannot be used here
(_: Foo<'_>) {} (_: Foo<'_>) {}

View file

@ -1,11 +1,11 @@
error[E0637]: `'_` cannot be used here 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 LL | fn foo<'_> //~ ERROR cannot be used here
| ^^ `'_` is a reserved lifetime name | ^^ `'_` is a reserved lifetime name
error[E0637]: `'_` cannot be used here 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 LL | fn meh() -> Box<for<'_> Meh<'_>> //~ ERROR cannot be used here
| ^^ `'_` is a reserved lifetime name | ^^ `'_` is a reserved lifetime name
@ -17,13 +17,7 @@ LL | struct Baz<'a>(&'_ &'a u8); //~ ERROR missing lifetime specifier
| ^^ expected lifetime parameter | ^^ expected lifetime parameter
error[E0106]: missing lifetime specifier error[E0106]: missing lifetime specifier
--> $DIR/underscore-lifetime-binders.rs:14:10 --> $DIR/underscore-lifetime-binders.rs:20:29
|
LL | impl Foo<'_> { //~ ERROR missing lifetime specifier
| ^^ expected lifetime parameter
error[E0106]: missing lifetime specifier
--> $DIR/underscore-lifetime-binders.rs:24:29
| |
LL | fn meh() -> Box<for<'_> Meh<'_>> //~ ERROR cannot be used here LL | fn meh() -> Box<for<'_> Meh<'_>> //~ ERROR cannot be used here
| ^^ expected lifetime parameter | ^^ expected lifetime parameter
@ -32,14 +26,14 @@ LL | fn meh() -> Box<for<'_> Meh<'_>> //~ ERROR cannot be used here
= help: consider giving it a 'static lifetime = help: consider giving it a 'static lifetime
error[E0106]: missing lifetime specifier 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 LL | fn foo2(_: &'_ u8, y: &'_ u8) -> &'_ u8 { y } //~ ERROR missing lifetime specifier
| ^^ expected lifetime parameter | ^^ 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` = 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. Some errors occurred: E0106, E0637.
For more information about an error, try `rustc --explain E0106`. For more information about an error, try `rustc --explain E0106`.