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

Diff for: compiler/rustc_ast/src/util/parser.rs

+2-2
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`?

Diff for: compiler/rustc_ast_passes/src/ast_validation.rs

+1-1
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`)")

Diff for: compiler/rustc_ast_pretty/src/pprust/state.rs

+1-1
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) {}`.

Diff for: compiler/rustc_hir_pretty/src/lib.rs

+1-1
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) {}`.

Diff for: compiler/rustc_lint/src/unused.rs

+1-1
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,

Diff for: compiler/rustc_parse/src/parser/diagnostics.rs

+2-2
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.

Diff for: compiler/rustc_parse/src/parser/mod.rs

+1-1
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> {

Diff for: compiler/rustc_parse/src/parser/stmt.rs

+2-2
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
)

Diff for: compiler/rustc_parse/src/parser/ty.rs

+1-1
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()?;

Diff for: compiler/rustc_resolve/src/late/diagnostics.rs

+1-1
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)

Diff for: compiler/rustc_typeck/src/check/callee.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
300300
let end = callee_span.shrink_to_hi();
301301
err.multipart_suggestion(
302302
"if you meant to create this closure and immediately call it, surround the \
303-
closure with parenthesis",
303+
closure with parentheses",
304304
vec![(start, "(".to_string()), (end, ")".to_string())],
305305
Applicability::MaybeIncorrect,
306306
);
@@ -383,7 +383,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
383383
call_expr.span,
384384
&format!(
385385
"`{}` is a unit variant, you need to write it \
386-
without the parenthesis",
386+
without the parentheses",
387387
path
388388
),
389389
path.to_string(),

Diff for: compiler/rustc_typeck/src/check/op.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
492492
other_ty: Ty<'tcx>,
493493
op: hir::BinOp,
494494
is_assign: IsAssign,
495-
) -> bool /* did we suggest to call a function because of missing parenthesis? */ {
495+
) -> bool /* did we suggest to call a function because of missing parentheses? */ {
496496
err.span_label(span, ty.to_string());
497497
if let FnDef(def_id, _) = *ty.kind() {
498498
let source_map = self.tcx.sess.source_map();

Diff for: src/librustdoc/clean/auto_trait.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
576576
rhs,
577577
});
578578
continue; // If something other than a Fn ends up
579-
// with parenthesis, leave it alone
579+
// with parentheses, leave it alone
580580
}
581581
}
582582

Diff for: src/test/ui/empty/empty-struct-unit-expr.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ LL | let e4 = E::Empty4();
2020
| |
2121
| call expression requires function
2222
|
23-
help: `E::Empty4` is a unit variant, you need to write it without the parenthesis
23+
help: `E::Empty4` is a unit variant, you need to write it without the parentheses
2424
|
2525
LL | let e4 = E::Empty4;
2626
| ~~~~~~~~~
@@ -41,7 +41,7 @@ LL | let xe4 = XE::XEmpty4();
4141
| |
4242
| call expression requires function
4343
|
44-
help: `XE::XEmpty4` is a unit variant, you need to write it without the parenthesis
44+
help: `XE::XEmpty4` is a unit variant, you need to write it without the parentheses
4545
|
4646
LL | let xe4 = XE::XEmpty4;
4747
| ~~~~~~~~~~~

Diff for: src/test/ui/error-codes/E0618.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ LL | X::Entry();
99
| |
1010
| call expression requires function
1111
|
12-
help: `X::Entry` is a unit variant, you need to write it without the parenthesis
12+
help: `X::Entry` is a unit variant, you need to write it without the parentheses
1313
|
1414
LL | X::Entry;
1515
| ~~~~~~~~

Diff for: src/test/ui/let-else/let-else-bool-binop-init.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error: a `&&` expression cannot be directly assigned in `let...else`
44
LL | let true = true && false else { return };
55
| ^^^^^^^^^^^^^
66
|
7-
help: wrap the expression in parenthesis
7+
help: wrap the expression in parentheses
88
|
99
LL | let true = (true && false) else { return };
1010
| + +
@@ -15,7 +15,7 @@ error: a `||` expression cannot be directly assigned in `let...else`
1515
LL | let true = true || false else { return };
1616
| ^^^^^^^^^^^^^
1717
|
18-
help: wrap the expression in parenthesis
18+
help: wrap the expression in parentheses
1919
|
2020
LL | let true = (true || false) else { return };
2121
| + +

