mirror of
https://github.com/rust-lang/rust-clippy
synced 2025-02-18 23:18:55 +00:00
Auto merge of #4024 - kraai:suppress-let_and_return-if-let-has-attributes, r=flip1995
Suppress let_and_return if let has attributes Fixes #3882. changelog: suppress `let_and_return` if `let` has attributes
This commit is contained in:
commit
253601a91c
2 changed files with 7 additions and 1 deletions
|
@ -157,7 +157,7 @@ impl Return {
|
||||||
if let ast::StmtKind::Local(ref local) = stmt.node;
|
if let ast::StmtKind::Local(ref local) = stmt.node;
|
||||||
// don't lint in the presence of type inference
|
// don't lint in the presence of type inference
|
||||||
if local.ty.is_none();
|
if local.ty.is_none();
|
||||||
if !local.attrs.iter().any(attr_is_cfg);
|
if local.attrs.is_empty();
|
||||||
if let Some(ref initexpr) = local.init;
|
if let Some(ref initexpr) = local.init;
|
||||||
if let ast::PatKind::Ident(_, ident, _) = local.pat.node;
|
if let ast::PatKind::Ident(_, ident, _) = local.pat.node;
|
||||||
if let ast::ExprKind::Path(_, ref path) = retexpr.node;
|
if let ast::ExprKind::Path(_, ref path) = retexpr.node;
|
||||||
|
|
|
@ -39,4 +39,10 @@ fn test_nowarn_4() -> i32 {
|
||||||
x
|
x
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn test_nowarn_5(x: i16) -> u16 {
|
||||||
|
#[allow(clippy::cast_possible_truncation, clippy::cast_sign_loss)]
|
||||||
|
let x = x as u16;
|
||||||
|
x
|
||||||
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
Loading…
Add table
Reference in a new issue