Skip to content

Commit bd1224d

Browse files
committed
Auto merge of rust-lang#13148 - xFrednet:lintcheck-link-correction-again, r=Alexendoo
Lintcheck: Support underscores replacement in URL crate names The generated URLs use `{krate}` for the crate name. This works well for the first part of the docs.rs domain, but the second part is actually the root module, which requires a replacement of all dashes with underscores. This PR adds `{krate_}` for the root module name. Diff: ```diff Removed `clippy::needless_borrows_for_generic_args` in `rustls-pemfile` at -https://docs.rs/rustls-pemfile/2.1.2/src/rustls-pemfile/pemfile.rs.html#194 +https://docs.rs/rustls-pemfile/2.1.2/src/rustls_pemfile/pemfile.rs.html#194 ``` > Example before: https://github.com/xFrednet/rust-clippy/actions/runs/10054236377?pr=4 > Example after: https://github.com/xFrednet/rust-clippy/actions/runs/10054878594?pr=4 --- changelog: none r? `@Alexendoo`
2 parents df1baed + 04693a4 commit bd1224d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lintcheck/src/input.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use walkdir::{DirEntry, WalkDir};
1010

1111
use crate::{Crate, LINTCHECK_DOWNLOADS, LINTCHECK_SOURCES};
1212

13-
const DEFAULT_DOCS_LINK: &str = "https://docs.rs/{krate}/{version}/src/{krate}/{file}.html#{line}";
13+
const DEFAULT_DOCS_LINK: &str = "https://docs.rs/{krate}/{version}/src/{krate_}/{file}.html#{line}";
1414
const DEFAULT_GITHUB_LINK: &str = "{url}/blob/{hash}/src/{file}#L{line}";
1515
const DEFAULT_PATH_LINK: &str = "{path}/src/{file}:{line}";
1616

@@ -39,6 +39,7 @@ struct TomlCrate {
3939
options: Option<Vec<String>>,
4040
/// Magic values:
4141
/// * `{krate}` will be replaced by `self.name`
42+
/// * `{krate_}` will be replaced by `self.name` with all `-` replaced by `_`
4243
/// * `{version}` will be replaced by `self.version`
4344
/// * `{url}` will be replaced with `self.git_url`
4445
/// * `{hash}` will be replaced with `self.git_hash`
@@ -55,6 +56,7 @@ impl TomlCrate {
5556
fn file_link(&self, default: &str) -> String {
5657
let mut link = self.online_link.clone().unwrap_or_else(|| default.to_string());
5758
link = link.replace("{krate}", &self.name);
59+
link = link.replace("{krate_}", &self.name.replace('-', "_"));
5860

5961
if let Some(version) = &self.version {
6062
link = link.replace("{version}", version);

0 commit comments

Comments
 (0)