Diff for: src/test/ui/let-else/let-else-brace-before-else.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error: right curly brace `}` before `else` in a `let...else` statement not allow
44
LL | let Some(1) = { Some(1) } else {
55
| ^
66
|
7-
help: try wrapping the expression in parenthesis
7+
help: try wrapping the expression in parentheses
88
|
99
LL | let Some(1) = ({ Some(1) }) else {
1010
| + +
@@ -15,7 +15,7 @@ error: right curly brace `}` before `else` in a `let...else` statement not allow
1515
LL | let Some(1) = loop { break Some(1) } else {
1616
| ^
1717
|
18-
help: try wrapping the expression in parenthesis
18+
help: try wrapping the expression in parentheses
1919
|
2020
LL | let Some(1) = (loop { break Some(1) }) else {
2121
| + +
@@ -26,7 +26,7 @@ error: right curly brace `}` before `else` in a `let...else` statement not allow
2626
LL | let 2 = 1 + match 1 { n => n } else {
2727
| ^
2828
|
29-
help: try wrapping the expression in parenthesis
29+
help: try wrapping the expression in parentheses
3030
|
3131
LL | let 2 = 1 + (match 1 { n => n }) else {
3232
| + +
@@ -37,7 +37,7 @@ error: right curly brace `}` before `else` in a `let...else` statement not allow
3737
LL | let Some(1) = unsafe { unsafe_fn() } else {
3838
| ^
3939
|
40-
help: try wrapping the expression in parenthesis
40+
help: try wrapping the expression in parentheses
4141
|
4242
LL | let Some(1) = (unsafe { unsafe_fn() }) else {
4343
| + +

Diff for: src/test/ui/parser/recover-for-loop-parens-around-head.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ fn main() {
99

1010
for ( elem in vec ) {
1111
//~^ ERROR expected one of `)`, `,`, `@`, or `|`, found keyword `in`
12-
//~| ERROR unexpected parenthesis surrounding `for` loop head
12+
//~| ERROR unexpected parentheses surrounding `for` loop head
1313
const RECOVERY_WITNESS: () = 0; //~ ERROR mismatched types
1414
}
1515
}

Diff for: src/test/ui/parser/recover-for-loop-parens-around-head.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ error: expected one of `)`, `,`, `@`, or `|`, found keyword `in`
44
LL | for ( elem in vec ) {
55
| ^^ expected one of `)`, `,`, `@`, or `|`
66

7-
error: unexpected parenthesis surrounding `for` loop head
7+
error: unexpected parentheses surrounding `for` loop head
88
--> $DIR/recover-for-loop-parens-around-head.rs:10:9
99
|
1010
LL | for ( elem in vec ) {
1111
| ^ ^
1212
|
13-
help: remove parenthesis in `for` loop
13+
help: remove parentheses in `for` loop
1414
|
1515
LL - for ( elem in vec ) {
1616
LL + for elem in vec {

Diff for: src/test/ui/pattern/issue-67037-pat-tup-scrut-ty-diff-less-fields.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// the tuple struct pattern, has 0 fields, but requires 1 field.
66
//
77
// In emitting E0023, we try to see if this is a case of e.g., `Some(a, b, c)` but where
8-
// the scrutinee was of type `Some((a, b, c))`, and suggest that parenthesis be added.
8+
// the scrutinee was of type `Some((a, b, c))`, and suggest that parentheses be added.
99
//
1010
// However, we did not account for the expected type being different than the tuple pattern type.
1111
// This caused an issue when the tuple pattern type (`P<T>`) was generic.

Diff for: src/test/ui/resolve/privacy-enum-ctor.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ LL | let _ = Z::Unit();
338338
| |
339339
| call expression requires function
340340
|
341-
help: `Z::Unit` is a unit variant, you need to write it without the parenthesis
341+
help: `Z::Unit` is a unit variant, you need to write it without the parentheses
342342
|
343343
LL | let _ = Z::Unit;
344344
| ~~~~~~~
@@ -372,7 +372,7 @@ LL | let _: E = m::E::Unit();
372372
| |
373373
| call expression requires function
374374
|
375-
help: `m::E::Unit` is a unit variant, you need to write it without the parenthesis
375+
help: `m::E::Unit` is a unit variant, you need to write it without the parentheses
376376
|
377377
LL | let _: E = m::E::Unit;
378378
| ~~~~~~~~~~
@@ -406,7 +406,7 @@ LL | let _: E = E::Unit();
406406
| |
407407
| call expression requires function
408408
|
409-
help: `E::Unit` is a unit variant, you need to write it without the parenthesis
409+
help: `E::Unit` is a unit variant, you need to write it without the parentheses
410410
|
411411
LL | let _: E = E::Unit;
412412
| ~~~~~~~

0 commit comments

Comments
 (0)