]> git.lizzy.rs Git - rust.git/commitdiff
Add end whitespace ignore flag for tidy
authorGuillaume Gomez <guillaume1.gomez@gmail.com>
Fri, 31 Mar 2017 18:08:31 +0000 (12:08 -0600)
committerGuillaume Gomez <guillaume1.gomez@gmail.com>
Fri, 31 Mar 2017 18:16:03 +0000 (12:16 -0600)
src/test/rustdoc/check-hard-break.rs
src/tools/tidy/src/style.rs

index 4604639c3c8d54b2ff359571a527f533fd9a7d83..5c5e3f8136c7311f717f642a8f1abf2791b72dc8 100644 (file)
@@ -10,7 +10,7 @@
 
 #![crate_name = "foo"]
 
-// ignore-tidy-linelength
+// ignore-tidy-end-whitespace
 
 // @has foo/fn.f.html
 // @has - '<p>hard break:<br>after hard break</p>'
index 2233f8c3529748dcc43bdd6e0f333bc147172548..012301299e0c54029a72cf35de4663bab803ff87 100644 (file)
@@ -110,6 +110,7 @@ pub fn check(path: &Path, bad: &mut bool) {
         let skip_cr = contents.contains("ignore-tidy-cr");
         let skip_tab = contents.contains("ignore-tidy-tab");
         let skip_length = contents.contains("ignore-tidy-linelength");
+        let skip_end_whitespace = contents.contains("ignore-tidy-end-whitespace");
         for (i, line) in contents.split("\n").enumerate() {
             let mut err = |msg: &str| {
                 println!("{}:{}: {}", file.display(), i + 1, msg);
@@ -122,7 +123,7 @@ pub fn check(path: &Path, bad: &mut bool) {
             if line.contains("\t") && !skip_tab {
                 err("tab character");
             }
-            if line.ends_with(" ") || line.ends_with("\t") {
+            if !skip_end_whitespace && (line.ends_with(" ") || line.ends_with("\t")) {
                 err("trailing whitespace");
             }
             if line.contains("\r") && !skip_cr {