mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-04 19:12:50 +00:00
Do not trigger unused_{braces,parens}
lints with yield
This commit is contained in:
parent
22e6099330
commit
86d0b9cbd0
@ -425,6 +425,7 @@ trait UnusedDelimLint {
|
||||
ExprKind::Ret(_) | ExprKind::Break(..) => true,
|
||||
_ => parser::contains_exterior_struct_lit(&inner),
|
||||
})
|
||||
|| if let ExprKind::Yield(..) = inner.kind { true } else { false }
|
||||
}
|
||||
|
||||
fn emit_unused_delims_expr(
|
||||
|
17
src/test/ui/lint/issue-74883-unused-paren-baren-yield.rs
Normal file
17
src/test/ui/lint/issue-74883-unused-paren-baren-yield.rs
Normal file
@ -0,0 +1,17 @@
|
||||
#![feature(generator_trait)]
|
||||
#![feature(generators)]
|
||||
#![deny(unused_braces, unused_parens)]
|
||||
|
||||
use std::ops::Generator;
|
||||
use std::pin::Pin;
|
||||
|
||||
fn main() {
|
||||
let mut x = |_| {
|
||||
while let Some(_) = (yield) {}
|
||||
while let Some(_) = {yield} {}
|
||||
// Only warn these cases
|
||||
while let Some(_) = ({yield}) {} //~ ERROR: unnecessary parentheses
|
||||
while let Some(_) = {(yield)} {} //~ ERROR: unnecessary braces
|
||||
};
|
||||
let _ = Pin::new(&mut x).resume(Some(5));
|
||||
}
|
26
src/test/ui/lint/issue-74883-unused-paren-baren-yield.stderr
Normal file
26
src/test/ui/lint/issue-74883-unused-paren-baren-yield.stderr
Normal file
@ -0,0 +1,26 @@
|
||||
error: unnecessary parentheses around `let` scrutinee expression
|
||||
--> $DIR/issue-74883-unused-paren-baren-yield.rs:13:29
|
||||
|
|
||||
LL | while let Some(_) = ({yield}) {}
|
||||
| ^^^^^^^^^ help: remove these parentheses
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/issue-74883-unused-paren-baren-yield.rs:3:24
|
||||
|
|
||||
LL | #![deny(unused_braces, unused_parens)]
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: unnecessary braces around `let` scrutinee expression
|
||||
--> $DIR/issue-74883-unused-paren-baren-yield.rs:14:29
|
||||
|
|
||||
LL | while let Some(_) = {(yield)} {}
|
||||
| ^^^^^^^^^ help: remove these braces
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/issue-74883-unused-paren-baren-yield.rs:3:9
|
||||
|
|
||||
LL | #![deny(unused_braces, unused_parens)]
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
Loading…
Reference in New Issue
Block a user