diff options
| author | flip1995 <hello@philkrones.com> | 2019-06-14 10:36:43 +0200 |
|---|---|---|
| committer | flip1995 <hello@philkrones.com> | 2019-06-14 13:07:33 +0200 |
| commit | 0e480ca4bc45fa5b104874a1e57d74ac2a527362 (patch) | |
| tree | f88cdaddafdd8d5cef6e62326a6fb4f81cadd07d | |
| parent | 7a95c20c1099ecaa1fdebfe6903ce4cb16cf12d9 (diff) | |
| download | rust-0e480ca4bc45fa5b104874a1e57d74ac2a527362.tar.gz rust-0e480ca4bc45fa5b104874a1e57d74ac2a527362.zip | |
Use replace_region_in_file for creating the lint list
| -rw-r--r-- | clippy_dev/src/main.rs | 33 | ||||
| -rw-r--r-- | src/lintlist/mod.rs | 25 |
2 files changed, 34 insertions, 24 deletions
diff --git a/clippy_dev/src/main.rs b/clippy_dev/src/main.rs index fedbb661763..302db24c74e 100644 --- a/clippy_dev/src/main.rs +++ b/clippy_dev/src/main.rs @@ -94,25 +94,26 @@ fn update_lints(update_mode: &UpdateMode) { let mut sorted_usable_lints = usable_lints.clone(); sorted_usable_lints.sort_by_key(|lint| lint.name.clone()); - std::fs::write( + let mut file_change = replace_region_in_file( "../src/lintlist/mod.rs", - &format!( - "\ -//! This file is managed by `util/dev update_lints`. Do not edit. - -pub mod lint; -pub use lint::Level; -pub use lint::Lint; -pub use lint::LINT_LEVELS; - -pub const ALL_LINTS: [Lint; {}] = {:#?};\n", - sorted_usable_lints.len(), - sorted_usable_lints - ), + "begin lint list", + "end lint list", + false, + update_mode == &UpdateMode::Change, + || { + format!( + "pub const ALL_LINTS: [Lint; {}] = {:#?};", + sorted_usable_lints.len(), + sorted_usable_lints + ) + .lines() + .map(ToString::to_string) + .collect::<Vec<_>>() + }, ) - .expect("can write to file"); + .changed; - let mut file_change = replace_region_in_file( + file_change |= replace_region_in_file( "../README.md", r#"\[There are \d+ lints included in this crate!\]\(https://rust-lang.github.io/rust-clippy/master/index.html\)"#, "", diff --git a/src/lintlist/mod.rs b/src/lintlist/mod.rs index 3317ccb5ed0..f28bbf31539 100644 --- a/src/lintlist/mod.rs +++ b/src/lintlist/mod.rs @@ -5,7 +5,8 @@ pub use lint::Level; pub use lint::Lint; pub use lint::LINT_LEVELS; -pub const ALL_LINTS: [Lint; 304] = [ +// begin lint list, do not remove this comment, it’s used in `update_lints` +pub const ALL_LINTS: [Lint; 305] = [ Lint { name: "absurd_extreme_comparisons", group: "correctness", @@ -252,13 +253,6 @@ pub const ALL_LINTS: [Lint; 304] = [ module: "collapsible_if", }, Lint { - name: "const_static_lifetime", - group: "style", - desc: "Using explicit `\'static` lifetime for constants when elision rules would allow omitting them.", - deprecation: None, - module: "const_static_lifetime", - }, - Lint { name: "copy_iterator", group: "pedantic", desc: "implementing `Iterator` on a `Copy` type", @@ -763,6 +757,13 @@ pub const ALL_LINTS: [Lint; 304] = [ module: "arithmetic", }, Lint { + name: "integer_division", + group: "pedantic", + desc: "integer division may cause loss of precision", + deprecation: None, + module: "integer_division", + }, + Lint { name: "into_iter_on_array", group: "correctness", desc: "using `.into_iter()` on an array", @@ -1526,6 +1527,13 @@ pub const ALL_LINTS: [Lint; 304] = [ module: "redundant_pattern_matching", }, Lint { + name: "redundant_static_lifetimes", + group: "style", + desc: "Using explicit `\'static` lifetime for constants or statics when elision rules would allow omitting them.", + deprecation: None, + module: "redundant_static_lifetimes", + }, + Lint { name: "ref_in_deref", group: "complexity", desc: "Use of reference in auto dereference expression.", @@ -2135,3 +2143,4 @@ pub const ALL_LINTS: [Lint; 304] = [ module: "unicode", }, ]; +// end lint list, do not remove this comment, it’s used in `update_lints` |
