1 // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 //! Library used by tidy and other tools
13 //! This library contains the tidy lints and exposes it
14 //! to be used by tools.
17 extern crate serde_json;
19 extern crate serde_derive;
26 ($e:expr, $p:expr) => (match $e {
28 Err(e) => panic!("{} failed on {} with {}", stringify!($e), ($p).display(), e),
31 ($e:expr) => (match $e {
33 Err(e) => panic!("{} failed with {}", stringify!($e), e),
37 macro_rules! tidy_error {
38 ($bad:expr, $fmt:expr, $($arg:tt)*) => ({
40 eprint!("tidy error: ");
41 eprintln!($fmt, $($arg)*);
53 pub mod unstable_book;
56 fn filter_dirs(path: &Path) -> bool {
61 "src/llvm-emscripten",
63 "src/libcompiler_builtins",
64 "src/librustc_data_structures/owning_ref",
72 "src/tools/rust-installer",
76 "src/librustc/mir/interpret",
77 "src/librustc_mir/interpret",
81 skip.iter().any(|p| path.ends_with(p))
84 fn walk_many(paths: &[&Path], skip: &mut FnMut(&Path) -> bool, f: &mut FnMut(&Path)) {
90 fn walk(path: &Path, skip: &mut FnMut(&Path) -> bool, f: &mut FnMut(&Path)) {
91 for entry in t!(fs::read_dir(path), path) {
92 let entry = t!(entry);
93 let kind = t!(entry.file_type());
94 let path = entry.path();