about summary refs log tree commit diff
path: root/compiler/rustc_driver_impl/src
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_driver_impl/src')
-rw-r--r--compiler/rustc_driver_impl/src/lib.rs18
1 files changed, 9 insertions, 9 deletions
diff --git a/compiler/rustc_driver_impl/src/lib.rs b/compiler/rustc_driver_impl/src/lib.rs
index f74eb028364..9c1a5d50230 100644
--- a/compiler/rustc_driver_impl/src/lib.rs
+++ b/compiler/rustc_driver_impl/src/lib.rs
@@ -362,13 +362,18 @@ fn run_compiler(
     interface::run_compiler(config, |compiler| {
         let sess = compiler.session();
         let codegen_backend = compiler.codegen_backend();
+
+        // This implements `-Whelp`. It should be handled very early, like
+        // `--help`/`-Zhelp`/`-Chelp`. This is the earliest it can run, because
+        // it must happen after lints are registered, during session creation.
+        if sess.opts.describe_lints {
+            describe_lints(sess);
+            return sess.compile_status();
+        }
+
         let handler = EarlyErrorHandler::new(sess.opts.error_format);
 
         if !has_input {
-            if sess.opts.describe_lints {
-                describe_lints(sess);
-                return sess.compile_status();
-            }
             let should_stop = print_crate_info(&handler, codegen_backend, sess, false);
             if should_stop == Compilation::Continue {
                 handler.early_error("no input filename given")
@@ -419,11 +424,6 @@ fn run_compiler(
                 return early_exit();
             }
 
-            if sess.opts.describe_lints {
-                describe_lints(sess);
-                return early_exit();
-            }
-
             // Make sure name resolution and macro expansion is run.
             queries.global_ctxt()?.enter(|tcx| tcx.resolver_for_lowering(()));