Skip to content

Commit d570b36

Browse files
committed
Auto merge of #54778 - scottmcm:stabilize-ihle, r=pnkfelix
Stabilize impl_header_lifetime_elision in 2015 ~~This is currently blocked on #54902; it should be good after that~~ It's already stable in 2018; this finishes the stabilization. FCP completed (#15872 (comment)), proposal (#15872 (comment)). Tracking issue: #15872 Usage examples (from libcore): #54687
2 parents 979fb16 + 18f7db3 commit d570b36

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+156
-264
lines changed

src/libcore/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
#![feature(doc_spotlight)]
8888
#![feature(extern_types)]
8989
#![feature(fundamental)]
90-
#![feature(impl_header_lifetime_elision)]
90+
#![cfg_attr(stage0, feature(impl_header_lifetime_elision))]
9191
#![feature(intrinsics)]
9292
#![feature(lang_items)]
9393
#![feature(link_llvm_intrinsics)]

src/libcore/tests/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#![feature(flt2dec)]
2020
#![feature(fmt_internals)]
2121
#![feature(hashmap_internals)]
22-
#![feature(impl_header_lifetime_elision)]
22+
#![cfg_attr(stage0, feature(impl_header_lifetime_elision))]
2323
#![feature(pattern)]
2424
#![feature(range_is_empty)]
2525
#![feature(raw)]

src/librustc/hir/lowering.rs

+4-9
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,8 @@ pub struct LoweringContext<'a> {
125125

126126
// Whether or not in-band lifetimes are being collected. This is used to
127127
// indicate whether or not we're in a place where new lifetimes will result
128-
// in in-band lifetime definitions, such a function or an impl header.
129-
// This will always be false unless the `in_band_lifetimes` or
130-
// `impl_header_lifetime_elision` feature is enabled.
128+
// in in-band lifetime definitions, such a function or an impl header,
129+
// including implicit lifetimes from `impl_header_lifetime_elision`.
131130
is_collecting_in_band_lifetimes: bool,
132131

133132
// Currently in-scope lifetimes defined in impl headers, fn headers, or HRTB.
@@ -709,12 +708,8 @@ impl<'a> LoweringContext<'a> {
709708
assert!(self.lifetimes_to_define.is_empty());
710709
let old_anonymous_lifetime_mode = self.anonymous_lifetime_mode;
711710

712-
if self.sess.features_untracked().impl_header_lifetime_elision {
713-
self.anonymous_lifetime_mode = anonymous_lifetime_mode;
714-
self.is_collecting_in_band_lifetimes = true;
715-
} else if self.sess.features_untracked().in_band_lifetimes {
716-
self.is_collecting_in_band_lifetimes = true;
717-
}
711+
self.anonymous_lifetime_mode = anonymous_lifetime_mode;
712+
self.is_collecting_in_band_lifetimes = true;
718713

719714
let (in_band_ty_params, res) = f(self);
720715

src/librustc/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
#![feature(step_trait)]
6868
#![feature(integer_atomics)]
6969
#![feature(test)]
70-
#![feature(impl_header_lifetime_elision)]
70+
#![cfg_attr(stage0, feature(impl_header_lifetime_elision))]
7171
#![feature(in_band_lifetimes)]
7272
#![feature(macro_at_most_once_rep)]
7373
#![feature(crate_visibility_modifier)]

src/librustc_data_structures/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
html_root_url = "https://doc.rust-lang.org/nightly/")]
2222

2323
#![feature(in_band_lifetimes)]
24-
#![feature(impl_header_lifetime_elision)]
24+
#![cfg_attr(stage0, feature(impl_header_lifetime_elision))]
2525
#![feature(unboxed_closures)]
2626
#![feature(fn_traits)]
2727
#![feature(unsize)]

src/librustc_mir/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Rust MIR: a lowered representation of Rust. Also: an experiment!
1616

1717
#![feature(nll)]
1818
#![feature(in_band_lifetimes)]
19-
#![feature(impl_header_lifetime_elision)]
19+
#![cfg_attr(stage0, feature(impl_header_lifetime_elision))]
2020
#![feature(slice_patterns)]
2121
#![feature(slice_sort_by_cached_key)]
2222
#![feature(box_patterns)]

src/libsyntax/diagnostic_list.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -375,15 +375,15 @@ and likely to change in the future.
375375

