Skip to content

Commit 6f3eeac

Browse files
committed
lintcheck: add a cmdline option --crates-toml <TOML PATH> to override crate sources file to use.
Fixes rust-lang#6691
1 parent c1ce78f commit 6f3eeac

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

clippy_dev/src/lintcheck.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,8 @@ fn build_clippy() {
192192
}
193193

194194
// get a list of CrateSources we want to check from a "lintcheck_crates.toml" file.
195-
fn read_crates() -> Vec<CrateSource> {
196-
let toml_path = PathBuf::from("clippy_dev/lintcheck_crates.toml");
195+
fn read_crates(toml_path: Option<&str>) -> Vec<CrateSource> {
196+
let toml_path = PathBuf::from(toml_path.unwrap_or("clippy_dev/lintcheck_crates.toml"));
197197
let toml_content: String =
198198
std::fs::read_to_string(&toml_path).unwrap_or_else(|_| panic!("Failed to read {}", toml_path.display()));
199199
let crate_list: CrateList =
@@ -288,7 +288,7 @@ pub fn run(clap_config: &ArgMatches) {
288288
// download and extract the crates, then run clippy on them and collect clippys warnings
289289
// flatten into one big list of warnings
290290

291-
let crates = read_crates();
291+
let crates = read_crates(clap_config.value_of("crates-toml"));
292292

293293
let clippy_warnings: Vec<ClippyWarning> = if let Some(only_one_crate) = clap_config.value_of("only") {
294294
// if we don't have the specified crate in the .toml, throw an error

clippy_dev/src/main.rs

+7
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ fn get_clap_config<'a>() -> ArgMatches<'a> {
6262
.value_name("CRATE")
6363
.long("only")
6464
.help("only process a single crate of the list"),
65+
)
66+
.arg(
67+
Arg::with_name("crates-toml")
68+
.takes_value(true)
69+
.value_name("CRATES-SOURCES-TOML-PATH")
70+
.long("crates-toml")
71+
.help("set the path for a crates.toml where lintcheck should read the sources from"),
6572
);
6673

6774
let app = App::new("Clippy developer tooling")

0 commit comments

Comments
 (0)