From 394945ee36301f0e2be2aa711d9fe6c063960083 Mon Sep 17 00:00:00 2001 From: Alex Burka Date: Wed, 2 May 2018 03:02:05 +0000 Subject: [PATCH 1/3] stabilize :lifetime --- .../macro-lifetime-matcher.md | 14 -------------- src/librustc/lib.rs | 1 - src/librustc_metadata/lib.rs | 2 -- src/librustc_save_analysis/lib.rs | 1 - src/libsyntax/ext/tt/macro_rules.rs | 14 +------------- src/libsyntax/feature_gate.rs | 8 ++------ .../macro-lifetime-used-with-bound.rs | 2 -- .../macro-lifetime-used-with-labels.rs | 1 - .../macro-lifetime-used-with-static.rs | 2 -- src/test/run-pass/macro-lifetime.rs | 2 -- .../ui/feature-gate-macro-lifetime-matcher.rs | 19 ------------------- src/test/ui/macros/nonterminal-matching.rs | 2 +- 12 files changed, 4 insertions(+), 64 deletions(-) delete mode 100644 src/doc/unstable-book/src/language-features/macro-lifetime-matcher.md delete mode 100644 src/test/ui/feature-gate-macro-lifetime-matcher.rs diff --git a/src/doc/unstable-book/src/language-features/macro-lifetime-matcher.md b/src/doc/unstable-book/src/language-features/macro-lifetime-matcher.md deleted file mode 100644 index 5b585d7f041d2..0000000000000 --- a/src/doc/unstable-book/src/language-features/macro-lifetime-matcher.md +++ /dev/null @@ -1,14 +0,0 @@ -# `macro_lifetime_matcher` - -The tracking issue for this feature is: [#46895] - -With this feature gate enabled, the [list of fragment specifiers][frags] gains one more entry: - -* `lifetime`: a lifetime. Examples: 'static, 'a. - -A `lifetime` variable may be followed by anything. - -[#46895]: https://github.com/rust-lang/rust/issues/46895 -[frags]: ../book/first-edition/macros.html#syntactic-requirements - ------------------------- diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index 879d38c489443..b9928a08131f2 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -50,7 +50,6 @@ #![feature(from_ref)] #![feature(fs_read_write)] #![cfg_attr(windows, feature(libc))] -#![feature(macro_lifetime_matcher)] #![feature(macro_vis_matcher)] #![feature(never_type)] #![feature(exhaustive_patterns)] diff --git a/src/librustc_metadata/lib.rs b/src/librustc_metadata/lib.rs index a99e0a32e6645..60016a0d86451 100644 --- a/src/librustc_metadata/lib.rs +++ b/src/librustc_metadata/lib.rs @@ -15,9 +15,7 @@ #![feature(box_patterns)] #![feature(fs_read_write)] #![feature(libc)] -#![feature(macro_lifetime_matcher)] #![feature(proc_macro_internals)] -#![feature(macro_lifetime_matcher)] #![feature(quote)] #![feature(rustc_diagnostic_macros)] #![feature(slice_sort_by_cached_key)] diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs index cf12302d98969..bfcb23c1fb891 100644 --- a/src/librustc_save_analysis/lib.rs +++ b/src/librustc_save_analysis/lib.rs @@ -12,7 +12,6 @@ html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/")] #![feature(custom_attribute)] -#![feature(macro_lifetime_matcher)] #![allow(unused_attributes)] #[macro_use] diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index 1fc5aed7e7a23..e96a0e838cfcd 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -904,20 +904,8 @@ fn is_legal_fragment_specifier(sess: &ParseSess, frag_name: &str, frag_span: Span) -> bool { match frag_name { - "item" | "block" | "stmt" | "expr" | "pat" | + "item" | "block" | "stmt" | "expr" | "pat" | "lifetime" | "path" | "ty" | "ident" | "meta" | "tt" | "" => true, - "lifetime" => { - if !features.macro_lifetime_matcher && - !attr::contains_name(attrs, "allow_internal_unstable") { - let explain = feature_gate::EXPLAIN_LIFETIME_MATCHER; - emit_feature_err(sess, - "macro_lifetime_matcher", - frag_span, - GateIssue::Language, - explain); - } - true - }, "literal" => { if !features.macro_literal_matcher && !attr::contains_name(attrs, "allow_internal_unstable") { diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 562705462e2a4..cb5125fe9ef5a 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -396,9 +396,6 @@ declare_features! ( // Termination trait in tests (RFC 1937) (active, termination_trait_test, "1.24.0", Some(48854), Some(Edition::Edition2018)), - // Allows use of the :lifetime macro fragment specifier - (active, macro_lifetime_matcher, "1.24.0", Some(46895), None), - // `extern` in paths (active, extern_in_paths, "1.23.0", Some(44660), None), @@ -598,6 +595,8 @@ declare_features! ( (accepted, dyn_trait, "1.27.0", Some(44662), None), // allow `#[must_use]` on functions; and, must-use operators (RFC 1940) (accepted, fn_must_use, "1.27.0", Some(43302), None), + // Allows use of the :lifetime macro fragment specifier + (accepted, macro_lifetime_matcher, "1.27.0", Some(34303), None), ); // If you change this, please modify src/doc/unstable-book as well. You must @@ -1331,9 +1330,6 @@ pub const EXPLAIN_DERIVE_UNDERSCORE: &'static str = pub const EXPLAIN_VIS_MATCHER: &'static str = ":vis fragment specifier is experimental and subject to change"; -pub const EXPLAIN_LIFETIME_MATCHER: &'static str = - ":lifetime fragment specifier is experimental and subject to change"; - pub const EXPLAIN_LITERAL_MATCHER: &'static str = ":literal fragment specifier is experimental and subject to change"; diff --git a/src/test/run-pass/macro-lifetime-used-with-bound.rs b/src/test/run-pass/macro-lifetime-used-with-bound.rs index b0c9280b6ce44..b9e1fde6b1f3e 100644 --- a/src/test/run-pass/macro-lifetime-used-with-bound.rs +++ b/src/test/run-pass/macro-lifetime-used-with-bound.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(macro_lifetime_matcher)] - macro_rules! foo { ($l:lifetime, $l2:lifetime) => { fn f<$l: $l2, $l2>(arg: &$l str, arg2: &$l2 str) -> &$l str { diff --git a/src/test/run-pass/macro-lifetime-used-with-labels.rs b/src/test/run-pass/macro-lifetime-used-with-labels.rs index 8a2d76e17df68..d003d7dcfb620 100644 --- a/src/test/run-pass/macro-lifetime-used-with-labels.rs +++ b/src/test/run-pass/macro-lifetime-used-with-labels.rs @@ -9,7 +9,6 @@ // except according to those terms. #![allow(unreachable_code)] -#![feature(macro_lifetime_matcher)] macro_rules! x { ($a:lifetime) => { diff --git a/src/test/run-pass/macro-lifetime-used-with-static.rs b/src/test/run-pass/macro-lifetime-used-with-static.rs index 468ee2e943657..5c1f8683e00f6 100644 --- a/src/test/run-pass/macro-lifetime-used-with-static.rs +++ b/src/test/run-pass/macro-lifetime-used-with-static.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(macro_lifetime_matcher)] - macro_rules! foo { ($l:lifetime) => { fn f(arg: &$l str) -> &$l str { diff --git a/src/test/run-pass/macro-lifetime.rs b/src/test/run-pass/macro-lifetime.rs index db521ca7f103f..ff5798ff78d62 100644 --- a/src/test/run-pass/macro-lifetime.rs +++ b/src/test/run-pass/macro-lifetime.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(macro_lifetime_matcher)] - macro_rules! foo { ($l:lifetime) => { fn f<$l>(arg: &$l str) -> &$l str { diff --git a/src/test/ui/feature-gate-macro-lifetime-matcher.rs b/src/test/ui/feature-gate-macro-lifetime-matcher.rs deleted file mode 100644 index 0d107d283cdff..0000000000000 --- a/src/test/ui/feature-gate-macro-lifetime-matcher.rs +++ /dev/null @@ -1,19 +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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that the :lifetime macro fragment cannot be used when macro_lifetime_matcher -// feature gate is not used. - -macro_rules! m { ($lt:lifetime) => {} } -//~^ ERROR :lifetime fragment specifier is experimental and subject to change - -fn main() { - m!('a); -} diff --git a/src/test/ui/macros/nonterminal-matching.rs b/src/test/ui/macros/nonterminal-matching.rs index 4dcb8afa94eab..54d280a63e798 100644 --- a/src/test/ui/macros/nonterminal-matching.rs +++ b/src/test/ui/macros/nonterminal-matching.rs @@ -11,7 +11,7 @@ // Check that we are refusing to match on complex nonterminals for which tokens are // unavailable and we'd have to go through AST comparisons. -#![feature(decl_macro, macro_lifetime_matcher)] +#![feature(decl_macro)] macro simple_nonterminal($nt_ident: ident, $nt_lifetime: lifetime, $nt_tt: tt) { macro n(a $nt_ident b $nt_lifetime c $nt_tt d) { From e6f7cf7e75286ca0e298bcdce7d831e5ebd451df Mon Sep 17 00:00:00 2001 From: Alex Burka Date: Wed, 2 May 2018 04:38:08 +0000 Subject: [PATCH 2/3] remove stray ui stderr --- .../ui/feature-gate-macro-lifetime-matcher.stderr | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 src/test/ui/feature-gate-macro-lifetime-matcher.stderr diff --git a/src/test/ui/feature-gate-macro-lifetime-matcher.stderr b/src/test/ui/feature-gate-macro-lifetime-matcher.stderr deleted file mode 100644 index b7805f6f5fbf5..0000000000000 --- a/src/test/ui/feature-gate-macro-lifetime-matcher.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0658]: :lifetime fragment specifier is experimental and subject to change (see issue #46895) - --> $DIR/feature-gate-macro-lifetime-matcher.rs:14:19 - | -LL | macro_rules! m { ($lt:lifetime) => {} } - | ^^^^^^^^^^^^ - | - = help: add #![feature(macro_lifetime_matcher)] to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0658`. From e857c1b79028765c62e7f29584c7ce75bfb739b9 Mon Sep 17 00:00:00 2001 From: Alex Burka Date: Thu, 10 May 2018 02:01:03 +0000 Subject: [PATCH 3/3] restore feature for stage0 --- src/librustc/lib.rs | 1 + src/librustc_metadata/lib.rs | 1 + src/librustc_save_analysis/lib.rs | 1 + 3 files changed, 3 insertions(+) diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index b9928a08131f2..2a288ae522aac 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -50,6 +50,7 @@ #![feature(from_ref)] #![feature(fs_read_write)] #![cfg_attr(windows, feature(libc))] +#![cfg_attr(stage0, feature(macro_lifetime_matcher))] #![feature(macro_vis_matcher)] #![feature(never_type)] #![feature(exhaustive_patterns)] diff --git a/src/librustc_metadata/lib.rs b/src/librustc_metadata/lib.rs index 60016a0d86451..7ecf2eba43ddf 100644 --- a/src/librustc_metadata/lib.rs +++ b/src/librustc_metadata/lib.rs @@ -15,6 +15,7 @@ #![feature(box_patterns)] #![feature(fs_read_write)] #![feature(libc)] +#![cfg_attr(stage0, feature(macro_lifetime_matcher))] #![feature(proc_macro_internals)] #![feature(quote)] #![feature(rustc_diagnostic_macros)] diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs index bfcb23c1fb891..e57a793ff426f 100644 --- a/src/librustc_save_analysis/lib.rs +++ b/src/librustc_save_analysis/lib.rs @@ -12,6 +12,7 @@ html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/")] #![feature(custom_attribute)] +#![cfg_attr(stage0, feature(macro_lifetime_matcher))] #![allow(unused_attributes)] #[macro_use]