Skip to content

Commit 125baf1

Browse files
committed
improve tidy to give you file that failed
the current tidy panics give you no idea why it failed
1 parent d1038da commit 125baf1

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

src/tools/tidy/src/bins.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub fn check(path: &Path, bad: &mut bool) {
3535
return
3636
}
3737

38-
let metadata = t!(fs::metadata(&file));
38+
let metadata = t!(fs::metadata(&file), &file);
3939
if metadata.mode() & 0o111 != 0 {
4040
println!("binary checked into source: {}", file.display());
4141
*bad = true;

src/tools/tidy/src/cargo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use std::fs::File;
2020
use std::path::Path;
2121

2222
pub fn check(path: &Path, bad: &mut bool) {
23-
for entry in t!(path.read_dir()).map(|e| t!(e)) {
23+
for entry in t!(path.read_dir(), path).map(|e| t!(e)) {
2424
// Look for `Cargo.toml` with a sibling `src/lib.rs` or `lib.rs`
2525
if entry.file_name().to_str() == Some("Cargo.toml") {
2626
if path.join("src/lib.rs").is_file() {

src/tools/tidy/src/main.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ use std::path::{PathBuf, Path};
1919
use std::env;
2020

2121
macro_rules! t {
22+
($e:expr, $p:expr) => (match $e {
23+
Ok(e) => e,
24+
Err(e) => panic!("{} failed on {} with {}", stringify!($e), ($p).display(), e),
25+
});
26+
2227
($e:expr) => (match $e {
2328
Ok(e) => e,
2429
Err(e) => panic!("{} failed with {}", stringify!($e), e),
@@ -63,7 +68,7 @@ fn filter_dirs(path: &Path) -> bool {
6368

6469

6570
fn walk(path: &Path, skip: &mut FnMut(&Path) -> bool, f: &mut FnMut(&Path)) {
66-
for entry in t!(fs::read_dir(path)) {
71+
for entry in t!(fs::read_dir(path), path) {
6772
let entry = t!(entry);
6873
let kind = t!(entry.file_type());
6974
let path = entry.path();

src/tools/tidy/src/style.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pub fn check(path: &Path, bad: &mut bool) {
5252
}
5353

5454
contents.truncate(0);
55-
t!(t!(File::open(file)).read_to_string(&mut contents));
55+
t!(t!(File::open(file), file).read_to_string(&mut contents));
5656
let skip_cr = contents.contains("ignore-tidy-cr");
5757
let skip_tab = contents.contains("ignore-tidy-tab");
5858
let skip_length = contents.contains("ignore-tidy-linelength");

0 commit comments

Comments
 (0)