Skip to content

Commit 959313a

Browse files
committed
format: minor stylistic improvements
1 parent 002310a commit 959313a

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

src/libsyntax_ext/format.rs

+6-12
Original file line numberDiff line numberDiff line change
@@ -413,12 +413,10 @@ impl<'a, 'b> Context<'a, 'b> {
413413
parse::CountIs(i) => count("Is", Some(self.ecx.expr_usize(sp, i))),
414414
parse::CountIsParam(i) => {
415415
// This needs mapping too, as `i` is referring to a macro
416-
// argument.
417-
let i = match self.count_positions.get(&i) {
418-
Some(&i) => i,
419-
None => 0, // error already emitted elsewhere
420-
};
421-
let i = i + self.count_args_index_offset;
416+
// argument. If `i` is not found in `count_positions` then
417+
// the error had already been emitted elsewhere.
418+
let i = self.count_positions.get(&i).cloned().unwrap_or(0)
419+
+ self.count_args_index_offset;
422420
count("Param", Some(self.ecx.expr_usize(sp, i)))
423421
}
424422
parse::CountImplied => count("Implied", None),
@@ -503,10 +501,7 @@ impl<'a, 'b> Context<'a, 'b> {
503501
},
504502
};
505503

506-
let fill = match arg.format.fill {
507-
Some(c) => c,
508-
None => ' ',
509-
};
504+
let fill = arg.format.fill.unwrap_or(' ');
510505

511506
if *arg != simple_arg || fill != ' ' {
512507
self.all_pieces_simple = false;
@@ -805,8 +800,7 @@ pub fn expand_preparsed_format_args(ecx: &mut ExtCtxt,
805800
if !parser.errors.is_empty() {
806801
let err = parser.errors.remove(0);
807802
let sp = fmt.span.from_inner_byte_pos(err.start, err.end);
808-
let mut e = ecx.struct_span_err(sp, &format!("invalid format string: {}",
809-
err.description));
803+
let mut e = ecx.struct_span_err(sp, &format!("invalid format string: {}", err.description));
810804
e.span_label(sp, err.label + " in format string");
811805
if let Some(note) = err.note {
812806
e.note(&note);

0 commit comments

Comments
 (0)