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

Slightly refactor syntax_ext/format #53215

Merged
merged 2 commits into from
Aug 9, 2018
Merged

Conversation

ljedrz
Copy link
Contributor

@ljedrz ljedrz commented Aug 9, 2018

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

@rust-highfive
Copy link
Collaborator

r? @nikomatsakis

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 9, 2018
@ljedrz
Copy link
Contributor Author

ljedrz commented Aug 9, 2018

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));
Copy link
Contributor

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, *};
Copy link
Contributor

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);
Copy link
Contributor

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...

@estebank
Copy link
Contributor

estebank commented Aug 9, 2018

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Aug 9, 2018

📌 Commit aab063a has been approved by estebank

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 9, 2018
kennytm added a commit to kennytm/rust that referenced this pull request Aug 9, 2018
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`
bors added a commit that referenced this pull request Aug 9, 2018
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)
@bors bors merged commit aab063a into rust-lang:master Aug 9, 2018
@ljedrz ljedrz deleted the refactor_format branch August 10, 2018 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants