Skip to content

Commit 9c2b375

Browse files
calebcartwrighttopecongiro
authored andcommitted
refactor to use param naming where appropriate (#3803)
1 parent 3bb2661 commit 9c2b375

File tree

3 files changed

+99
-98
lines changed

3 files changed

+99
-98
lines changed

src/closures.rs

+15-15
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use syntax::{ast, ptr};
44
use crate::config::lists::*;
55
use crate::config::Version;
66
use crate::expr::{block_contains_comment, is_simple_block, is_unsafe_block, rewrite_cond};
7-
use crate::items::{span_hi_for_arg, span_lo_for_arg};
7+
use crate::items::{span_hi_for_param, span_lo_for_param};
88
use crate::lists::{definitive_tactic, itemize_list, write_list, ListFormatting, Separator};
99
use crate::overflow::OverflowableItem;
1010
use crate::rewrite::{Rewrite, RewriteContext};
@@ -232,37 +232,37 @@ fn rewrite_closure_fn_decl(
232232
.sub_width(4)?;
233233

234234
// 1 = |
235-
let argument_offset = nested_shape.indent + 1;
236-
let arg_shape = nested_shape.offset_left(1)?.visual_indent(0);
237-
let ret_str = fn_decl.output.rewrite(context, arg_shape)?;
235+
let param_offset = nested_shape.indent + 1;
236+
let param_shape = nested_shape.offset_left(1)?.visual_indent(0);
237+
let ret_str = fn_decl.output.rewrite(context, param_shape)?;
238238

239-
let arg_items = itemize_list(
239+
let param_items = itemize_list(
240240
context.snippet_provider,
241241
fn_decl.inputs.iter(),
242242
"|",
243243
",",
244-
|arg| span_lo_for_arg(arg),
245-
|arg| span_hi_for_arg(context, arg),
246-
|arg| arg.rewrite(context, arg_shape),
244+
|param| span_lo_for_param(param),
245+
|param| span_hi_for_param(context, param),
246+
|param| param.rewrite(context, param_shape),
247247
context.snippet_provider.span_after(span, "|"),
248248
body.span.lo(),
249249
false,
250250
);
251-
let item_vec = arg_items.collect::<Vec<_>>();
252-
// 1 = space between arguments and return type.
251+
let item_vec = param_items.collect::<Vec<_>>();
252+
// 1 = space between parameters and return type.
253253
let horizontal_budget = nested_shape.width.saturating_sub(ret_str.len() + 1);
254254
let tactic = definitive_tactic(
255255
&item_vec,
256256
ListTactic::HorizontalVertical,
257257
Separator::Comma,
258258
horizontal_budget,
259259
);
260-
let arg_shape = match tactic {
261-
DefinitiveListTactic::Horizontal => arg_shape.sub_width(ret_str.len() + 1)?,
262-
_ => arg_shape,
260+
let param_shape = match tactic {
261+
DefinitiveListTactic::Horizontal => param_shape.sub_width(ret_str.len() + 1)?,
262+
_ => param_shape,
263263
};
264264

265-
let fmt = ListFormatting::new(arg_shape, context.config)
265+
let fmt = ListFormatting::new(param_shape, context.config)
266266
.tactic(tactic)
267267
.preserve_newline(true);
268268
let list_str = write_list(&item_vec, &fmt)?;
@@ -271,7 +271,7 @@ fn rewrite_closure_fn_decl(
271271
if !ret_str.is_empty() {
272272
if prefix.contains('\n') {
273273
prefix.push('\n');
274-
prefix.push_str(&argument_offset.to_string(context.config));
274+
prefix.push_str(&param_offset.to_string(context.config));
275275
} else {
276276
prefix.push(' ');
277277
}

0 commit comments

Comments
 (0)