Skip to content

Commit cd9e640

Browse files
committed
Remove version gates
1 parent 1b4e466 commit cd9e640

File tree

8 files changed

+20
-56
lines changed

8 files changed

+20
-56
lines changed

src/closures.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -409,19 +409,19 @@ fn is_block_closure_forced(context: &RewriteContext<'_>, expr: &ast::Expr) -> bo
409409
if context.inside_macro() {
410410
false
411411
} else {
412-
is_block_closure_forced_inner(expr, context.config.version())
412+
is_block_closure_forced_inner(expr)
413413
}
414414
}
415415

416-
fn is_block_closure_forced_inner(expr: &ast::Expr, version: Version) -> bool {
416+
fn is_block_closure_forced_inner(expr: &ast::Expr) -> bool {
417417
match expr.kind {
418418
ast::ExprKind::If(..) | ast::ExprKind::While(..) | ast::ExprKind::ForLoop(..) => true,
419-
ast::ExprKind::Loop(..) if version == Version::Two => true,
419+
ast::ExprKind::Loop(..) => true,
420420
ast::ExprKind::AddrOf(_, ref expr)
421421
| ast::ExprKind::Box(ref expr)
422422
| ast::ExprKind::Try(ref expr)
423423
| ast::ExprKind::Unary(_, ref expr)
424-
| ast::ExprKind::Cast(ref expr, _) => is_block_closure_forced_inner(expr, version),
424+
| ast::ExprKind::Cast(ref expr, _) => is_block_closure_forced_inner(expr),
425425
_ => false,
426426
}
427427
}

src/expr.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1238,7 +1238,6 @@ fn rewrite_string_lit(context: &RewriteContext<'_>, span: Span, shape: Shape) ->
12381238
.lines()
12391239
.dropping_back(1)
12401240
.all(|line| line.ends_with('\\'))
1241-
&& context.config.version() == Version::Two
12421241
{
12431242
return Some(string_lit.to_owned());
12441243
} else {

src/items.rs

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -860,15 +860,8 @@ fn format_impl_ref_and_type(
860860
result.push_str(format_defaultness(defaultness));
861861
result.push_str(format_unsafety(unsafety));
862862

863-
let shape = if context.config.version() == Version::Two {
864-
Shape::indented(offset + last_line_width(&result), context.config)
865-
} else {
866-
generics_shape_from_config(
867-
context.config,
868-
Shape::indented(offset + last_line_width(&result), context.config),
869-
0,
870-
)?
871-
};
863+
let shape =
864+
Shape::indented(offset + last_line_width(&result), context.config);
872865
let generics_str = rewrite_generics(context, "impl", generics, shape)?;
873866
result.push_str(&generics_str);
874867

@@ -1940,8 +1933,7 @@ impl Rewrite for ast::FunctionRetTy {
19401933
match *self {
19411934
ast::FunctionRetTy::Default(_) => Some(String::new()),
19421935
ast::FunctionRetTy::Ty(ref ty) => {
1943-
if context.config.version() == Version::One
1944-
|| context.config.indent_style() == IndentStyle::Visual
1936+
if context.config.indent_style() == IndentStyle::Visual
19451937
{
19461938
let inner_width = shape.width.checked_sub(3)?;
19471939
return ty
@@ -2296,7 +2288,6 @@ fn rewrite_fn_base(
22962288
.last()
22972289
.map_or(false, |last_line| last_line.contains("//"));
22982290

2299-
if context.config.version() == Version::Two {
23002291
if closing_paren_overflow_max_width {
23012292
result.push(')');
23022293
result.push_str(&indent.to_string_with_newline(context.config));
@@ -2308,12 +2299,6 @@ fn rewrite_fn_base(
23082299
} else {
23092300
result.push(')');
23102301
}
2311-
} else {
2312-
if closing_paren_overflow_max_width || params_last_line_contains_comment {
2313-
result.push_str(&indent.to_string_with_newline(context.config));
2314-
}
2315-
result.push(')');
2316-
}
23172302
}
23182303

23192304
// Return type.
@@ -2339,8 +2324,7 @@ fn rewrite_fn_base(
23392324
}
23402325
};
23412326
let ret_shape = if ret_should_indent {
2342-
if context.config.version() == Version::One
2343-
|| context.config.indent_style() == IndentStyle::Visual
2327+
if context.config.indent_style() == IndentStyle::Visual
23442328
{
23452329
let indent = if param_str.is_empty() {
23462330
// Aligning with non-existent params looks silly.
@@ -2372,13 +2356,9 @@ fn rewrite_fn_base(
23722356
ret_shape
23732357
}
23742358
} else {
2375-
if context.config.version() == Version::Two {
23762359
if !param_str.is_empty() || !no_params_and_over_max_width {
23772360
result.push(' ');
23782361
}
2379-
} else {
2380-
result.push(' ');
2381-
}
23822362

23832363
let ret_shape = Shape::indented(indent, context.config);
23842364
ret_shape

src/matches.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -405,15 +405,12 @@ fn rewrite_match_body(
405405
} else {
406406
""
407407
};
408-
let semicolon = if context.config.version() == Version::One {
409-
""
410-
} else {
408+
let semicolon =
411409
if semicolon_for_expr(context, body) {
412410
";"
413411
} else {
414412
""
415-
}
416-
};
413+
};
417414
("{", format!("{}{}}}{}", semicolon, indent_str, comma))
418415
} else {
419416
("", String::from(","))

src/overflow.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ impl<'a> Context<'a> {
475475
Some(OverflowableItem::MacroArg(MacroArg::Expr(expr)))
476476
if !combine_arg_with_callee
477477
&& is_method_call(expr)
478-
&& self.context.config.version() == Version::Two =>
478+
=>
479479
{
480480
self.context.force_one_line_chain.replace(true);
481481
}
@@ -660,15 +660,8 @@ impl<'a> Context<'a> {
660660
);
661661
result.push_str(self.ident);
662662
result.push_str(prefix);
663-
let force_single_line = if self.context.config.version() == Version::Two {
664-
!self.context.use_block_indent() || (is_extendable && extend_width <= shape.width)
665-
} else {
666-
// 2 = `()`
667-
let fits_one_line = items_str.len() + 2 <= shape.width;
668-
!self.context.use_block_indent()
669-
|| (self.context.inside_macro() && !items_str.contains('\n') && fits_one_line)
670-
|| (is_extendable && extend_width <= shape.width)
671-
};
663+
let force_single_line =
664+
!self.context.use_block_indent() || (is_extendable && extend_width <= shape.width);
672665
if force_single_line {
673666
result.push_str(items_str);
674667
} else {

src/stmt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ impl<'a> Stmt<'a> {
7171

7272
impl<'a> Rewrite for Stmt<'a> {
7373
fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String> {
74-
let expr_type = if context.config.version() == Version::Two && self.is_last_expr() {
74+
let expr_type = if self.is_last_expr() {
7575
ExprType::SubExpression
7676
} else {
7777
ExprType::Statement

src/types.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -678,8 +678,7 @@ impl Rewrite for ast::Ty {
678678
// FIXME: we drop any comments here, even though it's a silly place to put
679679
// comments.
680680
ast::TyKind::Paren(ref ty) => {
681-
if context.config.version() == Version::One
682-
|| context.config.indent_style() == IndentStyle::Visual
681+
if context.config.indent_style() == IndentStyle::Visual
683682
{
684683
let budget = shape.width.checked_sub(2)?;
685684
return ty
@@ -745,11 +744,8 @@ impl Rewrite for ast::Ty {
745744
if it.is_empty() {
746745
return Some("impl".to_owned());
747746
}
748-
let rw = if context.config.version() == Version::One {
749-
it.rewrite(context, shape)
750-
} else {
751-
join_bounds(context, shape, it, false)
752-
};
747+
let rw =
748+
join_bounds(context, shape, it, false);
753749
rw.map(|it_str| {
754750
let space = if it_str.is_empty() { "" } else { " " };
755751
format!("impl{}{}", space, it_str)

src/utils.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -568,8 +568,7 @@ pub(crate) fn trim_left_preserve_layout(
568568

569569
// just InString{Commented} in order to allow the start of a string to be indented
570570
let new_veto_trim_value = (kind == FullCodeCharKind::InString
571-
|| (config.version() == Version::Two
572-
&& kind == FullCodeCharKind::InStringCommented))
571+
|| kind == FullCodeCharKind::InStringCommented)
573572
&& !line.ends_with('\\');
574573
let line = if veto_trim || new_veto_trim_value {
575574
veto_trim = new_veto_trim_value;
@@ -584,7 +583,7 @@ pub(crate) fn trim_left_preserve_layout(
584583
// such lines should not be taken into account when computing the minimum.
585584
match kind {
586585
FullCodeCharKind::InStringCommented | FullCodeCharKind::EndStringCommented
587-
if config.version() == Version::Two =>
586+
=>
588587
{
589588
None
590589
}
@@ -619,7 +618,7 @@ pub(crate) fn trim_left_preserve_layout(
619618
/// Based on the given line, determine if the next line can be indented or not.
620619
/// This allows to preserve the indentation of multi-line literals.
621620
pub(crate) fn indent_next_line(kind: FullCodeCharKind, _line: &str, config: &Config) -> bool {
622-
!(kind.is_string() || (config.version() == Version::Two && kind.is_commented_string()))
621+
!(kind.is_string() || kind.is_commented_string())
623622
}
624623

625624
pub(crate) fn is_empty_line(s: &str) -> bool {

0 commit comments

Comments
 (0)