@@ -139,18 +139,18 @@ enum FileEntry {
139
139
type Cache = HashMap < String , FileEntry > ;
140
140
141
141
fn small_url_encode ( s : & str ) -> String {
142
- s. replace ( "<" , "%3C" )
143
- . replace ( ">" , "%3E" )
144
- . replace ( " " , "%20" )
145
- . replace ( "?" , "%3F" )
146
- . replace ( "'" , "%27" )
147
- . replace ( "&" , "%26" )
148
- . replace ( "," , "%2C" )
149
- . replace ( ":" , "%3A" )
150
- . replace ( ";" , "%3B" )
151
- . replace ( "[" , "%5B" )
152
- . replace ( "]" , "%5D" )
153
- . replace ( " \" " , "%22" )
142
+ s. replace ( '<' , "%3C" )
143
+ . replace ( '>' , "%3E" )
144
+ . replace ( ' ' , "%20" )
145
+ . replace ( '?' , "%3F" )
146
+ . replace ( '\'' , "%27" )
147
+ . replace ( '&' , "%26" )
148
+ . replace ( ',' , "%2C" )
149
+ . replace ( ':' , "%3A" )
150
+ . replace ( ';' , "%3B" )
151
+ . replace ( '[' , "%5B" )
152
+ . replace ( ']' , "%5D" )
153
+ . replace ( '\"' , "%22" )
154
154
}
155
155
156
156
impl Checker {
@@ -267,7 +267,6 @@ impl Checker {
267
267
FileEntry :: OtherFile => return ,
268
268
FileEntry :: Redirect { target } => {
269
269
let t = target. clone ( ) ;
270
- drop ( target) ;
271
270
let ( target, redir_entry) = self . load_file ( & t, report) ;
272
271
match redir_entry {
273
272
FileEntry :: Missing => {
@@ -391,7 +390,7 @@ impl Checker {
391
390
const ERROR_INVALID_NAME : i32 = 123 ;
392
391
393
392
let pretty_path =
394
- file. strip_prefix ( & self . root ) . unwrap_or ( & file) . to_str ( ) . unwrap ( ) . to_string ( ) ;
393
+ file. strip_prefix ( & self . root ) . unwrap_or ( file) . to_str ( ) . unwrap ( ) . to_string ( ) ;
395
394
396
395
let entry =
397
396
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 {
470
469
// NOTE: This cannot be added to `LINKCHECK_EXCEPTIONS` because the resolved path
471
470
// calculated in `check` function is outside `build/<triple>/doc` dir.
472
471
// So the `strip_prefix` method just returns the old absolute broken path.
473
- if file. ends_with ( "std/primitive.slice.html" ) {
474
- if link. ends_with ( "primitive.slice.html" ) {
475
- return true ;
476
- }
472
+ if file. ends_with ( "std/primitive.slice.html" ) && link. ends_with ( "primitive.slice.html" ) {
473
+ return true ;
477
474
}
478
475
false
479
476
}
@@ -545,7 +542,7 @@ fn with_attrs_in_source<F: FnMut(&str, usize, &str)>(source: &str, attr: &str, m
545
542
fn parse_ids ( ids : & mut HashSet < String > , file : & str , source : & str , report : & mut Report ) {
546
543
if ids. is_empty ( ) {
547
544
with_attrs_in_source ( source, " id" , |fragment, i, _| {
548
- let frag = fragment. trim_start_matches ( "#" ) . to_owned ( ) ;
545
+ let frag = fragment. trim_start_matches ( '#' ) . to_owned ( ) ;
549
546
let encoded = small_url_encode ( & frag) ;
550
547
if !ids. insert ( frag) {
551
548
report. errors += 1 ;
0 commit comments