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

Change String to &'static str in ParseResult::Failure. #57461

Merged
merged 1 commit into from
Jan 13, 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
6 changes: 3 additions & 3 deletions src/libsyntax/ext/tt/macro_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ pub enum ParseResult<T> {
Success(T),
/// Arm failed to match. If the second parameter is `token::Eof`, it indicates an unexpected
/// end of macro invocation. Otherwise, it indicates that no rules expected the given token.
Failure(syntax_pos::Span, Token, String),
Failure(syntax_pos::Span, Token, &'static str),
/// Fatal error (malformed macro?). Abort compilation.
Error(syntax_pos::Span, String),
}
Expand Down Expand Up @@ -721,7 +721,7 @@ pub fn parse(
sess.source_map().next_point(parser.span)
},
token::Eof,
"missing tokens in macro arguments".to_string(),
"missing tokens in macro arguments",
);
}
}
Expand Down Expand Up @@ -760,7 +760,7 @@ pub fn parse(
return Failure(
parser.span,
parser.token,
"no rules expected this token in macro call".to_string(),
"no rules expected this token in macro call",
);
}
// Dump all possible `next_items` into `cur_items` for the next iteration.
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/ext/tt/macro_rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ fn generic_extension<'cx>(cx: &'cx mut ExtCtxt,
let best_fail_msg = parse_failure_msg(best_fail_tok.expect("ran no matchers"));
let span = best_fail_spot.substitute_dummy(sp);
let mut err = cx.struct_span_err(span, &best_fail_msg);
err.span_label(span, best_fail_text.unwrap_or(best_fail_msg));
err.span_label(span, best_fail_text.unwrap_or(&best_fail_msg));
if let Some(sp) = def_span {
if cx.source_map().span_to_filename(sp).is_real() && !sp.is_dummy() {
err.span_label(cx.source_map().def_span(sp), "when calling this macro");
Expand Down