Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stabilize impl_header_lifetime_elision in 2015 #54778

Merged
merged 6 commits into from
Oct 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/libcore/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
#![feature(doc_spotlight)]
#![feature(extern_types)]
#![feature(fundamental)]
#![feature(impl_header_lifetime_elision)]
#![cfg_attr(stage0, feature(impl_header_lifetime_elision))]
#![feature(intrinsics)]
#![feature(lang_items)]
#![feature(link_llvm_intrinsics)]
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#![feature(flt2dec)]
#![feature(fmt_internals)]
#![feature(hashmap_internals)]
#![feature(impl_header_lifetime_elision)]
#![cfg_attr(stage0, feature(impl_header_lifetime_elision))]
#![feature(pattern)]
#![feature(range_is_empty)]
#![feature(raw)]
Expand Down
13 changes: 4 additions & 9 deletions src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,8 @@ pub struct LoweringContext<'a> {

// 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
// in in-band lifetime definitions, such a function or an impl header.
// This will always be false unless the `in_band_lifetimes` or
// `impl_header_lifetime_elision` feature is enabled.
// in in-band lifetime definitions, such a function or an impl header,
// including implicit lifetimes from `impl_header_lifetime_elision`.
is_collecting_in_band_lifetimes: bool,

// Currently in-scope lifetimes defined in impl headers, fn headers, or HRTB.
Expand Down Expand Up @@ -709,12 +708,8 @@ impl<'a> LoweringContext<'a> {
assert!(self.lifetimes_to_define.is_empty());
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.is_collecting_in_band_lifetimes = true;
} else if self.sess.features_untracked().in_band_lifetimes {
self.is_collecting_in_band_lifetimes = true;
}
self.anonymous_lifetime_mode = anonymous_lifetime_mode;
self.is_collecting_in_band_lifetimes = true;

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

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
#![feature(step_trait)]
#![feature(integer_atomics)]
#![feature(test)]
#![feature(impl_header_lifetime_elision)]
#![cfg_attr(stage0, feature(impl_header_lifetime_elision))]
#![feature(in_band_lifetimes)]
#![feature(macro_at_most_once_rep)]
#![feature(crate_visibility_modifier)]
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_data_structures/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
html_root_url = "https://doc.rust-lang.org/nightly/")]

#![feature(in_band_lifetimes)]
#![feature(impl_header_lifetime_elision)]
#![cfg_attr(stage0, feature(impl_header_lifetime_elision))]
#![feature(unboxed_closures)]
#![feature(fn_traits)]
#![feature(unsize)]
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Rust MIR: a lowered representation of Rust. Also: an experiment!

#![feature(nll)]
#![feature(in_band_lifetimes)]
#![feature(impl_header_lifetime_elision)]
#![cfg_attr(stage0, feature(impl_header_lifetime_elision))]
#![feature(slice_patterns)]
#![feature(slice_sort_by_cached_key)]
#![feature(box_patterns)]
Expand Down
8 changes: 4 additions & 4 deletions src/libsyntax/diagnostic_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,15 +375,15 @@ and likely to change in the future.

E0705: r##"
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:

```ignore (limited to a warning during 2018 edition development)
#![feature(rust_2018_preview)]
#![feature(impl_header_lifetime_elision)] // error: the feature
// `impl_header_lifetime_elision` is
// included in the Rust 2018 edition
#![feature(test_2018_feature)] // error: the feature
// `test_2018_feature` is
// included in the Rust 2018 edition
```

