]> git.lizzy.rs Git - rust.git/commitdiff
tidy: Fix false positives from long URLs
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>
Sat, 27 Apr 2019 17:29:27 +0000 (20:29 +0300)
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>
Sat, 27 Apr 2019 17:29:27 +0000 (20:29 +0300)
src/ci/docker/scripts/sccache.sh
src/librustc/error_codes.rs
src/librustc_typeck/error_codes.rs
src/tools/tidy/src/style.rs

index e05246201dd0c030cbec48ff06b31d5500ab8d9f..4c03419894e7cac95a9af3796e6132fa0420b509 100644 (file)
@@ -1,5 +1,3 @@
-# ignore-tidy-linelength
-
 set -ex
 
 curl -fo /usr/local/bin/sccache \
index f6917c45d57e8a1d78639dfa863159d39834a1b6..7f68b35d014cba72237797858644b332305fb062 100644 (file)
@@ -1,4 +1,3 @@
-// ignore-tidy-linelength
 #![allow(non_snake_case)]
 
 // Error messages for EXXXX errors.
index ba67593ce968ae426de0994843e7398c479ca948..fdca3230904a8124e0f805de3a7e6f1deb5657d2 100644 (file)
@@ -1,4 +1,3 @@
-// ignore-tidy-linelength
 // ignore-tidy-filelength
 
 #![allow(non_snake_case)]
index 599b6c676fb277835241c520a75d5a1dd8ab6681..e860f2e9df0ad6ec112b50c2b5f52b9b2bb63e0f 100644 (file)
@@ -38,7 +38,7 @@
 Use llvm::report_fatal_error for increased robustness.";
 
 /// Parser states for `line_is_url`.
-#[derive(PartialEq)]
+#[derive(Clone, Copy, PartialEq)]
 #[allow(non_camel_case_types)]
 enum LIUState {
     EXP_COMMENT_START,
@@ -56,11 +56,12 @@ enum LIUState {
 fn line_is_url(line: &str) -> bool {
     use self::LIUState::*;
     let mut state: LIUState = EXP_COMMENT_START;
+    let is_url = |w: &str| w.starts_with("http://") || w.starts_with("https://");
 
     for tok in line.split_whitespace() {
         match (state, tok) {
-            (EXP_COMMENT_START, "//") => state = EXP_LINK_LABEL_OR_URL,
-            (EXP_COMMENT_START, "///") => state = EXP_LINK_LABEL_OR_URL,
+            (EXP_COMMENT_START, "//") |
+            (EXP_COMMENT_START, "///") |
             (EXP_COMMENT_START, "//!") => state = EXP_LINK_LABEL_OR_URL,
 
             (EXP_LINK_LABEL_OR_URL, w)
@@ -68,14 +69,18 @@ fn line_is_url(line: &str) -> bool {
                 => state = EXP_URL,
 
             (EXP_LINK_LABEL_OR_URL, w)
-                if w.starts_with("http://") || w.starts_with("https://")
+                if is_url(w)
                 => state = EXP_END,
 
             (EXP_URL, w)
-                if w.starts_with("http://") || w.starts_with("https://") || w.starts_with("../")
+                if is_url(w) || w.starts_with("../")
                 => state = EXP_END,
 
-            (_, _) => return false,
+            (_, w)
+                if w.len() > COLS && is_url(w)
+                => state = EXP_END,
+
+            (_, _) => {}
         }
     }