fix missing a semicolon

This commit is contained in:
rchaser53 2019-03-07 22:07:01 +09:00
parent 0d8937299e
commit ae787d954e
8 changed files with 34 additions and 7 deletions

View file

@ -639,7 +639,7 @@ impl<'tcx> Visitor<'tcx> for PrintVisitor {
println!("Local(ref {}) = {};", local_pat, current);
if let Some(ref init) = local.init {
let init_pat = self.next("init");
println!(" if let Some(ref {}) = {}.init", init_pat, local_pat);
println!(" if let Some(ref {}) = {}.init;", init_pat, local_pat);
self.current = init_pat;
self.visit_expr(init);
}

BIN
main Executable file

Binary file not shown.

View file

@ -1,6 +1,6 @@
if_chain! {
if let StmtKind::Local(ref local) = stmt.node;
if let Some(ref init) = local.init
if let Some(ref init) = local.init;
if let ExprKind::Cast(ref expr, ref cast_ty) = init.node;
if let TyKind::Path(ref qp) = cast_ty.node;
if match_qpath(qp, &["char"]);

View file

@ -1,6 +1,6 @@
if_chain! {
if let StmtKind::Local(ref local) = stmt.node;
if let Some(ref init) = local.init
if let Some(ref init) = local.init;
if let ExprKind::Call(ref func, ref args) = init.node;
if let ExprKind::Path(ref path) = func.node;
if match_qpath(path, &["{{root}}", "std", "cmp", "min"]);

View file

@ -1,7 +1,7 @@
if_chain! {
if let ExprKind::Block(ref block) = expr.node;
if let StmtKind::Local(ref local) = block.node;
if let Some(ref init) = local.init
if let Some(ref init) = local.init;
if let ExprKind::Match(ref expr, ref arms, MatchSource::ForLoopDesugar) = init.node;
if let ExprKind::Call(ref func, ref args) = expr.node;
if let ExprKind::Path(ref path) = func.node;
@ -41,7 +41,7 @@ if_chain! {
if let PatKind::Path(ref path7) = arms1[1].pats[0].node;
if match_qpath(path7, &["{{root}}", "std", "option", "Option", "None"]);
if let StmtKind::Local(ref local2) = path7.node;
if let Some(ref init1) = local2.init
if let Some(ref init1) = local2.init;
if let ExprKind::Path(ref path8) = init1.node;
if match_qpath(path8, &["__next"]);
if let PatKind::Binding(BindingAnnotation::Unannotated, _, name1, None) = local2.pat.node;
@ -49,7 +49,7 @@ if_chain! {
if let StmtKind::Expr(ref e1, _) = local2.pat.node
if let ExprKind::Block(ref block1) = e1.node;
if let StmtKind::Local(ref local3) = block1.node;
if let Some(ref init2) = local3.init
if let Some(ref init2) = local3.init;
if let ExprKind::Path(ref path9) = init2.node;
if match_qpath(path9, &["y"]);
if let PatKind::Binding(BindingAnnotation::Unannotated, _, name2, None) = local3.pat.node;

View file

@ -1,7 +1,7 @@
if_chain! {
if let StmtKind::Decl(ref decl, _) = stmt.node
if let DeclKind::Local(ref local) = decl.node;
if let Some(ref init) = local.init
if let Some(ref init) = local.init;
if let ExprKind::Match(ref expr, ref arms, MatchSource::Normal) = init.node;
if let ExprKind::Lit(ref lit) = expr.node;
if let LitKind::Int(42, _) = lit.node;

13
tests/ui/issue_3849.rs Normal file
View file

@ -0,0 +1,13 @@
#![allow(dead_code)]
#![allow(clippy::zero_ptr)]
#![allow(clippy::transmute_ptr_to_ref)]
pub const ZPTR: *const usize = 0 as *const _;
fn main() {
unsafe {
#[clippy::author]
let _: &i32 = std::mem::transmute(ZPTR);
let _: &i32 = std::mem::transmute(0 as *const i32);
}
}

View file

@ -0,0 +1,14 @@
if_chain! {
if let StmtKind::Local(ref local) = stmt.node;
if let Some(ref init) = local.init;
if let ExprKind::Call(ref func, ref args) = init.node;
if let ExprKind::Path(ref path) = func.node;
if match_qpath(path, &["std", "mem", "transmute"]);
if args.len() == 1;
if let ExprKind::Path(ref path1) = args[0].node;
if match_qpath(path1, &["ZPTR"]);
if let PatKind::Wild = local.pat.node;
then {
// report your lint here
}
}