summaryrefslogtreecommitdiff
path: root/ci
diff options
context:
space:
mode:
authorYuki Okushi <jtitor@2k36.org>2022-06-12 15:20:33 +0900
committerYuki Okushi <jtitor@2k36.org>2022-06-12 15:26:42 +0900
commit9a193b0935eb86a8da91349febcef0654074278a (patch)
treec0bcf050513310fde945905d17fc6b38abb310e7 /ci
parent4042ce2ee148a5051f4609f00ef074e6b4e252f3 (diff)
downloadrust-libc-9a193b0935eb86a8da91349febcef0654074278a.tar.gz
Don't check typedefs in impls in style checker
Signed-off-by: Yuki Okushi <jtitor@2k36.org>
Diffstat (limited to 'ci')
-rw-r--r--ci/style.rs34
1 files changed, 8 insertions, 26 deletions
diff --git a/ci/style.rs b/ci/style.rs
index b7e5d8ee8f..5b4054f129 100644
--- a/ci/style.rs
+++ b/ci/style.rs
@@ -14,9 +14,6 @@
//!
//! The current style is:
//!
-//! * No trailing whitespace
-//! * No tabs
-//! * 100-character lines
//! * Specific module layout:
//! 1. use directives
//! 2. typedefs
@@ -29,7 +26,6 @@
//! Things not verified:
//!
//! * alignment
-//! * 4-space tabs
//! * leading colons on paths
use std::env;
@@ -69,10 +65,7 @@ fn walk(path: &Path, err: &mut Errors) {
match &name[..] {
n if !n.ends_with(".rs") => continue,
- "dox.rs" |
"lib.rs" |
- "ctypes.rs" |
- "libc.rs" |
"macros.rs" => continue,
_ => {}
@@ -105,26 +98,9 @@ fn check_style(file: &str, path: &Path, err: &mut Errors) {
let mut state = State::Start;
let mut s_macros = 0;
let mut f_macros = 0;
- let mut prev_blank = false;
+ let mut in_impl = false;
for (i, line) in file.lines().enumerate() {
- if line == "" {
- if prev_blank {
- err.error(path, i, "double blank line");
- }
- prev_blank = true;
- } else {
- prev_blank = false;
- }
- if line != line.trim_end() {
- err.error(path, i, "trailing whitespace");
- }
- if line.contains("\t") {
- err.error(path, i, "tab character");
- }
- if line.len() > 100 && !(line.contains("https://") || line.contains("http://")) {
- err.error(path, i, "line longer than 100 chars");
- }
if line.contains("#[cfg(") && line.contains(']') && !line.contains(" if ")
&& !(line.contains("target_endian") ||
line.contains("target_arch"))
@@ -137,6 +113,12 @@ fn check_style(file: &str, path: &Path, err: &mut Errors) {
if line.contains("#[derive(") && (line.contains("Copy") || line.contains("Clone")) {
err.error(path, i, "impl ::Copy and ::Clone manually");
}
+ if line.contains("impl") {
+ in_impl = true;
+ }
+ if in_impl && line.starts_with('}') {
+ in_impl = false;
+ }
let orig_line = line;
let line = line.trim_start();
@@ -154,7 +136,7 @@ fn check_style(file: &str, path: &Path, err: &mut Errors) {
}
} else if line.starts_with("const ") {
State::Constants
- } else if line.starts_with("type ") {
+ } else if line.starts_with("type ") && !in_impl {
State::Typedefs
} else if line.starts_with("s! {") {
s_macros += 1;