diff --git a/clippy_lints/src/utils/author.rs b/clippy_lints/src/utils/author.rs index f1ab545ad3e..d0b7dd7e808 100644 --- a/clippy_lints/src/utils/author.rs +++ b/clippy_lints/src/utils/author.rs @@ -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); } diff --git a/main b/main new file mode 100755 index 00000000000..353d347bcf1 Binary files /dev/null and b/main differ diff --git a/tests/ui/author.stdout b/tests/ui/author.stdout index 87593fafb46..1d7bf607a14 100644 --- a/tests/ui/author.stdout +++ b/tests/ui/author.stdout @@ -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"]); diff --git a/tests/ui/author/call.stdout b/tests/ui/author/call.stdout index d9322d618bf..5c8c90c6b4c 100644 --- a/tests/ui/author/call.stdout +++ b/tests/ui/author/call.stdout @@ -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"]); diff --git a/tests/ui/author/for_loop.stdout b/tests/ui/author/for_loop.stdout index 1611f419e5d..e223ba1a830 100644 --- a/tests/ui/author/for_loop.stdout +++ b/tests/ui/author/for_loop.stdout @@ -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; diff --git a/tests/ui/author/matches.stout b/tests/ui/author/matches.stout index 94b25aefabe..689ee695b60 100644 --- a/tests/ui/author/matches.stout +++ b/tests/ui/author/matches.stout @@ -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; diff --git a/tests/ui/issue_3849.rs b/tests/ui/issue_3849.rs new file mode 100644 index 00000000000..33462b0ea77 --- /dev/null +++ b/tests/ui/issue_3849.rs @@ -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); + } +} diff --git a/tests/ui/issue_3849.stdout b/tests/ui/issue_3849.stdout new file mode 100644 index 00000000000..126c230ac4c --- /dev/null +++ b/tests/ui/issue_3849.stdout @@ -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 + } +}