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

Fix for issue #58050 #58075

Merged
merged 1 commit into from
Feb 27, 2019
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
18 changes: 12 additions & 6 deletions src/libsyntax/ext/tt/quoted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -474,11 +474,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
Expand Down Expand Up @@ -506,10 +508,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
Expand All @@ -519,11 +523,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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ 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
|
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