Skip to content

Commit 962329f

Browse files
committed
Rename Sugg::maybe_par() into Sugg::maybe_paren()
"paren" is used throughout the Clippy codebase as an abbreviation for "parentheses".
1 parent b27a2bb commit 962329f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+89
-79
lines changed

clippy_lints/src/assigning_clones.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ fn build_sugg<'tcx>(
243243
// `lhs = self_expr.clone();` -> `lhs.clone_from(self_expr)`
244244
Sugg::hir_with_applicability(cx, lhs, "_", app)
245245
}
246-
.maybe_par();
246+
.maybe_paren();
247247

248248
// Determine whether we need to reference the argument to clone_from().
249249
let clone_receiver_type = cx.typeck_results().expr_ty(fn_arg);
@@ -284,7 +284,7 @@ fn build_sugg<'tcx>(
284284
let rhs_sugg = if let ExprKind::Unary(hir::UnOp::Deref, ref_expr) = lhs.kind {
285285
// `*lhs = rhs.to_owned()` -> `rhs.clone_into(lhs)`
286286
// `*lhs = ToOwned::to_owned(rhs)` -> `ToOwned::clone_into(rhs, lhs)`
287-
let sugg = Sugg::hir_with_applicability(cx, ref_expr, "_", app).maybe_par();
287+
let sugg = Sugg::hir_with_applicability(cx, ref_expr, "_", app).maybe_paren();
288288
let inner_type = cx.typeck_results().expr_ty(ref_expr);
289289
// If after unwrapping the dereference, the type is not a mutable reference, we add &mut to make it
290290
// deref to a mutable reference.
@@ -296,7 +296,7 @@ fn build_sugg<'tcx>(
296296
} else {
297297
// `lhs = rhs.to_owned()` -> `rhs.clone_into(&mut lhs)`
298298
// `lhs = ToOwned::to_owned(rhs)` -> `ToOwned::clone_into(rhs, &mut lhs)`
299-
Sugg::hir_with_applicability(cx, lhs, "_", app).maybe_par().mut_addr()
299+
Sugg::hir_with_applicability(cx, lhs, "_", app).maybe_paren().mut_addr()
300300
};
301301

302302
match call_kind {

clippy_lints/src/bool_to_int_with_if.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ impl<'tcx> LateLintPass<'tcx> for BoolToIntWithIf {
7272
s
7373
};
7474

75-
let into_snippet = snippet.clone().maybe_par();
75+
let into_snippet = snippet.clone().maybe_paren();
7676
let as_snippet = snippet.as_ty(ty);
7777

7878
span_lint_and_then(

clippy_lints/src/casts/cast_abs_to_unsigned.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub(super) fn check(
3636
span,
3737
format!("casting the result of `{cast_from}::abs()` to {cast_to}"),
3838
"replace with",
39-
format!("{}.unsigned_abs()", Sugg::hir(cx, receiver, "..").maybe_par()),
39+
format!("{}.unsigned_abs()", Sugg::hir(cx, receiver, "..").maybe_paren()),
4040
Applicability::MachineApplicable,
4141
);
4242
}

clippy_lints/src/casts/cast_lossless.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub(super) fn check(
4242
diag.span_suggestion_verbose(
4343
expr.span,
4444
"use `Into::into` instead",
45-
format!("{}.into()", from_sugg.maybe_par()),
45+
format!("{}.into()", from_sugg.maybe_paren()),
4646
applicability,
4747
);
4848
},

clippy_lints/src/casts/cast_possible_truncation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ fn offer_suggestion(
185185
) {
186186
let cast_to_snip = snippet(cx, cast_to_span, "..");
187187
let suggestion = if cast_to_snip == "_" {
188-
format!("{}.try_into()", Sugg::hir(cx, cast_expr, "..").maybe_par())
188+
format!("{}.try_into()", Sugg::hir(cx, cast_expr, "..").maybe_paren())
189189
} else {
190190
format!("{cast_to_snip}::try_from({})", Sugg::hir(cx, cast_expr, ".."))
191191
};

clippy_lints/src/casts/ptr_as_ptr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, msrv: Msrv) {
8181

8282
(
8383
"try `pointer::cast`, a safer alternative",
84-
format!("{}.cast{turbofish}()", cast_expr_sugg.maybe_par()),
84+
format!("{}.cast{turbofish}()", cast_expr_sugg.maybe_paren()),
8585
)
8686
};
8787

clippy_lints/src/casts/ptr_cast_constness.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ pub(super) fn check<'tcx>(
6565
expr.span,
6666
"`as` casting between raw pointers while changing only its constness",
6767
format!("try `pointer::cast_{constness}`, a safer alternative"),
68-
format!("{}.cast_{constness}()", sugg.maybe_par()),
68+
format!("{}.cast_{constness}()", sugg.maybe_paren()),
6969
Applicability::MachineApplicable,
7070
);
7171
}

