Some "parenthesis" and "parentheses" fixes

This commit is contained in:
r00ster91 2021-10-17 12:04:01 +02:00
parent 049ab82662
commit 599d9126a2
6 changed files with 10 additions and 10 deletions

View file

@ -98,7 +98,7 @@ fn lint_manual_unwrap_or<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
reindent_multiline(or_body_snippet.into(), true, Some(indent));
let suggestion = if scrutinee.span.from_expansion() {
// we don't want parenthesis around macro, e.g. `(some_macro!()).unwrap_or(0)`
// we don't want parentheses around macro, e.g. `(some_macro!()).unwrap_or(0)`
sugg::Sugg::hir_with_macro_callsite(cx, scrutinee, "..")
}
else {

View file

@ -16,10 +16,10 @@ use std::convert::TryInto;
use std::fmt::Display;
use std::ops::{Add, Neg, Not, Sub};
/// A helper type to build suggestion correctly handling parenthesis.
/// A helper type to build suggestion correctly handling parentheses.
#[derive(Clone, PartialEq)]
pub enum Sugg<'a> {
/// An expression that never needs parenthesis such as `1337` or `[0; 42]`.
/// An expression that never needs parentheses such as `1337` or `[0; 42]`.
NonParen(Cow<'a, str>),
/// An expression that does not fit in other variants.
MaybeParen(Cow<'a, str>),
@ -283,7 +283,7 @@ impl<'a> Sugg<'a> {
}
}
/// Adds parenthesis to any expression that might need them. Suitable to the
/// Adds parentheses to any expression that might need them. Suitable to the
/// `self` argument of a method call
/// (e.g., to build `bar.foo()` or `(1 + 2).foo()`).
pub fn maybe_par(self) -> Self {

View file

@ -74,10 +74,10 @@ fn result_unwrap_or() {
let a = Ok::<i32, &str>(1);
a.unwrap_or(42);
// int case, suggestion must surround Result expr with parenthesis
// int case, suggestion must surround Result expr with parentheses
(Ok(1) as Result<i32, &str>).unwrap_or(42);
// method call case, suggestion must not surround Result expr `s.method()` with parenthesis
// method call case, suggestion must not surround Result expr `s.method()` with parentheses
struct S {}
impl S {
fn method(self) -> Option<i32> {

View file

@ -95,13 +95,13 @@ fn result_unwrap_or() {
Err(_) => 42,
};
// int case, suggestion must surround Result expr with parenthesis
// int case, suggestion must surround Result expr with parentheses
match Ok(1) as Result<i32, &str> {
Ok(i) => i,
Err(_) => 42,
};
// method call case, suggestion must not surround Result expr `s.method()` with parenthesis
// method call case, suggestion must not surround Result expr `s.method()` with parentheses
struct S {}
impl S {
fn method(self) -> Option<i32> {

View file

@ -66,7 +66,7 @@ fn main() {
let _ = vec![1, 2, 3].into_iter();
let _: String = format!("Hello {}", "world");
// keep parenthesis around `a + b` for suggestion (see #4750)
// keep parentheses around `a + b` for suggestion (see #4750)
let a: i32 = 1;
let b: i32 = 1;
let _ = (a + b) * 3;

View file

@ -66,7 +66,7 @@ fn main() {
let _ = vec![1, 2, 3].into_iter().into_iter();
let _: String = format!("Hello {}", "world").into();
// keep parenthesis around `a + b` for suggestion (see #4750)
// keep parentheses around `a + b` for suggestion (see #4750)
let a: i32 = 1;
let b: i32 = 1;
let _ = i32::from(a + b) * 3;