Rollup merge of #135880 - bjorn3:misc_driver_refactors, r=oli-obk

Get rid of RunCompiler

The various `set_*` methods that have been removed can be replaced by setting the respective fields in the `Callbacks::config` implementation. `set_using_internal_features` was often forgotten and it's equivalent is now done automatically.
This commit is contained in:
Matthias Krüger 2025-01-23 19:54:26 +01:00 committed by GitHub
commit 7d31ae7f35
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 68 additions and 174 deletions

View file

@ -1,10 +1,10 @@
use std::sync::atomic::AtomicBool;
use std::sync::{Arc, LazyLock};
use std::sync::LazyLock;
use std::{io, mem};
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap};
use rustc_data_structures::sync::Lrc;
use rustc_data_structures::unord::UnordSet;
use rustc_driver::USING_INTERNAL_FEATURES;
use rustc_errors::TerminalUrl;
use rustc_errors::codes::*;
use rustc_errors::emitter::{
@ -221,7 +221,6 @@ pub(crate) fn create_config(
..
}: RustdocOptions,
RenderOptions { document_private, .. }: &RenderOptions,
using_internal_features: Arc<AtomicBool>,
) -> rustc_interface::Config {
// Add the doc cfg into the doc build.
cfgs.push("doc".to_string());
@ -316,7 +315,7 @@ pub(crate) fn create_config(
make_codegen_backend: None,
registry: rustc_driver::diagnostics_registry(),
ice_file: None,
using_internal_features,
using_internal_features: &USING_INTERNAL_FEATURES,
expanded_args,
}
}

View file

@ -193,7 +193,7 @@ pub(crate) fn run(dcx: DiagCtxtHandle<'_>, input: Input, options: RustdocOptions
make_codegen_backend: None,
registry: rustc_driver::diagnostics_registry(),
ice_file: None,
using_internal_features: Arc::default(),
using_internal_features: &rustc_driver::USING_INTERNAL_FEATURES,
expanded_args: options.expanded_args.clone(),
};

View file

@ -74,8 +74,6 @@ extern crate tikv_jemalloc_sys as jemalloc_sys;
use std::env::{self, VarError};
use std::io::{self, IsTerminal};
use std::process;
use std::sync::Arc;
use std::sync::atomic::AtomicBool;
use rustc_errors::DiagCtxtHandle;
use rustc_interface::interface;
@ -159,7 +157,7 @@ pub fn main() {
let mut early_dcx = EarlyDiagCtxt::new(ErrorOutputType::default());
let using_internal_features = rustc_driver::install_ice_hook(
rustc_driver::install_ice_hook(
"https://github.com/rust-lang/rust/issues/new\
?labels=C-bug%2C+I-ICE%2C+T-rustdoc&template=ice.md",
|_| (),
@ -180,7 +178,7 @@ pub fn main() {
let exit_code = rustc_driver::catch_with_exit_code(|| {
let at_args = rustc_driver::args::raw_args(&early_dcx)?;
main_args(&mut early_dcx, &at_args, using_internal_features);
main_args(&mut early_dcx, &at_args);
Ok(())
});
process::exit(exit_code);
@ -769,11 +767,7 @@ fn run_merge_finalize(opt: config::RenderOptions) -> Result<(), error::Error> {
Ok(())
}
fn main_args(
early_dcx: &mut EarlyDiagCtxt,
at_args: &[String],
using_internal_features: Arc<AtomicBool>,
) {
fn main_args(early_dcx: &mut EarlyDiagCtxt, at_args: &[String]) {
// Throw away the first argument, the name of the binary.
// In case of at_args being empty, as might be the case by
// passing empty argument array to execve under some platforms,
@ -826,8 +820,7 @@ fn main_args(
(false, Some(md_input)) => {
let md_input = md_input.to_owned();
let edition = options.edition;
let config =
core::create_config(input, options, &render_options, using_internal_features);
let config = core::create_config(input, options, &render_options);
// `markdown::render` can invoke `doctest::make_test`, which
// requires session globals and a thread pool, so we use
@ -860,7 +853,7 @@ fn main_args(
let scrape_examples_options = options.scrape_examples_options.clone();
let bin_crate = options.bin_crate;
let config = core::create_config(input, options, &render_options, using_internal_features);
let config = core::create_config(input, options, &render_options);
let registered_lints = config.register_lints.is_some();