Skip to content

Commit

Permalink
Rollup merge of rust-lang#56072 - da-x:stabilize-literal-matcher, r=p…
Browse files Browse the repository at this point in the history
…etrochenkov

Stabilize macro_literal_matcher

This followed FCP in rust-lang#35625.

Closes rust-lang#35625
  • Loading branch information
pietroalbini committed Nov 25, 2018
2 parents 6c2513c + b8ae7b8 commit b16d8eb
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 73 deletions.

This file was deleted.

31 changes: 13 additions & 18 deletions src/libsyntax/ext/tt/macro_rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use ext::tt::macro_parser::{MatchedSeq, MatchedNonterminal};
use ext::tt::macro_parser::{parse, parse_failure_msg};
use ext::tt::quoted;
use ext::tt::transcribe::transcribe;
use feature_gate::{self, emit_feature_err, Features, GateIssue};
use feature_gate::Features;
use parse::{Directory, ParseSess};
use parse::parser::Parser;
use parse::token::{self, NtTT};
Expand Down Expand Up @@ -1027,26 +1027,21 @@ fn has_legal_fragment_specifier(sess: &ParseSess,
Ok(())
}

fn is_legal_fragment_specifier(sess: &ParseSess,
features: &Features,
attrs: &[ast::Attribute],
fn is_legal_fragment_specifier(_sess: &ParseSess,
_features: &Features,
_attrs: &[ast::Attribute],
frag_name: &str,
frag_span: Span) -> bool {
_frag_span: Span) -> bool {
/*
* If new fragment specifiers are invented in nightly, `_sess`,
* `_features`, `_attrs`, and `_frag_span` will be useful here
* for checking against feature gates. See past versions of
* this function.
*/
match frag_name {
"item" | "block" | "stmt" | "expr" | "pat" | "lifetime" |
"path" | "ty" | "ident" | "meta" | "tt" | "vis" | "" => true,
"literal" => {
if !features.macro_literal_matcher &&
!attr::contains_name(attrs, "allow_internal_unstable") {
let explain = feature_gate::EXPLAIN_LITERAL_MATCHER;
emit_feature_err(sess,
"macro_literal_matcher",
frag_span,
GateIssue::Language,
explain);
}
true
},
"path" | "ty" | "ident" | "meta" | "tt" | "vis" | "literal" |
"" => true,
_ => false,
}
}
Expand Down
8 changes: 2 additions & 6 deletions src/libsyntax/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -436,9 +436,6 @@ declare_features! (
// Allows irrefutable patterns in if-let and while-let statements (RFC 2086)
(active, irrefutable_let_patterns, "1.27.0", Some(44495), None),

// Allows use of the :literal macro fragment specifier (RFC 1576)
(active, macro_literal_matcher, "1.27.0", Some(35625), None),

// inconsistent bounds in where clauses
(active, trivial_bounds, "1.28.0", Some(48214), None),

Expand Down Expand Up @@ -690,6 +687,8 @@ declare_features! (
(accepted, impl_header_lifetime_elision, "1.31.0", Some(15872), None),
// `extern crate foo as bar;` puts `bar` into extern prelude.
(accepted, extern_crate_item_prelude, "1.31.0", Some(55599), None),
// Allows use of the :literal macro fragment specifier (RFC 1576)
(accepted, macro_literal_matcher, "1.31.0", Some(35625), None),
);

// If you change this, please modify src/doc/unstable-book as well. You must
Expand Down Expand Up @@ -1425,9 +1424,6 @@ pub const EXPLAIN_DEPR_CUSTOM_DERIVE: &'static str =
pub const EXPLAIN_DERIVE_UNDERSCORE: &'static str =
"attributes of the form `#[derive_*]` are reserved for the compiler";

pub const EXPLAIN_LITERAL_MATCHER: &'static str =
":literal fragment specifier is experimental and subject to change";

pub const EXPLAIN_UNSIZED_TUPLE_COERCION: &'static str =
"unsized tuple coercion is not stable enough for use and is subject to change";

Expand Down
1 change: 0 additions & 1 deletion src/test/run-pass/issues/issue-52169.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
// except according to those terms.

// run-pass
#![feature(macro_literal_matcher)]

macro_rules! a {
($i:literal) => { "right" };
Expand Down
1 change: 0 additions & 1 deletion src/test/run-pass/macros/macro-literal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
// except according to those terms.

// run-pass
#![feature(macro_literal_matcher)]

macro_rules! mtester {
($l:literal) => {
Expand Down
19 changes: 0 additions & 19 deletions src/test/ui/feature-gates/feature-gate-macro-literal-matcher.rs

This file was deleted.

This file was deleted.

0 comments on commit b16d8eb

Please sign in to comment.