Add feature gate macro_lifetime_matcher
This commit is contained in:
parent
e838cfce03
commit
b284419064
@ -886,8 +886,20 @@ fn is_legal_fragment_specifier(sess: &ParseSess,
|
||||
frag_name: &str,
|
||||
frag_span: Span) -> bool {
|
||||
match frag_name {
|
||||
"item" | "block" | "stmt" | "expr" | "pat" | "lifetime" |
|
||||
"item" | "block" | "stmt" | "expr" | "pat" |
|
||||
"path" | "ty" | "ident" | "meta" | "tt" | "" => true,
|
||||
"lifetime" => {
|
||||
if !features.borrow().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
|
||||
},
|
||||
"vis" => {
|
||||
if !features.borrow().macro_vis_matcher
|
||||
&& !attr::contains_name(attrs, "allow_internal_unstable") {
|
||||
|
@ -447,6 +447,9 @@ declare_features! (
|
||||
|
||||
// Termination trait in main (RFC 1937)
|
||||
(active, termination_trait, "1.24.0", Some(43301)),
|
||||
|
||||
// Allows use of the :lifetime macro fragment specifier
|
||||
(active, macro_lifetime_matcher, "1.24.0", Some(46895)),
|
||||
);
|
||||
|
||||
declare_features! (
|
||||
@ -520,7 +523,7 @@ declare_features! (
|
||||
(accepted, loop_break_value, "1.19.0", Some(37339)),
|
||||
// Permits numeric fields in struct expressions and patterns.
|
||||
(accepted, relaxed_adts, "1.19.0", Some(35626)),
|
||||
// Coerces non capturing closures to function pointers
|
||||
// Coerces non capturing closures to function pointers
|
||||
(accepted, closure_to_fn_coercion, "1.19.0", Some(39817)),
|
||||
// Allows attributes on struct literal fields.
|
||||
(accepted, struct_field_attributes, "1.20.0", Some(38814)),
|
||||
@ -1226,6 +1229,9 @@ 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_PLACEMENT_IN: &'static str =
|
||||
"placement-in expression syntax is experimental and subject to change.";
|
||||
|
||||
|
@ -8,6 +8,8 @@
|
||||
// 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 {
|
||||
|
@ -9,6 +9,7 @@
|
||||
// except according to those terms.
|
||||
|
||||
#![allow(unreachable_code)]
|
||||
#![feature(macro_lifetime_matcher)]
|
||||
|
||||
macro_rules! x {
|
||||
($a:lifetime) => {
|
||||
|
@ -8,6 +8,8 @@
|
||||
// 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 {
|
||||
|
@ -8,6 +8,8 @@
|
||||
// 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 {
|
||||
|
19
src/test/ui/feature-gate-macro-lifetime-matcher.rs
Normal file
19
src/test/ui/feature-gate-macro-lifetime-matcher.rs
Normal file
@ -0,0 +1,19 @@
|
||||
// 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.
|
||||
|
||||
// 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);
|
||||
}
|
10
src/test/ui/feature-gate-macro-lifetime-matcher.stderr
Normal file
10
src/test/ui/feature-gate-macro-lifetime-matcher.stderr
Normal file
@ -0,0 +1,10 @@
|
||||
error: :lifetime fragment specifier is experimental and subject to change (see issue #46895)
|
||||
--> $DIR/feature-gate-macro-lifetime-matcher.rs:14:19
|
||||
|
|
||||
14 | macro_rules! m { ($lt:lifetime) => {} }
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
||||
= help: add #![feature(macro_lifetime_matcher)] to the crate attributes to enable
|
||||
|
||||
error: aborting due to previous error
|
||||
|
Loading…
x
Reference in New Issue
Block a user