diff options
Diffstat (limited to 'xtask')
-rw-r--r-- | xtask/src/tidy.rs | 43 |
1 files changed, 33 insertions, 10 deletions
diff --git a/xtask/src/tidy.rs b/xtask/src/tidy.rs index 63116ec6b..349ca14d0 100644 --- a/xtask/src/tidy.rs +++ b/xtask/src/tidy.rs | |||
@@ -101,21 +101,44 @@ fn cargo_files_are_tidy() { | |||
101 | let mut section = None; | 101 | let mut section = None; |
102 | for (line_no, text) in read_file(&cargo).unwrap().lines().enumerate() { | 102 | for (line_no, text) in read_file(&cargo).unwrap().lines().enumerate() { |
103 | let text = text.trim(); | 103 | let text = text.trim(); |
104 | if text.starts_with("[") { | 104 | if text.starts_with('[') { |
105 | if !text.ends_with(']') { | ||
106 | panic!( | ||
107 | "\nplease don't add comments or trailing whitespace in section lines.\n\ | ||
108 | {}:{}\n", | ||
109 | cargo.display(), | ||
110 | line_no + 1 | ||
111 | ) | ||
112 | } | ||
105 | section = Some(text); | 113 | section = Some(text); |
106 | continue; | 114 | continue; |
107 | } | 115 | } |
108 | if !section.map(|it| it.starts_with("[dependencies")).unwrap_or(false) { | 116 | let text: String = text.split_whitespace().collect(); |
117 | if !text.contains("path=") { | ||
109 | continue; | 118 | continue; |
110 | } | 119 | } |
111 | let text: String = text.split_whitespace().collect(); | 120 | match section { |
112 | if text.contains("path=") && !text.contains("version") { | 121 | Some(s) if s.contains("dev-dependencies") => { |
113 | panic!( | 122 | if text.contains("version") { |
114 | "\ncargo internal dependencies should have version.\n\ | 123 | panic!( |
115 | {}:{}\n", | 124 | "\ncargo internal dev-dependencies should not have a version.\n\ |
116 | cargo.display(), | 125 | {}:{}\n", |
117 | line_no + 1 | 126 | cargo.display(), |
118 | ) | 127 | line_no + 1 |
128 | ); | ||
129 | } | ||
130 | } | ||
131 | Some(s) if s.contains("dependencies") => { | ||
132 | if !text.contains("version") { | ||
133 | panic!( | ||
134 | "\ncargo internal dependencies should have a version.\n\ | ||
135 | {}:{}\n", | ||
136 | cargo.display(), | ||
137 | line_no + 1 | ||
138 | ); | ||
139 | } | ||
140 | } | ||
141 | _ => {} | ||
119 | } | 142 | } |
120 | } | 143 | } |
121 | } | 144 | } |