Stabilize underscore lifetimes

This commit is contained in:
Taylor Cramer 2018-03-28 17:25:39 +02:00
parent e5277c1457
commit e6e6bd27d5
32 changed files with 27 additions and 82 deletions

View file

@ -68,7 +68,7 @@
#![feature(slice_patterns)]
#![feature(specialization)]
#![feature(unboxed_closures)]
#![feature(underscore_lifetimes)]
#![cfg_attr(stage0, feature(underscore_lifetimes))]
#![cfg_attr(stage0, feature(universal_impl_trait))]
#![feature(trace_macros)]
#![feature(trusted_len)]

View file

@ -30,7 +30,7 @@
#![cfg_attr(stage0, feature(i128_type, i128))]
#![feature(specialization)]
#![feature(optin_builtin_traits)]
#![feature(underscore_lifetimes)]
#![cfg_attr(stage0, feature(underscore_lifetimes))]
#![feature(macro_vis_matcher)]
#![feature(allow_internal_unstable)]
#![cfg_attr(stage0, feature(universal_impl_trait))]

View file

@ -37,7 +37,7 @@ Rust MIR: a lowered representation of Rust. Also: an experiment!
#![feature(placement_in_syntax)]
#![feature(collection_placement)]
#![feature(nonzero)]
#![feature(underscore_lifetimes)]
#![cfg_attr(stage0, feature(underscore_lifetimes))]
#![cfg_attr(stage0, feature(never_type))]
#![feature(inclusive_range_fields)]

View file

@ -15,7 +15,7 @@
#![feature(crate_visibility_modifier)]
#![cfg_attr(stage0, feature(match_default_bindings))]
#![feature(underscore_lifetimes)]
#![cfg_attr(stage0, feature(underscore_lifetimes))]
#[macro_use]
extern crate log;

View file

@ -385,6 +385,9 @@ declare_features! (
// allow `'_` placeholder lifetimes
(active, underscore_lifetimes, "1.22.0", Some(44524), None),
// Default match binding modes (RFC 2005)
(active, match_default_bindings, "1.22.0", Some(42640), None),
// Trait object syntax with `dyn` prefix
(active, dyn_trait, "1.22.0", Some(44662), Some(Edition::Edition2018)),
@ -562,6 +565,8 @@ declare_features! (
(accepted, i128_type, "1.26.0", Some(35118), None),
// Default match binding modes (RFC 2005)
(accepted, match_default_bindings, "1.26.0", Some(42640), None),
// allow `'_` placeholder lifetimes
(accepted, underscore_lifetimes, "1.26.0", Some(44524), None),
);
// If you change this, please modify src/doc/unstable-book as well. You must
@ -1792,14 +1797,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
visit::walk_generic_param(self, param)
}
fn visit_lifetime(&mut self, lt: &'a ast::Lifetime) {
if lt.ident.name == keywords::UnderscoreLifetime.name() {
gate_feature_post!(&self, underscore_lifetimes, lt.span,
"underscore lifetimes are unstable");
}
visit::walk_lifetime(self, lt)
}
}
pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute],

View file

@ -10,7 +10,6 @@
// must-compile-successfully
#![feature(underscore_lifetimes)]
#![allow(warnings)]
type Different<'a, 'b> = &'a mut (&'a (), &'b ());

View file

@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(underscore_lifetimes)]
fn with_closure_expecting_fn_with_free_region<F>(_: F)
where F: for<'a> FnOnce(fn(&'a u32), &i32)
{

View file

@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(underscore_lifetimes)]
struct Foo<'a>(&'a u8);
struct Baz<'a>(&'_ &'a u8); //~ ERROR missing lifetime specifier

View file

@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(underscore_lifetimes)]
fn foo(x: &mut Vec<&'_ u8>, y: &'_ u8) { x.push(y); } //~ ERROR lifetime mismatch
fn main() {}

View file

@ -8,7 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(underscore_lifetimes)]
#![allow(warnings)]
use std::fmt::Debug;

View file

@ -8,8 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(underscore_lifetimes)]
struct Foo<'a>(&'a u8);
fn foo(x: &u8) -> Foo<'_> {

View file

