Skip to content

Commit 5a03532

Browse files
committedNov 29, 2018
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

Lines changed: 0 additions & 22 deletions
This file was deleted.

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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 13 additions & 45 deletions
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

Lines changed: 2 additions & 6 deletions
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 0 additions & 2 deletions
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 0 additions & 28 deletions
This file was deleted.

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

Lines changed: 0 additions & 18 deletions
This file was deleted.

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

Lines changed: 0 additions & 45 deletions
This file was deleted.

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

Lines changed: 0 additions & 80 deletions
This file was deleted.

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,20 @@
1212

1313
// edition:2018
1414

15-
#![feature(macro_at_most_once_rep)]
16-
1715
macro_rules! foo {
18-
($(a)?) => {}
16+
($(a)?) => {};
1917
}
2018

2119
macro_rules! baz {
22-
($(a),?) => {} //~ERROR the `?` macro repetition operator
20+
($(a),?) => {}; //~ERROR the `?` macro repetition operator
2321
}
2422

2523
macro_rules! barplus {
26-
($(a)?+) => {} // ok. matches "a+" and "+"
24+
($(a)?+) => {}; // ok. matches "a+" and "+"
2725
}
2826

2927
macro_rules! barstar {
30-
($(a)?*) => {} // ok. matches "a*" and "*"
28+
($(a)?*) => {}; // ok. matches "a*" and "*"
3129
}
3230

3331
pub fn main() {

‎src/test/ui/macros/macro-at-most-once-rep-2018.stderr

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error: the `?` macro repetition operator does not take a separator
2-
--> $DIR/macro-at-most-once-rep-2018.rs:22:10
2+
--> $DIR/macro-at-most-once-rep-2018.rs:20:10
33
|
4-
LL | ($(a),?) => {} //~ERROR the `?` macro repetition operator
4+
LL | ($(a),?) => {}; //~ERROR the `?` macro repetition operator
55
| ^
66

77
error: no rules expected the token `?`
8-
--> $DIR/macro-at-most-once-rep-2018.rs:36:11
8+
--> $DIR/macro-at-most-once-rep-2018.rs:34:11
99
|
1010
LL | macro_rules! foo {
1111
| ---------------- when calling this macro
@@ -14,7 +14,7 @@ LL | foo!(a?); //~ ERROR no rules expected the token `?`
1414
| ^ no rules expected this token in macro call
1515

1616
error: no rules expected the token `?`
17-
--> $DIR/macro-at-most-once-rep-2018.rs:37:11
17+
--> $DIR/macro-at-most-once-rep-2018.rs:35:11
1818
|
1919
LL | macro_rules! foo {
2020
| ---------------- when calling this macro
@@ -23,7 +23,7 @@ LL | foo!(a?a); //~ ERROR no rules expected the token `?`
2323
| ^ no rules expected this token in macro call
2424

2525
error: no rules expected the token `?`
26-
--> $DIR/macro-at-most-once-rep-2018.rs:38:11
26+
--> $DIR/macro-at-most-once-rep-2018.rs:36:11
2727
|
2828
LL | macro_rules! foo {
2929
| ---------------- when calling this macro
@@ -32,7 +32,7 @@ LL | foo!(a?a?a); //~ ERROR no rules expected the token `?`
3232
| ^ no rules expected this token in macro call
3333

3434
error: unexpected end of macro invocation
35-
--> $DIR/macro-at-most-once-rep-2018.rs:40:5
35+
--> $DIR/macro-at-most-once-rep-2018.rs:38:5
3636
|
3737
LL | macro_rules! barplus {
3838
| -------------------- when calling this macro
@@ -41,7 +41,7 @@ LL | barplus!(); //~ERROR unexpected end of macro invocation
4141
| ^^^^^^^^^^^ missing tokens in macro arguments
4242

4343
error: unexpected end of macro invocation
44-
--> $DIR/macro-at-most-once-rep-2018.rs:41:15
44+
--> $DIR/macro-at-most-once-rep-2018.rs:39:15
4545
|
4646
LL | macro_rules! barplus {
4747
| -------------------- when calling this macro
@@ -50,7 +50,7 @@ LL | barplus!(a); //~ERROR unexpected end of macro invocation
5050
| ^ missing tokens in macro arguments
5151

5252
error: no rules expected the token `?`
53-
--> $DIR/macro-at-most-once-rep-2018.rs:42:15
53+
--> $DIR/macro-at-most-once-rep-2018.rs:40:15
5454
|
5555
LL | macro_rules! barplus {
5656
| -------------------- when calling this macro
@@ -59,7 +59,7 @@ LL | barplus!(a?); //~ ERROR no rules expected the token `?`
5959
| ^ no rules expected this token in macro call
6060

6161
error: no rules expected the token `?`
62-
--> $DIR/macro-at-most-once-rep-2018.rs:43:15
62+
--> $DIR/macro-at-most-once-rep-2018.rs:41:15
6363
|
6464
LL | macro_rules! barplus {
6565
| -------------------- when calling this macro
@@ -68,7 +68,7 @@ LL | barplus!(a?a); //~ ERROR no rules expected the token `?`
6868
| ^ no rules expected this token in macro call
6969

7070
error: unexpected end of macro invocation
71-
--> $DIR/macro-at-most-once-rep-2018.rs:47:5
71+
--> $DIR/macro-at-most-once-rep-2018.rs:45:5
7272
|
7373
LL | macro_rules! barstar {
7474
| -------------------- when calling this macro
@@ -77,7 +77,7 @@ LL | barstar!(); //~ERROR unexpected end of macro invocation
7777
| ^^^^^^^^^^^ missing tokens in macro arguments
7878

7979
error: unexpected end of macro invocation
80-
--> $DIR/macro-at-most-once-rep-2018.rs:48:15
80+
--> $DIR/macro-at-most-once-rep-2018.rs:46:15
8181
|
8282
LL | macro_rules! barstar {
8383
| -------------------- when calling this macro
@@ -86,7 +86,7 @@ LL | barstar!(a); //~ERROR unexpected end of macro invocation
8686
| ^ missing tokens in macro arguments
8787

8888
error: no rules expected the token `?`
89-
--> $DIR/macro-at-most-once-rep-2018.rs:49:15
89+
--> $DIR/macro-at-most-once-rep-2018.rs:47:15
9090
|
9191
LL | macro_rules! barstar {
9292
| -------------------- when calling this macro
@@ -95,7 +95,7 @@ LL | barstar!(a?); //~ ERROR no rules expected the token `?`
9595
| ^ no rules expected this token in macro call
9696

9797
error: no rules expected the token `?`
98-
--> $DIR/macro-at-most-once-rep-2018.rs:50:15
98+
--> $DIR/macro-at-most-once-rep-2018.rs:48:15
9999
|
100100
LL | macro_rules! barstar {
101101
| -------------------- when calling this macro

0 commit comments

Comments
 (0)
Please sign in to comment.