This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +44
-0
lines changed Expand file tree Collapse file tree 3 files changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -425,6 +425,7 @@ trait UnusedDelimLint {
425425 ExprKind :: Ret ( _) | ExprKind :: Break ( ..) => true ,
426426 _ => parser:: contains_exterior_struct_lit ( & inner) ,
427427 } )
428+ || if let ExprKind :: Yield ( ..) = inner. kind { true } else { false }
428429 }
429430
430431 fn emit_unused_delims_expr (
Original file line number Diff line number Diff line change 1+ #![ feature( generator_trait) ]
2+ #![ feature( generators) ]
3+ #![ deny( unused_braces, unused_parens) ]
4+
5+ use std:: ops:: Generator ;
6+ use std:: pin:: Pin ;
7+
8+ fn main ( ) {
9+ let mut x = |_| {
10+ while let Some ( _) = ( yield ) { }
11+ while let Some ( _) = { yield } { }
12+ // Only warn these cases
13+ while let Some ( _) = ( { yield } ) { } //~ ERROR: unnecessary parentheses
14+ while let Some ( _) = { ( yield ) } { } //~ ERROR: unnecessary braces
15+ } ;
16+ let _ = Pin :: new ( & mut x) . resume ( Some ( 5 ) ) ;
17+ }
Original file line number Diff line number Diff line change 1+ error: unnecessary parentheses around `let` scrutinee expression
2+ --> $DIR/issue-74883-unused-paren-baren-yield.rs:13:29
3+ |
4+ LL | while let Some(_) = ({yield}) {}
5+ | ^^^^^^^^^ help: remove these parentheses
6+ |
7+ note: the lint level is defined here
8+ --> $DIR/issue-74883-unused-paren-baren-yield.rs:3:24
9+ |
10+ LL | #![deny(unused_braces, unused_parens)]
11+ | ^^^^^^^^^^^^^
12+
13+ error: unnecessary braces around `let` scrutinee expression
14+ --> $DIR/issue-74883-unused-paren-baren-yield.rs:14:29
15+ |
16+ LL | while let Some(_) = {(yield)} {}
17+ | ^^^^^^^^^ help: remove these braces
18+ |
19+ note: the lint level is defined here
20+ --> $DIR/issue-74883-unused-paren-baren-yield.rs:3:9
21+ |
22+ LL | #![deny(unused_braces, unused_parens)]
23+ | ^^^^^^^^^^^^^
24+
25+ error: aborting due to 2 previous errors
26+
You can’t perform that action at this time.
0 commit comments