Skip to content

Commit 1e652bd

Browse files
committed
Auto merge of #49458 - cramertj:stable-underscore-lt, r=nikomatsakis
Stabilize underscore lifetimes r? @nikomatsakis
2 parents d52c44e + e6e6bd2 commit 1e652bd

32 files changed

+27
-82
lines changed

src/librustc/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
#![feature(slice_patterns)]
6969
#![feature(specialization)]
7070
#![feature(unboxed_closures)]
71-
#![feature(underscore_lifetimes)]
71+
#![cfg_attr(stage0, feature(underscore_lifetimes))]
7272
#![cfg_attr(stage0, feature(universal_impl_trait))]
7373
#![feature(trace_macros)]
7474
#![feature(trusted_len)]

src/librustc_data_structures/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#![cfg_attr(stage0, feature(i128_type, i128))]
3131
#![feature(specialization)]
3232
#![feature(optin_builtin_traits)]
33-
#![feature(underscore_lifetimes)]
33+
#![cfg_attr(stage0, feature(underscore_lifetimes))]
3434
#![feature(macro_vis_matcher)]
3535
#![feature(allow_internal_unstable)]
3636
#![cfg_attr(stage0, feature(universal_impl_trait))]

src/librustc_mir/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Rust MIR: a lowered representation of Rust. Also: an experiment!
3737
#![feature(placement_in_syntax)]
3838
#![feature(collection_placement)]
3939
#![feature(nonzero)]
40-
#![feature(underscore_lifetimes)]
40+
#![cfg_attr(stage0, feature(underscore_lifetimes))]
4141
#![cfg_attr(stage0, feature(never_type))]
4242
#![feature(inclusive_range_fields)]
4343

src/librustc_traits/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
#![feature(crate_visibility_modifier)]
1717
#![cfg_attr(stage0, feature(match_default_bindings))]
18-
#![feature(underscore_lifetimes)]
18+
#![cfg_attr(stage0, feature(underscore_lifetimes))]
1919

2020
#[macro_use]
2121
extern crate log;

src/libsyntax/feature_gate.rs

+5-8
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,9 @@ declare_features! (
385385
// allow `'_` placeholder lifetimes
386386
(active, underscore_lifetimes, "1.22.0", Some(44524), None),
387387

388+
// Default match binding modes (RFC 2005)
389+
(active, match_default_bindings, "1.22.0", Some(42640), None),
390+
388391
// Trait object syntax with `dyn` prefix
389392
(active, dyn_trait, "1.22.0", Some(44662), Some(Edition::Edition2018)),
390393

@@ -562,6 +565,8 @@ declare_features! (
562565
(accepted, i128_type, "1.26.0", Some(35118), None),
563566
// Default match binding modes (RFC 2005)
564567
(accepted, match_default_bindings, "1.26.0", Some(42640), None),
568+
// allow `'_` placeholder lifetimes
569+
(accepted, underscore_lifetimes, "1.26.0", Some(44524), None),
565570
);
566571

567572
// 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> {
17921797

17931798
visit::walk_generic_param(self, param)
17941799
}
1795-
1796-
fn visit_lifetime(&mut self, lt: &'a ast::Lifetime) {
1797-
if lt.ident.name == keywords::UnderscoreLifetime.name() {
1798-
gate_feature_post!(&self, underscore_lifetimes, lt.span,
1799-
"underscore lifetimes are unstable");
1800-
}
1801-
visit::walk_lifetime(self, lt)
1802-
}
18031800
}
18041801

18051802
pub fn get_features(span_handler: &Handler, krate_attrs: &[ast::Attribute],

src/test/compile-fail/closure-expected-type/expect-fn-supply-fn-multiple.rs

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
// must-compile-successfully
1212

13-
#![feature(underscore_lifetimes)]
1413
#![allow(warnings)]
1514

1615
type Different<'a, 'b> = &'a mut (&'a (), &'b ());

src/test/compile-fail/closure-expected-type/expect-fn-supply-fn.rs

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(underscore_lifetimes)]
12-
1311
fn with_closure_expecting_fn_with_free_region<F>(_: F)
1412
where F: for<'a> FnOnce(fn(&'a u32), &i32)
1513
{

src/test/compile-fail/underscore-lifetime-binders.rs

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(underscore_lifetimes)]
12-
1311
struct Foo<'a>(&'a u8);
1412
struct Baz<'a>(&'_ &'a u8); //~ ERROR missing lifetime specifier
1513

