Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit cbd5680

Browse files
committed
Fixup formatting
1 parent b81b902 commit cbd5680

File tree

6 files changed

+47
-42
lines changed

6 files changed

+47
-42
lines changed

src/expr.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -898,10 +898,11 @@ impl<'a> ControlFlow<'a> {
898898
let trial = self.rewrite_single_line(&pat_expr_string, context, shape.width);
899899

900900
if let Some(cond_str) = trial {
901-
if cond_str.len() <= context
902-
.config
903-
.width_heuristics()
904-
.single_line_if_else_max_width
901+
if cond_str.len()
902+
<= context
903+
.config
904+
.width_heuristics()
905+
.single_line_if_else_max_width
905906
{
906907
return Some((cond_str, 0));
907908
}

src/lists.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,12 @@ impl ListItem {
146146
}
147147

148148
pub fn is_different_group(&self) -> bool {
149-
self.inner_as_ref().contains('\n') || self.pre_comment.is_some() || self
150-
.post_comment
151-
.as_ref()
152-
.map_or(false, |s| s.contains('\n'))
149+
self.inner_as_ref().contains('\n')
150+
|| self.pre_comment.is_some()
151+
|| self
152+
.post_comment
153+
.as_ref()
154+
.map_or(false, |s| s.contains('\n'))
153155
}
154156

155157
pub fn is_multiline(&self) -> bool {

src/macros.rs

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,22 +1168,24 @@ fn indent_macro_snippet(
11681168
.min()?;
11691169

11701170
Some(
1171-
first_line + "\n" + &trimmed_lines
1172-
.iter()
1173-
.map(
1174-
|&(trimmed, ref line, prefix_space_width)| match prefix_space_width {
1175-
_ if !trimmed => line.to_owned(),
1176-
Some(original_indent_width) => {
1177-
let new_indent_width = indent.width() + original_indent_width
1178-
.saturating_sub(min_prefix_space_width);
1179-
let new_indent = Indent::from_width(context.config, new_indent_width);
1180-
format!("{}{}", new_indent.to_string(context.config), line)
1181-
}
1182-
None => String::new(),
1183-
},
1184-
)
1185-
.collect::<Vec<_>>()
1186-
.join("\n"),
1171+
first_line
1172+
+ "\n"
1173+
+ &trimmed_lines
1174+
.iter()
1175+
.map(
1176+
|&(trimmed, ref line, prefix_space_width)| match prefix_space_width {
1177+
_ if !trimmed => line.to_owned(),
1178+
Some(original_indent_width) => {
1179+
let new_indent_width = indent.width()
1180+
+ original_indent_width.saturating_sub(min_prefix_space_width);
1181+
let new_indent = Indent::from_width(context.config, new_indent_width);
1182+
format!("{}{}", new_indent.to_string(context.config), line)
1183+
}
1184+
None => String::new(),
1185+
},
1186+
)
1187+
.collect::<Vec<_>>()
1188+
.join("\n"),
11871189
)
11881190
}
11891191

src/pairs.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,12 @@ where
204204
// If the length of the lhs is equal to or shorter than the tab width or
205205
// the rhs looks like block expression, we put the rhs on the same
206206
// line with the lhs even if the rhs is multi-lined.
207-
let allow_same_line = lhs_result.len() <= tab_spaces || rhs_result
208-
.lines()
209-
.next()
210-
.map(|first_line| first_line.ends_with('{'))
211-
.unwrap_or(false);
207+
let allow_same_line = lhs_result.len() <= tab_spaces
208+
|| rhs_result
209+
.lines()
210+
.next()
211+
.map(|first_line| first_line.ends_with('{'))
212+
.unwrap_or(false);
212213
if !rhs_result.contains('\n') || allow_same_line {
213214
let one_line_width = last_line_width(&lhs_result)
214215
+ pp.infix.len()
@@ -308,10 +309,7 @@ impl FlattenPair for ast::Expr {
308309
}
309310

310311
assert_eq!(list.len() - 1, separators.len());
311-
Some(PairList {
312-
list,
313-
separators,
314-
})
312+
Some(PairList { list, separators })
315313
}
316314
}
317315

src/string.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -287,11 +287,12 @@ fn break_string(max_chars: usize, trim_end: bool, line_end: &str, input: &[&str]
287287
return break_at(max_chars - 1);
288288
}
289289
if let Some(url_index_end) = detect_url(input, max_chars) {
290-
let index_plus_ws = url_index_end + input[url_index_end..]
291-
.iter()
292-
.skip(1)
293-
.position(|grapheme| not_whitespace_except_line_feed(grapheme))
294-
.unwrap_or(0);
290+
let index_plus_ws = url_index_end
291+
+ input[url_index_end..]
292+
.iter()
293+
.skip(1)
294+
.position(|grapheme| not_whitespace_except_line_feed(grapheme))
295+
.unwrap_or(0);
295296
return if trim_end {
296297
SnippetState::LineEnd(
297298
input[..=url_index_end].join("").to_string(),

src/utils.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -324,10 +324,11 @@ pub fn mk_sp(lo: BytePos, hi: BytePos) -> Span {
324324
// Return true if the given span does not intersect with file lines.
325325
macro_rules! out_of_file_lines_range {
326326
($self:ident, $span:expr) => {
327-
!$self.config.file_lines().is_all() && !$self
328-
.config
329-
.file_lines()
330-
.intersects(&$self.source_map.lookup_line_range($span))
327+
!$self.config.file_lines().is_all()
328+
&& !$self
329+
.config
330+
.file_lines()
331+
.intersects(&$self.source_map.lookup_line_range($span))
331332
};
332333
}
333334

0 commit comments

Comments
 (0)