@@ -10,9 +10,9 @@ use rustc_errors::Applicability;
1010use rustc_feature:: UnstableFeatures ;
1111use rustc_session:: lint;
1212
13- pub const CHECK_URL_IMPROVEMENTS : Pass = Pass {
14- name : "check-url-improvements " ,
15- run : check_url_improvements ,
13+ pub const CHECK_NON_AUTOLINKS : Pass = Pass {
14+ name : "check-non-autolinks " ,
15+ run : check_non_autolinks ,
1616 description : "detects URLS that could be written using angle brackets" ,
1717} ;
1818
@@ -23,14 +23,14 @@ const URL_REGEX: &str = concat!(
2323 r"\b([-a-zA-Z0-9@:%_\+.~#?&/=]*)" // optional query or url fragments
2424) ;
2525
26- struct UrlImprovementsLinter < ' a , ' tcx > {
26+ struct NonAutolinksLinter < ' a , ' tcx > {
2727 cx : & ' a DocContext < ' tcx > ,
2828 regex : Regex ,
2929}
3030
31- impl < ' a , ' tcx > UrlImprovementsLinter < ' a , ' tcx > {
31+ impl < ' a , ' tcx > NonAutolinksLinter < ' a , ' tcx > {
3232 fn new ( cx : & ' a DocContext < ' tcx > ) -> Self {
33- UrlImprovementsLinter { cx, regex : Regex :: new ( URL_REGEX ) . expect ( "failed to build regex" ) }
33+ Self { cx, regex : Regex :: new ( URL_REGEX ) . expect ( "failed to build regex" ) }
3434 }
3535
3636 fn find_raw_urls (
@@ -53,17 +53,17 @@ impl<'a, 'tcx> UrlImprovementsLinter<'a, 'tcx> {
5353 }
5454}
5555
56- pub fn check_url_improvements ( krate : Crate , cx : & DocContext < ' _ > ) -> Crate {
56+ pub fn check_non_autolinks ( krate : Crate , cx : & DocContext < ' _ > ) -> Crate {
5757 if !UnstableFeatures :: from_environment ( ) . is_nightly_build ( ) {
5858 krate
5959 } else {
60- let mut coll = UrlImprovementsLinter :: new ( cx) ;
60+ let mut coll = NonAutolinksLinter :: new ( cx) ;
6161
6262 coll. fold_crate ( krate)
6363 }
6464}
6565
66- impl < ' a , ' tcx > DocFolder for UrlImprovementsLinter < ' a , ' tcx > {
66+ impl < ' a , ' tcx > DocFolder for NonAutolinksLinter < ' a , ' tcx > {
6767 fn fold_item ( & mut self , item : Item ) -> Option < Item > {
6868 let hir_id = match self . cx . as_local_hir_id ( item. def_id ) {
6969 Some ( hir_id) => hir_id,
@@ -78,7 +78,7 @@ impl<'a, 'tcx> DocFolder for UrlImprovementsLinter<'a, 'tcx> {
7878 let sp = super :: source_span_for_markdown_range ( cx, & dox, & range, & item. attrs )
7979 . or_else ( || span_of_attrs ( & item. attrs ) )
8080 . unwrap_or ( item. source . span ( ) ) ;
81- cx. tcx . struct_span_lint_hir ( lint:: builtin:: URL_IMPROVEMENTS , hir_id, sp, |lint| {
81+ cx. tcx . struct_span_lint_hir ( lint:: builtin:: NON_AUTOLINKS , hir_id, sp, |lint| {
8282 lint. build ( msg)
8383 . span_suggestion (
8484 sp,
@@ -103,7 +103,8 @@ impl<'a, 'tcx> DocFolder for UrlImprovementsLinter<'a, 'tcx> {
103103 Event :: End ( Tag :: Link ( _, url, _) ) => {
104104 // NOTE: links cannot be nested, so we don't need to
105105 // check `kind`
106- if url. as_ref ( ) == title && !ignore && self . regex . matches ( url) {
106+ if url. as_ref ( ) == title && !ignore && self . regex . is_match ( & url)
107+ {
107108 report_diag (
108109 self . cx ,
109110 "unneeded long form for URL" ,
0 commit comments