Skip to content

Commit 79b73ac

Browse files
authored
Rollup merge of rust-lang#89963 - r00ster91:parenthesisparentheses, r=nagisa
Some "parenthesis" and "parentheses" fixes "Parenthesis" is the singular (e.g. one `(` or one `)`) and "parentheses" is the plural (multiple `(` or `)`s) and this is not hard to mix up so here are some fixes for that. Inspired by rust-lang#89958
2 parents 0a23fff + 599d912 commit 79b73ac

File tree

6 files changed

+10
-10
lines changed

6 files changed

+10
-10
lines changed

clippy_lints/src/manual_unwrap_or.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ fn lint_manual_unwrap_or<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
9898
reindent_multiline(or_body_snippet.into(), true, Some(indent));
9999

100100
let suggestion = if scrutinee.span.from_expansion() {
101-
// we don't want parenthesis around macro, e.g. `(some_macro!()).unwrap_or(0)`
101+
// we don't want parentheses around macro, e.g. `(some_macro!()).unwrap_or(0)`
102102
sugg::Sugg::hir_with_macro_callsite(cx, scrutinee, "..")
103103
}
104104
else {

clippy_utils/src/sugg.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ use std::convert::TryInto;
1616
use std::fmt::Display;
1717
use std::ops::{Add, Neg, Not, Sub};
1818

19-
/// A helper type to build suggestion correctly handling parenthesis.
19+
/// A helper type to build suggestion correctly handling parentheses.
2020
#[derive(Clone, PartialEq)]
2121
pub enum Sugg<'a> {
22-
/// An expression that never needs parenthesis such as `1337` or `[0; 42]`.
22+
/// An expression that never needs parentheses such as `1337` or `[0; 42]`.
2323
NonParen(Cow<'a, str>),
2424
/// An expression that does not fit in other variants.
2525
MaybeParen(Cow<'a, str>),
@@ -283,7 +283,7 @@ impl<'a> Sugg<'a> {
283283
}
284284
}
285285

286-
/// Adds parenthesis to any expression that might need them. Suitable to the
286+
/// Adds parentheses to any expression that might need them. Suitable to the
287287
/// `self` argument of a method call
288288
/// (e.g., to build `bar.foo()` or `(1 + 2).foo()`).
289289
pub fn maybe_par(self) -> Self {

tests/ui/manual_unwrap_or.fixed

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ fn result_unwrap_or() {
7474
let a = Ok::<i32, &str>(1);
7575
a.unwrap_or(42);
7676

77-
// int case, suggestion must surround Result expr with parenthesis
77+
// int case, suggestion must surround Result expr with parentheses
7878
(Ok(1) as Result<i32, &str>).unwrap_or(42);
7979

80-
// method call case, suggestion must not surround Result expr `s.method()` with parenthesis
80+
// method call case, suggestion must not surround Result expr `s.method()` with parentheses
8181
struct S {}
8282
impl S {
8383
fn method(self) -> Option<i32> {

tests/ui/manual_unwrap_or.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,13 @@ fn result_unwrap_or() {
9595
Err(_) => 42,
9696
};
9797

98-
// int case, suggestion must surround Result expr with parenthesis
98+
// int case, suggestion must surround Result expr with parentheses
9999
match Ok(1) as Result<i32, &str> {
100100
Ok(i) => i,
101101
Err(_) => 42,
102102
};
103103

104-
// method call case, suggestion must not surround Result expr `s.method()` with parenthesis
104+
// method call case, suggestion must not surround Result expr `s.method()` with parentheses
105105
struct S {}
106106
impl S {
107107
fn method(self) -> Option<i32> {

tests/ui/useless_conversion.fixed

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ fn main() {
6666
let _ = vec![1, 2, 3].into_iter();
6767
let _: String = format!("Hello {}", "world");
6868

69-
// keep parenthesis around `a + b` for suggestion (see #4750)
69+
// keep parentheses around `a + b` for suggestion (see #4750)
7070
let a: i32 = 1;
7171
let b: i32 = 1;
7272
let _ = (a + b) * 3;

tests/ui/useless_conversion.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ fn main() {
6666
let _ = vec![1, 2, 3].into_iter().into_iter();
6767
let _: String = format!("Hello {}", "world").into();
6868

69-
// keep parenthesis around `a + b` for suggestion (see #4750)
69+
// keep parentheses around `a + b` for suggestion (see #4750)
7070
let a: i32 = 1;
7171
let b: i32 = 1;
7272
let _ = i32::from(a + b) * 3;

0 commit comments

Comments
 (0)