From 3c1d55422a695204b70cbd23da582e3ab770a53c Mon Sep 17 00:00:00 2001 From: r00ster91 Date: Sun, 17 Oct 2021 12:04:01 +0200 Subject: [PATCH] Some "parenthesis" and "parentheses" fixes --- compiler/rustc_ast/src/util/parser.rs | 4 +- .../rustc_ast_passes/src/ast_validation.rs | 2 +- compiler/rustc_ast_pretty/src/pprust/state.rs | 2 +- compiler/rustc_hir_pretty/src/lib.rs | 2 +- compiler/rustc_lint/src/unused.rs | 2 +- .../rustc_parse/src/parser/diagnostics.rs | 4 +- compiler/rustc_parse/src/parser/mod.rs | 2 +- compiler/rustc_parse/src/parser/stmt.rs | 4 +- compiler/rustc_parse/src/parser/ty.rs | 2 +- .../rustc_resolve/src/late/diagnostics.rs | 2 +- compiler/rustc_typeck/src/check/callee.rs | 4 +- compiler/rustc_typeck/src/check/op.rs | 2 +- src/librustdoc/clean/auto_trait.rs | 2 +- .../ui/empty/empty-struct-unit-expr.stderr | 4 +- src/test/ui/error-codes/E0618.stderr | 2 +- .../let-else/let-else-bool-binop-init.stderr | 4 +- .../let-else-brace-before-else.stderr | 8 +- .../recover-for-loop-parens-around-head.rs | 2 +- ...recover-for-loop-parens-around-head.stderr | 4 +- ...67037-pat-tup-scrut-ty-diff-less-fields.rs | 2 +- src/test/ui/resolve/privacy-enum-ctor.stderr | 6 +- .../disallowed-positions.stderr | 110 +++++++++--------- .../suggest-on-bare-closure-call.stderr | 2 +- ...t-variant-form-through-alias-caught.stderr | 2 +- .../clippy_lints/src/manual_unwrap_or.rs | 2 +- src/tools/clippy/clippy_utils/src/sugg.rs | 6 +- .../clippy/tests/ui/manual_unwrap_or.fixed | 4 +- src/tools/clippy/tests/ui/manual_unwrap_or.rs | 4 +- .../clippy/tests/ui/useless_conversion.fixed | 2 +- .../clippy/tests/ui/useless_conversion.rs | 2 +- 30 files changed, 100 insertions(+), 100 deletions(-) diff --git a/compiler/rustc_ast/src/util/parser.rs b/compiler/rustc_ast/src/util/parser.rs index 078dd4bd6e6..500c97e65ef 100644 --- a/compiler/rustc_ast/src/util/parser.rs +++ b/compiler/rustc_ast/src/util/parser.rs @@ -357,13 +357,13 @@ impl ExprPrecedence { } } -/// In `let p = e`, operators with precedence `<=` this one requires parenthesis in `e`. +/// In `let p = e`, operators with precedence `<=` this one requires parentheses in `e`. pub fn prec_let_scrutinee_needs_par() -> usize { AssocOp::LAnd.precedence() } /// Suppose we have `let _ = e` and the `order` of `e`. -/// Is the `order` such that `e` in `let _ = e` needs parenthesis when it is on the RHS? +/// Is the `order` such that `e` in `let _ = e` needs parentheses when it is on the RHS? /// /// Conversely, suppose that we have `(let _ = a) OP b` and `order` is that of `OP`. /// Can we print this as `let _ = a OP b`? diff --git a/compiler/rustc_ast_passes/src/ast_validation.rs b/compiler/rustc_ast_passes/src/ast_validation.rs index 968e9fa3e24..793f6504be6 100644 --- a/compiler/rustc_ast_passes/src/ast_validation.rs +++ b/compiler/rustc_ast_passes/src/ast_validation.rs @@ -113,7 +113,7 @@ impl<'a> AstValidator<'a> { if sess.opts.unstable_features.is_nightly_build() { sess.struct_span_err(expr.span, "`let` expressions are not supported here") .note("only supported directly in conditions of `if`- and `while`-expressions") - .note("as well as when nested within `&&` and parenthesis in those conditions") + .note("as well as when nested within `&&` and parentheses in those conditions") .emit(); } else { sess.struct_span_err(expr.span, "expected expression, found statement (`let`)") diff --git a/compiler/rustc_ast_pretty/src/pprust/state.rs b/compiler/rustc_ast_pretty/src/pprust/state.rs index c24882086e1..6d0589b7ba1 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state.rs @@ -1675,7 +1675,7 @@ impl<'a> State<'a> { self.print_expr_cond_paren(expr, Self::cond_needs_par(expr)) } - // Does `expr` need parenthesis when printed in a condition position? + // Does `expr` need parentheses when printed in a condition position? // // These cases need parens due to the parse error observed in #26461: `if return {}` // parses as the erroneous construct `if (return {})`, not `if (return) {}`. diff --git a/compiler/rustc_hir_pretty/src/lib.rs b/compiler/rustc_hir_pretty/src/lib.rs index 9196344cb3f..532f1582970 100644 --- a/compiler/rustc_hir_pretty/src/lib.rs +++ b/compiler/rustc_hir_pretty/src/lib.rs @@ -1168,7 +1168,7 @@ impl<'a> State<'a> { self.print_expr_cond_paren(expr, Self::cond_needs_par(expr) || npals()) } - // Does `expr` need parenthesis when printed in a condition position? + // Does `expr` need parentheses when printed in a condition position? // // These cases need parens due to the parse error observed in #26461: `if return {}` // parses as the erroneous construct `if (return {})`, not `if (return) {}`. diff --git a/compiler/rustc_lint/src/unused.rs b/compiler/rustc_lint/src/unused.rs index 48b955e41ac..da1edcf6fe3 100644 --- a/compiler/rustc_lint/src/unused.rs +++ b/compiler/rustc_lint/src/unused.rs @@ -670,7 +670,7 @@ declare_lint! { /// /// ### Explanation /// - /// The parenthesis are not needed, and should be removed. This is the + /// The parentheses are not needed, and should be removed. This is the /// preferred style for writing these expressions. pub(super) UNUSED_PARENS, Warn, diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs index 8095f386fa3..81328e09156 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -1342,10 +1342,10 @@ impl<'a> Parser<'a> { self.struct_span_err( MultiSpan::from_spans(vec![begin_par_sp, self.prev_token.span]), - "unexpected parenthesis surrounding `for` loop head", + "unexpected parentheses surrounding `for` loop head", ) .multipart_suggestion( - "remove parenthesis in `for` loop", + "remove parentheses in `for` loop", vec![(begin_par_sp, String::new()), (self.prev_token.span, String::new())], // With e.g. `for (x) in y)` this would replace `(x) in y)` // with `x) in y)` which is syntactically invalid. diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs index 5c701fefd17..e50b983ec62 100644 --- a/compiler/rustc_parse/src/parser/mod.rs +++ b/compiler/rustc_parse/src/parser/mod.rs @@ -1258,7 +1258,7 @@ impl<'a> Parser<'a> { /// Parses `pub`, `pub(crate)` and `pub(in path)` plus shortcuts `crate` for `pub(crate)`, /// `pub(self)` for `pub(in self)` and `pub(super)` for `pub(in super)`. /// If the following element can't be a tuple (i.e., it's a function definition), then - /// it's not a tuple struct field), and the contents within the parentheses isn't valid, + /// it's not a tuple struct field), and the contents within the parentheses aren't valid, /// so emit a proper diagnostic. // Public for rustfmt usage. pub fn parse_visibility(&mut self, fbt: FollowedByType) -> PResult<'a, Visibility> { diff --git a/compiler/rustc_parse/src/parser/stmt.rs b/compiler/rustc_parse/src/parser/stmt.rs index 9ec6effeb4e..c4569c07db4 100644 --- a/compiler/rustc_parse/src/parser/stmt.rs +++ b/compiler/rustc_parse/src/parser/stmt.rs @@ -328,7 +328,7 @@ impl<'a> Parser<'a> { ), ) .multipart_suggestion( - "wrap the expression in parenthesis", + "wrap the expression in parentheses", suggs, Applicability::MachineApplicable, ) @@ -349,7 +349,7 @@ impl<'a> Parser<'a> { "right curly brace `}` before `else` in a `let...else` statement not allowed", ) .multipart_suggestion( - "try wrapping the expression in parenthesis", + "try wrapping the expression in parentheses", suggs, Applicability::MachineApplicable, ) diff --git a/compiler/rustc_parse/src/parser/ty.rs b/compiler/rustc_parse/src/parser/ty.rs index 98400372c36..c4c0c17addf 100644 --- a/compiler/rustc_parse/src/parser/ty.rs +++ b/compiler/rustc_parse/src/parser/ty.rs @@ -430,7 +430,7 @@ impl<'a> Parser<'a> { } // Parses the `typeof(EXPR)`. - // To avoid ambiguity, the type is surrounded by parenthesis. + // To avoid ambiguity, the type is surrounded by parentheses. fn parse_typeof_ty(&mut self) -> PResult<'a, TyKind> { self.expect(&token::OpenDelim(token::Paren))?; let expr = self.parse_anon_const_expr()?; diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index 7b0dd82f0e6..1748a9be8e1 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -1552,7 +1552,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> { matches!(source, PathSource::TupleStruct(..)) || source.is_call(); if suggest_only_tuple_variants { // Suggest only tuple variants regardless of whether they have fields and do not - // suggest path with added parenthesis. + // suggest path with added parentheses. let mut suggestable_variants = variants .iter() .filter(|(.., kind)| *kind == CtorKind::Fn) diff --git a/compiler/rustc_typeck/src/check/callee.rs b/compiler/rustc_typeck/src/check/callee.rs index 06c42098791..5d22e300774 100644 --- a/compiler/rustc_typeck/src/check/callee.rs +++ b/compiler/rustc_typeck/src/check/callee.rs @@ -300,7 +300,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let end = callee_span.shrink_to_hi(); err.multipart_suggestion( "if you meant to create this closure and immediately call it, surround the \ - closure with parenthesis", + closure with parentheses", vec![(start, "(".to_string()), (end, ")".to_string())], Applicability::MaybeIncorrect, ); @@ -383,7 +383,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { call_expr.span, &format!( "`{}` is a unit variant, you need to write it \ - without the parenthesis", + without the parentheses", path ), path.to_string(), diff --git a/compiler/rustc_typeck/src/check/op.rs b/compiler/rustc_typeck/src/check/op.rs index 79e004a47db..1bbdf910e42 100644 --- a/compiler/rustc_typeck/src/check/op.rs +++ b/compiler/rustc_typeck/src/check/op.rs @@ -492,7 +492,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { other_ty: Ty<'tcx>, op: hir::BinOp, is_assign: IsAssign, - ) -> bool /* did we suggest to call a function because of missing parenthesis? */ { + ) -> bool /* did we suggest to call a function because of missing parentheses? */ { err.span_label(span, ty.to_string()); if let FnDef(def_id, _) = *ty.kind() { let source_map = self.tcx.sess.source_map(); diff --git a/src/librustdoc/clean/auto_trait.rs b/src/librustdoc/clean/auto_trait.rs index f9d16669771..05817e1b1d9 100644 --- a/src/librustdoc/clean/auto_trait.rs +++ b/src/librustdoc/clean/auto_trait.rs @@ -576,7 +576,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> { rhs, }); continue; // If something other than a Fn ends up - // with parenthesis, leave it alone + // with parentheses, leave it alone } } diff --git a/src/test/ui/empty/empty-struct-unit-expr.stderr b/src/test/ui/empty/empty-struct-unit-expr.stderr index 1023950639a..26bfc4355fa 100644 --- a/src/test/ui/empty/empty-struct-unit-expr.stderr +++ b/src/test/ui/empty/empty-struct-unit-expr.stderr @@ -20,7 +20,7 @@ LL | let e4 = E::Empty4(); | | | call expression requires function | -help: `E::Empty4` is a unit variant, you need to write it without the parenthesis +help: `E::Empty4` is a unit variant, you need to write it without the parentheses | LL | let e4 = E::Empty4; | ~~~~~~~~~ @@ -41,7 +41,7 @@ LL | let xe4 = XE::XEmpty4(); | | | call expression requires function | -help: `XE::XEmpty4` is a unit variant, you need to write it without the parenthesis +help: `XE::XEmpty4` is a unit variant, you need to write it without the parentheses | LL | let xe4 = XE::XEmpty4; | ~~~~~~~~~~~ diff --git a/src/test/ui/error-codes/E0618.stderr b/src/test/ui/error-codes/E0618.stderr index 19a1a8e20cc..db1b3f09837 100644 --- a/src/test/ui/error-codes/E0618.stderr +++ b/src/test/ui/error-codes/E0618.stderr @@ -9,7 +9,7 @@ LL | X::Entry(); | | | call expression requires function | -help: `X::Entry` is a unit variant, you need to write it without the parenthesis +help: `X::Entry` is a unit variant, you need to write it without the parentheses | LL | X::Entry; | ~~~~~~~~ diff --git a/src/test/ui/let-else/let-else-bool-binop-init.stderr b/src/test/ui/let-else/let-else-bool-binop-init.stderr index 6551e24cc83..edee6576244 100644 --- a/src/test/ui/let-else/let-else-bool-binop-init.stderr +++ b/src/test/ui/let-else/let-else-bool-binop-init.stderr @@ -4,7 +4,7 @@ error: a `&&` expression cannot be directly assigned in `let...else` LL | let true = true && false else { return }; | ^^^^^^^^^^^^^ | -help: wrap the expression in parenthesis +help: wrap the expression in parentheses | LL | let true = (true && false) else { return }; | + + @@ -15,7 +15,7 @@ error: a `||` expression cannot be directly assigned in `let...else` LL | let true = true || false else { return }; | ^^^^^^^^^^^^^ | -help: wrap the expression in parenthesis +help: wrap the expression in parentheses | LL | let true = (true || false) else { return }; | + + diff --git a/src/test/ui/let-else/let-else-brace-before-else.stderr b/src/test/ui/let-else/let-else-brace-before-else.stderr index eac029c848b..51051bbd4d8 100644 --- a/src/test/ui/let-else/let-else-brace-before-else.stderr +++ b/src/test/ui/let-else/let-else-brace-before-else.stderr @@ -4,7 +4,7 @@ error: right curly brace `}` before `else` in a `let...else` statement not allow LL | let Some(1) = { Some(1) } else { | ^ | -help: try wrapping the expression in parenthesis +help: try wrapping the expression in parentheses | LL | let Some(1) = ({ Some(1) }) else { | + + @@ -15,7 +15,7 @@ error: right curly brace `}` before `else` in a `let...else` statement not allow LL | let Some(1) = loop { break Some(1) } else { | ^ | -help: try wrapping the expression in parenthesis +help: try wrapping the expression in parentheses | LL | let Some(1) = (loop { break Some(1) }) else { | + + @@ -26,7 +26,7 @@ error: right curly brace `}` before `else` in a `let...else` statement not allow LL | let 2 = 1 + match 1 { n => n } else { | ^ | -help: try wrapping the expression in parenthesis +help: try wrapping the expression in parentheses | LL | let 2 = 1 + (match 1 { n => n }) else { | + + @@ -37,7 +37,7 @@ error: right curly brace `}` before `else` in a `let...else` statement not allow LL | let Some(1) = unsafe { unsafe_fn() } else { | ^ | -help: try wrapping the expression in parenthesis +help: try wrapping the expression in parentheses | LL | let Some(1) = (unsafe { unsafe_fn() }) else { | + + diff --git a/src/test/ui/parser/recover-for-loop-parens-around-head.rs b/src/test/ui/parser/recover-for-loop-parens-around-head.rs index 8080dbc332a..053b428bd12 100644 --- a/src/test/ui/parser/recover-for-loop-parens-around-head.rs +++ b/src/test/ui/parser/recover-for-loop-parens-around-head.rs @@ -9,7 +9,7 @@ fn main() { for ( elem in vec ) { //~^ ERROR expected one of `)`, `,`, `@`, or `|`, found keyword `in` - //~| ERROR unexpected parenthesis surrounding `for` loop head + //~| ERROR unexpected parentheses surrounding `for` loop head const RECOVERY_WITNESS: () = 0; //~ ERROR mismatched types } } diff --git a/src/test/ui/parser/recover-for-loop-parens-around-head.stderr b/src/test/ui/parser/recover-for-loop-parens-around-head.stderr index 21991348327..fa55970dbd1 100644 --- a/src/test/ui/parser/recover-for-loop-parens-around-head.stderr +++ b/src/test/ui/parser/recover-for-loop-parens-around-head.stderr @@ -4,13 +4,13 @@ error: expected one of `)`, `,`, `@`, or `|`, found keyword `in` LL | for ( elem in vec ) { | ^^ expected one of `)`, `,`, `@`, or `|` -error: unexpected parenthesis surrounding `for` loop head +error: unexpected parentheses surrounding `for` loop head --> $DIR/recover-for-loop-parens-around-head.rs:10:9 | LL | for ( elem in vec ) { | ^ ^ | -help: remove parenthesis in `for` loop +help: remove parentheses in `for` loop | LL - for ( elem in vec ) { LL + for elem in vec { diff --git a/src/test/ui/pattern/issue-67037-pat-tup-scrut-ty-diff-less-fields.rs b/src/test/ui/pattern/issue-67037-pat-tup-scrut-ty-diff-less-fields.rs index a3023ee906d..ae28c140375 100644 --- a/src/test/ui/pattern/issue-67037-pat-tup-scrut-ty-diff-less-fields.rs +++ b/src/test/ui/pattern/issue-67037-pat-tup-scrut-ty-diff-less-fields.rs @@ -5,7 +5,7 @@ // the tuple struct pattern, has 0 fields, but requires 1 field. // // In emitting E0023, we try to see if this is a case of e.g., `Some(a, b, c)` but where -// the scrutinee was of type `Some((a, b, c))`, and suggest that parenthesis be added. +// the scrutinee was of type `Some((a, b, c))`, and suggest that parentheses be added. // // However, we did not account for the expected type being different than the tuple pattern type. // This caused an issue when the tuple pattern type (`P`) was generic. diff --git a/src/test/ui/resolve/privacy-enum-ctor.stderr b/src/test/ui/resolve/privacy-enum-ctor.stderr index ff72b0b563a..06c52befd52 100644 --- a/src/test/ui/resolve/privacy-enum-ctor.stderr +++ b/src/test/ui/resolve/privacy-enum-ctor.stderr @@ -338,7 +338,7 @@ LL | let _ = Z::Unit(); | | | call expression requires function | -help: `Z::Unit` is a unit variant, you need to write it without the parenthesis +help: `Z::Unit` is a unit variant, you need to write it without the parentheses | LL | let _ = Z::Unit; | ~~~~~~~ @@ -372,7 +372,7 @@ LL | let _: E = m::E::Unit(); | | | call expression requires function | -help: `m::E::Unit` is a unit variant, you need to write it without the parenthesis +help: `m::E::Unit` is a unit variant, you need to write it without the parentheses | LL | let _: E = m::E::Unit; | ~~~~~~~~~~ @@ -406,7 +406,7 @@ LL | let _: E = E::Unit(); | | | call expression requires function | -help: `E::Unit` is a unit variant, you need to write it without the parenthesis +help: `E::Unit` is a unit variant, you need to write it without the parentheses | LL | let _: E = E::Unit; | ~~~~~~~ diff --git a/src/test/ui/rfc-2497-if-let-chains/disallowed-positions.stderr b/src/test/ui/rfc-2497-if-let-chains/disallowed-positions.stderr index 5ec4352919e..513b473c4de 100644 --- a/src/test/ui/rfc-2497-if-let-chains/disallowed-positions.stderr +++ b/src/test/ui/rfc-2497-if-let-chains/disallowed-positions.stderr @@ -16,7 +16,7 @@ LL | if &let 0 = 0 {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if`- and `while`-expressions - = note: as well as when nested within `&&` and parenthesis in those conditions + = note: as well as when nested within `&&` and parentheses in those conditions error: `let` expressions are not supported here --> $DIR/disallowed-positions.rs:33:9 @@ -25,7 +25,7 @@ LL | if !let 0 = 0 {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if`- and `while`-expressions - = note: as well as when nested within `&&` and parenthesis in those conditions + = note: as well as when nested within `&&` and parentheses in those conditions error: `let` expressions are not supported here --> $DIR/disallowed-positions.rs:34:9 @@ -34,7 +34,7 @@ LL | if *let 0 = 0 {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if`- and `while`-expressions - = note: as well as when nested within `&&` and parenthesis in those conditions + = note: as well as when nested within `&&` and parentheses in those conditions error: `let` expressions are not supported here --> $DIR/disallowed-positions.rs:36:9 @@ -43,7 +43,7 @@ LL | if -let 0 = 0 {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if`- and `while`-expressions - = note: as well as when nested within `&&` and parenthesis in those conditions + = note: as well as when nested within `&&` and parentheses in those conditions error: `let` expressions are not supported here --> $DIR/disallowed-positions.rs:44:9 @@ -52,7 +52,7 @@ LL | if (let 0 = 0)? {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if`- and `while`-expressions - = note: as well as when nested within `&&` and parenthesis in those conditions + = note: as well as when nested within `&&` and parentheses in those conditions error: `let` expressions are not supported here --> $DIR/disallowed-positions.rs:48:16 @@ -61,7 +61,7 @@ LL | if true || let 0 = 0 {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if`- and `while`-expressions - = note: as well as when nested within `&&` and parenthesis in those conditions + = note: as well as when nested within `&&` and parentheses in those conditions error: `let` expressions are not supported here --> $DIR/disallowed-positions.rs:49:17 @@ -70,7 +70,7 @@ LL | if (true || let 0 = 0) {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if`- and `while`-expressions - = note: as well as when nested within `&&` and parenthesis in those conditions + = note: as well as when nested within `&&` and parentheses in those conditions error: `let` expressions are not supported here --> $DIR/disallowed-positions.rs:50:25 @@ -79,7 +79,7 @@ LL | if true && (true || let 0 = 0) {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if`- and `while`-expressions - = note: as well as when nested within `&&` and parenthesis in those conditions + = note: as well as when nested within `&&` and parentheses in those conditions error: `let` expressions are not supported here --> $DIR/disallowed-positions.rs:51:25 @@ -88,7 +88,7 @@ LL | if true || (true && let 0 = 0) {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if`- and `while`-expressions - = note: as well as when nested within `&&` and parenthesis in those conditions + = note: as well as when nested within `&&` and parentheses in those conditions error: `let` expressions are not supported here --> $DIR/disallowed-positions.rs:54:12 @@ -97,7 +97,7 @@ LL | if x = let 0 = 0 {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if`- and `while`-expressions - = note: as well as when nested within `&&` and parenthesis in those conditions + = note: as well as when nested within `&&` and parentheses in those conditions error: `let` expressions are not supported here --> $DIR/disallowed-positions.rs:57:15 @@ -106,7 +106,7 @@ LL | if true..(let 0 = 0) {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if`- and `while`-expressions - = note: as well as when nested within `&&` and parenthesis in those conditions + = note: as well as when nested within `&&` and parentheses in those conditions error: `let` expressions are not supported here --> $DIR/disallowed-positions.rs:59:11 @@ -115,7 +115,7 @@ LL | if ..(let 0 = 0) {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if`- and `while`-expressions - = note: as well as when nested within `&&` and parenthesis in those conditions + = note: as well as when nested within `&&` and parentheses in those conditions error: `let` expressions are not supported here --> $DIR/disallowed-positions.rs:61:9 @@ -124,7 +124,7 @@ LL | if (let 0 = 0).. {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if`- and `while`-expressions - = note: as well as when nested within `&&` and parenthesis in those conditions + = note: as well as when nested within `&&` and parentheses in those conditions error: `let` expressions are not supported here --> $DIR/disallowed-positions.rs:65:8 @@ -133,7 +133,7 @@ LL | if let Range { start: _, end: _ } = true..true && false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: only supported directly in conditions of `if`- and `while`-expressions - = note: as well as when nested within `&&` and parenthesis in those conditions + = note: as well as when nested within `&&` and parentheses in those conditions error: `let` expressions are not supported here --> $DIR/disallowed-positions.rs:69:8 @@ -142,7 +142,7 @@ LL | if let Range { start: _, end: _ } = true..true || false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: only supported directly in conditions of `if`- and `while`-expressions - = note: as well as when nested within `&&` and parenthesis in those conditions + = note: as well as when nested within `&&` and parentheses in those conditions error: `let` expressions are not supported here --> $DIR/disallowed-positions.rs:76:8 @@ -151,7 +151,7 @@ LL | if let Range { start: F, end } = F..|| true {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: only supported directly in conditions of `if`- and `while`-expressions - = note: as well as when nested within `&&` and parenthesis in those conditions + = note: as well as when nested within `&&` and parentheses in those conditions error: `let` expressions are not supported here --> $DIR/disallowed-positions.rs:84:8 @@ -160,7 +160,7 @@ LL | if let Range { start: true, end } = t..&&false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: only supported directly in conditions of `if`- and `while`-expressions - = note: as well as when nested within `&&` and parenthesis in those conditions + = note: as well as when nested within `&&` and parentheses in those conditions error: `let` expressions are not supported here --> $DIR/disallowed-positions.rs:90:19 @@ -169,7 +169,7 @@ LL | if let true = let true = true {} | ^^^^^^^^^^^^^^^ | = note: only supported directly in conditions of `if`- and `while`-expressions - = note: as well as when nested within `&&` and parenthesis in those conditions + = note: as well as when nested within `&&` and parentheses in those conditions error: `let` expressions are not supported here --> $DIR/disallowed-positions.rs:94:12 @@ -178,7 +178,7 @@ LL | while &let 0 = 0 {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if`- and `while`-expressions - = note: as well as when nested within `&&` and parenthesis in those conditions + = note: as well as when nested within `&&` and parentheses in those conditions error: `let` expressions are not supported here --> $DIR/disallowed-positions.rs:97:12 @@ -187,7 +187,7 @@ LL | while !let 0 = 0 {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if`- and `while`-expressions - = note: as well as when nested within `&&` and parenthesis in those conditions + = note: as well as when nested within `&&` and parentheses in those conditions error: `let` expressions are not supported here --> $DIR/disallowed-positions.rs:98:12 @@ -196,7 +196,7 @@ LL | while *let 0 = 0 {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if`- and `while`-expressions - = note: as well as when nested within `&&` and parenthesis in those conditions + = note: as well as when nested within `&&` and parentheses in those conditions error: `let` expressions are not supported here --> $DIR/disallowed-positions.rs:100:12 @@ -205,7 +205,7 @@ LL | while -let 0 = 0 {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if`- and `while`-expressions - = note: as well as when nested within `&&` and parenthesis in those conditions + = note: as well as when nested within `&&` and parentheses in those conditions error: `let` expressions are not supported here --> $DIR/disallowed-positions.rs:108:12 @@ -214,7 +214,7 @@ LL | while (let 0 = 0)? {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if`- and `while`-expressions - = note: as well as when nested within `&&` and parenthesis in those conditions + = note: as well as when nested within `&&` and parentheses in those conditions error: `let` expressions are not supported here --> $DIR/disallowed-positions.rs:112:19 @@ -223,7 +223,7 @@ LL | while true || let 0 = 0 {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if`- and `while`-expressions - = note: as well as when nested within `&&` and parenthesis in those conditions + = note: as well as when nested within `&&` and parentheses in those conditions error: `let` expressions are not supported here --> $DIR/disallowed-positions.rs:113:20 @@ -232,7 +232,7 @@ LL | while (true || let 0 = 0) {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if`- and `while`-expressions - = note: as well as when nested within `&&` and parenthesis in those conditions + = note: as well as when nested within `&&` and parentheses in those conditions error: `let` expressions are not supported here --> $DIR/disallowed-positions.rs:114:28 @@ -241,7 +241,7 @@ LL | while true && (true || let 0 = 0) {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if`- and `while`-expressions - = note: as well as when nested within `&&` and parenthesis in those conditions + = note: as well as when nested within `&&` and parentheses in those conditions error: `let` expressions are not supported here --> $DIR/disallowed-positions.rs:115:28 @@ -250,7 +250,7 @@ LL | while true || (true && let 0 = 0) {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if`- and `while`-expressions - = note: as well as when nested within `&&` and parenthesis in those conditions + = note: as well as when nested within `&&` and parentheses in those conditions error: `let` expressions are not supported here --> $DIR/disallowed-positions.rs:118:15 @@ -259,7 +259,7 @@ LL | while x = let 0 = 0 {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if`- and `while`-expressions - = note: as well as when nested within `&&` and parenthesis in those conditions + = note: as well as when nested within `&&` and parentheses in those conditions error: `let` expressions are not supported here --> $DIR/disallowed-positions.rs:121:18 @@ -268,7 +268,7 @@ LL | while true..(let 0 = 0) {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if`- and `while`-expressions - = note: as well as when nested within `&&` and parenthesis in those conditions + = note: as well as when nested within `&&` and parentheses in those conditions error: `let` expressions are not supported here --> $DIR/disallowed-positions.rs:123:14 @@ -277,7 +277,7 @@ LL | while ..(let 0 = 0) {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if`- and `while`-expressions - = note: as well as when nested within `&&` and parenthesis in those conditions + = note: as well as when nested within `&&` and parentheses in those conditions error: `let` expressions are not supported here --> $DIR/disallowed-positions.rs:125:12 @@ -286,7 +286,7 @@ LL | while (let 0 = 0).. {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if`- and `while`-expressions - = note: as well as when nested within `&&` and parenthesis in those conditions + = note: as well as when nested within `&&` and parentheses in those conditions error: `let` expressions are not supported here --> $DIR/disallowed-positions.rs:129:11 @@ -295,7 +295,7 @@ LL | while let Range { start: _, end: _ } = true..true && false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: only supported directly in conditions of `if`- and `while`-expressions - = note: as well as when nested within `&&` and parenthesis in those conditions + = note: as well as when nested within `&&` and parentheses in those conditions error: `let` expressions are not supported here --> $DIR/disallowed-positions.rs:133:11 @@ -304,7 +304,7 @@ LL | while let Range { start: _, end: _ } = true..true || false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: only supported directly in conditions of `if`- and `while`-expressions - = note: as well as when nested within `&&` and parenthesis in those conditions + = note: as well as when nested within `&&` and parentheses in those conditions error: `let` expressions are not supported here --> $DIR/disallowed-positions.rs:140:11 @@ -313,7 +313,7 @@ LL | while let Range { start: F, end } = F..|| true {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: only supported directly in conditions of `if`- and `while`-expressions - = note: as well as when nested within `&&` and parenthesis in those conditions + = note: as well as when nested within `&&` and parentheses in those conditions error: `let` expressions are not supported here --> $DIR/disallowed-positions.rs:148:11 @@ -322,7 +322,7 @@ LL | while let Range { start: true, end } = t..&&false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: only supported directly in conditions of `if`- and `while`-expressions - = note: as well as when nested within `&&` and parenthesis in those conditions + = note: as well as when nested within `&&` and parentheses in those conditions error: `let` expressions are not supported here --> $DIR/disallowed-positions.rs:154:22 @@ -331,7 +331,7 @@ LL | while let true = let true = true {} | ^^^^^^^^^^^^^^^ | = note: only supported directly in conditions of `if`- and `while`-expressions - = note: as well as when nested within `&&` and parenthesis in those conditions + = note: as well as when nested within `&&` and parentheses in those conditions error: `let` expressions are not supported here --> $DIR/disallowed-positions.rs:168:6 @@ -340,7 +340,7 @@ LL | &let 0 = 0; | ^^^^^^^^^ | = note: only supported directly in conditions of `if`- and `while`-expressions - = note: as well as when nested within `&&` and parenthesis in those conditions + = note: as well as when nested within `&&` and parentheses in those conditions error: `let` expressions are not supported here --> $DIR/disallowed-positions.rs:170:6 @@ -349,7 +349,7 @@ LL | !let 0 = 0; | ^^^^^^^^^ | = note: only supported directly in conditions of `if`- and `while`-expressions - = note: as well as when nested within `&&` and parenthesis in those conditions + = note: as well as when nested within `&&` and parentheses in those conditions error: `let` expressions are not supported here --> $DIR/disallowed-positions.rs:171:6 @@ -358,7 +358,7 @@ LL | *let 0 = 0; | ^^^^^^^^^ | = note: only supported directly in conditions of `if`- and `while`-expressions - = note: as well as when nested within `&&` and parenthesis in those conditions + = note: as well as when nested within `&&` and parentheses in those conditions error: `let` expressions are not supported here --> $DIR/disallowed-positions.rs:173:6 @@ -367,7 +367,7 @@ LL | -let 0 = 0; | ^^^^^^^^^ | = note: only supported directly in conditions of `if`- and `while`-expressions - = note: as well as when nested within `&&` and parenthesis in those conditions + = note: as well as when nested within `&&` and parentheses in those conditions error: `let` expressions are not supported here --> $DIR/disallowed-positions.rs:181:6 @@ -376,7 +376,7 @@ LL | (let 0 = 0)?; | ^^^^^^^^^ | = note: only supported directly in conditions of `if`- and `while`-expressions - = note: as well as when nested within `&&` and parenthesis in those conditions + = note: as well as when nested within `&&` and parentheses in those conditions error: `let` expressions are not supported here --> $DIR/disallowed-positions.rs:185:13 @@ -385,7 +385,7 @@ LL | true || let 0 = 0; | ^^^^^^^^^ | = note: only supported directly in conditions of `if`- and `while`-expressions - = note: as well as when nested within `&&` and parenthesis in those conditions + = note: as well as when nested within `&&` and parentheses in those conditions error: `let` expressions are not supported here --> $DIR/disallowed-positions.rs:186:14 @@ -394,7 +394,7 @@ LL | (true || let 0 = 0); | ^^^^^^^^^ | = note: only supported directly in conditions of `if`- and `while`-expressions - = note: as well as when nested within `&&` and parenthesis in those conditions + = note: as well as when nested within `&&` and parentheses in those conditions error: `let` expressions are not supported here --> $DIR/disallowed-positions.rs:187:22 @@ -403,7 +403,7 @@ LL | true && (true || let 0 = 0); | ^^^^^^^^^ | = note: only supported directly in conditions of `if`- and `while`-expressions - = note: as well as when nested within `&&` and parenthesis in those conditions + = note: as well as when nested within `&&` and parentheses in those conditions error: `let` expressions are not supported here --> $DIR/disallowed-positions.rs:190:9 @@ -412,7 +412,7 @@ LL | x = let 0 = 0; | ^^^^^^^^^ | = note: only supported directly in conditions of `if`- and `while`-expressions - = note: as well as when nested within `&&` and parenthesis in those conditions + = note: as well as when nested within `&&` and parentheses in those conditions error: `let` expressions are not supported here --> $DIR/disallowed-positions.rs:192:12 @@ -421,7 +421,7 @@ LL | true..(let 0 = 0); | ^^^^^^^^^ | = note: only supported directly in conditions of `if`- and `while`-expressions - = note: as well as when nested within `&&` and parenthesis in those conditions + = note: as well as when nested within `&&` and parentheses in those conditions error: `let` expressions are not supported here --> $DIR/disallowed-positions.rs:193:8 @@ -430,7 +430,7 @@ LL | ..(let 0 = 0); | ^^^^^^^^^ | = note: only supported directly in conditions of `if`- and `while`-expressions - = note: as well as when nested within `&&` and parenthesis in those conditions + = note: as well as when nested within `&&` and parentheses in those conditions error: `let` expressions are not supported here --> $DIR/disallowed-positions.rs:194:6 @@ -439,7 +439,7 @@ LL | (let 0 = 0)..; | ^^^^^^^^^ | = note: only supported directly in conditions of `if`- and `while`-expressions - = note: as well as when nested within `&&` and parenthesis in those conditions + = note: as well as when nested within `&&` and parentheses in those conditions error: `let` expressions are not supported here --> $DIR/disallowed-positions.rs:196:6 @@ -448,7 +448,7 @@ LL | (let Range { start: _, end: _ } = true..true || false); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: only supported directly in conditions of `if`- and `while`-expressions - = note: as well as when nested within `&&` and parenthesis in those conditions + = note: as well as when nested within `&&` and parentheses in those conditions error: `let` expressions are not supported here --> $DIR/disallowed-positions.rs:200:6 @@ -457,7 +457,7 @@ LL | (let true = let true = true); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: only supported directly in conditions of `if`- and `while`-expressions - = note: as well as when nested within `&&` and parenthesis in those conditions + = note: as well as when nested within `&&` and parentheses in those conditions error: `let` expressions are not supported here --> $DIR/disallowed-positions.rs:204:6 @@ -466,7 +466,7 @@ LL | &let 0 = 0 | ^^^^^^^^^ | = note: only supported directly in conditions of `if`- and `while`-expressions - = note: as well as when nested within `&&` and parenthesis in those conditions + = note: as well as when nested within `&&` and parentheses in those conditions error: `let` expressions are not supported here --> $DIR/disallowed-positions.rs:215:17 @@ -475,7 +475,7 @@ LL | true && let 1 = 1 | ^^^^^^^^^ | = note: only supported directly in conditions of `if`- and `while`-expressions - = note: as well as when nested within `&&` and parenthesis in those conditions + = note: as well as when nested within `&&` and parentheses in those conditions error: `let` expressions are not supported here --> $DIR/disallowed-positions.rs:219:17 @@ -484,7 +484,7 @@ LL | true && let 1 = 1 | ^^^^^^^^^ | = note: only supported directly in conditions of `if`- and `while`-expressions - = note: as well as when nested within `&&` and parenthesis in those conditions + = note: as well as when nested within `&&` and parentheses in those conditions error: `let` expressions are not supported here --> $DIR/disallowed-positions.rs:223:17 @@ -493,7 +493,7 @@ LL | true && let 1 = 1 | ^^^^^^^^^ | = note: only supported directly in conditions of `if`- and `while`-expressions - = note: as well as when nested within `&&` and parenthesis in those conditions + = note: as well as when nested within `&&` and parentheses in those conditions error: `let` expressions are not supported here --> $DIR/disallowed-positions.rs:233:17 @@ -502,7 +502,7 @@ LL | true && let 1 = 1 | ^^^^^^^^^ | = note: only supported directly in conditions of `if`- and `while`-expressions - = note: as well as when nested within `&&` and parenthesis in those conditions + = note: as well as when nested within `&&` and parentheses in those conditions warning: the feature `let_chains` is incomplete and may not be safe to use and/or cause compiler crashes --> $DIR/disallowed-positions.rs:20:12 diff --git a/src/test/ui/suggestions/suggest-on-bare-closure-call.stderr b/src/test/ui/suggestions/suggest-on-bare-closure-call.stderr index 0c91e2feed3..81f2e498fe5 100644 --- a/src/test/ui/suggestions/suggest-on-bare-closure-call.stderr +++ b/src/test/ui/suggestions/suggest-on-bare-closure-call.stderr @@ -6,7 +6,7 @@ LL | let _ = ||{}(); | | | call expression requires function | -help: if you meant to create this closure and immediately call it, surround the closure with parenthesis +help: if you meant to create this closure and immediately call it, surround the closure with parentheses | LL | let _ = (||{})(); | + + diff --git a/src/test/ui/type-alias-enum-variants/incorrect-variant-form-through-alias-caught.stderr b/src/test/ui/type-alias-enum-variants/incorrect-variant-form-through-alias-caught.stderr index 2e12b768f70..e918551020c 100644 --- a/src/test/ui/type-alias-enum-variants/incorrect-variant-form-through-alias-caught.stderr +++ b/src/test/ui/type-alias-enum-variants/incorrect-variant-form-through-alias-caught.stderr @@ -27,7 +27,7 @@ LL | Alias::Unit(); | | | call expression requires function | -help: `Alias::Unit` is a unit variant, you need to write it without the parenthesis +help: `Alias::Unit` is a unit variant, you need to write it without the parentheses | LL | Alias::Unit; | ~~~~~~~~~~~ diff --git a/src/tools/clippy/clippy_lints/src/manual_unwrap_or.rs b/src/tools/clippy/clippy_lints/src/manual_unwrap_or.rs index 2ae9cb4f9c1..42478e3416e 100644 --- a/src/tools/clippy/clippy_lints/src/manual_unwrap_or.rs +++ b/src/tools/clippy/clippy_lints/src/manual_unwrap_or.rs @@ -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 { diff --git a/src/tools/clippy/clippy_utils/src/sugg.rs b/src/tools/clippy/clippy_utils/src/sugg.rs index 5b0efb1fd71..01fb944cc36 100644 --- a/src/tools/clippy/clippy_utils/src/sugg.rs +++ b/src/tools/clippy/clippy_utils/src/sugg.rs @@ -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 { diff --git a/src/tools/clippy/tests/ui/manual_unwrap_or.fixed b/src/tools/clippy/tests/ui/manual_unwrap_or.fixed index 3717f962745..05d6c56f2ac 100644 --- a/src/tools/clippy/tests/ui/manual_unwrap_or.fixed +++ b/src/tools/clippy/tests/ui/manual_unwrap_or.fixed @@ -74,10 +74,10 @@ fn result_unwrap_or() { let a = Ok::(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).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 { diff --git a/src/tools/clippy/tests/ui/manual_unwrap_or.rs b/src/tools/clippy/tests/ui/manual_unwrap_or.rs index 989adde1f5b..09f62c69b71 100644 --- a/src/tools/clippy/tests/ui/manual_unwrap_or.rs +++ b/src/tools/clippy/tests/ui/manual_unwrap_or.rs @@ -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 { 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 { diff --git a/src/tools/clippy/tests/ui/useless_conversion.fixed b/src/tools/clippy/tests/ui/useless_conversion.fixed index 76aa82068d6..70ff08f3655 100644 --- a/src/tools/clippy/tests/ui/useless_conversion.fixed +++ b/src/tools/clippy/tests/ui/useless_conversion.fixed @@ -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; diff --git a/src/tools/clippy/tests/ui/useless_conversion.rs b/src/tools/clippy/tests/ui/useless_conversion.rs index ccee7abb404..f2444a8f436 100644 --- a/src/tools/clippy/tests/ui/useless_conversion.rs +++ b/src/tools/clippy/tests/ui/useless_conversion.rs @@ -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;