mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
Rollup merge of #111569 - LucasFA:linkchecker-lints, r=ehuss
Appease lints Resolved an unnecessary drop warning that appeared when running the linkchecker. Some clippy warnings, too. Edit: Well this fired up all the CI pipeline. I hope that's not a problem.
This commit is contained in:
commit
74952de4b7
@ -139,18 +139,18 @@ enum FileEntry {
|
|||||||
type Cache = HashMap<String, FileEntry>;
|
type Cache = HashMap<String, FileEntry>;
|
||||||
|
|
||||||
fn small_url_encode(s: &str) -> String {
|
fn small_url_encode(s: &str) -> String {
|
||||||
s.replace("<", "%3C")
|
s.replace('<', "%3C")
|
||||||
.replace(">", "%3E")
|
.replace('>', "%3E")
|
||||||
.replace(" ", "%20")
|
.replace(' ', "%20")
|
||||||
.replace("?", "%3F")
|
.replace('?', "%3F")
|
||||||
.replace("'", "%27")
|
.replace('\'', "%27")
|
||||||
.replace("&", "%26")
|
.replace('&', "%26")
|
||||||
.replace(",", "%2C")
|
.replace(',', "%2C")
|
||||||
.replace(":", "%3A")
|
.replace(':', "%3A")
|
||||||
.replace(";", "%3B")
|
.replace(';', "%3B")
|
||||||
.replace("[", "%5B")
|
.replace('[', "%5B")
|
||||||
.replace("]", "%5D")
|
.replace(']', "%5D")
|
||||||
.replace("\"", "%22")
|
.replace('\"', "%22")
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Checker {
|
impl Checker {
|
||||||
@ -267,7 +267,6 @@ impl Checker {
|
|||||||
FileEntry::OtherFile => return,
|
FileEntry::OtherFile => return,
|
||||||
FileEntry::Redirect { target } => {
|
FileEntry::Redirect { target } => {
|
||||||
let t = target.clone();
|
let t = target.clone();
|
||||||
drop(target);
|
|
||||||
let (target, redir_entry) = self.load_file(&t, report);
|
let (target, redir_entry) = self.load_file(&t, report);
|
||||||
match redir_entry {
|
match redir_entry {
|
||||||
FileEntry::Missing => {
|
FileEntry::Missing => {
|
||||||
@ -391,7 +390,7 @@ impl Checker {
|
|||||||
const ERROR_INVALID_NAME: i32 = 123;
|
const ERROR_INVALID_NAME: i32 = 123;
|
||||||
|
|
||||||
let pretty_path =
|
let pretty_path =
|
||||||
file.strip_prefix(&self.root).unwrap_or(&file).to_str().unwrap().to_string();
|
file.strip_prefix(&self.root).unwrap_or(file).to_str().unwrap().to_string();
|
||||||
|
|
||||||
let entry =
|
let entry =
|
||||||
self.cache.entry(pretty_path.clone()).or_insert_with(|| match fs::metadata(file) {
|
self.cache.entry(pretty_path.clone()).or_insert_with(|| match fs::metadata(file) {
|
||||||
@ -470,10 +469,8 @@ fn is_exception(file: &Path, link: &str) -> bool {
|
|||||||
// NOTE: This cannot be added to `LINKCHECK_EXCEPTIONS` because the resolved path
|
// NOTE: This cannot be added to `LINKCHECK_EXCEPTIONS` because the resolved path
|
||||||
// calculated in `check` function is outside `build/<triple>/doc` dir.
|
// calculated in `check` function is outside `build/<triple>/doc` dir.
|
||||||
// So the `strip_prefix` method just returns the old absolute broken path.
|
// So the `strip_prefix` method just returns the old absolute broken path.
|
||||||
if file.ends_with("std/primitive.slice.html") {
|
if file.ends_with("std/primitive.slice.html") && link.ends_with("primitive.slice.html") {
|
||||||
if link.ends_with("primitive.slice.html") {
|
return true;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
@ -545,7 +542,7 @@ fn with_attrs_in_source<F: FnMut(&str, usize, &str)>(source: &str, attr: &str, m
|
|||||||
fn parse_ids(ids: &mut HashSet<String>, file: &str, source: &str, report: &mut Report) {
|
fn parse_ids(ids: &mut HashSet<String>, file: &str, source: &str, report: &mut Report) {
|
||||||
if ids.is_empty() {
|
if ids.is_empty() {
|
||||||
with_attrs_in_source(source, " id", |fragment, i, _| {
|
with_attrs_in_source(source, " id", |fragment, i, _| {
|
||||||
let frag = fragment.trim_start_matches("#").to_owned();
|
let frag = fragment.trim_start_matches('#').to_owned();
|
||||||
let encoded = small_url_encode(&frag);
|
let encoded = small_url_encode(&frag);
|
||||||
if !ids.insert(frag) {
|
if !ids.insert(frag) {
|
||||||
report.errors += 1;
|
report.errors += 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user