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 11// 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).
34//
45// When a new lint is introduced, we can search the results for new warnings and check for false
56// positives.
@@ -556,12 +557,29 @@ fn lintcheck_needs_rerun(lintcheck_logs_path: &Path) -> bool {
556557 logs_modified < clippy_modified
557558}
558559
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+
559570/// lintchecks `main()` function
560571///
561572/// # Panics
562573///
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)
564576pub 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+
565583 let clap_config = & get_clap_config ( ) ;
566584
567585 let config = LintcheckConfig :: from_clap ( clap_config) ;
You can’t perform that action at this time.
0 commit comments