376376
E0705: r##"
377377
A `#![feature]` attribute was declared for a feature that is stable in
378-
the current edition.
378+
the current edition, but not in all editions.
379379
380380
Erroneous code example:
381381
382382
```ignore (limited to a warning during 2018 edition development)
383383
#![feature(rust_2018_preview)]
384-
#![feature(impl_header_lifetime_elision)] // error: the feature
385-
// `impl_header_lifetime_elision` is
386-
// included in the Rust 2018 edition
384+
#![feature(test_2018_feature)] // error: the feature
385+
// `test_2018_feature` is
386+
// included in the Rust 2018 edition
387387
```
388388
389389
"##,

src/libsyntax/feature_gate.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -462,9 +462,8 @@ declare_features! (
462462

463463
(active, abi_amdgpu_kernel, "1.29.0", Some(51575), None),
464464

465-
// impl<I:Iterator> Iterator for &mut Iterator
466-
// impl Debug for Foo<'_>
467-
(active, impl_header_lifetime_elision, "1.30.0", Some(15872), Some(Edition::Edition2018)),
465+
// Perma-unstable; added for testing E0705
466+
(active, test_2018_feature, "1.31.0", Some(0), Some(Edition::Edition2018)),
468467

469468
// Support for arbitrary delimited token streams in non-macro attributes
470469
(active, unrestricted_attribute_tokens, "1.30.0", Some(44690), None),
@@ -684,6 +683,9 @@ declare_features! (
684683
(accepted, min_const_fn, "1.31.0", Some(53555), None),
685684
// Scoped lints
686685
(accepted, tool_lints, "1.31.0", Some(44690), None),
686+
// impl<I:Iterator> Iterator for &mut Iterator
687+
// impl Debug for Foo<'_>
688+
(accepted, impl_header_lifetime_elision, "1.31.0", Some(15872), None),
687689
);
688690

689691
// If you change this, please modify src/doc/unstable-book as well. You must

src/test/ui/E0705.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@
1010

1111
// compile-pass
1212

13-
#![feature(impl_header_lifetime_elision)]
14-
//~^ WARN the feature `impl_header_lifetime_elision` is included in the Rust 2018 edition
13+
// This is a stub feature that doesn't control anything, so to make tidy happy,
14+
// gate-test-test_2018_feature
15+
16+
#![feature(test_2018_feature)]
17+
//~^ WARN the feature `test_2018_feature` is included in the Rust 2018 edition
1518
#![feature(rust_2018_preview)]
1619

1720
fn main() {}

src/test/ui/E0705.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
warning[E0705]: the feature `impl_header_lifetime_elision` is included in the Rust 2018 edition
2-
--> $DIR/E0705.rs:13:12
1+
warning[E0705]: the feature `test_2018_feature` is included in the Rust 2018 edition
2+
--> $DIR/E0705.rs:16:12
33
|
4-
LL | #![feature(impl_header_lifetime_elision)]
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4+
LL | #![feature(test_2018_feature)]
5+
| ^^^^^^^^^^^^^^^^^
66

src/test/ui/feature-gates/feature-gate-impl_header_lifetime_elision-with-in_band.stderr

-15
This file was deleted.

src/test/ui/feature-gates/feature-gate-impl_header_lifetime_elision.stderr

-15
This file was deleted.

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

-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010

1111
#![allow(warnings)]
1212

13-
// Make sure this related feature didn't accidentally enable this
14-
#![feature(impl_header_lifetime_elision)]
15-
1613
fn foo(x: &'x u8) -> &'x u8 { x }
1714
//~^ ERROR use of undeclared lifetime name
1815
//~^^ ERROR use of undeclared lifetime name

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

+17-17
Original file line numberDiff line numberDiff line change
@@ -1,101 +1,101 @@
11
error[E0261]: use of undeclared lifetime name `'x`
2-
--> $DIR/feature-gate-in_band_lifetimes.rs:16:12
2+
--> $DIR/feature-gate-in_band_lifetimes.rs:13:12
33
|
44
LL | fn foo(x: &'x u8) -> &'x u8 { x }
55
| ^^ undeclared lifetime
66

77
error[E0261]: use of undeclared lifetime name `'x`
8-
--> $DIR/feature-gate-in_band_lifetimes.rs:16:23
8+
--> $DIR/feature-gate-in_band_lifetimes.rs:13:23
99
|
1010
LL | fn foo(x: &'x u8) -> &'x u8 { x }
1111
| ^^ undeclared lifetime
1212

1313
error[E0261]: use of undeclared lifetime name `'b`
14-
--> $DIR/feature-gate-in_band_lifetimes.rs:28:12
14+
--> $DIR/feature-gate-in_band_lifetimes.rs:25:12
1515
|
1616
LL | impl<'a> X<'b> {
1717
| ^^ undeclared lifetime
1818

1919
error[E0261]: use of undeclared lifetime name `'b`
20-
--> $DIR/feature-gate-in_band_lifetimes.rs:30:27
20+
--> $DIR/feature-gate-in_band_lifetimes.rs:27:27
2121
|
2222
LL | fn inner_2(&self) -> &'b u8 {
2323
| ^^ undeclared lifetime
2424

2525
error[E0261]: use of undeclared lifetime name `'b`
26-
--> $DIR/feature-gate-in_band_lifetimes.rs:36:8
26+
--> $DIR/feature-gate-in_band_lifetimes.rs:33:8
2727
|
2828
LL | impl X<'b> {
2929
| ^^ undeclared lifetime
3030

3131
error[E0261]: use of undeclared lifetime name `'b`
32-
--> $DIR/feature-gate-in_band_lifetimes.rs:38:27
32+
--> $DIR/feature-gate-in_band_lifetimes.rs:35:27
3333
|
3434
LL | fn inner_3(&self) -> &'b u8 {
3535
| ^^ undeclared lifetime
3636

3737
error[E0261]: use of undeclared lifetime name `'a`
38-
--> $DIR/feature-gate-in_band_lifetimes.rs:46:9
38+
--> $DIR/feature-gate-in_band_lifetimes.rs:43:9
3939
|
4040
LL | impl Y<&'a u8> {
4141
| ^^ undeclared lifetime
4242

4343
error[E0261]: use of undeclared lifetime name `'a`
44-
--> $DIR/feature-gate-in_band_lifetimes.rs:48:25
44+
--> $DIR/feature-gate-in_band_lifetimes.rs:45:25
4545
|
4646
LL | fn inner(&self) -> &'a u8 {
4747
| ^^ undeclared lifetime
4848

4949
error[E0261]: use of undeclared lifetime name `'b`
50-
--> $DIR/feature-gate-in_band_lifetimes.rs:56:27
50+
--> $DIR/feature-gate-in_band_lifetimes.rs:53:27
5151
|
5252
LL | fn any_lifetime() -> &'b u8;
5353
| ^^ undeclared lifetime
5454

5555
error[E0261]: use of undeclared lifetime name `'b`
56-
--> $DIR/feature-gate-in_band_lifetimes.rs:58:27
56+
--> $DIR/feature-gate-in_band_lifetimes.rs:55:27
5757
|
5858
LL | fn borrowed_lifetime(&'b self) -> &'b u8;
5959
| ^^ undeclared lifetime
6060

6161
error[E0261]: use of undeclared lifetime name `'b`
62-
--> $DIR/feature-gate-in_band_lifetimes.rs:58:40
62+
--> $DIR/feature-gate-in_band_lifetimes.rs:55:40
6363
|
6464
LL | fn borrowed_lifetime(&'b self) -> &'b u8;
6565
| ^^ undeclared lifetime
6666

6767
error[E0261]: use of undeclared lifetime name `'a`
68-
--> $DIR/feature-gate-in_band_lifetimes.rs:63:14
68+
--> $DIR/feature-gate-in_band_lifetimes.rs:60:14
6969
|
7070
LL | impl MyTrait<'a> for Y<&'a u8> {
7171
| ^^ undeclared lifetime
7272

7373
error[E0261]: use of undeclared lifetime name `'a`
74-
--> $DIR/feature-gate-in_band_lifetimes.rs:63:25
74+
--> $DIR/feature-gate-in_band_lifetimes.rs:60:25
7575
|
7676
LL | impl MyTrait<'a> for Y<&'a u8> {
7777
| ^^ undeclared lifetime
7878

7979
error[E0261]: use of undeclared lifetime name `'a`
80-
--> $DIR/feature-gate-in_band_lifetimes.rs:66:31
80+
--> $DIR/feature-gate-in_band_lifetimes.rs:63:31
8181
|
8282
LL | fn my_lifetime(&self) -> &'a u8 { self.0 }
8383
| ^^ undeclared lifetime
8484

8585
error[E0261]: use of undeclared lifetime name `'b`
86-
--> $DIR/feature-gate-in_band_lifetimes.rs:68:27
86+
--> $DIR/feature-gate-in_band_lifetimes.rs:65:27
8787
|
8888
LL | fn any_lifetime() -> &'b u8 { &0 }
8989
| ^^ undeclared lifetime
9090

9191
error[E0261]: use of undeclared lifetime name `'b`
92-
--> $DIR/feature-gate-in_band_lifetimes.rs:70:27
92+
--> $DIR/feature-gate-in_band_lifetimes.rs:67:27
9393
|
9494
LL | fn borrowed_lifetime(&'b self) -> &'b u8 { &*self.0 }
9595
| ^^ undeclared lifetime
9696

9797
error[E0261]: use of undeclared lifetime name `'b`
98-
--> $DIR/feature-gate-in_band_lifetimes.rs:70:40
98+
--> $DIR/feature-gate-in_band_lifetimes.rs:67:40
9999
|
100100
LL | fn borrowed_lifetime(&'b self) -> &'b u8 { &*self.0 }
101101
| ^^ undeclared lifetime

src/test/ui/impl-header-lifetime-elision/assoc-type.rs

-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313

1414
#![allow(warnings)]
1515

16-
#![feature(impl_header_lifetime_elision)]
17-
1816
trait MyTrait {
1917
type Output;
2018
}

src/test/ui/impl-header-lifetime-elision/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:23:19
2+
--> $DIR/assoc-type.rs:21:19
33
|
44
LL | type Output = &i32;
55
| ^ expected lifetime parameter
66

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

src/test/ui/impl-header-lifetime-elision/dyn-trait.rs

-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313

1414
#![allow(warnings)]
1515

16-
#![feature(impl_header_lifetime_elision)]
17-
1816
use std::fmt::Debug;
1917

2018
// Equivalent to `Box<dyn Debug + 'static>`:

src/test/ui/impl-header-lifetime-elision/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:32:16
2+
--> $DIR/dyn-trait.rs:30: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 31:26...
8-
--> $DIR/dyn-trait.rs:31:26
7+
note: first, the lifetime cannot outlive the lifetime 'a as defined on the function body at 29:26...
8+
--> $DIR/dyn-trait.rs:29:26
99
|
1010
LL | fn with_dyn_debug_static<'a>(x: Box<dyn Debug + 'a>) {
1111
| ^^

src/test/ui/impl-header-lifetime-elision/explicit-and-elided-same-header.rs

-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212

1313
#![allow(warnings)]
1414

15-
#![feature(impl_header_lifetime_elision)]
16-
1715
// This works for functions...
1816
fn foo<'a>(x: &str, y: &'a str) {}
1917

src/test/ui/feature-gates/feature-gate-impl_header_lifetime_elision.rs renamed to src/test/ui/impl-header-lifetime-elision/inherent-impl.rs

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

11-
#![allow(warnings)]
11+
// compile-pass
1212

13-
trait MyTrait<'a> { }
13+
struct Foo<'a>(&'a u8);
1414

15-
impl<'a> MyTrait<'a> for &u32 { }
16-
//~^ ERROR missing lifetime specifier
17-
18-
impl<'a> MyTrait<'_> for &'a f32 { }
19-
//~^ ERROR missing lifetime specifier
15+
impl Foo<'_> {
16+
fn x() {}
17+
}
2018

2119
fn main() {}

src/test/ui/impl-header-lifetime-elision/path-elided.rs

-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
// except according to those terms.
1010
#![allow(warnings)]
1111

12-
#![feature(impl_header_lifetime_elision)]
13-
1412
trait MyTrait { }
1513

1614
struct Foo<'a> { x: &'a u32 }

src/test/ui/impl-header-lifetime-elision/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:18:18
2+
--> $DIR/path-elided.rs:16:18
33
|
44
LL | impl MyTrait for Foo {
55
| ^^^ expected lifetime parameter

0 commit comments

Comments
 (0)