about summary refs log tree commit diff
path: root/clippy_dev/src
diff options
context:
space:
mode:
authorflip1995 <hello@philkrones.com>2019-06-14 10:36:43 +0200
committerflip1995 <hello@philkrones.com>2019-06-14 13:07:33 +0200
commit0e480ca4bc45fa5b104874a1e57d74ac2a527362 (patch)
treef88cdaddafdd8d5cef6e62326a6fb4f81cadd07d /clippy_dev/src
parent7a95c20c1099ecaa1fdebfe6903ce4cb16cf12d9 (diff)
downloadrust-0e480ca4bc45fa5b104874a1e57d74ac2a527362.tar.gz
rust-0e480ca4bc45fa5b104874a1e57d74ac2a527362.zip
Use replace_region_in_file for creating the lint list
Diffstat (limited to 'clippy_dev/src')
-rw-r--r--clippy_dev/src/main.rs33
1 files changed, 17 insertions, 16 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\)"#,
         "",