@ -7,7 +7,6 @@
// <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.
#![feature(underscore_lifetimes)]
struct Foo<'a: '_>(&'a u8); //~ ERROR invalid lifetime bound name: `'_`
fn foo<'a: '_>(_: &'a u8) {} //~ ERROR invalid lifetime bound name: `'_`

View file

@ -1,17 +1,17 @@
error[E0637]: invalid lifetime bound name: `'_`
--> $DIR/E0637.rs:12:16
--> $DIR/E0637.rs:11:16
|
LL | struct Foo<'a: '_>(&'a u8); //~ ERROR invalid lifetime bound name: `'_`
| ^^ `'_` is a reserved lifetime name
error[E0637]: invalid lifetime bound name: `'_`
--> $DIR/E0637.rs:13:12
--> $DIR/E0637.rs:12:12
|
LL | fn foo<'a: '_>(_: &'a u8) {} //~ ERROR invalid lifetime bound name: `'_`
| ^^ `'_` is a reserved lifetime name
error[E0637]: invalid lifetime bound name: `'_`
--> $DIR/E0637.rs:16:10
--> $DIR/E0637.rs:15:10
|
LL | impl<'a: '_> Bar<'a> { //~ ERROR invalid lifetime bound name: `'_`
| ^^ `'_` is a reserved lifetime name

View file

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

View file

@ -1,11 +1,11 @@
error[E0106]: missing lifetime specifier
--> $DIR/feature-gate-in_band_lifetimes-impl.rs:16:26
--> $DIR/feature-gate-in_band_lifetimes-impl.rs:15:26
|
LL | impl<'a> MyTrait<'a> for &u32 { }
| ^ expected lifetime parameter
error[E0106]: missing lifetime specifier
--> $DIR/feature-gate-in_band_lifetimes-impl.rs:19:18
--> $DIR/feature-gate-in_band_lifetimes-impl.rs:18:18
|
LL | impl<'a> MyTrait<'_> for &'a f32 { }
| ^^ expected lifetime parameter

View file

@ -1,20 +0,0 @@
// 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.
struct Foo<'a>(&'a u8);
fn foo(x: &u8) -> Foo<'_> { //~ ERROR underscore lifetimes are unstable
Foo(x)
}
fn main() {
let x = 5;
let _ = foo(&x);
}

View file

@ -1,11 +0,0 @@
error[E0658]: underscore lifetimes are unstable (see issue #44524)
--> $DIR/feature-gate-underscore-lifetimes.rs:13:23
|
LL | fn foo(x: &u8) -> Foo<'_> { //~ ERROR underscore lifetimes are unstable
| ^^
|
= help: add #![feature(underscore_lifetimes)] to the crate attributes to enable
error: aborting due to previous error
For more information about this error, try `rustc --explain E0658`.

View file

@ -14,7 +14,6 @@
#![allow(warnings)]
#![feature(in_band_lifetimes)]
#![feature(underscore_lifetimes)]
trait MyTrait {
type Output;

View file

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

View file

@ -15,7 +15,6 @@
#![feature(dyn_trait)]
#![feature(in_band_lifetimes)]
#![feature(underscore_lifetimes)]
use std::fmt::Debug;

View file

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

View file

@ -10,7 +10,6 @@
#![allow(warnings)]
#![feature(in_band_lifetimes)]
#![feature(underscore_lifetimes)]
trait MyTrait { }

View file

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

View file

@ -15,7 +15,6 @@
#![allow(warnings)]
#![feature(in_band_lifetimes)]
#![feature(underscore_lifetimes)]
trait MyTrait { }

View file

@ -15,7 +15,6 @@
#![allow(warnings)]
#![feature(in_band_lifetimes)]
#![feature(underscore_lifetimes)]
trait MyTrait { }

View file

@ -10,7 +10,6 @@
#![allow(warnings)]
#![feature(in_band_lifetimes)]
#![feature(underscore_lifetimes)]
trait MyTrait<'a> { }

View file

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

View file

@ -16,7 +16,6 @@
#![allow(warnings)]
#![feature(in_band_lifetimes)]
#![feature(underscore_lifetimes)]
trait MyTrait<'a> { }

View file

@ -14,7 +14,6 @@
// cc #48468
#![feature(dyn_trait)]
#![feature(underscore_lifetimes)]
use std::fmt::Debug;

View file

@ -1,11 +1,11 @@
error[E0106]: missing lifetime specifier
--> $DIR/dyn-trait-underscore-in-struct.rs:22:24
--> $DIR/dyn-trait-underscore-in-struct.rs:21:24
|
LL | x: Box<dyn Debug + '_>, //~ ERROR missing lifetime specifier
| ^^ expected lifetime parameter
error[E0228]: the lifetime bound for this object type cannot be deduced from context; please supply an explicit bound
--> $DIR/dyn-trait-underscore-in-struct.rs:22:12
--> $DIR/dyn-trait-underscore-in-struct.rs:21:12
|
LL | x: Box<dyn Debug + '_>, //~ ERROR missing lifetime specifier
| ^^^^^^^^^^^^^^

View file

@ -14,7 +14,6 @@
// cc #48468
#![feature(dyn_trait)]
#![feature(underscore_lifetimes)]
fn a<T>(items: &[T]) -> Box<dyn Iterator<Item=&T>> {
// ^^^^^^^^^^^^^^^^^^^^^ bound *here* defaults to `'static`

View file

@ -1,11 +1,11 @@
error[E0495]: cannot infer an appropriate lifetime for autoref due to conflicting requirements
--> $DIR/dyn-trait-underscore.rs:21:20
--> $DIR/dyn-trait-underscore.rs:20:20
|
LL | Box::new(items.iter()) //~ ERROR cannot infer an appropriate lifetime
| ^^^^
|
note: first, the lifetime cannot outlive the anonymous lifetime #1 defined on the function body at 19:1...
--> $DIR/dyn-trait-underscore.rs:19:1
note: first, the lifetime cannot outlive the anonymous lifetime #1 defined on the function body at 18:1...
--> $DIR/dyn-trait-underscore.rs:18:1
|
LL | / fn a<T>(items: &[T]) -> Box<dyn Iterator<Item=&T>> {
LL | | // ^^^^^^^^^^^^^^^^^^^^^ bound *here* defaults to `'static`
@ -13,7 +13,7 @@ LL | | Box::new(items.iter()) //~ ERROR cannot infer an appropriate lifetime
LL | | }
| |_^
note: ...so that reference does not outlive borrowed content
--> $DIR/dyn-trait-underscore.rs:21:14
--> $DIR/dyn-trait-underscore.rs:20:14
|
LL | Box::new(items.iter()) //~ ERROR cannot infer an appropriate lifetime
| ^^^^^