diff --git a/clippy_lints/src/needless_continue.rs b/clippy_lints/src/needless_continue.rs index 5784032b750e..9b248b894a05 100644 --- a/clippy_lints/src/needless_continue.rs +++ b/clippy_lints/src/needless_continue.rs @@ -225,6 +225,7 @@ fn with_if_expr(stmt: &ast::Stmt, mut func: F) } /// A type to distinguish between the two distinct cases this lint handles. +#[derive(Copy, Clone, Debug)] enum LintType { ContinueInsideElseBlock, ContinueInsideThenBlock, @@ -361,17 +362,18 @@ fn check_and_warn<'a>(ctx: &EarlyContext, expr: &'a ast::Expr) { /// continues eating till a non-whitespace character is found. /// e.g., the string /// -/// " +/// ``` /// { /// let x = 5; /// } -/// " +/// ``` /// /// is transformed to /// -/// " +/// ``` /// { /// let x = 5;" +/// ``` /// /// NOTE: when there is no closing brace in `s`, `s` is _not_ preserved, i.e., /// an empty string will be returned in that case. @@ -391,19 +393,21 @@ pub fn erode_from_back(s: &str) -> String { /// any number of opening braces are eaten, followed by any number of newlines. /// e.g., the string /// -/// " +/// ``` /// { /// something(); /// inside_a_block(); /// } -/// " +/// ``` /// /// is transformed to /// -/// " something(); +/// ``` +/// something(); /// inside_a_block(); /// } -/// " +/// +/// ``` /// pub fn erode_from_front(s: &str) -> String { s.chars() diff --git a/clippy_lints/src/utils/mod.rs b/clippy_lints/src/utils/mod.rs index 2e35140cdf55..5782d3ef3a8a 100644 --- a/clippy_lints/src/utils/mod.rs +++ b/clippy_lints/src/utils/mod.rs @@ -1093,6 +1093,7 @@ pub fn align_two_snippets(s: &str, t: &str) -> String { /// /// For example, consider /// +/// ``` /// let s1 = "\ /// if (condition()) { /// do_something()"; @@ -1103,18 +1104,19 @@ pub fn align_two_snippets(s: &str, t: &str) -> String { /// let s3 = "\ /// another_piece_of_code(); /// indented_here();"; -/// +/// ``` /// /// /// /// Now calling `align_snippets(&[s1, s2, s3])` will yield the following: /// -/// "\ +/// ``` /// if (condition()) { /// do_something(); /// code_from_somewhere_else(); /// another_piece_of_code(); -/// indented_here();" +/// indented_here(); +/// ``` pub fn align_snippets(xs: &[&str]) -> String { if xs.is_empty() { String::from("")