Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 00c3896

Browse files
committedMar 10, 2025
Add a tidy check for [lints] workspace = true.
For `compiler/` crates.
1 parent 385970f commit 00c3896

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed
 

‎src/tools/tidy/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,5 @@ pub mod unit_tests;
9393
pub mod unknown_revision;
9494
pub mod unstable_book;
9595
pub mod walk;
96+
pub mod workspace_lints;
9697
pub mod x_version;

‎src/tools/tidy/src/main.rs

+1
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ fn main() {
115115
check!(fluent_alphabetical, &compiler_path, bless);
116116
check!(fluent_period, &compiler_path);
117117
check!(target_policy, &root_path);
118+
check!(workspace_lints, &compiler_path);
118119

119120
// Checks that only make sense for the std libs.
120121
check!(pal, &library_path);

‎src/tools/tidy/src/workspace_lints.rs

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//! Tidy check to ensure that all `compiler/` crates have `[lints] workspace =
2+
//! true` and therefore inherit the standard lints.
3+
4+
use std::path::Path;
5+
6+
use crate::walk::{filter_dirs, walk};
7+
8+
pub fn check(path: &Path, bad: &mut bool) {
9+
walk(path, |path, _is_dir| filter_dirs(path), &mut |entry, contents| {
10+
let file = entry.path();
11+
let filename = file.file_name().unwrap();
12+
if filename != "Cargo.toml" {
13+
return;
14+
}
15+
16+
let has_lints_line = contents.lines().any(|line| line.trim() == "[lints]");
17+
let has_workspace_line = contents.lines().any(|line| line.trim() == "workspace = true");
18+
19+
if !has_lints_line {
20+
tidy_error!(bad, "{} doesn't have a `[lints]` line", file.display());
21+
}
22+
if !has_lints_line || !has_workspace_line {
23+
tidy_error!(bad, "{} doesn't have a `workspace = true` line", file.display());
24+
}
25+
});
26+
}

0 commit comments

Comments
 (0)
Failed to load comments.