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 feature macro_at_most_once_rep #56245

Merged
merged 8 commits into from
Nov 29, 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

This file was deleted.

1 change: 0 additions & 1 deletion src/doc/unstable-book/src/language-features/plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ that warns about any item named `lintme`.
```rust,ignore
#![feature(plugin_registrar)]
#![feature(box_syntax, rustc_private)]
#![feature(macro_at_most_once_rep)]

extern crate syntax;

Expand Down
1 change: 0 additions & 1 deletion src/libcore/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@
#![feature(never_type)]
#![feature(nll)]
#![feature(exhaustive_patterns)]
#![feature(macro_at_most_once_rep)]
#![feature(no_core)]
#![feature(on_unimplemented)]
#![feature(optin_builtin_traits)]
Expand Down
1 change: 0 additions & 1 deletion src/librustc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
#![feature(integer_atomics)]
#![feature(test)]
#![feature(in_band_lifetimes)]
#![feature(macro_at_most_once_rep)]
#![feature(crate_visibility_modifier)]
#![feature(transpose_result)]

Expand Down
1 change: 0 additions & 1 deletion src/librustc_lint/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#![feature(nll)]
#![feature(quote)]
#![feature(rustc_diagnostic_macros)]
#![feature(macro_at_most_once_rep)]

#[macro_use]
extern crate syntax;
Expand Down
1 change: 0 additions & 1 deletion src/librustc_metadata/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

#![feature(box_patterns)]
#![feature(libc)]
#![feature(macro_at_most_once_rep)]
#![feature(nll)]
#![feature(proc_macro_internals)]
#![feature(proc_macro_quote)]
Expand Down
58 changes: 13 additions & 45 deletions src/libsyntax/ext/tt/quoted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
use ast::NodeId;
use early_buffered_lints::BufferedEarlyLintId;
use ext::tt::macro_parser;
use feature_gate::{self, emit_feature_err, Features, GateIssue};
use feature_gate::Features;
use parse::{token, ParseSess};
use print::pprust;
use symbol::keywords;
use syntax_pos::{edition::Edition, BytePos, Span};
use tokenstream::{self, DelimSpan};
use {ast, attr};
use ast;

use rustc_data_structures::sync::Lrc;
use std::iter::Peekable;
Expand Down Expand Up @@ -566,32 +566,17 @@ fn parse_sep_and_kleene_op_2018<I>(
input: &mut Peekable<I>,
span: Span,
sess: &ParseSess,
features: &Features,
attrs: &[ast::Attribute],
_features: &Features,
_attrs: &[ast::Attribute],
) -> (Option<token::Token>, KleeneOp)
where
I: Iterator<Item = tokenstream::TokenTree>,
{
// We basically look at two token trees here, denoted as #1 and #2 below
let span = match parse_kleene_op(input, span) {
// #1 is a `?` (needs feature gate)
mark-i-m marked this conversation as resolved.
Show resolved Hide resolved
Ok(Ok((op, op1_span))) if op == KleeneOp::ZeroOrOne => {
if !features.macro_at_most_once_rep
&& !attr::contains_name(attrs, "allow_internal_unstable")
{
let explain = feature_gate::EXPLAIN_MACRO_AT_MOST_ONCE_REP;
emit_feature_err(
sess,
"macro_at_most_once_rep",
op1_span,
GateIssue::Language,
explain,
);

op1_span
} else {
return (None, op);
}
Ok(Ok((op, _op1_span))) if op == KleeneOp::ZeroOrOne => {
return (None, op);
}

// #1 is a `+` or `*` KleeneOp
Expand All @@ -600,24 +585,12 @@ where
// #1 is a separator followed by #2, a KleeneOp
Ok(Err((tok, span))) => match parse_kleene_op(input, span) {
// #2 is the `?` Kleene op, which does not take a separator (error)
Ok(Ok((op, op2_span))) if op == KleeneOp::ZeroOrOne => {
Ok(Ok((op, _op2_span))) if op == KleeneOp::ZeroOrOne => {
// Error!

if !features.macro_at_most_once_rep
&& !attr::contains_name(attrs, "allow_internal_unstable")
{
// FIXME: when `?` as a Kleene op is stabilized, we only need the "does not
// take a macro separator" error (i.e. the `else` case).
sess.span_diagnostic
.struct_span_err(op2_span, "expected `*` or `+`")
.note("`?` is not a macro repetition operator")
.emit();
} else {
sess.span_diagnostic.span_err(
span,
"the `?` macro repetition operator does not take a separator",
);
}
sess.span_diagnostic.span_err(
span,
"the `?` macro repetition operator does not take a separator",
);

// Return a dummy
return (None, KleeneOp::ZeroOrMore);
Expand All @@ -638,13 +611,8 @@ where
};

// If we ever get to this point, we have experienced an "unexpected token" error

if !features.macro_at_most_once_rep && !attr::contains_name(attrs, "allow_internal_unstable") {
sess.span_diagnostic.span_err(span, "expected `*` or `+`");
} else {
sess.span_diagnostic
.span_err(span, "expected one of: `*`, `+`, or `?`");
}
sess.span_diagnostic
.span_err(span, "expected one of: `*`, `+`, or `?`");

// Return a dummy
(None, KleeneOp::ZeroOrMore)
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 @@ -393,9 +393,6 @@ declare_features! (
// `extern` in paths
(active, extern_in_paths, "1.23.0", Some(55600), None),

// Use `?` as the Kleene "at most one" operator
(active, macro_at_most_once_rep, "1.25.0", Some(48075), None),

// Infer static outlives requirements; RFC 2093
(active, infer_static_outlives_requirements, "1.26.0", Some(54185), None),

Expand Down Expand Up @@ -689,6 +686,8 @@ declare_features! (
(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),
// Use `?` as the Kleene "at most one" operator
(accepted, macro_at_most_once_rep, "1.32.0", Some(48075), None),
);

// If you change this, please modify src/doc/unstable-book as well. You must
Expand Down Expand Up @@ -1427,9 +1426,6 @@ pub const EXPLAIN_DERIVE_UNDERSCORE: &'static str =
pub const EXPLAIN_UNSIZED_TUPLE_COERCION: &'static str =
"unsized tuple coercion is not stable enough for use and is subject to change";

pub const EXPLAIN_MACRO_AT_MOST_ONCE_REP: &'static str =
"using the `?` macro Kleene operator for \"at most one\" repetition is unstable";

struct PostExpansionVisitor<'a> {
context: &'a Context<'a>,
}
Expand Down
1 change: 0 additions & 1 deletion src/libsyntax/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
test(attr(deny(warnings))))]

#![feature(crate_visibility_modifier)]
#![feature(macro_at_most_once_rep)]
#![feature(nll)]
#![feature(rustc_attrs)]
#![feature(rustc_diagnostic_macros)]
Expand Down
1 change: 0 additions & 1 deletion src/test/compile-fail-fulldeps/auxiliary/lint_for_crate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

#![feature(plugin_registrar, rustc_private)]
#![feature(box_syntax)]
#![feature(macro_at_most_once_rep)]

#[macro_use] extern crate rustc;
extern crate rustc_plugin;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

#![feature(plugin_registrar)]
#![feature(box_syntax, rustc_private)]
#![feature(macro_at_most_once_rep)]

// Load rustc as a plugin to get macros
#[macro_use]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

#![feature(plugin_registrar)]
#![feature(box_syntax, rustc_private)]
#![feature(macro_at_most_once_rep)]

extern crate syntax;

Expand Down
1 change: 0 additions & 1 deletion src/test/run-pass-fulldeps/auxiliary/lint_for_crate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

#![feature(plugin_registrar, rustc_private)]
#![feature(box_syntax)]
#![feature(macro_at_most_once_rep)]

#[macro_use] extern crate rustc;
extern crate rustc_plugin;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
// except according to those terms.

#![feature(box_syntax, plugin, plugin_registrar, rustc_private)]
#![feature(macro_at_most_once_rep)]
#![crate_type = "dylib"]

#[macro_use]
Expand Down
2 changes: 0 additions & 2 deletions src/test/run-pass/macros/macro-at-most-once-rep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@

// edition:2018

#![feature(macro_at_most_once_rep)]

macro_rules! foo {
($($a:ident)? ; $num:expr) => { {
let mut x = 0;
Expand Down
1 change: 0 additions & 1 deletion src/test/ui-fulldeps/auxiliary/lint_group_plugin_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

#![feature(plugin_registrar)]
#![feature(box_syntax, rustc_private)]
#![feature(macro_at_most_once_rep)]

// Load rustc as a plugin to get macros
#[macro_use]
Expand Down
1 change: 0 additions & 1 deletion src/test/ui-fulldeps/auxiliary/lint_plugin_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

#![feature(plugin_registrar)]
#![feature(box_syntax, rustc_private)]
#![feature(macro_at_most_once_rep)]

extern crate syntax;

Expand Down
1 change: 0 additions & 1 deletion src/test/ui-fulldeps/auxiliary/lint_tool_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

#![feature(plugin_registrar)]
#![feature(box_syntax, rustc_private)]
#![feature(macro_at_most_once_rep)]

extern crate syntax;

Expand Down

This file was deleted.

This file was deleted.

45 changes: 0 additions & 45 deletions src/test/ui/macros/macro-at-most-once-rep-2018-feature-gate.rs

This file was deleted.

Loading