-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Slightly refactor syntax_ext/format #53215
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
r? @estebank |
let err = parser.errors.remove(0); | ||
let sp = fmt.span.from_inner_byte_pos(err.start, err.end); | ||
let mut e = ecx.struct_span_err(sp, &format!("invalid format string: {}", | ||
err.description)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: formatting
@@ -14,8 +14,7 @@ use self::Position::*; | |||
use fmt_macros as parse; | |||
|
|||
use syntax::ast; | |||
use syntax::ext::base; | |||
use syntax::ext::base::*; | |||
use syntax::ext::base::{self, *}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[not actionable] This change is ok and valid, I'm just finding odd to use foo::{self, *};
:)
} | ||
|
||
if !parser.errors.is_empty() { | ||
let err = parser.errors.remove(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not introduced in this change, but now I'm intrigued wether parser.errors.len()
could be > 1 and if it could, what the correct behavior would be...
@bors r+ rollup |
📌 Commit aab063a has been approved by |
Slightly refactor syntax_ext/format expand_preparsed_format_args: - move a potential error `return` earlier in the processing - pre-allocate some of the required space for `cx.pieces` and `cx.str_pieces` - create `cx`-independent objects before `cx` - build `pieces` and `errs` using `collect` instead of a `push` loop describe_num_args: - return `Cow<str>` instead of `String`
Rollup of 15 pull requests Successful merges: - #52773 (Avoid unnecessary pattern matching against Option and Result) - #53082 (Fix doc link (again)) - #53094 (Automatically expand section if url id point to one of its component) - #53106 (atomic ordering docs) - #53110 (Account for --remap-path-prefix in save-analysis) - #53116 (NetBSD: fix signedess of char) - #53179 (Whitelist wasm32 simd128 target feature) - #53183 (Suggest comma when missing in macro call) - #53207 (Add individual docs for rotate_{left, right}) - #53211 ([nll] enable feature(nll) on various crates for bootstrap) - #53214 ([nll] enable feature(nll) on various crates for bootstrap: part 2) - #53215 (Slightly refactor syntax_ext/format) - #53217 (inline some short functions) - #53219 ([nll] enable feature(nll) on various crates for bootstrap: part 3) - #53222 (A few cleanups for rustc_target)
expand_preparsed_format_args:
return
earlier in the processingcx.pieces
andcx.str_pieces
cx
-independent objects beforecx
pieces
anderrs
usingcollect
instead of apush
loopdescribe_num_args:
Cow<str>
instead ofString