about summary refs log tree commit diff
path: root/compiler/rustc_driver_impl/src
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2023-11-06 16:52:38 +1100
committerNicholas Nethercote <n.nethercote@gmail.com>2023-11-17 10:39:18 +1100
commita3b4961d5f4ddbb0e86d323ebaeccc391f04d8a7 (patch)
tree11983c79f565787193e08fe0b7d86ae771934046 /compiler/rustc_driver_impl/src
parent73c1fc5bc0632b16705756fc91174c3c3a44e52d (diff)
downloadrust-a3b4961d5f4ddbb0e86d323ebaeccc391f04d8a7.tar.gz
rust-a3b4961d5f4ddbb0e86d323ebaeccc391f04d8a7.zip
Move `lint_store` from `GlobalCtxt` to `Session`.
This was made possible by the removal of plugin support, which
simplified lint store creation.

This simplifies the places in rustc and rustdoc that call
`describe_lints`, which are early on. The lint store is now built before
those places, so they don't have to create their own lint store for
temporary use, they can just use the main one.
Diffstat (limited to 'compiler/rustc_driver_impl/src')
-rw-r--r--compiler/rustc_driver_impl/src/lib.rs22
1 files changed, 6 insertions, 16 deletions
diff --git a/compiler/rustc_driver_impl/src/lib.rs b/compiler/rustc_driver_impl/src/lib.rs
index b323ae8d29e..4ad7b9f6cd1 100644
--- a/compiler/rustc_driver_impl/src/lib.rs
+++ b/compiler/rustc_driver_impl/src/lib.rs
@@ -33,7 +33,7 @@ use rustc_feature::find_gated_cfg;
 use rustc_fluent_macro::fluent_messages;
 use rustc_interface::util::{self, collect_crate_types, get_codegen_backend};
 use rustc_interface::{interface, Queries};
-use rustc_lint::{unerased_lint_store, LintStore};
+use rustc_lint::unerased_lint_store;
 use rustc_metadata::locator;
 use rustc_session::config::{nightly_options, CG_OPTIONS, Z_OPTIONS};
 use rustc_session::config::{ErrorOutputType, Input, OutFileName, OutputType, TrimmedDefPaths};
@@ -356,16 +356,7 @@ fn run_compiler(
                     let handler = EarlyErrorHandler::new(sopts.error_format);
 
                     if sopts.describe_lints {
-                        let mut lint_store =
-                            rustc_lint::new_lint_store(compiler.session().enable_internal_lints());
-                        let registered_lints =
-                            if let Some(register_lints) = compiler.register_lints() {
-                                register_lints(compiler.session(), &mut lint_store);
-                                true
-                            } else {
-                                false
-                            };
-                        describe_lints(compiler.session(), &lint_store, registered_lints);
+                        describe_lints(compiler.session());
                         return;
                     }
                     let should_stop = print_crate_info(
@@ -442,9 +433,7 @@ fn run_compiler(
             }
 
             if sess.opts.describe_lints {
-                queries
-                    .global_ctxt()?
-                    .enter(|tcx| describe_lints(sess, unerased_lint_store(tcx), true));
+                describe_lints(sess);
                 return early_exit();
             }
 
@@ -991,7 +980,7 @@ the command line flag directly.
 }
 
 /// Write to stdout lint command options, together with a list of all available lints
-pub fn describe_lints(sess: &Session, lint_store: &LintStore, loaded_lints: bool) {
+pub fn describe_lints(sess: &Session) {
     safe_println!(
         "
 Available lint options:
@@ -1017,6 +1006,7 @@ Available lint options:
         lints
     }
 
+    let lint_store = unerased_lint_store(sess);
     let (loaded, builtin): (Vec<_>, _) =
         lint_store.get_lints().iter().cloned().partition(|&lint| lint.is_loaded);
     let loaded = sort_lints(sess, loaded);
@@ -1094,7 +1084,7 @@ Available lint options:
 
     print_lint_groups(builtin_groups, true);
 
-    match (loaded_lints, loaded.len(), loaded_groups.len()) {
+    match (sess.registered_lints, loaded.len(), loaded_groups.len()) {
         (false, 0, _) | (false, _, 0) => {
             safe_println!("Lint tools like Clippy can load additional lints and lint groups.");
         }