clippy_lints/src/comparison_chain.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ impl<'tcx> LateLintPass<'tcx> for ComparisonChain {
125125
let ExprKind::Binary(_, lhs, rhs) = conds[0].kind else {
126126
unreachable!();
127127
};
128-
let lhs = Sugg::hir(cx, lhs, "..").maybe_par();
128+
let lhs = Sugg::hir(cx, lhs, "..").maybe_paren();
129129
let rhs = Sugg::hir(cx, rhs, "..").addr();
130130
span_lint_and_sugg(
131131
cx,

clippy_lints/src/floating_point_arithmetic.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ fn prepare_receiver_sugg<'a>(cx: &LateContext<'_>, mut expr: &'a Expr<'a>) -> Su
154154
};
155155
}
156156

157-
suggestion.maybe_par()
157+
suggestion.maybe_paren()
158158
}
159159

160160
fn check_log_base(cx: &LateContext<'_>, expr: &Expr<'_>, receiver: &Expr<'_>, args: &[Expr<'_>]) {
@@ -165,7 +165,7 @@ fn check_log_base(cx: &LateContext<'_>, expr: &Expr<'_>, receiver: &Expr<'_>, ar
165165
expr.span,
166166
"logarithm for bases 2, 10 and e can be computed more accurately",
167167
"consider using",
168-
format!("{}.{method}()", Sugg::hir(cx, receiver, "..").maybe_par()),
168+
format!("{}.{method}()", Sugg::hir(cx, receiver, "..").maybe_paren()),
169169
Applicability::MachineApplicable,
170170
);
171171
}
@@ -254,21 +254,21 @@ fn check_powf(cx: &LateContext<'_>, expr: &Expr<'_>, receiver: &Expr<'_>, args:
254254
(
255255
SUBOPTIMAL_FLOPS,
256256
"square-root of a number can be computed more efficiently and accurately",
257-
format!("{}.sqrt()", Sugg::hir(cx, receiver, "..").maybe_par()),
257+
format!("{}.sqrt()", Sugg::hir(cx, receiver, "..").maybe_paren()),
258258
)
259259
} else if F32(1.0 / 3.0) == value || F64(1.0 / 3.0) == value {
260260
(
261261
IMPRECISE_FLOPS,
262262
"cube-root of a number can be computed more accurately",
263-
format!("{}.cbrt()", Sugg::hir(cx, receiver, "..").maybe_par()),
263+
format!("{}.cbrt()", Sugg::hir(cx, receiver, "..").maybe_paren()),
264264
)
265265
} else if let Some(exponent) = get_integer_from_float_constant(&value) {
266266
(
267267
SUBOPTIMAL_FLOPS,
268268
"exponentiation with integer powers can be computed more efficiently",
269269
format!(
270270
"{}.powi({})",
271-
Sugg::hir(cx, receiver, "..").maybe_par(),
271+
Sugg::hir(cx, receiver, "..").maybe_paren(),
272272
numeric_literal::format(&exponent.to_string(), None, false)
273273
),
274274
)
@@ -330,7 +330,7 @@ fn check_powi(cx: &LateContext<'_>, expr: &Expr<'_>, receiver: &Expr<'_>, args:
330330
"consider using",
331331
format!(
332332
"{}.mul_add({}, {})",
333-
Sugg::hir(cx, receiver, "..").maybe_par(),
333+
Sugg::hir(cx, receiver, "..").maybe_paren(),
334334
maybe_neg_sugg(receiver, expr.hir_id),
335335
maybe_neg_sugg(other_addend, other_addend.hir_id),
336336
),
@@ -371,7 +371,7 @@ fn detect_hypot(cx: &LateContext<'_>, receiver: &Expr<'_>) -> Option<String> {
371371
{
372372
return Some(format!(
373373
"{}.hypot({})",
374-
Sugg::hir(cx, lmul_lhs, "..").maybe_par(),
374+
Sugg::hir(cx, lmul_lhs, "..").maybe_paren(),
375375
Sugg::hir(cx, rmul_lhs, "..")
376376
));
377377
}
@@ -403,7 +403,7 @@ fn detect_hypot(cx: &LateContext<'_>, receiver: &Expr<'_>) -> Option<String> {
403403
{
404404
return Some(format!(
405405
"{}.hypot({})",
406-
Sugg::hir(cx, largs_0, "..").maybe_par(),
406+
Sugg::hir(cx, largs_0, "..").maybe_paren(),
407407
Sugg::hir(cx, rargs_0, "..")
408408
));
409409
}
@@ -449,7 +449,7 @@ fn check_expm1(cx: &LateContext<'_>, expr: &Expr<'_>) {
449449
expr.span,
450450
"(e.pow(x) - 1) can be computed more accurately",
451451
"consider using",
452-
format!("{}.exp_m1()", Sugg::hir(cx, self_arg, "..").maybe_par()),
452+
format!("{}.exp_m1()", Sugg::hir(cx, self_arg, "..").maybe_paren()),
453453
Applicability::MachineApplicable,
454454
);
455455
}
@@ -591,11 +591,11 @@ fn check_custom_abs(cx: &LateContext<'_>, expr: &Expr<'_>) {
591591
{
592592
let positive_abs_sugg = (
593593
"manual implementation of `abs` method",
594-
format!("{}.abs()", Sugg::hir(cx, body, "..").maybe_par()),
594+
format!("{}.abs()", Sugg::hir(cx, body, "..").maybe_paren()),
595595
);
596596
let negative_abs_sugg = (
597597
"manual implementation of negation of `abs` method",
598-
format!("-{}.abs()", Sugg::hir(cx, body, "..").maybe_par()),
598+
format!("-{}.abs()", Sugg::hir(cx, body, "..").maybe_paren()),
599599
);
600600
let sugg = if is_testing_positive(cx, cond, body) {
601601
if if_expr_positive {
@@ -672,7 +672,7 @@ fn check_log_division(cx: &LateContext<'_>, expr: &Expr<'_>) {
672672
"consider using",
673673
format!(
674674
"{}.log({})",
675-
Sugg::hir(cx, largs_self, "..").maybe_par(),
675+
Sugg::hir(cx, largs_self, "..").maybe_paren(),
676676
Sugg::hir(cx, rargs_self, ".."),
677677
),
678678
Applicability::MachineApplicable,
@@ -703,7 +703,7 @@ fn check_radians(cx: &LateContext<'_>, expr: &Expr<'_>) {
703703
if (F32(f32_consts::PI) == rvalue || F64(f64_consts::PI) == rvalue)
704704
&& (F32(180_f32) == lvalue || F64(180_f64) == lvalue)
705705
{
706-
let mut proposal = format!("{}.to_degrees()", Sugg::hir(cx, mul_lhs, "..").maybe_par());
706+
let mut proposal = format!("{}.to_degrees()", Sugg::hir(cx, mul_lhs, "..").maybe_paren());
707707
if let ExprKind::Lit(literal) = mul_lhs.kind
708708
&& let ast::LitKind::Float(ref value, float_type) = literal.node
709709
&& float_type == ast::LitFloatType::Unsuffixed
@@ -726,7 +726,7 @@ fn check_radians(cx: &LateContext<'_>, expr: &Expr<'_>) {
726726
} else if (F32(180_f32) == rvalue || F64(180_f64) == rvalue)
727727
&& (F32(f32_consts::PI) == lvalue || F64(f64_consts::PI) == lvalue)
728728
{
729-
let mut proposal = format!("{}.to_radians()", Sugg::hir(cx, mul_lhs, "..").maybe_par());
729+
let mut proposal = format!("{}.to_radians()", Sugg::hir(cx, mul_lhs, "..").maybe_paren());
730730
if let ExprKind::Lit(literal) = mul_lhs.kind
731731
&& let ast::LitKind::Float(ref value, float_type) = literal.node
732732
&& float_type == ast::LitFloatType::Unsuffixed

clippy_lints/src/format.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ impl<'tcx> LateLintPass<'tcx> for UselessFormat {
9494
.into_owned()
9595
} else {
9696
let sugg = Sugg::hir_with_context(cx, value, call_site.ctxt(), "<arg>", &mut applicability);
97-
format!("{}.to_string()", sugg.maybe_par())
97+
format!("{}.to_string()", sugg.maybe_paren())
9898
};
9999
span_useless_format(cx, call_site, sugg, applicability);
100100
}

0 commit comments

Comments
 (0)