Skip to content

Commit cf58537

Browse files
committed
dev: Move DOCS_LINK out of lazy_static and reuse it
1 parent 344603a commit cf58537

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

clippy_dev/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@ lazy_static! {
3030
)
3131
.unwrap();
3232
static ref NL_ESCAPE_RE: Regex = Regex::new(r#"\\\n\s*"#).unwrap();
33-
pub static ref DOCS_LINK: String = "https://rust-lang.github.io/rust-clippy/master/index.html".to_string();
3433
}
3534

35+
pub static DOCS_LINK: &str = "https://rust-lang.github.io/rust-clippy/master/index.html";
36+
3637
/// Lint data parsed from the Clippy source code.
3738
#[derive(Clone, PartialEq, Debug)]
3839
pub struct Lint {
@@ -120,7 +121,7 @@ pub fn gen_changelog_lint_list(lints: Vec<Lint>) -> Vec<String> {
120121
if l.is_internal() {
121122
None
122123
} else {
123-
Some(format!("[`{}`]: {}#{}", l.name, DOCS_LINK.clone(), l.name))
124+
Some(format!("[`{}`]: {}#{}", l.name, DOCS_LINK, l.name))
124125
}
125126
})
126127
.collect()

clippy_dev/src/main.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ fn print_lints() {
150150
println!(
151151
"* [{}]({}#{}) ({})",
152152
lint.name,
153-
clippy_dev::DOCS_LINK.clone(),
153+
clippy_dev::DOCS_LINK,
154154
lint.name,
155155
lint.desc
156156
);
@@ -191,16 +191,18 @@ fn update_lints(update_mode: UpdateMode) {
191191

192192
file_change |= replace_region_in_file(
193193
Path::new("README.md"),
194-
r#"\[There are \d+ lints included in this crate!\]\(https://rust-lang.github.io/rust-clippy/master/index.html\)"#,
194+
&format!(r#"\[There are \d+ lints included in this crate!\]\({}\)"#, DOCS_LINK),
195195
"",
196196
true,
197197
update_mode == UpdateMode::Change,
198198
|| {
199-
vec![
200-
format!("[There are {} lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html)", lint_count)
201-
]
202-
}
203-
).changed;
199+
vec![format!(
200+
"[There are {} lints included in this crate!]({})",
201+
lint_count, DOCS_LINK
202+
)]
203+
},
204+
)
205+
.changed;
204206

205207
file_change |= replace_region_in_file(
206208
Path::new("CHANGELOG.md"),

0 commit comments

Comments
 (0)