summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ci/style.rs41
1 files changed, 24 insertions, 17 deletions
diff --git a/ci/style.rs b/ci/style.rs
index 5b4054f129..e21a40cf1d 100644
--- a/ci/style.rs
+++ b/ci/style.rs
@@ -34,10 +34,12 @@ use std::io::prelude::*;
use std::path::Path;
macro_rules! t {
- ($e:expr) => (match $e {
- Ok(e) => e,
- Err(e) => panic!("{} failed with {}", stringify!($e), e),
- })
+ ($e:expr) => {
+ match $e {
+ Ok(e) => e,
+ Err(e) => panic!("{} failed with {}", stringify!($e), e),
+ }
+ };
}
fn main() {
@@ -58,15 +60,14 @@ fn walk(path: &Path, err: &mut Errors) {
let path = entry.path();
if t!(entry.file_type()).is_dir() {
walk(&path, err);
- continue
+ continue;
}
let name = entry.file_name().into_string().unwrap();
match &name[..] {
n if !n.ends_with(".rs") => continue,
- "lib.rs" |
- "macros.rs" => continue,
+ "lib.rs" | "macros.rs" => continue,
_ => {}
}
@@ -101,13 +102,13 @@ fn check_style(file: &str, path: &Path, err: &mut Errors) {
let mut in_impl = false;
for (i, line) in file.lines().enumerate() {
- if line.contains("#[cfg(") && line.contains(']') && !line.contains(" if ")
- && !(line.contains("target_endian") ||
- line.contains("target_arch"))
+ if line.contains("#[cfg(")
+ && line.contains(']')
+ && !line.contains(" if ")
+ && !(line.contains("target_endian") || line.contains("target_arch"))
{
if state != State::Structs {
- err.error(path, i, "use cfg_if! and submodules \
- instead of #[cfg]");
+ err.error(path, i, "use cfg_if! and submodules instead of #[cfg]");
}
}
if line.contains("#[derive(") && (line.contains("Copy") || line.contains("Clone")) {
@@ -123,7 +124,7 @@ fn check_style(file: &str, path: &Path, err: &mut Errors) {
let orig_line = line;
let line = line.trim_start();
let is_pub = line.starts_with("pub ");
- let line = if is_pub {&line[4..]} else {line};
+ let line = if is_pub { &line[4..] } else { line };
let line_state = if line.starts_with("use ") {
if line.contains("c_void") {
@@ -149,13 +150,19 @@ fn check_style(file: &str, path: &Path, err: &mut Errors) {
} else if line.starts_with("mod ") {
State::Modules
} else {
- continue
+ continue;
};
if state as usize > line_state as usize {
- err.error(path, i, &format!("{} found after {} when \
- it belongs before",
- line_state.desc(), state.desc()));
+ err.error(
+ path,
+ i,
+ &format!(
+ "{} found after {} when it belongs before",
+ line_state.desc(),
+ state.desc()
+ ),
+ );
}
if f_macros == 2 {