File tree Expand file tree Collapse file tree 6 files changed +58
-3
lines changed
rustc_ast_pretty/src/pprust
rustc_borrowck/src/diagnostics
rustc_mir_build/src/thir/pattern Expand file tree Collapse file tree 6 files changed +58
-3
lines changed Original file line number Diff line number Diff line change @@ -377,7 +377,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
377
377
378
378
fn print_string ( & mut self , st : & str , style : ast:: StrStyle ) {
379
379
let st = match style {
380
- ast:: StrStyle :: Cooked => ( format ! ( "\" {}\" " , st. escape_debug( ) ) ) ,
380
+ ast:: StrStyle :: Cooked => format ! ( "\" {}\" " , st. escape_debug( ) ) ,
381
381
ast:: StrStyle :: Raw ( n) => {
382
382
format ! ( "r{delim}\" {string}\" {delim}" , delim = "#" . repeat( n as usize ) , string = st)
383
383
}
Original file line number Diff line number Diff line change @@ -839,7 +839,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
839
839
hir:: Node :: Expr ( hir:: Expr {
840
840
kind : hir:: ExprKind :: Closure ( & hir:: Closure { fn_decl_span, .. } ) ,
841
841
..
842
- } ) => ( tcx. sess . source_map ( ) . end_point ( fn_decl_span) ) ,
842
+ } ) => tcx. sess . source_map ( ) . end_point ( fn_decl_span) ,
843
843
_ => self . body . span ,
844
844
} ;
845
845
Original file line number Diff line number Diff line change @@ -396,6 +396,7 @@ enum UnusedDelimsCtx {
396
396
LetScrutineeExpr ,
397
397
ArrayLenExpr ,
398
398
AnonConst ,
399
+ MatchArmExpr ,
399
400
}
400
401
401
402
impl From < UnusedDelimsCtx > for & ' static str {
@@ -414,6 +415,7 @@ impl From<UnusedDelimsCtx> for &'static str {
414
415
UnusedDelimsCtx :: BlockRetValue => "block return value" ,
415
416
UnusedDelimsCtx :: LetScrutineeExpr => "`let` scrutinee expression" ,
416
417
UnusedDelimsCtx :: ArrayLenExpr | UnusedDelimsCtx :: AnonConst => "const expression" ,
418
+ UnusedDelimsCtx :: MatchArmExpr => "match arm expression" ,
417
419
}
418
420
}
419
421
}
@@ -805,6 +807,18 @@ impl EarlyLintPass for UnusedParens {
805
807
}
806
808
return ;
807
809
}
810
+ ExprKind :: Match ( ref _expr, ref arm) => {
811
+ for a in arm {
812
+ self . check_unused_delims_expr (
813
+ cx,
814
+ & a. body ,
815
+ UnusedDelimsCtx :: MatchArmExpr ,
816
+ false ,
817
+ None ,
818
+ None ,
819
+ ) ;
820
+ }
821
+ }
808
822
_ => { }
809
823
}
810
824
Original file line number Diff line number Diff line change @@ -617,7 +617,7 @@ impl SplitVarLenSlice {
617
617
// The only admissible fixed-length slice is one of the array size. Whether `max_slice`
618
618
// is fixed-length or variable-length, it will be the only relevant slice to output
619
619
// here.
620
- Some ( _) => ( 0 ..0 ) , // empty range
620
+ Some ( _) => 0 ..0 , // empty range
621
621
// We cover all arities in the range `(self.arity..infinity)`. We split that range into
622
622
// two: lengths smaller than `max_slice.arity()` are treated independently as
623
623
// fixed-lengths slices, and lengths above are captured by `max_slice`.
Original file line number Diff line number Diff line change
1
+ #[ deny( unused) ]
2
+ pub fn broken ( x : Option < ( ) > ) -> i32 {
3
+ match x {
4
+ Some ( ( ) ) => ( 1 ) , //~ ERROR unnecessary parentheses around match arm expression
5
+ None => ( 2 ) , //~ ERROR unnecessary parentheses around match arm expression
6
+ }
7
+ }
8
+
9
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ error: unnecessary parentheses around match arm expression
2
+ --> $DIR/issue-92751.rs:4:21
3
+ |
4
+ LL | Some(()) => (1),
5
+ | ^ ^
6
+ |
7
+ note: the lint level is defined here
8
+ --> $DIR/issue-92751.rs:1:8
9
+ |
10
+ LL | #[deny(unused)]
11
+ | ^^^^^^
12
+ = note: `#[deny(unused_parens)]` implied by `#[deny(unused)]`
13
+ help: remove these parentheses
14
+ |
15
+ LL - Some(()) => (1),
16
+ LL + Some(()) => 1,
17
+ |
18
+
19
+ error: unnecessary parentheses around match arm expression
20
+ --> $DIR/issue-92751.rs:5:17
21
+ |
22
+ LL | None => (2),
23
+ | ^ ^
24
+ |
25
+ help: remove these parentheses
26
+ |
27
+ LL - None => (2),
28
+ LL + None => 2,
29
+ |
30
+
31
+ error: aborting due to 2 previous errors
32
+
You can’t perform that action at this time.
0 commit comments