Rollup merge of #58075 - asettouf:master, r=varkor
Fix for issue #58050 Hi, a quick PR to mention in the compiler error message that `?` is a macro operator, as according to issue #58050 It passed `python x.py test src/tools/tidy` locally, as well as the recommendation to run `/x.py test src/test/ui --stage 1 --bless`. Let me know if anything else is needed.
This commit is contained in:
commit
2f58c2cfc0
@ -475,11 +475,13 @@ where
|
||||
// #1 is a separator and #2 should be a KleepeOp.
|
||||
// (N.B. We need to advance the input iterator.)
|
||||
match parse_kleene_op(input, span) {
|
||||
// #2 is `?`, which is not allowed as a Kleene op in 2015 edition.
|
||||
// #2 is `?`, which is not allowed as a Kleene op in 2015 edition,
|
||||
// but is allowed in the 2018 edition.
|
||||
Ok(Ok((op, op2_span))) if op == KleeneOp::ZeroOrOne => {
|
||||
sess.span_diagnostic
|
||||
.struct_span_err(op2_span, "expected `*` or `+`")
|
||||
.note("`?` is not a macro repetition operator")
|
||||
.note("`?` is not a macro repetition operator in the 2015 edition, \
|
||||
but is accepted in the 2018 edition")
|
||||
.emit();
|
||||
|
||||
// Return a dummy
|
||||
@ -507,10 +509,12 @@ where
|
||||
Err(_) => op1_span,
|
||||
}
|
||||
} else {
|
||||
// `?` is not allowed as a Kleene op in 2015
|
||||
// `?` is not allowed as a Kleene op in 2015,
|
||||
// but is allowed in the 2018 edition
|
||||
sess.span_diagnostic
|
||||
.struct_span_err(op1_span, "expected `*` or `+`")
|
||||
.note("`?` is not a macro repetition operator")
|
||||
.note("`?` is not a macro repetition operator in the 2015 edition, \
|
||||
but is accepted in the 2018 edition")
|
||||
.emit();
|
||||
|
||||
// Return a dummy
|
||||
@ -520,11 +524,13 @@ where
|
||||
|
||||
// #1 is a separator followed by #2, a KleeneOp
|
||||
Ok(Err((tok, span))) => match parse_kleene_op(input, span) {
|
||||
// #2 is a `?`, which is not allowed as a Kleene op in 2015 edition.
|
||||
// #2 is a `?`, which is not allowed as a Kleene op in 2015 edition,
|
||||
// but is allowed in the 2018 edition
|
||||
Ok(Ok((op, op2_span))) if op == KleeneOp::ZeroOrOne => {
|
||||
sess.span_diagnostic
|
||||
.struct_span_err(op2_span, "expected `*` or `+`")
|
||||
.note("`?` is not a macro repetition operator")
|
||||
.note("`?` is not a macro repetition operator in the 2015 edition, \
|
||||
but is accepted in the 2018 edition")
|
||||
.emit();
|
||||
|
||||
// Return a dummy
|
||||
|
@ -4,7 +4,7 @@ error: expected `*` or `+`
|
||||
LL | ($(a)?) => {} //~ERROR expected `*` or `+`
|
||||
| ^
|
||||
|
|
||||
= note: `?` is not a macro repetition operator
|
||||
= note: `?` is not a macro repetition operator in the 2015 edition, but is accepted in the 2018 edition
|
||||
|
||||
error: expected `*` or `+`
|
||||
--> $DIR/macro-at-most-once-rep-2015-ques-rep.rs:10:11
|
||||
@ -12,7 +12,7 @@ error: expected `*` or `+`
|
||||
LL | ($(a),?) => {} //~ERROR expected `*` or `+`
|
||||
| ^
|
||||
|
|
||||
= note: `?` is not a macro repetition operator
|
||||
= note: `?` is not a macro repetition operator in the 2015 edition, but is accepted in the 2018 edition
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user