Skip to content

Commit 15d1731

Browse files
committed
Auto merge of #3845 - euclio:unused-comments, r=phansch
move lint documentation into macro invocations This PR moves lint documentation inside `declare_clippy_lint!` macro invocations, to avoid triggering the `unused_doc_comments` lint once it's modified in rust-lang/rust#57882. This PR is necessary to unblock that work, since the large number of warnings generated in `clippy_lints` causes Travis to hit the log length limit. This PR also updates the documentation and website generation script. It would be nice to get a clippy update in the Rust repo once this is merged. cc @phansch
2 parents 400ee06 + a9de64a commit 15d1731

File tree

132 files changed

+5418
-5393
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

132 files changed

+5418
-5393
lines changed

clippy_dev/src/lib.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ use walkdir::WalkDir;
1212
lazy_static! {
1313
static ref DEC_CLIPPY_LINT_RE: Regex = Regex::new(
1414
r#"(?x)
15-
declare_clippy_lint!\s*[\{(]\s*
16-
pub\s+(?P<name>[A-Z_][A-Z_0-9]*)\s*,\s*
15+
declare_clippy_lint!\s*[\{(]
16+
(?:\s+///.*)*
17+
\s+pub\s+(?P<name>[A-Z_][A-Z_0-9]*)\s*,\s*
1718
(?P<cat>[a-z_]+)\s*,\s*
1819
"(?P<desc>(?:[^"\\]+|\\(?s).(?-s))*)"\s*[})]
1920
"#
@@ -22,7 +23,8 @@ lazy_static! {
2223
static ref DEC_DEPRECATED_LINT_RE: Regex = Regex::new(
2324
r#"(?x)
2425
declare_deprecated_lint!\s*[{(]\s*
25-
pub\s+(?P<name>[A-Z_][A-Z_0-9]*)\s*,\s*
26+
(?:\s+///.*)*
27+
\s+pub\s+(?P<name>[A-Z_][A-Z_0-9]*)\s*,\s*
2628
"(?P<desc>(?:[^"\\]+|\\(?s).(?-s))*)"\s*[})]
2729
"#
2830
)

clippy_lints/src/approx_const.rs

+21-21
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,28 @@ use std::f64::consts as f64;
66
use syntax::ast::{FloatTy, Lit, LitKind};
77
use syntax::symbol;
88

9-
/// **What it does:** Checks for floating point literals that approximate
10-
/// constants which are defined in
11-
/// [`std::f32::consts`](https://doc.rust-lang.org/stable/std/f32/consts/#constants)
12-
/// or
13-
/// [`std::f64::consts`](https://doc.rust-lang.org/stable/std/f64/consts/#constants),
14-
/// respectively, suggesting to use the predefined constant.
15-
///
16-
/// **Why is this bad?** Usually, the definition in the standard library is more
17-
/// precise than what people come up with. If you find that your definition is
18-
/// actually more precise, please [file a Rust
19-
/// issue](https://github.com/rust-lang/rust/issues).
20-
///
21-
/// **Known problems:** If you happen to have a value that is within 1/8192 of a
22-
/// known constant, but is not *and should not* be the same, this lint will
23-
/// report your value anyway. We have not yet noticed any false positives in
24-
/// code we tested clippy with (this includes servo), but YMMV.
25-
///
26-
/// **Example:**
27-
/// ```rust
28-
/// let x = 3.14;
29-
/// ```
309
declare_clippy_lint! {
10+
/// **What it does:** Checks for floating point literals that approximate
11+
/// constants which are defined in
12+
/// [`std::f32::consts`](https://doc.rust-lang.org/stable/std/f32/consts/#constants)
13+
/// or
14+
/// [`std::f64::consts`](https://doc.rust-lang.org/stable/std/f64/consts/#constants),
15+
/// respectively, suggesting to use the predefined constant.
16+
///
17+
/// **Why is this bad?** Usually, the definition in the standard library is more
18+
/// precise than what people come up with. If you find that your definition is
19+
/// actually more precise, please [file a Rust
20+
/// issue](https://github.com/rust-lang/rust/issues).
21+
///
22+
/// **Known problems:** If you happen to have a value that is within 1/8192 of a
23+
/// known constant, but is not *and should not* be the same, this lint will
24+
/// report your value anyway. We have not yet noticed any false positives in
25+
/// code we tested clippy with (this includes servo), but YMMV.
26+
///
27+
/// **Example:**
28+
/// ```rust
29+
/// let x = 3.14;
30+
/// ```
3131
pub APPROX_CONSTANT,
3232
correctness,
3333
"the approximate of a known float constant (in `std::fXX::consts`)"

clippy_lints/src/arithmetic.rs

+23-23
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,36 @@ use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
55
use rustc::{declare_tool_lint, lint_array};
66
use syntax::source_map::Span;
77

8-
/// **What it does:** Checks for plain integer arithmetic.
9-
///
10-
/// **Why is this bad?** This is only checked against overflow in debug builds.
11-
/// In some applications one wants explicitly checked, wrapping or saturating
12-
/// arithmetic.
13-
///
14-
/// **Known problems:** None.
15-
///
16-
/// **Example:**
17-
/// ```rust
18-
/// a + 1
19-
/// ```
208
declare_clippy_lint! {
9+
/// **What it does:** Checks for plain integer arithmetic.
10+
///
11+
/// **Why is this bad?** This is only checked against overflow in debug builds.
12+
/// In some applications one wants explicitly checked, wrapping or saturating
13+
/// arithmetic.
14+
///
15+
/// **Known problems:** None.
16+
///
17+
/// **Example:**
18+
/// ```rust
19+
/// a + 1
20+
/// ```
2121
pub INTEGER_ARITHMETIC,
2222
restriction,
2323
"any integer arithmetic statement"
2424
}
2525

26-
/// **What it does:** Checks for float arithmetic.
27-
///
28-
/// **Why is this bad?** For some embedded systems or kernel development, it
29-
/// can be useful to rule out floating-point numbers.
30-
///
31-
/// **Known problems:** None.
32-
///
33-
/// **Example:**
34-
/// ```rust
35-
/// a + 1.0
36-
/// ```
3726
declare_clippy_lint! {
27+
/// **What it does:** Checks for float arithmetic.
28+
///
29+
/// **Why is this bad?** For some embedded systems or kernel development, it
30+
/// can be useful to rule out floating-point numbers.
31+
///
32+
/// **Known problems:** None.
33+
///
34+
/// **Example:**
35+
/// ```rust
36+
/// a + 1.0
37+
/// ```
3838
pub FLOAT_ARITHMETIC,
3939
restriction,
4040
"any floating-point arithmetic statement"

clippy_lints/src/assertions_on_constants.rs

+16-16
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,23 @@ use crate::syntax::ast::LitKind;
66
use crate::utils::{in_macro, is_direct_expn_of, span_help_and_lint};
77
use if_chain::if_chain;
88

9-
/// **What it does:** Check to call assert!(true/false)
10-
///
11-
/// **Why is this bad?** Will be optimized out by the compiler or should probably be replaced by a
12-
/// panic!() or unreachable!()
13-
///
14-
/// **Known problems:** None
15-
///
16-
/// **Example:**
17-
/// ```rust
18-
/// assert!(false)
19-
/// // or
20-
/// assert!(true)
21-
/// // or
22-
/// const B: bool = false;
23-
/// assert!(B)
24-
/// ```
259
declare_clippy_lint! {
10+
/// **What it does:** Check to call assert!(true/false)
11+
///
12+
/// **Why is this bad?** Will be optimized out by the compiler or should probably be replaced by a
13+
/// panic!() or unreachable!()
14+
///
15+
/// **Known problems:** None
16+
///
17+
/// **Example:**
18+
/// ```no_run
19+
/// assert!(false);
20+
/// // or
21+
/// assert!(true);
22+
/// // or
23+
/// const B: bool = false;
24+
/// assert!(B);
25+
/// ```
2626
pub ASSERTIONS_ON_CONSTANTS,
2727
style,
2828
"assert!(true/false) will be optimized out by the compiler/should probably be replaced by a panic!() or unreachable!()"

clippy_lints/src/assign_ops.rs

+30-30
Original file line numberDiff line numberDiff line change
@@ -7,43 +7,43 @@ use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
77
use rustc::{declare_tool_lint, lint_array};
88
use rustc_errors::Applicability;
99

10-
/// **What it does:** Checks for `a = a op b` or `a = b commutative_op a`
11-
/// patterns.
12-
///
13-
/// **Why is this bad?** These can be written as the shorter `a op= b`.
14-
///
15-
/// **Known problems:** While forbidden by the spec, `OpAssign` traits may have
16-
/// implementations that differ from the regular `Op` impl.
17-
///
18-
/// **Example:**
19-
/// ```rust
20-
/// let mut a = 5;
21-
/// ...
22-
/// a = a + b;
23-
/// ```
2410
declare_clippy_lint! {
11+
/// **What it does:** Checks for `a = a op b` or `a = b commutative_op a`
12+
/// patterns.
13+
///
14+
/// **Why is this bad?** These can be written as the shorter `a op= b`.
15+
///
16+
/// **Known problems:** While forbidden by the spec, `OpAssign` traits may have
17+
/// implementations that differ from the regular `Op` impl.
18+
///
19+
/// **Example:**
20+
/// ```ignore
21+
/// let mut a = 5;
22+
/// ...
23+
/// a = a + b;
24+
/// ```
2525
pub ASSIGN_OP_PATTERN,
2626
style,
2727
"assigning the result of an operation on a variable to that same variable"
2828
}
2929

30-
/// **What it does:** Checks for `a op= a op b` or `a op= b op a` patterns.
31-
///
32-
/// **Why is this bad?** Most likely these are bugs where one meant to write `a
33-
/// op= b`.
34-
///
35-
/// **Known problems:** Clippy cannot know for sure if `a op= a op b` should have
36-
/// been `a = a op a op b` or `a = a op b`/`a op= b`. Therefore it suggests both.
37-
/// If `a op= a op b` is really the correct behaviour it should be
38-
/// written as `a = a op a op b` as it's less confusing.
39-
///
40-
/// **Example:**
41-
/// ```rust
42-
/// let mut a = 5;
43-
/// ...
44-
/// a += a + b;
45-
/// ```
4630
declare_clippy_lint! {
31+
/// **What it does:** Checks for `a op= a op b` or `a op= b op a` patterns.
32+
///
33+
/// **Why is this bad?** Most likely these are bugs where one meant to write `a
34+
/// op= b`.
35+
///
36+
/// **Known problems:** Clippy cannot know for sure if `a op= a op b` should have
37+
/// been `a = a op a op b` or `a = a op b`/`a op= b`. Therefore it suggests both.
38+
/// If `a op= a op b` is really the correct behaviour it should be
39+
/// written as `a = a op a op b` as it's less confusing.
40+
///
41+
/// **Example:**
42+
/// ```ignore
43+
/// let mut a = 5;
44+
/// ...
45+
/// a += a + b;
46+
/// ```
4747
pub MISREFACTORED_ASSIGN_OP,
4848
complexity,
4949
"having a variable on both sides of an assign op"

0 commit comments

Comments
 (0)