From dda13d46037f11a1dd39bb6ef85079d7132ded8a Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Thu, 6 Feb 2020 21:29:43 +0700 Subject: [PATCH] dev: Move DOCS_LINK out of lazy_static and reuse it --- clippy_dev/src/lib.rs | 3 ++- clippy_dev/src/main.rs | 16 +++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/clippy_dev/src/lib.rs b/clippy_dev/src/lib.rs index f50ef4aff950..bc05f18d910b 100644 --- a/clippy_dev/src/lib.rs +++ b/clippy_dev/src/lib.rs @@ -30,9 +30,10 @@ lazy_static! { ) .unwrap(); static ref NL_ESCAPE_RE: Regex = Regex::new(r#"\\\n\s*"#).unwrap(); - pub static ref DOCS_LINK: String = "https://rust-lang.github.io/rust-clippy/master/index.html".to_string(); } +pub static DOCS_LINK: &str = "https://rust-lang.github.io/rust-clippy/master/index.html"; + /// Lint data parsed from the Clippy source code. #[derive(Clone, PartialEq, Debug)] pub struct Lint { diff --git a/clippy_dev/src/main.rs b/clippy_dev/src/main.rs index 403aa634c34f..154876817429 100644 --- a/clippy_dev/src/main.rs +++ b/clippy_dev/src/main.rs @@ -150,7 +150,7 @@ fn print_lints() { println!( "* [{}]({}#{}) ({})", lint.name, - clippy_dev::DOCS_LINK.clone(), + clippy_dev::DOCS_LINK, lint.name, lint.desc ); @@ -191,16 +191,18 @@ fn update_lints(update_mode: UpdateMode) { file_change |= replace_region_in_file( Path::new("README.md"), - r#"\[There are \d+ lints included in this crate!\]\(https://rust-lang.github.io/rust-clippy/master/index.html\)"#, + &format!(r#"\[There are \d+ lints included in this crate!\]\({}\)"#, DOCS_LINK), "", true, update_mode == UpdateMode::Change, || { - vec![ - format!("[There are {} lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html)", lint_count) - ] - } - ).changed; + vec![format!( + "[There are {} lints included in this crate!]({})", + lint_count, DOCS_LINK + )] + }, + ) + .changed; file_change |= replace_region_in_file( Path::new("CHANGELOG.md"),