diff --git a/compiler/rustc_codegen_cranelift/scripts/filter_profile.rs b/compiler/rustc_codegen_cranelift/scripts/filter_profile.rs index 4595063c032dc..cbc721757bf39 100755 --- a/compiler/rustc_codegen_cranelift/scripts/filter_profile.rs +++ b/compiler/rustc_codegen_cranelift/scripts/filter_profile.rs @@ -48,7 +48,7 @@ fn main() -> Result<(), Box> { // Trim start if let Some(index) = stack.find("rustc_interface::passes::configure_and_expand") { stack = &stack[index..]; - } else if let Some(index) = stack.find("rustc_interface::passes::analysis") { + } else if let Some(index) = stack.find("rustc_interface::passes::full_analysis") { stack = &stack[index..]; } else if let Some(index) = stack.find("rustc_interface::passes::start_codegen") { stack = &stack[index..]; diff --git a/compiler/rustc_codegen_cranelift/src/driver/aot.rs b/compiler/rustc_codegen_cranelift/src/driver/aot.rs index 6fde623d46f73..5b5039ba5adf5 100644 --- a/compiler/rustc_codegen_cranelift/src/driver/aot.rs +++ b/compiler/rustc_codegen_cranelift/src/driver/aot.rs @@ -22,7 +22,8 @@ use rustc_errors::{DiagCtxt, DiagCtxtHandle}; use rustc_middle::dep_graph::WorkProduct; use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags; use rustc_middle::mono::{MonoItem, MonoItemData, Visibility}; -use rustc_session::config::{OutputFilenames, OutputType}; +use rustc_session::config::OutputFilenames; +use rustc_session::output::OutputType; use rustc_session::{BorrowedIncrCompSession, Session}; use rustc_span::Symbol; diff --git a/compiler/rustc_codegen_cranelift/src/pretty_clif.rs b/compiler/rustc_codegen_cranelift/src/pretty_clif.rs index fee3562c7bede..e3e80532a67f3 100644 --- a/compiler/rustc_codegen_cranelift/src/pretty_clif.rs +++ b/compiler/rustc_codegen_cranelift/src/pretty_clif.rs @@ -65,7 +65,8 @@ use cranelift_codegen::isa::TargetIsa; use cranelift_codegen::write::{FuncWriter, PlainWriter}; use rustc_middle::ty::print::with_no_trimmed_paths; use rustc_session::Session; -use rustc_session::config::{OutputFilenames, OutputType}; +use rustc_session::config::OutputFilenames; +use rustc_session::output::OutputType; use rustc_target::callconv::FnAbi; use crate::prelude::*; @@ -282,7 +283,7 @@ pub(crate) fn write_ir_file( if let Err(err) = res { // Using early_warn as no Session is available here let handler = - rustc_session::EarlyDiagCtxt::new(rustc_session::config::ErrorOutputType::default()); + rustc_session::EarlyDiagCtxt::new(rustc_session::output::ErrorOutputType::default()); handler.early_warn(format!("error writing ir file: {}", err)); } } diff --git a/compiler/rustc_codegen_gcc/src/back/write.rs b/compiler/rustc_codegen_gcc/src/back/write.rs index dcb4bcde38b60..1bdfeb58a4d16 100644 --- a/compiler/rustc_codegen_gcc/src/back/write.rs +++ b/compiler/rustc_codegen_gcc/src/back/write.rs @@ -8,7 +8,7 @@ use rustc_data_structures::profiling::SelfProfilerRef; use rustc_errors::DiagCtxtHandle; use rustc_fs_util::link_or_copy; use rustc_log::tracing::debug; -use rustc_session::config::OutputType; +use rustc_session::output::OutputType; use rustc_target::spec::SplitDebuginfo; use crate::diagnostics::CopyBitcode; diff --git a/compiler/rustc_codegen_llvm/src/back/write.rs b/compiler/rustc_codegen_llvm/src/back/write.rs index c41b95a02b597..c64aca4ac90a4 100644 --- a/compiler/rustc_codegen_llvm/src/back/write.rs +++ b/compiler/rustc_codegen_llvm/src/back/write.rs @@ -19,7 +19,8 @@ use rustc_errors::{DiagCtxt, DiagCtxtHandle, Level}; use rustc_fs_util::{link_or_copy, path_to_c_string}; use rustc_middle::ty::TyCtxt; use rustc_session::Session; -use rustc_session::config::{self, Lto, OutputType, Passes, SplitDwarfKind, SwitchWithOptPath}; +use rustc_session::config::{self, Lto, Passes, SplitDwarfKind, SwitchWithOptPath}; +use rustc_session::output::OutputType; use rustc_span::{BytePos, DUMMY_SP, InnerSpan, Pos, RemapPathScopeComponents}; use rustc_target::spec::{CodeModel, FloatAbi, RelocModel, SanitizerSet, SplitDebuginfo, TlsModel}; use tracing::{debug, trace}; diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index d4003a581c1f5..94c97e7740c06 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -33,9 +33,11 @@ use rustc_middle::middle::dependency_format::Linkage; use rustc_middle::middle::exported_symbols::SymbolExportKind; use rustc_session::config::{ self, CFGuard, DebugInfo, InstrumentMcount, JobsMode, LinkerFeaturesCli, LinkerJobs, - OutFileName, OutputFilenames, OutputType, PrintKind, SplitDwarfKind, Strip, + OutFileName, OutputFilenames, PrintKind, SplitDwarfKind, Strip, +}; +use rustc_session::output::{ + OutputType, check_file_is_writeable, invalid_output_for_target, out_filename, }; -use rustc_session::output::{check_file_is_writeable, invalid_output_for_target, out_filename}; use rustc_session::search_paths::PathKind; /// For all the linkers we support, and information they might /// need out of the shared crate context before we get rid of it. diff --git a/compiler/rustc_codegen_ssa/src/back/write.rs b/compiler/rustc_codegen_ssa/src/back/write.rs index 24fcab7218f7e..8d8f04f7b3b33 100644 --- a/compiler/rustc_codegen_ssa/src/back/write.rs +++ b/compiler/rustc_codegen_ssa/src/back/write.rs @@ -23,9 +23,10 @@ use rustc_metadata::fs::copy_to_stdout; use rustc_middle::dep_graph::{WorkProduct, WorkProductMap}; use rustc_middle::ty::TyCtxt; use rustc_session::config::{ - self, JobsMode, Lto, OptimizationObjective, OutFileName, OutputFilenames, OutputType, Passes, + self, JobsMode, Lto, OptimizationObjective, OutFileName, OutputFilenames, Passes, SwitchWithOptPath, }; +use rustc_session::output::OutputType; use rustc_session::{BorrowedIncrCompSession, IncrCompSession, Session}; use rustc_span::source_map::SourceMap; use rustc_span::{BytePos, FileName, InnerSpan, Span, SyntaxContext, bug}; diff --git a/compiler/rustc_codegen_ssa/src/lib.rs b/compiler/rustc_codegen_ssa/src/lib.rs index d19b80897a21d..27b2cc888a254 100644 --- a/compiler/rustc_codegen_ssa/src/lib.rs +++ b/compiler/rustc_codegen_ssa/src/lib.rs @@ -37,7 +37,8 @@ use rustc_middle::util::Providers; use rustc_serialize::opaque::{FileEncoder, MemDecoder}; use rustc_serialize::{Decodable, Decoder, Encodable, Encoder}; use rustc_session::Session; -use rustc_session::config::{OutputFilenames, OutputType}; +use rustc_session::config::OutputFilenames; +use rustc_session::output::OutputType; use rustc_span::{Span, Symbol}; use rustc_structures::{CrateType, NativeLibKind}; diff --git a/compiler/rustc_driver_impl/src/lib.rs b/compiler/rustc_driver_impl/src/lib.rs index 93f84d6cf9635..d53c3de10e923 100644 --- a/compiler/rustc_driver_impl/src/lib.rs +++ b/compiler/rustc_driver_impl/src/lib.rs @@ -51,11 +51,11 @@ use rustc_middle::ty::TyCtxt; use rustc_parse::lexer::StripTokens; use rustc_parse::{new_parser_from_file, new_parser_from_source_str, unwrap_or_emit_fatal}; use rustc_session::config::{ - CG_OPTIONS, ErrorOutputType, Input, OptionDesc, OutFileName, OutputType, Sysroot, - UnstableOptions, Z_OPTIONS, nightly_options, parse_target_triple, + CG_OPTIONS, Input, OptionDesc, OutFileName, Sysroot, UnstableOptions, Z_OPTIONS, + nightly_options, parse_target_triple, }; use rustc_session::getopts::{self, Matches}; -use rustc_session::output::invalid_output_for_target; +use rustc_session::output::{ErrorOutputType, OutputType, invalid_output_for_target}; use rustc_session::{EarlyDiagCtxt, Session, config}; use rustc_span::def_id::LOCAL_CRATE; use rustc_span::{DUMMY_SP, FileName}; @@ -323,7 +323,7 @@ pub fn compiler_entrypoint(at_args: &[String], callbacks: &mut (dyn Callbacks + return None; } - tcx.ensure_ok().analysis(()); + rustc_interface::passes::full_analysis(tcx); if callbacks.after_analysis(compiler, tcx) == Compilation::Stop { return None; diff --git a/compiler/rustc_driver_impl/src/pretty.rs b/compiler/rustc_driver_impl/src/pretty.rs index 952a9041df87e..01dc2f9d8451f 100644 --- a/compiler/rustc_driver_impl/src/pretty.rs +++ b/compiler/rustc_driver_impl/src/pretty.rs @@ -15,7 +15,8 @@ use rustc_middle::ty::{self, TyCtxt}; use rustc_mir_build::thir::print::{thir_flat, thir_tree}; use rustc_public::rustc_internal::pretty::write_smir_pretty; use rustc_session::Session; -use rustc_session::config::{OutFileName, OutputType, PpHirMode, PpMode, PpSourceMode}; +use rustc_session::config::{OutFileName, PpHirMode, PpMode, PpSourceMode}; +use rustc_session::output::OutputType; use rustc_span::{FileName, Ident, bug}; use tracing::debug; @@ -231,7 +232,7 @@ impl<'tcx> PrintExtra<'tcx> { pub fn print<'tcx>(sess: &Session, ppm: PpMode, ex: PrintExtra<'tcx>) { if ppm.needs_analysis() { - ex.tcx().ensure_ok().analysis(()); + rustc_interface::passes::full_analysis(ex.tcx()); } let (src, src_name) = get_source(sess); diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs index e8041796a6195..1c9e76e4af18a 100644 --- a/compiler/rustc_errors/src/emitter.rs +++ b/compiler/rustc_errors/src/emitter.rs @@ -5,7 +5,7 @@ //! There are various `Emitter` implementations that generate different output formats such as //! JSON and human readable output. //! -//! The output types are defined in `rustc_session::config::ErrorOutputType`. +//! The output types are defined in `rustc_session::output::ErrorOutputType`. use std::borrow::Cow; use std::io::prelude::*; diff --git a/compiler/rustc_incremental/src/persist/fs.rs b/compiler/rustc_incremental/src/persist/fs.rs index 038bddaa021d2..e139ef72e433d 100644 --- a/compiler/rustc_incremental/src/persist/fs.rs +++ b/compiler/rustc_incremental/src/persist/fs.rs @@ -108,7 +108,7 @@ use rustc_data_structures::unord::{UnordMap, UnordSet}; use rustc_data_structures::{base_n, flock}; use rustc_fs_util::try_canonicalize; use rustc_middle::dep_graph::WorkProduct; -use rustc_session::config::OutputType; +use rustc_session::output::OutputType; use rustc_session::{IncrCompSession, Session, StableCrateId}; use rustc_span::{Symbol, bug}; use tracing::debug; diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index 7b881f99fb8d7..1fc1df52885b5 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -36,9 +36,9 @@ use rustc_parse::lexer::StripTokens; use rustc_parse::{new_parser_from_file, new_parser_from_source_str, unwrap_or_emit_fatal}; use rustc_passes::{abi_test, input_stats, layout_test}; use rustc_resolve::{Resolver, ResolverOutputs}; -use rustc_session::config::{Input, Offload, OutFileName, OutputFilenames, OutputType}; +use rustc_session::config::{Input, Offload, OutFileName, OutputFilenames}; use rustc_session::diagnostics::feature_err; -use rustc_session::output::{filename_for_input, invalid_output_for_target}; +use rustc_session::output::{OutputType, filename_for_input, invalid_output_for_target}; use rustc_session::search_paths::PathKind; use rustc_session::{IncrCompSession, Session}; use rustc_span::{ @@ -919,7 +919,7 @@ pub fn finish_and_emit_metadata<'tcx>(tcx: TyCtxt<'tcx>) -> EncodedMetadata { pub static DEFAULT_QUERY_PROVIDERS: LazyLock = LazyLock::new(|| { let providers = &mut Providers::default(); - providers.queries.analysis = analysis; + providers.queries.required_analysis = run_required_analyses; providers.queries.resolver_for_lowering_raw = resolver_for_lowering_raw; providers.queries.stripped_cfg_items = |tcx, _| &tcx.resolutions(()).stripped_cfg_items[..]; providers.queries.get_lang_items = |tcx, ()| &tcx.resolutions(()).lang_items; @@ -1125,7 +1125,7 @@ pub fn emit_delayed_lints(tcx: TyCtxt<'_>) { /// Runs all analyses that we guarantee to run, even if errors were reported in earlier analyses. /// This function never fails. -fn run_required_analyses(tcx: TyCtxt<'_>) { +fn run_required_analyses(tcx: TyCtxt<'_>, (): ()) { if tcx.sess.opts.unstable_opts.input_stats { rustc_passes::input_stats::print_hir_stats(tcx); } @@ -1227,8 +1227,8 @@ fn run_required_analyses(tcx: TyCtxt<'_>) { /// Runs the type-checking, region checking and other miscellaneous analysis /// passes on the crate. -fn analysis(tcx: TyCtxt<'_>, (): ()) { - run_required_analyses(tcx); +pub fn full_analysis(tcx: TyCtxt<'_>) { + tcx.ensure_ok().required_analysis(()); let sess = tcx.sess; diff --git a/compiler/rustc_interface/src/queries.rs b/compiler/rustc_interface/src/queries.rs index 89e22b1c0c3b6..5559075d4e732 100644 --- a/compiler/rustc_interface/src/queries.rs +++ b/compiler/rustc_interface/src/queries.rs @@ -9,7 +9,8 @@ use rustc_hir::def_id::LOCAL_CRATE; use rustc_metadata::EncodedMetadata; use rustc_middle::dep_graph::{DepGraph, WorkProduct, WorkProductMap}; use rustc_middle::ty::TyCtxt; -use rustc_session::config::{self, OutputFilenames, OutputType}; +use rustc_session::config::{self, OutputFilenames}; +use rustc_session::output::OutputType; use rustc_session::{IncrCompSession, Session}; use crate::diagnostics::FailedWritingFile; diff --git a/compiler/rustc_interface/src/tests.rs b/compiler/rustc_interface/src/tests.rs index e7f0fc6cd4c07..711e9dc28ee71 100644 --- a/compiler/rustc_interface/src/tests.rs +++ b/compiler/rustc_interface/src/tests.rs @@ -11,14 +11,15 @@ use rustc_errors::emitter::HumanReadableErrorType; use rustc_lint_defs::Level; use rustc_session::config::{ AnnotateMoves, AutoDiff, BranchProtection, CFGuard, Cfg, CodegenRetagOptions, CoverageLevel, - CoverageOptions, DebugInfo, DumpMonoStatsFormat, ErrorOutputType, ExternEntry, ExternLocation, - Externs, FmtDebug, FunctionReturn, IncrementalStateAssertion, InliningThreshold, Input, + CoverageOptions, DebugInfo, DumpMonoStatsFormat, ExternEntry, ExternLocation, Externs, + FmtDebug, FunctionReturn, IncrementalStateAssertion, InliningThreshold, Input, InstrumentCoverage, InstrumentMcount, InstrumentMcountOpts, InstrumentXRay, LinkSelfContained, LinkerPluginLto, LlvmTpde, LocationDetail, LtoCli, MirIncludeSpans, NextSolverConfig, Offload, - Options, OutFileName, OutputType, OutputTypes, PAuthKey, PacRet, Passes, - PatchableFunctionEntry, Polonius, ProcMacroExecutionStrategy, Strip, SwitchWithOptPath, - SymbolManglingVersion, WasiExecModel, build_session_options, rustc_optgroups, + Options, OutFileName, PAuthKey, PacRet, Passes, PatchableFunctionEntry, Polonius, + ProcMacroExecutionStrategy, Strip, SwitchWithOptPath, SymbolManglingVersion, WasiExecModel, + build_session_options, rustc_optgroups, }; +use rustc_session::output::{ErrorOutputType, OutputType, OutputTypes}; use rustc_session::search_paths::SearchPath; use rustc_session::utils::{CanonicalizedPath, NativeLib}; use rustc_session::{ diff --git a/compiler/rustc_interface/src/util.rs b/compiler/rustc_interface/src/util.rs index d1110ecf33cb7..004be0257d854 100644 --- a/compiler/rustc_interface/src/util.rs +++ b/compiler/rustc_interface/src/util.rs @@ -23,9 +23,9 @@ use rustc_middle::ty::{CurrentGcx, TyCtxt}; use rustc_query_impl::{CollectActiveJobsKind, collect_active_query_jobs}; pub use rustc_session::config::DEFAULT_STACK_SIZE; use rustc_session::config::{ - Cfg, Jobs, OptionsTargetModifiers, OutFileName, OutputFilenames, OutputTypes, Sysroot, - host_tuple, + Cfg, Jobs, OptionsTargetModifiers, OutFileName, OutputFilenames, Sysroot, host_tuple, }; +use rustc_session::output::OutputTypes; use rustc_session::{EarlyDiagCtxt, EarlySession, IncrCompSession, Session, filesearch}; use rustc_span::edition::Edition; use rustc_span::source_map::SourceMapInputs; diff --git a/compiler/rustc_metadata/src/fs.rs b/compiler/rustc_metadata/src/fs.rs index e653522950651..32e20e37d4c2f 100644 --- a/compiler/rustc_metadata/src/fs.rs +++ b/compiler/rustc_metadata/src/fs.rs @@ -5,8 +5,8 @@ use rustc_data_structures::temp_dir::MaybeTempDir; use rustc_fs_util::TempDirBuilder; use rustc_middle::ty::TyCtxt; use rustc_session::Session; -use rustc_session::config::{OutFileName, OutputType}; -use rustc_session::output::filename_for_metadata; +use rustc_session::config::OutFileName; +use rustc_session::output::{OutputType, filename_for_metadata}; use rustc_span::ErrorGuaranteed; use rustc_structures::CrateType; diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs index cd65f566ce198..dc6310227ebee 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -34,7 +34,8 @@ use rustc_middle::ty::fast_reject::{self, TreatParams}; use rustc_serialize::opaque::FileEncoder; use rustc_serialize::{Decodable, Decoder, Encodable, Encoder}; use rustc_session::config::mitigation_coverage::DeniedPartialMitigation; -use rustc_session::config::{OptLevel, OutputType, TargetModifier}; +use rustc_session::config::{OptLevel, TargetModifier}; +use rustc_session::output::OutputType; use rustc_span::def_id::CRATE_MOD_ID; use rustc_span::hygiene::{ HygieneEncodeContext, HygieneRemapper, HygieneRemappingResults, LocalExpnIdRemapper, diff --git a/compiler/rustc_middle/src/queries.rs b/compiler/rustc_middle/src/queries.rs index c91ec5eeedd25..4681789835244 100644 --- a/compiler/rustc_middle/src/queries.rs +++ b/compiler/rustc_middle/src/queries.rs @@ -403,10 +403,10 @@ rustc_queries! { } /// The root query triggering all analysis passes like typeck or borrowck. - query analysis(key: ()) { + query required_analysis(key: ()) { eval_always desc { - "running analysis passes on crate `{}`", + "running required analysis passes on crate `{}`", tcx.crate_name(LOCAL_CRATE), } } diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 738599b3ef5d4..cb26e7b14e0ff 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -1621,7 +1621,7 @@ impl<'tcx> TyCtxt<'tcx> { pub fn iter_local_def_id(self) -> impl Iterator { // Depend on the `analysis` query to ensure compilation if finished. - self.ensure_ok().analysis(()); + self.ensure_ok().required_analysis(()); let definitions = &self.untracked.definitions; gen { @@ -1642,7 +1642,7 @@ impl<'tcx> TyCtxt<'tcx> { pub fn definitions(self) -> &'tcx rustc_hir::definitions::Definitions { // Depend on the `analysis` query to ensure compilation if finished. - self.ensure_ok().analysis(()); + self.ensure_ok().required_analysis(()); // Freeze definitions once we start iterating on them, to prevent adding new ones // while iterating. If some query needs to add definitions, it should be `ensure`d above. diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index 6b33279947115..3510c62d3651f 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -36,8 +36,8 @@ use rustc_middle::middle::resolve::{ }; use rustc_middle::middle::resolve_bound_vars::Set1; use rustc_middle::ty::{AssocTag, Visibility}; -use rustc_session::config::ResolveDocLinks; use rustc_session::diagnostics::feature_err; +use rustc_session::output::ResolveDocLinks; use rustc_span::{BytePos, DUMMY_SP, Ident, Span, Spanned, Symbol, bug, kw, respan, span_bug, sym}; use rustc_structures::CrateType; use smallvec::{SmallVec, smallvec}; diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index 0975423ecf363..15e6b01bfcda7 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -1,9 +1,7 @@ //! Contains infrastructure for configuring the compiler, including parsing //! command-line options. -use std::collections::btree_map::{ - Iter as BTreeMapIter, Keys as BTreeMapKeysIter, Values as BTreeMapValuesIter, -}; +use std::collections::btree_map::Iter as BTreeMapIter; use std::collections::{BTreeMap, BTreeSet}; use std::ffi::OsStr; use std::hash::Hash; @@ -15,7 +13,7 @@ use std::{cmp, fs, iter, thread}; use externs::{ExternOpt, split_extern_opt}; use rustc_data_structures::fx::FxHashSet; -use rustc_data_structures::stable_hash::{StableHasher, StableOrd}; +use rustc_data_structures::stable_hash::StableHasher; use rustc_errors::emitter::HumanReadableErrorType; use rustc_errors::{ColorConfig, DiagCtxtFlags}; use rustc_feature::UnstableFeatures; @@ -43,6 +41,7 @@ pub use crate::config::print_request::{ use crate::diagnostics::FileWriteFail; use crate::macros::AllVariants; pub use crate::options::*; +use crate::output::{ErrorOutputType, OutputType, OutputTypes, ResolveDocLinks}; use crate::search_paths::SearchPath; use crate::utils::CanonicalizedPath; use crate::{EarlyDiagCtxt, Session, filesearch, lint}; @@ -692,298 +691,6 @@ impl FromStr for SplitDwarfKind { } } -macro_rules! define_output_types { - ( - $( - $(#[doc = $doc:expr])* - $Variant:ident => { - shorthand: $shorthand:expr, - extension: $extension:expr, - description: $description:expr, - default_filename: $default_filename:expr, - is_text: $is_text:expr, - compatible_with_cgus_and_single_output: $compatible:expr - } - ),* $(,)? - ) => { - #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, PartialOrd, Ord, StableHash)] - #[derive(Encodable, Decodable)] - pub enum OutputType { - $( - $(#[doc = $doc])* - $Variant, - )* - } - - impl StableOrd for OutputType { - const CAN_USE_UNSTABLE_SORT: bool = true; - - // Trivial C-Style enums have a stable sort order across compilation sessions. - const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = (); - } - - impl OutputType { - pub fn iter_all() -> impl Iterator { - static ALL_VARIANTS: &[OutputType] = &[ - $( - OutputType::$Variant, - )* - ]; - ALL_VARIANTS.iter().copied() - } - - fn is_compatible_with_codegen_units_and_single_output_file(&self) -> bool { - match *self { - $( - OutputType::$Variant => $compatible, - )* - } - } - - pub fn shorthand(&self) -> &'static str { - match *self { - $( - OutputType::$Variant => $shorthand, - )* - } - } - - fn from_shorthand(shorthand: &str) -> Option { - match shorthand { - $( - s if s == $shorthand => Some(OutputType::$Variant), - )* - _ => None, - } - } - - fn shorthands_display() -> String { - let shorthands = vec![ - $( - format!("`{}`", $shorthand), - )* - ]; - shorthands.join(", ") - } - - pub fn extension(&self) -> &'static str { - match *self { - $( - OutputType::$Variant => $extension, - )* - } - } - - pub fn is_text_output(&self) -> bool { - match *self { - $( - OutputType::$Variant => $is_text, - )* - } - } - - pub fn description(&self) -> &'static str { - match *self { - $( - OutputType::$Variant => $description, - )* - } - } - - pub fn default_filename(&self) -> &'static str { - match *self { - $( - OutputType::$Variant => $default_filename, - )* - } - } - - - } - } -} - -define_output_types! { - Assembly => { - shorthand: "asm", - extension: "s", - description: "Generates a file with the crate's assembly code", - default_filename: "CRATE_NAME.s", - is_text: true, - compatible_with_cgus_and_single_output: false - }, - #[doc = "This is the optimized bitcode, which could be either pre-LTO or non-LTO bitcode,"] - #[doc = "depending on the specific request type."] - Bitcode => { - shorthand: "llvm-bc", - extension: "bc", - description: "Generates a binary file containing the LLVM bitcode", - default_filename: "CRATE_NAME.bc", - is_text: false, - compatible_with_cgus_and_single_output: false - }, - DepInfo => { - shorthand: "dep-info", - extension: "d", - description: "Generates a file with Makefile syntax that indicates all the source files that were loaded to generate the crate", - default_filename: "CRATE_NAME.d", - is_text: true, - compatible_with_cgus_and_single_output: true - }, - Exe => { - shorthand: "link", - extension: "", - description: "Generates the crates specified by --crate-type. This is the default if --emit is not specified", - default_filename: "(platform and crate-type dependent)", - is_text: false, - compatible_with_cgus_and_single_output: true - }, - LlvmAssembly => { - shorthand: "llvm-ir", - extension: "ll", - description: "Generates a file containing LLVM IR", - default_filename: "CRATE_NAME.ll", - is_text: true, - compatible_with_cgus_and_single_output: false - }, - Metadata => { - shorthand: "metadata", - extension: "rmeta", - description: "Generates a file containing metadata about the crate", - default_filename: "libCRATE_NAME.rmeta", - is_text: false, - compatible_with_cgus_and_single_output: true - }, - Mir => { - shorthand: "mir", - extension: "mir", - description: "Generates a file containing rustc's mid-level intermediate representation", - default_filename: "CRATE_NAME.mir", - is_text: true, - compatible_with_cgus_and_single_output: false - }, - Object => { - shorthand: "obj", - extension: "o", - description: "Generates a native object file", - default_filename: "CRATE_NAME.o", - is_text: false, - compatible_with_cgus_and_single_output: false - }, - #[doc = "This is the summary or index data part of the ThinLTO bitcode."] - ThinLinkBitcode => { - shorthand: "thin-link-bitcode", - extension: "indexing.o", - description: "Generates the ThinLTO summary as bitcode", - default_filename: "CRATE_NAME.indexing.o", - is_text: false, - compatible_with_cgus_and_single_output: false - }, -} - -/// The type of diagnostics output to generate. -#[derive(Clone, Copy, Debug, PartialEq, Eq, Default)] -pub enum ErrorOutputType { - /// Output meant for the consumption of humans. - #[default] - HumanReadable { - kind: HumanReadableErrorType = HumanReadableErrorType { no_graphics: false, short: false, unicode: false }, - color_config: ColorConfig = ColorConfig::Auto, - }, - /// Output that's consumed by other tools such as `rustfix` or the `RLS`. - Json { - /// Render the JSON in a human readable way (with indents and newlines). - pretty: bool, - /// The JSON output includes a `rendered` field that includes the rendered - /// human output. - json_rendered: HumanReadableErrorType, - color_config: ColorConfig, - }, -} - -#[derive(Clone, Hash, Debug)] -pub enum ResolveDocLinks { - /// Do not resolve doc links. - None, - /// Resolve doc links on exported items only for crate types that have metadata. - ExportedMetadata, - /// Resolve doc links on exported items. - Exported, - /// Resolve doc links on all items. - All, -} - -/// Use tree-based collections to cheaply get a deterministic `Hash` implementation. -/// *Do not* switch `BTreeMap` out for an unsorted container type! That would break -/// dependency tracking for command-line arguments. Also only hash keys, since tracking -/// should only depend on the output types, not the paths they're written to. -#[derive(Clone, Debug, Hash, StableHash, Encodable, Decodable)] -pub struct OutputTypes(BTreeMap>); - -impl OutputTypes { - pub fn new(entries: &[(OutputType, Option)]) -> OutputTypes { - OutputTypes(BTreeMap::from_iter(entries.iter().map(|&(k, ref v)| (k, v.clone())))) - } - - pub(crate) fn get(&self, key: &OutputType) -> Option<&Option> { - self.0.get(key) - } - - pub fn contains_key(&self, key: &OutputType) -> bool { - self.0.contains_key(key) - } - - /// Returns `true` if user specified a name and not just produced type - pub fn contains_explicit_name(&self, key: &OutputType) -> bool { - matches!(self.0.get(key), Some(Some(..))) - } - - pub fn iter(&self) -> BTreeMapIter<'_, OutputType, Option> { - self.0.iter() - } - - pub fn keys(&self) -> BTreeMapKeysIter<'_, OutputType, Option> { - self.0.keys() - } - - pub fn values(&self) -> BTreeMapValuesIter<'_, OutputType, Option> { - self.0.values() - } - - pub fn len(&self) -> usize { - self.0.len() - } - - /// Returns `true` if any of the output types require codegen or linking. - pub fn should_codegen(&self) -> bool { - self.0.keys().any(|k| match *k { - OutputType::Bitcode - | OutputType::ThinLinkBitcode - | OutputType::Assembly - | OutputType::LlvmAssembly - | OutputType::Mir - | OutputType::Object - | OutputType::Exe => true, - OutputType::Metadata | OutputType::DepInfo => false, - }) - } - - /// Returns `true` if any of the output types require linking. - pub fn should_link(&self) -> bool { - self.0.keys().any(|k| match *k { - OutputType::Bitcode - | OutputType::ThinLinkBitcode - | OutputType::Assembly - | OutputType::LlvmAssembly - | OutputType::Mir - | OutputType::Metadata - | OutputType::Object - | OutputType::DepInfo => false, - OutputType::Exe => true, - }) - } -} - /// Use tree-based collections to cheaply get a deterministic `Hash` implementation. /// *Do not* switch `BTreeMap` or `BTreeSet` out for an unsorted container type! That /// would break dependency tracking for command-line arguments. diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index 326323b727a04..b8a2269a3f8a8 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -22,6 +22,7 @@ use rustc_target::spec::{ }; use crate::config::*; +use crate::output::{ErrorOutputType, OutputTypes, ResolveDocLinks}; use crate::search_paths::SearchPath; use crate::utils::NativeLib; use crate::{EarlyDiagCtxt, Session, lint}; diff --git a/compiler/rustc_session/src/output.rs b/compiler/rustc_session/src/output.rs index 4824abae622c2..e24d5f3dd8724 100644 --- a/compiler/rustc_session/src/output.rs +++ b/compiler/rustc_session/src/output.rs @@ -1,12 +1,20 @@ //! Related to out filenames of compilation (e.g. binaries). +use std::collections::BTreeMap; +use std::collections::btree_map::{ + Iter as BTreeMapIter, Keys as BTreeMapKeysIter, Values as BTreeMapValuesIter, +}; use std::path::Path; +use rustc_data_structures::stable_hash::StableOrd; +use rustc_errors::ColorConfig; +use rustc_errors::emitter::HumanReadableErrorType; +use rustc_macros::{Decodable, Encodable, StableHash}; use rustc_span::{Span, Symbol}; use rustc_structures::CrateType; use crate::Session; -use crate::config::{OutFileName, OutputFilenames, OutputType}; +use crate::config::{OutFileName, OutputFilenames}; use crate::diagnostics::{ CrateNameEmpty, FileIsNotWriteable, InvalidCharacterInCrateName, InvalidCharacterInCrateNameSuggestion, @@ -158,3 +166,295 @@ pub fn invalid_output_for_target(sess: &Session, crate_type: CrateType) -> bool false } + +macro_rules! define_output_types { + ( + $( + $(#[doc = $doc:expr])* + $Variant:ident => { + shorthand: $shorthand:expr, + extension: $extension:expr, + description: $description:expr, + default_filename: $default_filename:expr, + is_text: $is_text:expr, + compatible_with_cgus_and_single_output: $compatible:expr + } + ),* $(,)? + ) => { + #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, PartialOrd, Ord, StableHash)] + #[derive(Encodable, Decodable)] + pub enum OutputType { + $( + $(#[doc = $doc])* + $Variant, + )* + } + + impl StableOrd for OutputType { + const CAN_USE_UNSTABLE_SORT: bool = true; + + // Trivial C-Style enums have a stable sort order across compilation sessions. + const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED: () = (); + } + + impl OutputType { + pub fn iter_all() -> impl Iterator { + static ALL_VARIANTS: &[OutputType] = &[ + $( + OutputType::$Variant, + )* + ]; + ALL_VARIANTS.iter().copied() + } + + pub(crate) fn is_compatible_with_codegen_units_and_single_output_file(&self) -> bool { + match *self { + $( + OutputType::$Variant => $compatible, + )* + } + } + + pub fn shorthand(&self) -> &'static str { + match *self { + $( + OutputType::$Variant => $shorthand, + )* + } + } + + pub(crate) fn from_shorthand(shorthand: &str) -> Option { + match shorthand { + $( + s if s == $shorthand => Some(OutputType::$Variant), + )* + _ => None, + } + } + + pub(crate) fn shorthands_display() -> String { + let shorthands = vec![ + $( + format!("`{}`", $shorthand), + )* + ]; + shorthands.join(", ") + } + + pub fn extension(&self) -> &'static str { + match *self { + $( + OutputType::$Variant => $extension, + )* + } + } + + pub fn is_text_output(&self) -> bool { + match *self { + $( + OutputType::$Variant => $is_text, + )* + } + } + + pub fn description(&self) -> &'static str { + match *self { + $( + OutputType::$Variant => $description, + )* + } + } + + pub fn default_filename(&self) -> &'static str { + match *self { + $( + OutputType::$Variant => $default_filename, + )* + } + } + + + } + } +} + +define_output_types! { + Assembly => { + shorthand: "asm", + extension: "s", + description: "Generates a file with the crate's assembly code", + default_filename: "CRATE_NAME.s", + is_text: true, + compatible_with_cgus_and_single_output: false + }, + #[doc = "This is the optimized bitcode, which could be either pre-LTO or non-LTO bitcode,"] + #[doc = "depending on the specific request type."] + Bitcode => { + shorthand: "llvm-bc", + extension: "bc", + description: "Generates a binary file containing the LLVM bitcode", + default_filename: "CRATE_NAME.bc", + is_text: false, + compatible_with_cgus_and_single_output: false + }, + DepInfo => { + shorthand: "dep-info", + extension: "d", + description: "Generates a file with Makefile syntax that indicates all the source files that were loaded to generate the crate", + default_filename: "CRATE_NAME.d", + is_text: true, + compatible_with_cgus_and_single_output: true + }, + Exe => { + shorthand: "link", + extension: "", + description: "Generates the crates specified by --crate-type. This is the default if --emit is not specified", + default_filename: "(platform and crate-type dependent)", + is_text: false, + compatible_with_cgus_and_single_output: true + }, + LlvmAssembly => { + shorthand: "llvm-ir", + extension: "ll", + description: "Generates a file containing LLVM IR", + default_filename: "CRATE_NAME.ll", + is_text: true, + compatible_with_cgus_and_single_output: false + }, + Metadata => { + shorthand: "metadata", + extension: "rmeta", + description: "Generates a file containing metadata about the crate", + default_filename: "libCRATE_NAME.rmeta", + is_text: false, + compatible_with_cgus_and_single_output: true + }, + Mir => { + shorthand: "mir", + extension: "mir", + description: "Generates a file containing rustc's mid-level intermediate representation", + default_filename: "CRATE_NAME.mir", + is_text: true, + compatible_with_cgus_and_single_output: false + }, + Object => { + shorthand: "obj", + extension: "o", + description: "Generates a native object file", + default_filename: "CRATE_NAME.o", + is_text: false, + compatible_with_cgus_and_single_output: false + }, + #[doc = "This is the summary or index data part of the ThinLTO bitcode."] + ThinLinkBitcode => { + shorthand: "thin-link-bitcode", + extension: "indexing.o", + description: "Generates the ThinLTO summary as bitcode", + default_filename: "CRATE_NAME.indexing.o", + is_text: false, + compatible_with_cgus_and_single_output: false + }, +} + +/// The type of diagnostics output to generate. +#[derive(Clone, Copy, Debug, PartialEq, Eq, Default)] +pub enum ErrorOutputType { + /// Output meant for the consumption of humans. + #[default] + HumanReadable { + kind: HumanReadableErrorType = HumanReadableErrorType { no_graphics: false, short: false, unicode: false }, + color_config: ColorConfig = ColorConfig::Auto, + }, + /// Output that's consumed by other tools such as `rustfix` or the `RLS`. + Json { + /// Render the JSON in a human readable way (with indents and newlines). + pretty: bool, + /// The JSON output includes a `rendered` field that includes the rendered + /// human output. + json_rendered: HumanReadableErrorType, + color_config: ColorConfig, + }, +} + +#[derive(Clone, Hash, Debug)] +pub enum ResolveDocLinks { + /// Do not resolve doc links. + None, + /// Resolve doc links on exported items only for crate types that have metadata. + ExportedMetadata, + /// Resolve doc links on exported items. + Exported, + /// Resolve doc links on all items. + All, +} + +/// Use tree-based collections to cheaply get a deterministic `Hash` implementation. +/// *Do not* switch `BTreeMap` out for an unsorted container type! That would break +/// dependency tracking for command-line arguments. Also only hash keys, since tracking +/// should only depend on the output types, not the paths they're written to. +#[derive(Clone, Debug, Hash, StableHash, Encodable, Decodable)] +pub struct OutputTypes(pub(crate) BTreeMap>); + +impl OutputTypes { + pub fn new(entries: &[(OutputType, Option)]) -> OutputTypes { + OutputTypes(BTreeMap::from_iter(entries.iter().map(|&(k, ref v)| (k, v.clone())))) + } + + pub(crate) fn get(&self, key: &OutputType) -> Option<&Option> { + self.0.get(key) + } + + pub fn contains_key(&self, key: &OutputType) -> bool { + self.0.contains_key(key) + } + + /// Returns `true` if user specified a name and not just produced type + pub fn contains_explicit_name(&self, key: &OutputType) -> bool { + matches!(self.0.get(key), Some(Some(..))) + } + + pub fn iter(&self) -> BTreeMapIter<'_, OutputType, Option> { + self.0.iter() + } + + pub fn keys(&self) -> BTreeMapKeysIter<'_, OutputType, Option> { + self.0.keys() + } + + pub fn values(&self) -> BTreeMapValuesIter<'_, OutputType, Option> { + self.0.values() + } + + pub fn len(&self) -> usize { + self.0.len() + } + + /// Returns `true` if any of the output types require codegen or linking. + pub fn should_codegen(&self) -> bool { + self.0.keys().any(|k| match *k { + OutputType::Bitcode + | OutputType::ThinLinkBitcode + | OutputType::Assembly + | OutputType::LlvmAssembly + | OutputType::Mir + | OutputType::Object + | OutputType::Exe => true, + OutputType::Metadata | OutputType::DepInfo => false, + }) + } + + /// Returns `true` if any of the output types require linking. + pub fn should_link(&self) -> bool { + self.0.keys().any(|k| match *k { + OutputType::Bitcode + | OutputType::ThinLinkBitcode + | OutputType::Assembly + | OutputType::LlvmAssembly + | OutputType::Mir + | OutputType::Metadata + | OutputType::Object + | OutputType::DepInfo => false, + OutputType::Exe => true, + }) + } +} diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index 6b7e2214f26d9..195a370707497 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -38,11 +38,12 @@ use crate::code_stats::CodeStats; pub use crate::code_stats::{DataTypeKind, FieldInfo, FieldKind, SizeKind, VariantInfo}; use crate::config::{ self, BranchProtection, Cfg, CheckCfg, CoverageLevel, CoverageOptions, DebugInfo, - ErrorOutputType, FunctionReturn, Input, InstrumentCoverage, InstrumentMcount, LtoCli, - NATIVE_CPU, OutFileName, OutputType, PAuthKey, PointerAuthOption, SwitchWithOptPath, + FunctionReturn, Input, InstrumentCoverage, InstrumentMcount, LtoCli, NATIVE_CPU, OutFileName, + PAuthKey, PointerAuthOption, SwitchWithOptPath, }; use crate::filesearch::FileSearch; use crate::lint::LintId; +use crate::output::{ErrorOutputType, OutputType}; use crate::parse::ParseSess; use crate::search_paths::SearchPath; use crate::{diagnostics, filesearch, lint}; @@ -1310,7 +1311,7 @@ fn default_emitter(sopts: &config::Options, source_map: Arc) -> Box match kind { + ErrorOutputType::HumanReadable { kind, color_config } => match kind { HumanReadableErrorType { no_graphics, short, unicode } => { let emitter = AnnotateSnippetEmitter::new(stderr_destination(color_config)) .sm(source_map) @@ -1327,7 +1328,7 @@ fn default_emitter(sopts: &config::Options, source_map: Arc) -> Box Box::new( + ErrorOutputType::Json { pretty, json_rendered, color_config } => Box::new( JsonEmitter::new( Box::new(io::BufWriter::new(io::stderr())), source_map, @@ -1971,7 +1972,7 @@ impl EarlyDiagCtxt { fn mk_emitter(output: ErrorOutputType) -> Box { let emitter: Box = match output { - config::ErrorOutputType::HumanReadable { kind, color_config } => match kind { + ErrorOutputType::HumanReadable { kind, color_config } => match kind { HumanReadableErrorType { no_graphics, short, unicode } => Box::new( AnnotateSnippetEmitter::new(stderr_destination(color_config)) .theme(if unicode { OutputTheme::Unicode } else { OutputTheme::Ascii }) @@ -1979,7 +1980,7 @@ fn mk_emitter(output: ErrorOutputType) -> Box { .no_graphics(no_graphics), ), }, - config::ErrorOutputType::Json { pretty, json_rendered, color_config } => { + ErrorOutputType::Json { pretty, json_rendered, color_config } => { Box::new(JsonEmitter::new( Box::new(io::BufWriter::new(io::stderr())), Some(Arc::new(SourceMap::new(FilePathMapping::empty()))), diff --git a/src/doc/rustc-dev-guide/src/parallel-rustc.md b/src/doc/rustc-dev-guide/src/parallel-rustc.md index c4e0663068e6e..4a530518c8696 100644 --- a/src/doc/rustc-dev-guide/src/parallel-rustc.md +++ b/src/doc/rustc-dev-guide/src/parallel-rustc.md @@ -116,18 +116,18 @@ the parallel iterator function has been used are as follows: | caller | scenario | callee | | ------------------------------------------------------- | ------------------------------------------------------------ | ------------------------ | -| rustc_metadata::rmeta::encoder::prefetch_mir | Prefetch queries which will be needed later by metadata encoding | par_iter | +| rustc_metadata::rmeta::encoder::prefetch_mir | Prefetch queries which will be needed later by metadata encoding | par_iter | | rustc_monomorphize::collector::collect_crate_mono_items | Collect monomorphized items reachable from non-generic items | par_for_each_in | -| rustc_interface::passes::analysis | Check the validity of the match statements | Map::par_body_owners | -| rustc_interface::passes::analysis | MIR borrow check | Map::par_body_owners | +| rustc_interface::passes::full_analysis | Check the validity of the match statements | Map::par_body_owners | +| rustc_interface::passes::full_analysis | MIR borrow check | Map::par_body_owners | | rustc_typeck::check::typeck_item_bodies | Type check | Map::par_body_owners | | rustc_interface::passes::hir_id_validator::check_crate | Check the validity of hir | Map::par_for_each_module | -| rustc_interface::passes::analysis | Check the validity of loops body, attributes, naked functions, unstable abi, const bodys | Map::par_for_each_module | -| rustc_interface::passes::analysis | Liveness and intrinsic checking of MIR | Map::par_for_each_module | -| rustc_interface::passes::analysis | Deathness checking | Map::par_for_each_module | -| rustc_interface::passes::analysis | Privacy checking | Map::par_for_each_module | +| rustc_interface::passes::full_analysis | Check the validity of loops body, attributes, naked functions, unstable abi, const bodys | Map::par_for_each_module | +| rustc_interface::passes::full_analysis | Liveness and intrinsic checking of MIR | Map::par_for_each_module | +| rustc_interface::passes::full_analysis | Deathness checking | Map::par_for_each_module | +| rustc_interface::passes::full_analysis | Privacy checking | Map::par_for_each_module | | rustc_lint::late::check_crate | Run per-module lints | Map::par_for_each_module | -| rustc_typeck::check_crate | Well-formedness checking | Map::par_for_each_module | +| rustc_typeck::check_crate | Well-formedness checking | Map::par_for_each_module | There are still many loops that have the potential to use parallel iterators. diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs index 4c8793c2cd4a6..38ce45cb009a9 100644 --- a/src/librustdoc/config.rs +++ b/src/librustdoc/config.rs @@ -9,11 +9,12 @@ use rustc_data_structures::fx::FxIndexMap; use rustc_errors::DiagCtxtHandle; use rustc_lint::Level; use rustc_session::config::{ - self, CodegenOptions, ErrorOutputType, Externs, Input, JsonUnusedExterns, - OptionsTargetModifiers, OutFileName, PrintCategory, PrintRequest, Sysroot, UnstableOptions, - collect_print_requests, get_cmd_lint_options, nightly_options, parse_crate_types_from_list, - parse_externs, parse_target_triple, + self, CodegenOptions, Externs, Input, JsonUnusedExterns, OptionsTargetModifiers, OutFileName, + PrintCategory, PrintRequest, Sysroot, UnstableOptions, collect_print_requests, + get_cmd_lint_options, nightly_options, parse_crate_types_from_list, parse_externs, + parse_target_triple, }; +use rustc_session::output::ErrorOutputType; use rustc_session::search_paths::SearchPath; use rustc_session::{EarlyDiagCtxt, getopts}; use rustc_span::edition::Edition; diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index e7e47cba44dd6..0a39a1a9cebee 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -19,10 +19,9 @@ use rustc_lint::{MissingDoc, late_lint_mod}; use rustc_middle::hir::nested_filter; use rustc_middle::ty::{self, ParamEnv, Ty, TyCtxt}; use rustc_session::Session; -use rustc_session::config::{ - self, ErrorOutputType, Input, OutputType, OutputTypes, ResolveDocLinks, -}; +use rustc_session::config::{self, Input}; pub(crate) use rustc_session::config::{Options, UnstableOptions}; +use rustc_session::output::{ErrorOutputType, OutputType, OutputTypes, ResolveDocLinks}; use rustc_span::source_map; use rustc_span::symbol::sym; use rustc_structures::CrateType; diff --git a/src/librustdoc/doctest.rs b/src/librustdoc/doctest.rs index 0c0e2cddf6826..ca2ecb407d77a 100644 --- a/src/librustdoc/doctest.rs +++ b/src/librustdoc/doctest.rs @@ -27,7 +27,8 @@ use rustc_hir::def_id::LOCAL_CRATE; use rustc_interface::interface; use rustc_lint as lint; use rustc_middle::ty::TyCtxt; -use rustc_session::config::{self, ErrorOutputType, Input}; +use rustc_session::config::{self, Input}; +use rustc_session::output::ErrorOutputType; use rustc_span::edition::Edition; use rustc_span::{FileName, RemapPathScopeComponents, Span}; use rustc_structures::CrateType; diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 9a16942a2e5bc..b49703b2844b2 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -70,7 +70,8 @@ use rustc_errors::DiagCtxtHandle; use rustc_hir::def_id::LOCAL_CRATE; use rustc_interface::interface; use rustc_middle::ty::TyCtxt; -use rustc_session::config::{ErrorOutputType, Input, RustcOptGroup, make_crate_type_option}; +use rustc_session::config::{Input, RustcOptGroup, make_crate_type_option}; +use rustc_session::output::ErrorOutputType; use rustc_session::{EarlyDiagCtxt, getopts}; use rustc_span::{BytePos, Span, SyntaxContext}; use tracing::info; diff --git a/src/tools/clippy/clippy_config/src/de.rs b/src/tools/clippy/clippy_config/src/de.rs index fb335f27aeed6..4e0f1ed31201c 100644 --- a/src/tools/clippy/clippy_config/src/de.rs +++ b/src/tools/clippy/clippy_config/src/de.rs @@ -5,7 +5,7 @@ use rustc_attr_ir::RustcVersion; use rustc_attr_parsing::parse_version; use rustc_errors::{DiagCtxtHandle, DiagMessage}; use rustc_session::Session; -use rustc_session::config::ErrorOutputType; +use rustc_session::output::ErrorOutputType; use rustc_span::edit_distance::edit_distance; use rustc_span::{BytePos, Pos as _, Span, Spanned, Symbol}; use std::collections::{HashMap, HashSet}; diff --git a/src/tools/clippy/src/driver.rs b/src/tools/clippy/src/driver.rs index e83fe592a7ca6..c179a9a84f5f8 100644 --- a/src/tools/clippy/src/driver.rs +++ b/src/tools/clippy/src/driver.rs @@ -18,7 +18,7 @@ rustc_driver::override_c_allocator_in_binary!(); use clippy_utils::sym; use declare_clippy_lint::LintListBuilder; use rustc_interface::interface; -use rustc_session::config::ErrorOutputType; +use rustc_session::output::ErrorOutputType; use rustc_session::{EarlyDiagCtxt, Session}; use rustc_span::symbol::Symbol; diff --git a/src/tools/error_index_generator/main.rs b/src/tools/error_index_generator/main.rs index c78df2b60b56d..c18b73a4c656e 100644 --- a/src/tools/error_index_generator/main.rs +++ b/src/tools/error_index_generator/main.rs @@ -191,7 +191,7 @@ fn parse_args() -> (OutputFormat, PathBuf) { fn main() { let handler = - rustc_session::EarlyDiagCtxt::new(rustc_session::config::ErrorOutputType::default()); + rustc_session::EarlyDiagCtxt::new(rustc_session::output::ErrorOutputType::default()); rustc_driver::init_logger(&handler, rustc_log::LoggerConfig::from_env("RUST_LOG")); let (format, dst) = parse_args(); let result = main_with_result(format, &dst); diff --git a/src/tools/miri/priroda/src/main.rs b/src/tools/miri/priroda/src/main.rs index 73809cd50a6df..c5ba7c415967e 100644 --- a/src/tools/miri/priroda/src/main.rs +++ b/src/tools/miri/priroda/src/main.rs @@ -19,7 +19,7 @@ use rustc_driver::Compilation; use rustc_interface::interface; use rustc_middle::ty::TyCtxt; use rustc_session::EarlyDiagCtxt; -use rustc_session::config::ErrorOutputType; +use rustc_session::output::ErrorOutputType; use rustc_structures::CrateType; fn find_sysroot() -> String { diff --git a/src/tools/miri/src/bin/miri.rs b/src/tools/miri/src/bin/miri.rs index e3e2eef146ccc..7a69297c1a221 100644 --- a/src/tools/miri/src/bin/miri.rs +++ b/src/tools/miri/src/bin/miri.rs @@ -45,7 +45,8 @@ use rustc_interface::util::DummyCodegenBackend; use rustc_log::tracing::debug; use rustc_middle::query::LocalCrate; use rustc_middle::ty::TyCtxt; -use rustc_session::config::{ErrorOutputType, OptLevel}; +use rustc_session::config::{OptLevel}; +use rustc_session::output::{ErrorOutputType}; use rustc_session::{EarlyDiagCtxt, EarlySession, Session}; use rustc_structures::CrateType; diff --git a/src/tools/rustfmt/src/bin/main.rs b/src/tools/rustfmt/src/bin/main.rs index b662959adaad9..d2c95f089d263 100644 --- a/src/tools/rustfmt/src/bin/main.rs +++ b/src/tools/rustfmt/src/bin/main.rs @@ -28,7 +28,7 @@ extern crate rustc_driver; extern crate rustc_session; use rustc_session::EarlyDiagCtxt; -use rustc_session::config::ErrorOutputType; +use rustc_session::output::ErrorOutputType; fn main() { rustc_driver::install_ice_hook(BUG_REPORT_URL, |_| ()); diff --git a/tests/ui-fulldeps/run-compiler-twice.rs b/tests/ui-fulldeps/run-compiler-twice.rs index 85e370769517d..dafa4b011c4dc 100644 --- a/tests/ui-fulldeps/run-compiler-twice.rs +++ b/tests/ui-fulldeps/run-compiler-twice.rs @@ -18,7 +18,8 @@ extern crate rustc_span; use std::path::{Path, PathBuf}; use rustc_interface::{Linker, interface}; -use rustc_session::config::{Input, Options, OutFileName, OutputType, OutputTypes, Sysroot}; +use rustc_session::config::{Input, Options, OutFileName, Sysroot}; +use rustc_session::output::{OutputType, OutputTypes}; use rustc_span::FileName; fn main() { @@ -78,7 +79,7 @@ fn compile(code: String, output: PathBuf, sysroot: Sysroot, linker: Option<&Path let krate = rustc_interface::passes::parse(&compiler.sess); let (linker, incr_comp_session) = rustc_interface::create_and_enter_global_ctxt(&compiler, krate, |tcx| { - let _ = tcx.analysis(()); + let _ = rustc_interface::passes::full_analysis(tcx); let metadata = rustc_interface::passes::finish_and_emit_metadata(tcx); Linker::codegen_and_build_linker(tcx, &*compiler.codegen_backend, metadata) }); diff --git a/tests/ui/consts/const-eval/const-eval-query-stack.stderr b/tests/ui/consts/const-eval/const-eval-query-stack.stderr index 5e1179d3993af..683e8e3bc4fc2 100644 --- a/tests/ui/consts/const-eval/const-eval-query-stack.stderr +++ b/tests/ui/consts/const-eval/const-eval-query-stack.stderr @@ -11,5 +11,5 @@ query stack during panic: #0 [eval_to_allocation_raw] const-evaluating + checking `X` #1 [eval_to_const_value_raw] simplifying constant for the type system `X` #2 [eval_to_const_value_raw] simplifying constant for the type system `X` -#3 [analysis] running analysis passes on crate `const_eval_query_stack` +#3 [required_analysis] running required analysis passes on crate `const_eval_query_stack` end of query stack diff --git a/tests/ui/consts/const-eval/do_not_const_check.stderr b/tests/ui/consts/const-eval/do_not_const_check.stderr index 7db40e7ab0114..a6fdf58154384 100644 --- a/tests/ui/consts/const-eval/do_not_const_check.stderr +++ b/tests/ui/consts/const-eval/do_not_const_check.stderr @@ -15,7 +15,7 @@ query stack during panic: #0 [eval_to_allocation_raw] const-evaluating + checking `_` #1 [eval_to_const_value_raw] simplifying constant for the type system `_` #2 [eval_to_const_value_raw] simplifying constant for the type system `_` -#3 [analysis] running analysis passes on crate `do_not_const_check` +#3 [required_analysis] running required analysis passes on crate `do_not_const_check` end of query stack error: internal compiler error: compiler/rustc_const_eval/src/const_eval/machine.rs:LL:CC: calling non-const function `integer_min::` --> $DIR/do_not_const_check.rs:34:5 @@ -34,7 +34,7 @@ query stack during panic: #0 [eval_to_allocation_raw] const-evaluating + checking `_` #1 [eval_to_const_value_raw] simplifying constant for the type system `_` #2 [eval_to_const_value_raw] simplifying constant for the type system `_` -#3 [analysis] running analysis passes on crate `do_not_const_check` +#3 [required_analysis] running required analysis passes on crate `do_not_const_check` end of query stack error: aborting due to 2 previous errors diff --git a/tests/ui/consts/recursive-zst-static.default.stderr b/tests/ui/consts/recursive-zst-static.default.stderr index 44a07cf3dc807..c01dbe5a6e6f0 100644 --- a/tests/ui/consts/recursive-zst-static.default.stderr +++ b/tests/ui/consts/recursive-zst-static.default.stderr @@ -16,7 +16,7 @@ note: ...which requires evaluating initializer of static `B`... LL | static B: () = A; | ^^^^^^^^^^^^ = note: ...which again requires evaluating initializer of static `A`, completing the cycle - = note: cycle used when running analysis passes on crate `recursive_zst_static` + = note: cycle used when running required analysis passes on crate `recursive_zst_static` = note: for more information, see and error: aborting due to 2 previous errors diff --git a/tests/ui/consts/recursive-zst-static.unleash.stderr b/tests/ui/consts/recursive-zst-static.unleash.stderr index 44a07cf3dc807..c01dbe5a6e6f0 100644 --- a/tests/ui/consts/recursive-zst-static.unleash.stderr +++ b/tests/ui/consts/recursive-zst-static.unleash.stderr @@ -16,7 +16,7 @@ note: ...which requires evaluating initializer of static `B`... LL | static B: () = A; | ^^^^^^^^^^^^ = note: ...which again requires evaluating initializer of static `A`, completing the cycle - = note: cycle used when running analysis passes on crate `recursive_zst_static` + = note: cycle used when running required analysis passes on crate `recursive_zst_static` = note: for more information, see and error: aborting due to 2 previous errors diff --git a/tests/ui/track-diagnostics/track.stderr b/tests/ui/track-diagnostics/track.stderr index 9ac567436939b..6a203f0c12e99 100644 --- a/tests/ui/track-diagnostics/track.stderr +++ b/tests/ui/track-diagnostics/track.stderr @@ -41,7 +41,7 @@ note: compiler flags: ... -Z ui-testing ... -Z track-diagnostics query stack during panic: #0 [typeck_root] type-checking `main` -#1 [analysis] running analysis passes on crate `track` +#1 [required_analysis] running required analysis passes on crate `track` end of query stack error: aborting due to 3 previous errors diff --git a/tests/ui/treat-err-as-bug/err.stderr b/tests/ui/treat-err-as-bug/err.stderr index 8ff267deacef5..6e2b513ea16b0 100644 --- a/tests/ui/treat-err-as-bug/err.stderr +++ b/tests/ui/treat-err-as-bug/err.stderr @@ -9,5 +9,5 @@ error: the compiler unexpectedly panicked. This is a bug query stack during panic: #0 [eval_static_initializer] evaluating initializer of static `C` -#1 [analysis] running analysis passes on crate `err` +#1 [required_analysis] running required analysis passes on crate `err` end of query stack