Skip to content

Commit e0e2b3c

Browse files
authored
Rollup merge of #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 #89958
2 parents 0f1ba8d + 3c1d554 commit e0e2b3c

File tree

30 files changed

+100
-100
lines changed

30 files changed

+100
-100
lines changed

compiler/rustc_ast/src/util/parser.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,13 +357,13 @@ impl ExprPrecedence {
357357
}
358358
}
359359

360-
/// In `let p = e`, operators with precedence `<=` this one requires parenthesis in `e`.
360+
/// In `let p = e`, operators with precedence `<=` this one requires parentheses in `e`.
361361
pub fn prec_let_scrutinee_needs_par() -> usize {
362362
AssocOp::LAnd.precedence()
363363
}
364364

365365
/// Suppose we have `let _ = e` and the `order` of `e`.
366-
/// Is the `order` such that `e` in `let _ = e` needs parenthesis when it is on the RHS?
366+
/// Is the `order` such that `e` in `let _ = e` needs parentheses when it is on the RHS?
367367
///
368368
/// Conversely, suppose that we have `(let _ = a) OP b` and `order` is that of `OP`.
369369
/// Can we print this as `let _ = a OP b`?

compiler/rustc_ast_passes/src/ast_validation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ impl<'a> AstValidator<'a> {
113113
if sess.opts.unstable_features.is_nightly_build() {
114114
sess.struct_span_err(expr.span, "`let` expressions are not supported here")
115115
.note("only supported directly in conditions of `if`- and `while`-expressions")
116-
.note("as well as when nested within `&&` and parenthesis in those conditions")
116+
.note("as well as when nested within `&&` and parentheses in those conditions")
117117
.emit();
118118
} else {
119119
sess.struct_span_err(expr.span, "expected expression, found statement (`let`)")

compiler/rustc_ast_pretty/src/pprust/state.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1675,7 +1675,7 @@ impl<'a> State<'a> {
16751675
self.print_expr_cond_paren(expr, Self::cond_needs_par(expr))
16761676
}
16771677

1678-
// Does `expr` need parenthesis when printed in a condition position?
1678+
// Does `expr` need parentheses when printed in a condition position?
16791679
//
16801680
// These cases need parens due to the parse error observed in #26461: `if return {}`
16811681
// parses as the erroneous construct `if (return {})`, not `if (return) {}`.

compiler/rustc_hir_pretty/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1168,7 +1168,7 @@ impl<'a> State<'a> {
11681168
self.print_expr_cond_paren(expr, Self::cond_needs_par(expr) || npals())
11691169
}
11701170

1171-
// Does `expr` need parenthesis when printed in a condition position?
1171+
// Does `expr` need parentheses when printed in a condition position?
11721172
//
11731173
// These cases need parens due to the parse error observed in #26461: `if return {}`
11741174
// parses as the erroneous construct `if (return {})`, not `if (return) {}`.

compiler/rustc_lint/src/unused.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ declare_lint! {
670670
///
671671
/// ### Explanation
672672
///
673-
/// The parenthesis are not needed, and should be removed. This is the
673+
/// The parentheses are not needed, and should be removed. This is the
674674
/// preferred style for writing these expressions.
675675
pub(super) UNUSED_PARENS,
676676
Warn,

compiler/rustc_parse/src/parser/diagnostics.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,10 +1342,10 @@ impl<'a> Parser<'a> {
13421342

13431343
self.struct_span_err(
13441344
MultiSpan::from_spans(vec![begin_par_sp, self.prev_token.span]),
1345-
"unexpected parenthesis surrounding `for` loop head",
1345+
"unexpected parentheses surrounding `for` loop head",
13461346
)
13471347
.multipart_suggestion(
1348-
"remove parenthesis in `for` loop",
1348+
"remove parentheses in `for` loop",
13491349
vec![(begin_par_sp, String::new()), (self.prev_token.span, String::new())],
13501350
// With e.g. `for (x) in y)` this would replace `(x) in y)`
13511351
// with `x) in y)` which is syntactically invalid.

compiler/rustc_parse/src/parser/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1258,7 +1258,7 @@ impl<'a> Parser<'a> {
12581258
/// Parses `pub`, `pub(crate)` and `pub(in path)` plus shortcuts `crate` for `pub(crate)`,
12591259
/// `pub(self)` for `pub(in self)` and `pub(super)` for `pub(in super)`.
12601260
/// If the following element can't be a tuple (i.e., it's a function definition), then
1261-
/// it's not a tuple struct field), and the contents within the parentheses isn't valid,
1261+
/// it's not a tuple struct field), and the contents within the parentheses aren't valid,
12621262
/// so emit a proper diagnostic.
12631263
// Public for rustfmt usage.
12641264
pub fn parse_visibility(&mut self, fbt: FollowedByType) -> PResult<'a, Visibility> {

compiler/rustc_parse/src/parser/stmt.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ impl<'a> Parser<'a> {
328328
),
329329
)
330330
.multipart_suggestion(
331-
"wrap the expression in parenthesis",
331+
"wrap the expression in parentheses",
332332
suggs,
333333
Applicability::MachineApplicable,
334334
)
@@ -349,7 +349,7 @@ impl<'a> Parser<'a> {
349349
"right curly brace `}` before `else` in a `let...else` statement not allowed",
350350
)
351351
.multipart_suggestion(
352-
"try wrapping the expression in parenthesis",
352+
"try wrapping the expression in parentheses",
353353
suggs,
354354
Applicability::MachineApplicable,
355355
)

compiler/rustc_parse/src/parser/ty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ impl<'a> Parser<'a> {
430430
}
431431

432432
// Parses the `typeof(EXPR)`.
433-
// To avoid ambiguity, the type is surrounded by parenthesis.
433+
// To avoid ambiguity, the type is surrounded by parentheses.
434434
fn parse_typeof_ty(&mut self) -> PResult<'a, TyKind> {
435435
self.expect(&token::OpenDelim(token::Paren))?;
436436
let expr = self.parse_anon_const_expr()?;

compiler/rustc_resolve/src/late/diagnostics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1552,7 +1552,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
15521552
matches!(source, PathSource::TupleStruct(..)) || source.is_call();
15531553
if suggest_only_tuple_variants {
15541554
// Suggest only tuple variants regardless of whether they have fields and do not
1555-
// suggest path with added parenthesis.
1555+
// suggest path with added parentheses.
15561556
let mut suggestable_variants = variants
15571557
.iter()
15581558
.filter(|(.., kind)| *kind == CtorKind::Fn)

0 commit comments

Comments
 (0)