Skip to content

Commit 9a193b0

Browse files
committed
Don't check typedefs in impls in style checker
Signed-off-by: Yuki Okushi <[email protected]>
1 parent 4042ce2 commit 9a193b0

File tree

1 file changed

+8
-26
lines changed

1 file changed

+8
-26
lines changed

ci/style.rs

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414
//!
1515
//! The current style is:
1616
//!
17-
//! * No trailing whitespace
18-
//! * No tabs
19-
//! * 100-character lines
2017
//! * Specific module layout:
2118
//! 1. use directives
2219
//! 2. typedefs
@@ -29,7 +26,6 @@
2926
//! Things not verified:
3027
//!
3128
//! * alignment
32-
//! * 4-space tabs
3329
//! * leading colons on paths
3430
3531
use std::env;
@@ -69,10 +65,7 @@ fn walk(path: &Path, err: &mut Errors) {
6965
match &name[..] {
7066
n if !n.ends_with(".rs") => continue,
7167

72-
"dox.rs" |
7368
"lib.rs" |
74-
"ctypes.rs" |
75-
"libc.rs" |
7669
"macros.rs" => continue,
7770

7871
_ => {}
@@ -105,26 +98,9 @@ fn check_style(file: &str, path: &Path, err: &mut Errors) {
10598
let mut state = State::Start;
10699
let mut s_macros = 0;
107100
let mut f_macros = 0;
108-
let mut prev_blank = false;
101+
let mut in_impl = false;
109102

110103
for (i, line) in file.lines().enumerate() {
111-
if line == "" {
112-
if prev_blank {
113-
err.error(path, i, "double blank line");
114-
}
115-
prev_blank = true;
116-
} else {
117-
prev_blank = false;
118-
}
119-
if line != line.trim_end() {
120-
err.error(path, i, "trailing whitespace");
121-
}
122-
if line.contains("\t") {
123-
err.error(path, i, "tab character");
124-
}
125-
if line.len() > 100 && !(line.contains("https://") || line.contains("http://")) {
126-
err.error(path, i, "line longer than 100 chars");
127-
}
128104
if line.contains("#[cfg(") && line.contains(']') && !line.contains(" if ")
129105
&& !(line.contains("target_endian") ||
130106
line.contains("target_arch"))
@@ -137,6 +113,12 @@ fn check_style(file: &str, path: &Path, err: &mut Errors) {
137113
if line.contains("#[derive(") && (line.contains("Copy") || line.contains("Clone")) {
138114
err.error(path, i, "impl ::Copy and ::Clone manually");
139115
}
116+
if line.contains("impl") {
117+
in_impl = true;
118+
}
119+
if in_impl && line.starts_with('}') {
120+
in_impl = false;
121+
}
140122

141123
let orig_line = line;
142124
let line = line.trim_start();
@@ -154,7 +136,7 @@ fn check_style(file: &str, path: &Path, err: &mut Errors) {
154136
}
155137
} else if line.starts_with("const ") {
156138
State::Constants
157-
} else if line.starts_with("type ") {
139+
} else if line.starts_with("type ") && !in_impl {
158140
State::Typedefs
159141
} else if line.starts_with("s! {") {
160142
s_macros += 1;

0 commit comments

Comments
 (0)