Skip to content

Commit 5a03532

Browse files
committed
Auto merge of #56245 - mark-i-m:stabilize_ques_kleene, r=alexcrichton
Stabilize feature `macro_at_most_once_rep` a.k.a. `?` Kleene operator 🎉 cc #48075 r? @Centril
2 parents a49316d + 5d77173 commit 5a03532

24 files changed

+32
-279
lines changed

src/doc/unstable-book/src/language-features/macro-at-most-once-rep.md

-22
This file was deleted.

src/doc/unstable-book/src/language-features/plugin.md

-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,6 @@ that warns about any item named `lintme`.
181181
```rust,ignore
182182
#![feature(plugin_registrar)]
183183
#![feature(box_syntax, rustc_private)]
184-
#![feature(macro_at_most_once_rep)]
185184
186185
extern crate syntax;
187186

src/libcore/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@
9393
#![feature(never_type)]
9494
#![feature(nll)]
9595
#![feature(exhaustive_patterns)]
96-
#![feature(macro_at_most_once_rep)]
9796
#![feature(no_core)]
9897
#![feature(on_unimplemented)]
9998
#![feature(optin_builtin_traits)]

src/librustc/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@
6767
#![feature(integer_atomics)]
6868
#![feature(test)]
6969
#![feature(in_band_lifetimes)]
70-
#![feature(macro_at_most_once_rep)]
7170
#![feature(crate_visibility_modifier)]
7271
#![feature(transpose_result)]
7372

src/librustc_lint/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#![feature(nll)]
3030
#![feature(quote)]
3131
#![feature(rustc_diagnostic_macros)]
32-
#![feature(macro_at_most_once_rep)]
3332

3433
#[macro_use]
3534
extern crate syntax;

src/librustc_metadata/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
#![feature(box_patterns)]
1616
#![feature(libc)]
17-
#![feature(macro_at_most_once_rep)]
1817
#![feature(nll)]
1918
#![feature(proc_macro_internals)]
2019
#![feature(proc_macro_quote)]

src/libsyntax/ext/tt/quoted.rs

+13-45
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
use ast::NodeId;
1212
use early_buffered_lints::BufferedEarlyLintId;
1313
use ext::tt::macro_parser;
14-
use feature_gate::{self, emit_feature_err, Features, GateIssue};
14+
use feature_gate::Features;
1515
use parse::{token, ParseSess};
1616
use print::pprust;
1717
use symbol::keywords;
1818
use syntax_pos::{edition::Edition, BytePos, Span};
1919
use tokenstream::{self, DelimSpan};
20-
use {ast, attr};
20+
use ast;
2121

2222
use rustc_data_structures::sync::Lrc;
2323
use std::iter::Peekable;
@@ -566,32 +566,17 @@ fn parse_sep_and_kleene_op_2018<I>(
566566
input: &mut Peekable<I>,
567567
span: Span,
568568
sess: &ParseSess,
569-
features: &Features,
570-
attrs: &[ast::Attribute],
569+
_features: &Features,
570+
_attrs: &[ast::Attribute],
571571
) -> (Option<token::Token>, KleeneOp)
572572
where
573573
I: Iterator<Item = tokenstream::TokenTree>,
574574
{
575575
// We basically look at two token trees here, denoted as #1 and #2 below
576576
let span = match parse_kleene_op(input, span) {
577577
// #1 is a `?` (needs feature gate)
578-
Ok(Ok((op, op1_span))) if op == KleeneOp::ZeroOrOne => {
579-
if !features.macro_at_most_once_rep
580-
&& !attr::contains_name(attrs, "allow_internal_unstable")
581-
{
582-
let explain = feature_gate::EXPLAIN_MACRO_AT_MOST_ONCE_REP;
583-
emit_feature_err(
584-
sess,
585-
"macro_at_most_once_rep",
586-
op1_span,
587-
GateIssue::Language,
588-
explain,
589-
);
590-
591-
op1_span
592-
} else {
593-
return (None, op);
594-
}
578+
Ok(Ok((op, _op1_span))) if op == KleeneOp::ZeroOrOne => {
579+
return (None, op);
595580
}
596581

597582
// #1 is a `+` or `*` KleeneOp
@@ -600,24 +585,12 @@ where
600585
// #1 is a separator followed by #2, a KleeneOp
601586
Ok(Err((tok, span))) => match parse_kleene_op(input, span) {
602587
// #2 is the `?` Kleene op, which does not take a separator (error)
603-
Ok(Ok((op, op2_span))) if op == KleeneOp::ZeroOrOne => {
588+
Ok(Ok((op, _op2_span))) if op == KleeneOp::ZeroOrOne => {
604589
// Error!
605-
606-
if !features.macro_at_most_once_rep
607-
&& !attr::contains_name(attrs, "allow_internal_unstable")
608-
{
609-
// FIXME: when `?` as a Kleene op is stabilized, we only need the "does not
610-
// take a macro separator" error (i.e. the `else` case).
611-
sess.span_diagnostic
612-
.struct_span_err(op2_span, "expected `*` or `+`")
613-
.note("`?` is not a macro repetition operator")
614-
.emit();
615-
} else {
616-
sess.span_diagnostic.span_err(
617-
span,
618-
"the `?` macro repetition operator does not take a separator",
619-
);
620-
}
590+
sess.span_diagnostic.span_err(
591+
span,
592+
"the `?` macro repetition operator does not take a separator",
593+
);
621594

622595
// Return a dummy
623596
return (None, KleeneOp::ZeroOrMore);
@@ -638,13 +611,8 @@ where
638611
};
639612

640613
// If we ever get to this point, we have experienced an "unexpected token" error
641-
642-
if !features.macro_at_most_once_rep && !attr::contains_name(attrs, "allow_internal_unstable") {
643-
sess.span_diagnostic.span_err(span, "expected `*` or `+`");
644-
} else {
645-
sess.span_diagnostic
646-
.span_err(span, "expected one of: `*`, `+`, or `?`");
647-
}
614+
sess.span_diagnostic
615+
.span_err(span, "expected one of: `*`, `+`, or `?`");
648616

649617
// Return a dummy
650618
(None, KleeneOp::ZeroOrMore)

src/libsyntax/feature_gate.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -393,9 +393,6 @@ declare_features! (
393393
// `extern` in paths
394394
(active, extern_in_paths, "1.23.0", Some(55600), None),
395395

396-
// Use `?` as the Kleene "at most one" operator
397-
(active, macro_at_most_once_rep, "1.25.0", Some(48075), None),
398-
399396
// Infer static outlives requirements; RFC 2093
400397
(active, infer_static_outlives_requirements, "1.26.0", Some(54185), None),
401398

@@ -689,6 +686,8 @@ declare_features! (
689686
(accepted, extern_crate_item_prelude, "1.31.0", Some(55599), None),
690687
// Allows use of the :literal macro fragment specifier (RFC 1576)
691688
(accepted, macro_literal_matcher, "1.31.0", Some(35625), None),
689+
// Use `?` as the Kleene "at most one" operator
690+
(accepted, macro_at_most_once_rep, "1.32.0", Some(48075), None),
692691
);
693692

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

1430-
pub const EXPLAIN_MACRO_AT_MOST_ONCE_REP: &'static str =
1431-
"using the `?` macro Kleene operator for \"at most one\" repetition is unstable";
1432-
14331429
struct PostExpansionVisitor<'a> {
14341430
context: &'a Context<'a>,
14351431
}

src/libsyntax/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
test(attr(deny(warnings))))]
2121

2222
#![feature(crate_visibility_modifier)]
23-
#![feature(macro_at_most_once_rep)]
2423
#![feature(nll)]
2524
#![feature(rustc_attrs)]
2625
#![feature(rustc_diagnostic_macros)]

src/test/compile-fail-fulldeps/auxiliary/lint_for_crate.rs

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
#![feature(plugin_registrar, rustc_private)]
1414
#![feature(box_syntax)]
15-
#![feature(macro_at_most_once_rep)]
1615

1716
#[macro_use] extern crate rustc;
1817
extern crate rustc_plugin;

src/test/compile-fail-fulldeps/auxiliary/lint_group_plugin_test.rs

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
#![feature(plugin_registrar)]
1414
#![feature(box_syntax, rustc_private)]
15-
#![feature(macro_at_most_once_rep)]
1615

1716
// Load rustc as a plugin to get macros
1817
#[macro_use]

src/test/compile-fail-fulldeps/auxiliary/lint_plugin_test.rs

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
#![feature(plugin_registrar)]
1414
#![feature(box_syntax, rustc_private)]
15-
#![feature(macro_at_most_once_rep)]
1615

1716
extern crate syntax;
1817

src/test/run-pass-fulldeps/auxiliary/lint_for_crate.rs

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
#![feature(plugin_registrar, rustc_private)]
1414
#![feature(box_syntax)]
15-
#![feature(macro_at_most_once_rep)]
1615

1716
#[macro_use] extern crate rustc;
1817
extern crate rustc_plugin;

src/test/run-pass-fulldeps/proc-macro/auxiliary/issue-40001-plugin.rs

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
// except according to those terms.
1010

1111
#![feature(box_syntax, plugin, plugin_registrar, rustc_private)]
12-
#![feature(macro_at_most_once_rep)]
1312
#![crate_type = "dylib"]
1413

1514
#[macro_use]

src/test/run-pass/macros/macro-at-most-once-rep.rs

-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222

2323
// edition:2018
2424

25-
#![feature(macro_at_most_once_rep)]
26-
2725
macro_rules! foo {
2826
($($a:ident)? ; $num:expr) => { {
2927
let mut x = 0;

src/test/ui-fulldeps/auxiliary/lint_group_plugin_test.rs

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
#![feature(plugin_registrar)]
1414
#![feature(box_syntax, rustc_private)]
15-
#![feature(macro_at_most_once_rep)]
1615

1716
// Load rustc as a plugin to get macros
1817
#[macro_use]

src/test/ui-fulldeps/auxiliary/lint_plugin_test.rs

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
#![feature(plugin_registrar)]
1414
#![feature(box_syntax, rustc_private)]
15-
#![feature(macro_at_most_once_rep)]
1615

1716
extern crate syntax;
1817

src/test/ui-fulldeps/auxiliary/lint_tool_test.rs

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
#![feature(plugin_registrar)]
1212
#![feature(box_syntax, rustc_private)]
13-
#![feature(macro_at_most_once_rep)]
1413

1514
extern crate syntax;
1615

src/test/ui/macros/macro-at-most-once-rep-2015-ques-rep-feature-flag.rs

-28
This file was deleted.

src/test/ui/macros/macro-at-most-once-rep-2015-ques-rep-feature-flag.stderr

-18
This file was deleted.

src/test/ui/macros/macro-at-most-once-rep-2018-feature-gate.rs

-45
This file was deleted.

0 commit comments

Comments
 (0)