"##,
Expand Down
8 changes: 5 additions & 3 deletions src/libsyntax/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -462,9 +462,8 @@ declare_features! (

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

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

// Support for arbitrary delimited token streams in non-macro attributes
(active, unrestricted_attribute_tokens, "1.30.0", Some(44690), None),
Expand Down Expand Up @@ -684,6 +683,9 @@ declare_features! (
(accepted, min_const_fn, "1.31.0", Some(53555), None),
// Scoped lints
(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
Expand Down
7 changes: 5 additions & 2 deletions src/test/ui/E0705.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@

// compile-pass

#![feature(impl_header_lifetime_elision)]
//~^ WARN the feature `impl_header_lifetime_elision` is included in the Rust 2018 edition
// This is a stub feature that doesn't control anything, so to make tidy happy,
// 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)]

fn main() {}
8 changes: 4 additions & 4 deletions src/test/ui/E0705.stderr
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
warning[E0705]: the feature `impl_header_lifetime_elision` is included in the Rust 2018 edition
--> $DIR/E0705.rs:13:12
warning[E0705]: the feature `test_2018_feature` is included in the Rust 2018 edition
--> $DIR/E0705.rs:16:12
|
LL | #![feature(impl_header_lifetime_elision)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | #![feature(test_2018_feature)]
| ^^^^^^^^^^^^^^^^^

This file was deleted.

This file was deleted.

3 changes: 0 additions & 3 deletions src/test/ui/feature-gates/feature-gate-in_band_lifetimes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@

#![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 }
//~^ ERROR use of undeclared lifetime name
//~^^ ERROR use of undeclared lifetime name
Expand Down
34 changes: 17 additions & 17 deletions src/test/ui/feature-gates/feature-gate-in_band_lifetimes.stderr
Original file line number Diff line number Diff line change
@@ -1,101 +1,101 @@
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 }
| ^^ undeclared lifetime

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 }
| ^^ undeclared lifetime

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> {
| ^^ undeclared lifetime

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 {
| ^^ undeclared lifetime

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> {
| ^^ undeclared lifetime

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 {
| ^^ undeclared lifetime

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> {
| ^^ undeclared lifetime

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 {
| ^^ undeclared lifetime

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;
| ^^ undeclared lifetime

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;
| ^^ undeclared lifetime

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;
| ^^ undeclared lifetime

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> {
| ^^ undeclared lifetime

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> {
| ^^ undeclared lifetime

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 }
| ^^ undeclared lifetime

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 }
| ^^ undeclared lifetime

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 }
| ^^ undeclared lifetime

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 }
| ^^ undeclared lifetime
Expand Down
2 changes: 0 additions & 2 deletions src/test/ui/impl-header-lifetime-elision/assoc-type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

#![allow(warnings)]

#![feature(impl_header_lifetime_elision)]

trait MyTrait {
type Output;
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/impl-header-lifetime-elision/assoc-type.stderr
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
error[E0106]: missing lifetime specifier
--> $DIR/assoc-type.rs:23:19
--> $DIR/assoc-type.rs:21:19
|
LL | type Output = &i32;
| ^ expected lifetime parameter

error[E0106]: missing lifetime specifier
--> $DIR/assoc-type.rs:28:20
--> $DIR/assoc-type.rs:26:20
|
LL | type Output = &'_ i32;
| ^^ expected lifetime parameter
Expand Down
2 changes: 0 additions & 2 deletions src/test/ui/impl-header-lifetime-elision/dyn-trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

#![allow(warnings)]

#![feature(impl_header_lifetime_elision)]

use std::fmt::Debug;

// Equivalent to `Box<dyn Debug + 'static>`:
Expand Down
6 changes: 3 additions & 3 deletions src/test/ui/impl-header-lifetime-elision/dyn-trait.stderr
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
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
| ^
|
note: first, the lifetime cannot outlive the lifetime 'a as defined on the function body at 31:26...
--> $DIR/dyn-trait.rs:31:26
note: first, the lifetime cannot outlive the lifetime 'a as defined on the function body at 29:26...
--> $DIR/dyn-trait.rs:29:26
|
LL | fn with_dyn_debug_static<'a>(x: Box<dyn Debug + 'a>) {
| ^^
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

#![allow(warnings)]

#![feature(impl_header_lifetime_elision)]

// This works for functions...
fn foo<'a>(x: &str, y: &'a str) {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

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

trait MyTrait<'a> { }
struct Foo<'a>(&'a u8);

impl<'a> MyTrait<'a> for &u32 { }
//~^ ERROR missing lifetime specifier

impl<'a> MyTrait<'_> for &'a f32 { }
//~^ ERROR missing lifetime specifier
impl Foo<'_> {
fn x() {}
}

fn main() {}
2 changes: 0 additions & 2 deletions src/test/ui/impl-header-lifetime-elision/path-elided.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
// except according to those terms.
#![allow(warnings)]

#![feature(impl_header_lifetime_elision)]

trait MyTrait { }

struct Foo<'a> { x: &'a u32 }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0106]: missing lifetime specifier
--> $DIR/path-elided.rs:18:18
--> $DIR/path-elided.rs:16:18
|
LL | impl MyTrait for Foo {
| ^^^ expected lifetime parameter
Expand Down
Loading