return Ok(Operation::Stdin {
input: buffer,
- config_path: config_path,
+ config_path,
});
}
.collect();
Ok(Operation::Format {
- files: files,
- config_path: config_path,
- minimal_config_path: minimal_config_path,
+ files,
+ config_path,
+ minimal_config_path,
})
}
};
let fmt = ListFormatting {
- tactic: tactic,
+ tactic,
separator: ",",
trailing_separator: SeparatorTactic::Never,
separator_place: SeparatorPlace::Back,
let mut fmt = StringFormat {
opener: "",
closer: "",
- line_start: line_start,
+ line_start,
line_end: "",
shape: Shape::legacy(max_chars, fmt_indent),
trim_end: true,
- config: config,
+ config,
};
let line_breaks = count_newlines(orig.trim_right());
impl<'a> CommentCodeSlices<'a> {
pub fn new(slice: &'a str) -> CommentCodeSlices<'a> {
CommentCodeSlices {
- slice: slice,
+ slice,
last_slice_kind: CodeCharKind::Comment,
last_slice_end: 0,
}
let is_block = comment.starts_with("/*");
let comment = remove_comment_header(comment);
CommentReducer {
- is_block: is_block,
+ is_block,
at_start_line: false, // There are no supplementary '*' on the first line
iter: comment.chars(),
}
let ends_with_newline = tactic.ends_with_newline(context.config.indent_style());
let fmt = ListFormatting {
- tactic: tactic,
+ tactic,
separator: ",",
trailing_separator: if trailing_comma {
SeparatorTactic::Always
},
separator_place: SeparatorPlace::Back,
shape: nested_shape,
- ends_with_newline: ends_with_newline,
+ ends_with_newline,
preserve_newline: false,
config: context.config,
};
) -> ControlFlow<'a> {
ControlFlow {
cond: Some(cond),
- block: block,
- else_block: else_block,
+ block,
+ else_block,
label: None,
- pat: pat,
+ pat,
keyword: "if",
matcher: match pat {
Some(..) => "let",
None => "",
},
connector: " =",
- allow_single_line: allow_single_line,
- nested_if: nested_if,
- span: span,
+ allow_single_line,
+ nested_if,
+ span,
}
}
) -> ControlFlow<'a> {
ControlFlow {
cond: None,
- block: block,
+ block,
else_block: None,
- label: label,
+ label,
pat: None,
keyword: "loop",
matcher: "",
connector: "",
allow_single_line: false,
nested_if: false,
- span: span,
+ span,
}
}
) -> ControlFlow<'a> {
ControlFlow {
cond: Some(cond),
- block: block,
+ block,
else_block: None,
- label: label,
- pat: pat,
+ label,
+ pat,
keyword: "while",
matcher: match pat {
Some(..) => "let",
connector: " =",
allow_single_line: false,
nested_if: false,
- span: span,
+ span,
}
}
) -> ControlFlow<'a> {
ControlFlow {
cond: Some(cond),
- block: block,
+ block,
else_block: None,
- label: label,
+ label,
pat: Some(pat),
keyword: "for",
matcher: "",
connector: " in",
allow_single_line: false,
nested_if: false,
- span: span,
+ span,
}
}
)
};
let fmt = ListFormatting {
- tactic: tactic,
+ tactic,
separator: " |",
trailing_separator: SeparatorTactic::Never,
separator_place: context.config.binop_separator(),
);
let fmt = ListFormatting {
- tactic: tactic,
+ tactic,
separator: ",",
trailing_separator: if force_trailing_comma {
SeparatorTactic::Always
nested_shape.width,
);
let fmt = ListFormatting {
- tactic: tactic,
+ tactic,
separator: ",",
trailing_separator: SeparatorTactic::Never,
separator_place: SeparatorPlace::Back,
- shape: shape,
+ shape,
ends_with_newline: false,
preserve_newline: false,
config: context.config,
impl Range {
pub fn new(lo: usize, hi: usize) -> Range {
- Range { lo: lo, hi: hi }
+ Range { lo, hi }
}
fn is_empty(self) -> bool {
separator: "",
trailing_separator: SeparatorTactic::Never,
separator_place: SeparatorPlace::Back,
- shape: shape,
+ shape,
ends_with_newline: true,
preserve_newline: false,
config: context.config,
&& tactic != DefinitiveListTactic::Horizontal;
let fmt = ListFormatting {
- tactic: tactic,
+ tactic,
separator: ",",
trailing_separator: if ends_with_newline {
context.config.trailing_comma()
},
separator_place: SeparatorPlace::Back,
shape: nested_shape,
- ends_with_newline: ends_with_newline,
+ ends_with_newline,
preserve_newline: true,
config: context.config,
};
todo_idx: 0,
fixme_idx: 0,
},
- report_todo: report_todo,
- report_fixme: report_fixme,
+ report_todo,
+ report_fixme,
}
}
}
Seeking::Issue {
- todo_idx: todo_idx,
- fixme_idx: fixme_idx,
+ todo_idx,
+ fixme_idx,
}
}
NumberPart::CloseParen => {}
}
- self.state = Seeking::Number {
- part: part,
- issue: issue,
- };
+ self.state = Seeking::Number { part, issue };
IssueClassification::None
}
.iter()
.map(|i| BodyElement::ForeignItem(i))
.collect(),
- span: span,
+ span,
}
}
}
vis: ast::Visibility,
) -> FnSig<'a> {
FnSig {
- decl: decl,
- generics: generics,
+ decl,
+ generics,
abi: abi::Abi::Rust,
constness: ast::Constness::NotConst,
defaultness: ast::Defaultness::Final,
defaultness: ast::Defaultness::Final,
abi: method_sig.abi,
decl: &*method_sig.decl,
- generics: generics,
+ generics,
visibility: ast::Visibility::Inherited,
}
}
) -> FnSig<'a> {
match *fn_kind {
visit::FnKind::ItemFn(_, unsafety, constness, abi, visibility, _) => FnSig {
- decl: decl,
- generics: generics,
- abi: abi,
+ decl,
+ generics,
+ abi,
constness: constness.node,
defaultness: defualtness,
- unsafety: unsafety,
+ unsafety,
visibility: visibility.clone(),
},
visit::FnKind::Method(_, method_sig, vis, _) => {
separator: ",",
trailing_separator: self.config.trailing_comma(),
separator_place: SeparatorPlace::Back,
- shape: shape,
+ shape,
ends_with_newline: true,
preserve_newline: true,
config: self.config,
_ => unreachable!(),
};
StructParts {
- prefix: prefix,
+ prefix,
ident: item.ident,
vis: &item.vis,
- def: def,
+ def,
generics: Some(generics),
span: item.span,
}
_ => unreachable!(),
};
StaticParts {
- prefix: prefix,
+ prefix,
vis: &item.vis,
ident: item.ident,
- ty: ty,
- mutability: mutability,
+ ty,
+ mutability,
expr_opt: Some(expr),
defaultness: None,
span: item.span,
prefix: "const",
vis: &ast::Visibility::Inherited,
ident: ti.ident,
- ty: ty,
+ ty,
mutability: ast::Mutability::Immutable,
expr_opt: expr_opt.as_ref(),
defaultness: None,
prefix: "const",
vis: &ii.vis,
ident: ii.ident,
- ty: ty,
+ ty,
mutability: ast::Mutability::Immutable,
expr_opt: Some(expr),
defaultness: Some(ii.defaultness),
let one_line_budget = context.budget(used_width + overhead);
let shape = Shape {
width: one_line_budget,
- indent: indent,
+ indent,
offset: used_width,
};
let fd = fn_sig.decl;
impl WhereClauseOption {
pub fn new(suppress_comma: bool, snuggle: bool) -> WhereClauseOption {
WhereClauseOption {
- suppress_comma: suppress_comma,
- snuggle: snuggle,
+ suppress_comma,
+ snuggle,
compress_where: false,
}
}
debug!("rewrite_args: budget: {}, tactic: {:?}", budget, tactic);
let fmt = ListFormatting {
- tactic: tactic,
+ tactic,
separator: ",",
trailing_separator: if variadic {
SeparatorTactic::Never
one_line_budget,
);
let fmt = ListFormatting {
- tactic: tactic,
+ tactic,
separator: ",",
trailing_separator: if context.config.indent_style() == IndentStyle::Visual {
SeparatorTactic::Never
context.config.trailing_comma()
},
separator_place: SeparatorPlace::Back,
- shape: shape,
+ shape,
ends_with_newline: tactic.ends_with_newline(context.config.indent_style()),
preserve_newline: true,
config: context.config,
}
let fmt = ListFormatting {
- tactic: tactic,
+ tactic,
separator: ",",
trailing_separator: comma_tactic,
separator_place: SeparatorPlace::Back,
line: cur_line,
kind: error_kind,
is_comment: kind.is_comment(),
- is_string: is_string,
+ is_string,
line_buffer: line_buffer.clone(),
});
}
};
ListItem {
- pre_comment: pre_comment,
- pre_comment_style: pre_comment_style,
+ pre_comment,
+ pre_comment_style,
item: if self.inner.peek().is_none() && self.leave_last {
None
} else {
(self.get_item_string)(&item)
},
- post_comment: post_comment,
- new_lines: new_lines,
+ post_comment,
+ new_lines,
}
})
}
F3: Fn(&T) -> Option<String>,
{
ListItems {
- codemap: codemap,
+ codemap,
inner: inner.peekable(),
- get_lo: get_lo,
- get_hi: get_hi,
- get_item_string: get_item_string,
- prev_span_end: prev_span_end,
- next_span_start: next_span_start,
- terminator: terminator,
- separator: separator,
- leave_last: leave_last,
+ get_lo,
+ get_hi,
+ get_item_string,
+ prev_span_end,
+ next_span_start,
+ terminator,
+ separator,
+ leave_last,
}
}
let ends_with_newline = context.config.indent_style() != IndentStyle::Visual
&& tactic == DefinitiveListTactic::Vertical;
ListFormatting {
- tactic: tactic,
+ tactic,
separator: ",",
trailing_separator: if force_no_trailing_comma {
SeparatorTactic::Never
context.config.trailing_comma()
},
separator_place: SeparatorPlace::Back,
- shape: shape,
- ends_with_newline: ends_with_newline,
+ shape,
+ ends_with_newline,
preserve_newline: true,
config: context.config,
}
impl Mismatch {
fn new(line_number: u32) -> Mismatch {
Mismatch {
- line_number: line_number,
+ line_number,
lines: Vec::new(),
}
}
impl Indent {
pub fn new(block_indent: usize, alignment: usize) -> Indent {
Indent {
- block_indent: block_indent,
- alignment: alignment,
+ block_indent,
+ alignment,
}
}
// |<--->| width
pub fn legacy(width: usize, indent: Indent) -> Shape {
Shape {
- width: width,
- indent: indent,
+ width,
+ indent,
offset: indent.alignment,
}
}
pub fn indented(indent: Indent, config: &Config) -> Shape {
Shape {
width: config.max_width().checked_sub(indent.width()).unwrap_or(0),
- indent: indent,
+ indent,
offset: indent.alignment,
}
}
pub fn offset(width: usize, indent: Indent, offset: usize) -> Shape {
Shape {
- width: width,
- indent: indent,
- offset: offset,
+ width,
+ indent,
+ offset,
}
}
closer: "\"",
line_start: " ",
line_end: "\\",
- shape: shape,
+ shape,
trim_end: false,
- config: config,
+ config,
}
}
}
);
let fmt = ListFormatting {
- tactic: tactic,
+ tactic,
separator: ",",
trailing_separator: if !context.use_block_indent() || variadic {
SeparatorTactic::Never
);
let fmt = ListFormatting {
- tactic: tactic,
+ tactic,
separator: ",",
trailing_separator: context.config.trailing_comma(),
separator_place: SeparatorPlace::Back,
snippet_provider: &'a SnippetProvider,
) -> FmtVisitor<'a> {
FmtVisitor {
- parse_session: parse_session,
+ parse_session,
codemap: parse_session.codemap(),
buffer: String::with_capacity(snippet_provider.big_snippet.len() * 2),
last_pos: BytePos(0),
block_indent: Indent::empty(),
- config: config,
+ config,
is_if_else_block: false,
- snippet_provider: snippet_provider,
+ snippet_provider,
line_number: 0,
skipped_range: vec![],
}
hair::PatternRef::Hair(pattern),
&lvalue,
);
- ArgDecl { ty: ty }
+ ArgDecl { ty }
},
);
}
pub fn new(value: V) -> Self {
Test {
cloned_value: value.clone(),
- value: value,
+ value,
}
}
}