src/test/compile-fail/underscore-lifetime-elison-mismatch.rs

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(underscore_lifetimes)]
12-
1311
fn foo(x: &mut Vec<&'_ u8>, y: &'_ u8) { x.push(y); } //~ ERROR lifetime mismatch
1412

1513
fn main() {}

src/test/run-pass/impl-trait/lifetimes.rs

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(underscore_lifetimes)]
1211
#![allow(warnings)]
1312

1413
use std::fmt::Debug;

src/test/run-pass/underscore-lifetimes.rs

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(underscore_lifetimes)]
12-
1311
struct Foo<'a>(&'a u8);
1412

1513
fn foo(x: &u8) -> Foo<'_> {

src/test/ui/error-codes/E0637.rs

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
10-
#![feature(underscore_lifetimes)]
1110

1211
struct Foo<'a: '_>(&'a u8); //~ ERROR invalid lifetime bound name: `'_`
1312
fn foo<'a: '_>(_: &'a u8) {} //~ ERROR invalid lifetime bound name: `'_`

src/test/ui/error-codes/E0637.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
error[E0637]: invalid lifetime bound name: `'_`
2-
--> $DIR/E0637.rs:12:16
2+
--> $DIR/E0637.rs:11:16
33
|
44
LL | struct Foo<'a: '_>(&'a u8); //~ ERROR invalid lifetime bound name: `'_`
55
| ^^ `'_` is a reserved lifetime name
66

77
error[E0637]: invalid lifetime bound name: `'_`
8-
--> $DIR/E0637.rs:13:12
8+
--> $DIR/E0637.rs:12:12
99
|
1010
LL | fn foo<'a: '_>(_: &'a u8) {} //~ ERROR invalid lifetime bound name: `'_`
1111
| ^^ `'_` is a reserved lifetime name
1212

1313
error[E0637]: invalid lifetime bound name: `'_`
14-
--> $DIR/E0637.rs:16:10
14+
--> $DIR/E0637.rs:15:10
1515
|
1616
LL | impl<'a: '_> Bar<'a> { //~ ERROR invalid lifetime bound name: `'_`
1717
| ^^ `'_` is a reserved lifetime name

src/test/ui/feature-gate-in_band_lifetimes-impl.rs

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
// except according to those terms.
1010

1111
#![allow(warnings)]
12-
#![feature(underscore_lifetimes)]
1312

1413
trait MyTrait<'a> { }
1514

src/test/ui/feature-gate-in_band_lifetimes-impl.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error[E0106]: missing lifetime specifier
2-
--> $DIR/feature-gate-in_band_lifetimes-impl.rs:16:26
2+
--> $DIR/feature-gate-in_band_lifetimes-impl.rs:15:26
33
|
44
LL | impl<'a> MyTrait<'a> for &u32 { }
55
| ^ expected lifetime parameter
66

77
error[E0106]: missing lifetime specifier
8-
--> $DIR/feature-gate-in_band_lifetimes-impl.rs:19:18
8+
--> $DIR/feature-gate-in_band_lifetimes-impl.rs:18:18
99
|
1010
LL | impl<'a> MyTrait<'_> for &'a f32 { }
1111
| ^^ expected lifetime parameter

src/test/ui/feature-gate-underscore-lifetimes.rs

-20
This file was deleted.

src/test/ui/feature-gate-underscore-lifetimes.stderr

-11
This file was deleted.

src/test/ui/in-band-lifetimes/impl/assoc-type.rs

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#![allow(warnings)]
1515

1616
#![feature(in_band_lifetimes)]
17-
#![feature(underscore_lifetimes)]
1817

1918
trait MyTrait {
2019
type Output;

src/test/ui/in-band-lifetimes/impl/assoc-type.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error[E0106]: missing lifetime specifier
2-
--> $DIR/assoc-type.rs:24:19
2+
--> $DIR/assoc-type.rs:23:19
33
|
44
LL | type Output = &i32;
55
| ^ expected lifetime parameter
66

77
error[E0106]: missing lifetime specifier
8-
--> $DIR/assoc-type.rs:29:20
8+
--> $DIR/assoc-type.rs:28:20
99
|
1010
LL | type Output = &'_ i32;
1111
| ^^ expected lifetime parameter

src/test/ui/in-band-lifetimes/impl/dyn-trait.rs

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
#![feature(dyn_trait)]
1717
#![feature(in_band_lifetimes)]
18-
#![feature(underscore_lifetimes)]
1918

2019
use std::fmt::Debug;
2120

src/test/ui/in-band-lifetimes/impl/dyn-trait.stderr

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

src/test/ui/in-band-lifetimes/impl/path-elided.rs

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#![allow(warnings)]
1111

1212
#![feature(in_band_lifetimes)]
13-
#![feature(underscore_lifetimes)]
1413

1514
trait MyTrait { }
1615

src/test/ui/in-band-lifetimes/impl/path-elided.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0106]: missing lifetime specifier
2-
--> $DIR/path-elided.rs:19:18
2+
--> $DIR/path-elided.rs:18:18
33
|
44
LL | impl MyTrait for Foo {
55
| ^^^ expected lifetime parameter

src/test/ui/in-band-lifetimes/impl/path-underscore.rs

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#![allow(warnings)]
1616

1717
#![feature(in_band_lifetimes)]
18-
#![feature(underscore_lifetimes)]
1918

2019
trait MyTrait { }
2120

src/test/ui/in-band-lifetimes/impl/ref-underscore.rs

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#![allow(warnings)]
1616

1717
#![feature(in_band_lifetimes)]
18-
#![feature(underscore_lifetimes)]
1918

2019
trait MyTrait { }
2120

src/test/ui/in-band-lifetimes/impl/trait-elided.rs

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#![allow(warnings)]
1111

1212
#![feature(in_band_lifetimes)]
13-
#![feature(underscore_lifetimes)]
1413

1514
trait MyTrait<'a> { }
1615

src/test/ui/in-band-lifetimes/impl/trait-elided.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0106]: missing lifetime specifier
2-
--> $DIR/trait-elided.rs:17:6
2+
--> $DIR/trait-elided.rs:16:6
33
|
44
LL | impl MyTrait for u32 {
55
| ^^^^^^^ expected lifetime parameter

src/test/ui/in-band-lifetimes/impl/trait-underscore.rs

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#![allow(warnings)]
1717

1818
#![feature(in_band_lifetimes)]
19-
#![feature(underscore_lifetimes)]
2019

2120
trait MyTrait<'a> { }
2221

src/test/ui/underscore-lifetime/dyn-trait-underscore-in-struct.rs

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
// cc #48468
1515

1616
#![feature(dyn_trait)]
17-
#![feature(underscore_lifetimes)]
1817

1918
use std::fmt::Debug;
2019

src/test/ui/underscore-lifetime/dyn-trait-underscore-in-struct.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error[E0106]: missing lifetime specifier
2-
--> $DIR/dyn-trait-underscore-in-struct.rs:22:24
2+
--> $DIR/dyn-trait-underscore-in-struct.rs:21:24
33
|
44
LL | x: Box<dyn Debug + '_>, //~ ERROR missing lifetime specifier
55
| ^^ expected lifetime parameter
66

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

src/test/ui/underscore-lifetime/dyn-trait-underscore.rs

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
// cc #48468
1515

1616
#![feature(dyn_trait)]
17-
#![feature(underscore_lifetimes)]
1817

1918
fn a<T>(items: &[T]) -> Box<dyn Iterator<Item=&T>> {
2019
// ^^^^^^^^^^^^^^^^^^^^^ bound *here* defaults to `'static`

src/test/ui/underscore-lifetime/dyn-trait-underscore.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
error[E0495]: cannot infer an appropriate lifetime for autoref due to conflicting requirements
2-
--> $DIR/dyn-trait-underscore.rs:21:20
2+
--> $DIR/dyn-trait-underscore.rs:20:20
33
|
44
LL | Box::new(items.iter()) //~ ERROR cannot infer an appropriate lifetime
55
| ^^^^
66
|
7-
note: first, the lifetime cannot outlive the anonymous lifetime #1 defined on the function body at 19:1...
8-
--> $DIR/dyn-trait-underscore.rs:19:1
7+
note: first, the lifetime cannot outlive the anonymous lifetime #1 defined on the function body at 18:1...
8+
--> $DIR/dyn-trait-underscore.rs:18:1
99
|
1010
LL | / fn a<T>(items: &[T]) -> Box<dyn Iterator<Item=&T>> {
1111
LL | | // ^^^^^^^^^^^^^^^^^^^^^ bound *here* defaults to `'static`
1212
LL | | Box::new(items.iter()) //~ ERROR cannot infer an appropriate lifetime
1313
LL | | }
1414
| |_^
1515
note: ...so that reference does not outlive borrowed content
16-
--> $DIR/dyn-trait-underscore.rs:21:14
16+
--> $DIR/dyn-trait-underscore.rs:20:14
1717
|
1818
LL | Box::new(items.iter()) //~ ERROR cannot infer an appropriate lifetime
1919
| ^^^^^

0 commit comments

Comments
 (0)