File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change 1
1
// Run clippy on a fixed set of crates and collect the warnings.
2
- // This helps observing the impact clippy changes have on a set of real-world code (and not just our testsuite).
2
+ // This helps observing the impact clippy changes have on a set of real-world code (and not just our
3
+ // testsuite).
3
4
//
4
5
// When a new lint is introduced, we can search the results for new warnings and check for false
5
6
// positives.
@@ -556,12 +557,29 @@ fn lintcheck_needs_rerun(lintcheck_logs_path: &Path) -> bool {
556
557
logs_modified < clippy_modified
557
558
}
558
559
560
+ fn is_in_clippy_root ( ) -> bool {
561
+ if let Ok ( pb) = std:: env:: current_dir ( ) {
562
+ if let Some ( file) = pb. file_name ( ) {
563
+ return file == PathBuf :: from ( "rust-clippy" ) ;
564
+ }
565
+ }
566
+
567
+ false
568
+ }
569
+
559
570
/// lintchecks `main()` function
560
571
///
561
572
/// # Panics
562
573
///
563
- /// This function panics if the clippy binaries don't exist.
574
+ /// This function panics if the clippy binaries don't exist
575
+ /// or if lintcheck is executed from the wrong directory (aka none-repo-root)
564
576
pub fn main ( ) {
577
+ // assert that we launch lintcheck from the repo root (via cargo dev-lintcheck)
578
+ if !is_in_clippy_root ( ) {
579
+ eprintln ! ( "lintcheck needs to be run from clippys repo root!\n Use `cargo dev-lintcheck` alternatively." ) ;
580
+ std:: process:: exit ( 3 ) ;
581
+ }
582
+
565
583
let clap_config = & get_clap_config ( ) ;
566
584
567
585
let config = LintcheckConfig :: from_clap ( clap_config) ;
You can’t perform that action at this time.
0 commit comments