@@ -139,18 +139,18 @@ enum FileEntry {
139139type Cache = HashMap < String , FileEntry > ;
140140
141141fn 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" )
154154}
155155
156156impl Checker {
@@ -267,7 +267,6 @@ impl Checker {
267267 FileEntry :: OtherFile => return ,
268268 FileEntry :: Redirect { target } => {
269269 let t = target. clone ( ) ;
270- drop ( target) ;
271270 let ( target, redir_entry) = self . load_file ( & t, report) ;
272271 match redir_entry {
273272 FileEntry :: Missing => {
@@ -391,7 +390,7 @@ impl Checker {
391390 const ERROR_INVALID_NAME : i32 = 123 ;
392391
393392 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 ( ) ;
395394
396395 let entry =
397396 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 {
470469 // NOTE: This cannot be added to `LINKCHECK_EXCEPTIONS` because the resolved path
471470 // calculated in `check` function is outside `build/<triple>/doc` dir.
472471 // 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 ;
477474 }
478475 false
479476 }
@@ -545,7 +542,7 @@ fn with_attrs_in_source<F: FnMut(&str, usize, &str)>(source: &str, attr: &str, m
545542fn parse_ids ( ids : & mut HashSet < String > , file : & str , source : & str , report : & mut Report ) {
546543 if ids. is_empty ( ) {
547544 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 ( ) ;
549546 let encoded = small_url_encode ( & frag) ;
550547 if !ids. insert ( frag) {
551548 report. errors += 1 ;
0 commit comments