mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-24 05:33:27 +00:00
8494f57c82
The author lint was generating invalid code as shown on issue: https://github.com/rust-lang-nursery/rust-clippy/issues/2442 I've changed the generated code to properly track cast expressions. Unfortunatelly, I've had to rewrite the `visit_decl` method, to avoid that last if of the chain will be added. After looking at the code, this last line was being added because of the `let x: char` part, but not because of the `0x45df as char` expression. It seems that let statements should not generate code on the author lint, but I'm not sure that this is true or if I'm breaking something on other code generation parts. Finally, I've added a test for the author lint, but I'm not sure that this needs to be added to the testsuite.
10 lines
300 B
Text
10 lines
300 B
Text
if_chain! {
|
|
if let Expr_::ExprCast(ref expr, ref cast_ty) = stmt.node;
|
|
if let Ty_::TyPath(ref qp) = cast_ty.node;
|
|
if match_qpath(qp, &["char"]);
|
|
if let Expr_::ExprLit(ref lit) = expr.node;
|
|
if let LitKind::Int(69, _) = lit.node;
|
|
then {
|
|
// report your lint here
|
|
}
|
|
}
|