]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/utils/author.rs
Merge branch 'master' into fix-3739
[rust.git] / clippy_lints / src / utils / author.rs
index e61fb2bde4b8661b98e1b57c8af048a6ddd511da..d0b7dd7e8089a66213c68608c160f94793fd6ae5 100644 (file)
 use rustc_data_structures::fx::FxHashMap;
 use syntax::ast::{Attribute, LitKind};
 
-/// **What it does:** Generates clippy code that detects the offending pattern
-///
-/// **Example:**
-/// ```rust
-/// // ./tests/ui/my_lint.rs
-/// fn foo() {
-///     // detect the following pattern
-///     #[clippy::author]
-///     if x == 42 {
-///         // but ignore everything from here on
-///         #![clippy::author = "ignore"]
-///     }
-/// }
-/// ```
-///
-/// Running `TESTNAME=ui/my_lint cargo uitest` will produce
-/// a `./tests/ui/new_lint.stdout` file with the generated code:
-///
-/// ```rust
-/// // ./tests/ui/new_lint.stdout
-/// if_chain! {
-///     if let ExprKind::If(ref cond, ref then, None) = item.node,
-///     if let ExprKind::Binary(BinOp::Eq, ref left, ref right) = cond.node,
-///     if let ExprKind::Path(ref path) = left.node,
-///     if let ExprKind::Lit(ref lit) = right.node,
-///     if let LitKind::Int(42, _) = lit.node,
-///     then {
-///         // report your lint here
-///     }
-/// }
-/// ```
 declare_clippy_lint! {
+    /// **What it does:** Generates clippy code that detects the offending pattern
+    ///
+    /// **Example:**
+    /// ```rust
+    /// // ./tests/ui/my_lint.rs
+    /// fn foo() {
+    ///     // detect the following pattern
+    ///     #[clippy::author]
+    ///     if x == 42 {
+    ///         // but ignore everything from here on
+    ///         #![clippy::author = "ignore"]
+    ///     }
+    /// }
+    /// ```
+    ///
+    /// Running `TESTNAME=ui/my_lint cargo uitest` will produce
+    /// a `./tests/ui/new_lint.stdout` file with the generated code:
+    ///
+    /// ```rust
+    /// // ./tests/ui/new_lint.stdout
+    /// if_chain! {
+    ///     if let ExprKind::If(ref cond, ref then, None) = item.node,
+    ///     if let ExprKind::Binary(BinOp::Eq, ref left, ref right) = cond.node,
+    ///     if let ExprKind::Path(ref path) = left.node,
+    ///     if let ExprKind::Lit(ref lit) = right.node,
+    ///     if let LitKind::Int(42, _) = lit.node,
+    ///     then {
+    ///         // report your lint here
+    ///     }
+    /// }
+    /// ```
     pub LINT_AUTHOR,
     internal_warn,
     "helper for writing lints"
@@ -639,7 +639,7 @@ fn visit_stmt(&mut self, s: &Stmt) {
                 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);
                 }