From 371a5537eb0435fef43763d1bbbc21007ac707e4 Mon Sep 17 00:00:00 2001 From: mcarton Date: Mon, 28 Mar 2016 21:23:21 +0200 Subject: [PATCH] Address nits in DOC_MARKDOWN --- README.md | 2 +- src/bit_mask.rs | 34 +++++++++++++++++----------------- src/doc.rs | 4 +++- tests/compile-fail/doc.rs | 8 ++++++++ 4 files changed, 29 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 264bc6f010bb..43caa80543a8 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Table of contents: * [License](#license) ##Lints -There are 136 lints included in this crate: +There are 137 lints included in this crate: name | default | meaning ---------------------------------------------------------------------------------------------------------------------|---------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ diff --git a/src/bit_mask.rs b/src/bit_mask.rs index 15fbabf9f0b3..28fc311507d9 100644 --- a/src/bit_mask.rs +++ b/src/bit_mask.rs @@ -13,14 +13,14 @@ use utils::span_lint; /// The formula for detecting if an expression of the type `_ m c` (where `` /// is one of {`&`, `|`} and `` is one of {`!=`, `>=`, `>`, `!=`, `>=`, `>`}) can be determined from the following table: /// -/// |Comparison |Bit Op |Example |is always|Formula | -/// |------------|-------|------------|---------|----------------------| -/// |`==` or `!=`| `&` |`x & 2 == 3`|`false` |`c & m != c` | -/// |`<` or `>=`| `&` |`x & 2 < 3` |`true` |`m < c` | -/// |`>` or `<=`| `&` |`x & 1 > 1` |`false` |`m <= c` | -/// |`==` or `!=`| `|` |`x | 1 == 0`|`false` |`c | m != c` | -/// |`<` or `>=`| `|` |`x | 1 < 1` |`false` |`m >= c` | -/// |`<=` or `>` | `|` |`x | 1 > 0` |`true` |`m > c` | +/// |Comparison |Bit Op|Example |is always|Formula | +/// |------------|------|------------|---------|----------------------| +/// |`==` or `!=`| `&` |`x & 2 == 3`|`false` |`c & m != c` | +/// |`<` or `>=`| `&` |`x & 2 < 3` |`true` |`m < c` | +/// |`>` or `<=`| `&` |`x & 1 > 1` |`false` |`m <= c` | +/// |`==` or `!=`| `|` |`x | 1 == 0`|`false` |`c | m != c` | +/// |`<` or `>=`| `|` |`x | 1 < 1` |`false` |`m >= c` | +/// |`<=` or `>` | `|` |`x | 1 > 0` |`true` |`m > c` | /// /// **Why is this bad?** If the bits that the comparison cares about are always set to zero or one by the bit mask, the comparison is constant `true` or `false` (depending on mask, compared value, and operators). /// @@ -61,21 +61,21 @@ declare_lint! { /// is one of {`&`, '|'} and `` is one of {`!=`, `>=`, `>` , /// `!=`, `>=`, `>`}) can be determined from the following table: /// -/// |Comparison |Bit Op |Example |is always|Formula | -/// |------------|-------|------------|---------|----------------------| -/// |`==` or `!=`| `&` |`x & 2 == 3`|`false` |`c & m != c` | -/// |`<` or `>=`| `&` |`x & 2 < 3` |`true` |`m < c` | -/// |`>` or `<=`| `&` |`x & 1 > 1` |`false` |`m <= c` | -/// |`==` or `!=`| `|` |`x | 1 == 0`|`false` |`c | m != c` | -/// |`<` or `>=`| `|` |`x | 1 < 1` |`false` |`m >= c` | -/// |`<=` or `>` | `|` |`x | 1 > 0` |`true` |`m > c` | +/// |Comparison |Bit Op|Example |is always|Formula | +/// |------------|------|------------|---------|----------------------| +/// |`==` or `!=`| `&` |`x & 2 == 3`|`false` |`c & m != c` | +/// |`<` or `>=`| `&` |`x & 2 < 3` |`true` |`m < c` | +/// |`>` or `<=`| `&` |`x & 1 > 1` |`false` |`m <= c` | +/// |`==` or `!=`| `|` |`x | 1 == 0`|`false` |`c | m != c` | +/// |`<` or `>=`| `|` |`x | 1 < 1` |`false` |`m >= c` | +/// |`<=` or `>` | `|` |`x | 1 > 0` |`true` |`m > c` | /// /// This lint is **deny** by default /// /// There is also a lint that warns on ineffective masks that is *warn* /// by default. /// -/// |Comparison| Bit Op |Example |equals |Formula| +/// |Comparison|Bit Op |Example |equals |Formula| /// |`>` / `<=`|`|` / `^`|`x | 2 > 3`|`x > 3`|`¹ && m <= c`| /// |`<` / `>=`|`|` / `^`|`x ^ 1 < 4`|`x < 4`|`¹ && m < c` | /// diff --git a/src/doc.rs b/src/doc.rs index a4a0448c102e..5637fb2cefb6 100644 --- a/src/doc.rs +++ b/src/doc.rs @@ -8,7 +8,8 @@ use utils::span_lint; /// ticks in documentation. /// /// **Why is this bad?** *Rustdoc* supports markdown formatting, `_`, `::` and camel-case probably -/// indicates some code which should be included between ticks. +/// indicates some code which should be included between ticks. `_` can also be used for empasis in +/// markdown, this lint tries to consider that. /// /// **Known problems:** Lots of bad docs won’t be fixed, what the lint checks for is limited. /// @@ -114,6 +115,7 @@ fn check_word(cx: &EarlyContext, word: &str, span: Span) { s }; + s.chars().all(char::is_alphanumeric) && s.chars().filter(|&c| c.is_uppercase()).take(2).count() > 1 && s.chars().filter(|&c| c.is_lowercase()).take(1).count() > 0 } diff --git a/tests/compile-fail/doc.rs b/tests/compile-fail/doc.rs index 35b5857d9372..eecf5e0b2062 100755 --- a/tests/compile-fail/doc.rs +++ b/tests/compile-fail/doc.rs @@ -18,13 +18,21 @@ fn foo_bar() { /// That one tests multiline ticks. /// ```rust /// foo_bar FOO_BAR +/// _foo bar_ /// ``` fn multiline_ticks() { } +/// This _is a test for +/// multiline +/// emphasis_. +fn test_emphasis() { +} + /// The `main` function is the entry point of the program. Here it only calls the `foo_bar` and /// `multiline_ticks` functions. fn main() { foo_bar(); multiline_ticks(); + test_emphasis(); }