added wiki comments + wiki-generating python script

This commit is contained in:
llogiq 2015-12-11 01:22:27 +01:00
parent 2fbe762a99
commit 5bbc1427fd
28 changed files with 668 additions and 0 deletions

View file

@ -3,10 +3,24 @@ use rustc_front::hir::*;
use syntax::codemap::Spanned;
use utils::{is_integer_literal, match_type, snippet};
/// **What it does:** This lint checks for iterating over ranges with a `.step_by(0)`, which never terminates. It is `Warn` by default.
///
/// **Why is this bad?** This very much looks like an oversight, since with `loop { .. }` there is an obvious better way to endlessly loop.
///
/// **Known problems:** None
///
/// **Example:** `for x in (5..5).step_by(0) { .. }`
declare_lint! {
pub RANGE_STEP_BY_ZERO, Warn,
"using Range::step_by(0), which produces an infinite iterator"
}
/// **What it does:** This lint checks for zipping a collection with the range of `0.._.len()`. It is `Warn` by default.
///
/// **Why is this bad?** The code is better expressed with `.enumerate()`.
///
/// **Known problems:** None
///
/// **Example:** `x.iter().zip(0..x.len())`
declare_lint! {
pub RANGE_ZIP_WITH_LEN, Warn,
"zipping iterator with a range when enumerate() would do"