diff options
Diffstat (limited to 'compiler/rustc_session/src')
| -rw-r--r-- | compiler/rustc_session/src/code_stats.rs | 3 | ||||
| -rw-r--r-- | compiler/rustc_session/src/config.rs | 70 | ||||
| -rw-r--r-- | compiler/rustc_session/src/config/cfg.rs | 9 | ||||
| -rw-r--r-- | compiler/rustc_session/src/cstore.rs | 9 | ||||
| -rw-r--r-- | compiler/rustc_session/src/errors.rs | 8 | ||||
| -rw-r--r-- | compiler/rustc_session/src/filesearch.rs | 19 | ||||
| -rw-r--r-- | compiler/rustc_session/src/options.rs | 29 | ||||
| -rw-r--r-- | compiler/rustc_session/src/output.rs | 12 | ||||
| -rw-r--r-- | compiler/rustc_session/src/parse.rs | 22 | ||||
| -rw-r--r-- | compiler/rustc_session/src/search_paths.rs | 8 | ||||
| -rw-r--r-- | compiler/rustc_session/src/session.rs | 46 | ||||
| -rw-r--r-- | compiler/rustc_session/src/utils.rs | 10 | ||||
| -rw-r--r-- | compiler/rustc_session/src/version.rs | 8 |
13 files changed, 129 insertions, 124 deletions
diff --git a/compiler/rustc_session/src/code_stats.rs b/compiler/rustc_session/src/code_stats.rs index 93839fa1186..3668fe4f0a8 100644 --- a/compiler/rustc_session/src/code_stats.rs +++ b/compiler/rustc_session/src/code_stats.rs @@ -1,9 +1,10 @@ +use std::cmp; + use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::sync::Lock; use rustc_span::def_id::DefId; use rustc_span::Symbol; use rustc_target::abi::{Align, Size}; -use std::cmp; #[derive(Clone, PartialEq, Eq, Hash, Debug)] pub struct VariantInfo { diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index e748d1ff47b..f58a991a616 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -3,13 +3,17 @@ #![allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable -pub use crate::options::*; +use std::collections::btree_map::{ + Iter as BTreeMapIter, Keys as BTreeMapKeysIter, Values as BTreeMapValuesIter, +}; +use std::collections::{BTreeMap, BTreeSet}; +use std::ffi::OsStr; +use std::hash::Hash; +use std::path::{Path, PathBuf}; +use std::str::{self, FromStr}; +use std::sync::LazyLock; +use std::{fmt, fs, iter}; -use crate::errors::FileWriteFail; -use crate::search_paths::SearchPath; -use crate::utils::{CanonicalizedPath, NativeLib, NativeLibKind}; -use crate::{filesearch, lint, HashStableContext}; -use crate::{EarlyDiagCtxt, Session}; use rustc_data_structures::fx::{FxHashSet, FxIndexMap}; use rustc_data_structures::stable_hasher::{StableOrd, ToStableHashKey}; use rustc_errors::emitter::HumanReadableErrorType; @@ -19,22 +23,17 @@ use rustc_macros::{Decodable, Encodable, HashStable_Generic}; use rustc_span::edition::{Edition, DEFAULT_EDITION, EDITION_NAME_LIST, LATEST_STABLE_EDITION}; use rustc_span::source_map::FilePathMapping; use rustc_span::{FileName, FileNameDisplayPreference, RealFileName, SourceFileHashAlgorithm}; -use rustc_target::spec::{FramePointer, LinkSelfContainedComponents, LinkerFeatures}; -use rustc_target::spec::{SplitDebuginfo, Target, TargetTriple}; -use std::collections::btree_map::{ - Iter as BTreeMapIter, Keys as BTreeMapKeysIter, Values as BTreeMapValuesIter, +use rustc_target::spec::{ + FramePointer, LinkSelfContainedComponents, LinkerFeatures, SplitDebuginfo, Target, TargetTriple, }; -use std::collections::{BTreeMap, BTreeSet}; -use std::ffi::OsStr; -use std::fmt; -use std::fs; -use std::hash::Hash; -use std::iter; -use std::path::{Path, PathBuf}; -use std::str::{self, FromStr}; -use std::sync::LazyLock; use tracing::debug; +use crate::errors::FileWriteFail; +pub use crate::options::*; +use crate::search_paths::SearchPath; +use crate::utils::{CanonicalizedPath, NativeLib, NativeLibKind}; +use crate::{filesearch, lint, EarlyDiagCtxt, HashStableContext, Session}; + mod cfg; pub mod sigpipe; @@ -2765,9 +2764,10 @@ pub fn parse_crate_types_from_list(list_list: Vec<String>) -> Result<Vec<CrateTy } pub mod nightly_options { + use rustc_feature::UnstableFeatures; + use super::{OptionStability, RustcOptGroup}; use crate::EarlyDiagCtxt; - use rustc_feature::UnstableFeatures; pub fn is_unstable_enabled(matches: &getopts::Matches) -> bool { match_is_nightly_build(matches) @@ -2960,6 +2960,22 @@ pub enum WasiExecModel { /// we have an opt-in scheme here, so one is hopefully forced to think about /// how the hash should be calculated when adding a new command-line argument. pub(crate) mod dep_tracking { + use std::collections::BTreeMap; + use std::hash::{DefaultHasher, Hash}; + use std::num::NonZero; + use std::path::PathBuf; + + use rustc_data_structures::fx::FxIndexMap; + use rustc_data_structures::stable_hasher::Hash64; + use rustc_errors::LanguageIdentifier; + use rustc_feature::UnstableFeatures; + use rustc_span::edition::Edition; + use rustc_span::RealFileName; + use rustc_target::spec::{ + CodeModel, FramePointer, MergeFunctions, OnBrokenPipe, PanicStrategy, RelocModel, + RelroLevel, SanitizerSet, SplitDebuginfo, StackProtector, TargetTriple, TlsModel, WasmCAbi, + }; + use super::{ BranchProtection, CFGuard, CFProtection, CollapseMacroDebuginfo, CoverageOptions, CrateType, DebugInfo, DebugInfoCompression, ErrorOutputType, FunctionReturn, @@ -2971,20 +2987,6 @@ pub(crate) mod dep_tracking { }; use crate::lint; use crate::utils::NativeLib; - use rustc_data_structures::fx::FxIndexMap; - use rustc_data_structures::stable_hasher::Hash64; - use rustc_errors::LanguageIdentifier; - use rustc_feature::UnstableFeatures; - use rustc_span::edition::Edition; - use rustc_span::RealFileName; - use rustc_target::spec::{ - CodeModel, FramePointer, MergeFunctions, OnBrokenPipe, PanicStrategy, RelocModel, - RelroLevel, SanitizerSet, SplitDebuginfo, StackProtector, TargetTriple, TlsModel, WasmCAbi, - }; - use std::collections::BTreeMap; - use std::hash::{DefaultHasher, Hash}; - use std::num::NonZero; - use std::path::PathBuf; pub(crate) trait DepTrackingHash { fn hash( diff --git a/compiler/rustc_session/src/config/cfg.rs b/compiler/rustc_session/src/config/cfg.rs index 2fa04bbe345..4109ebb6d34 100644 --- a/compiler/rustc_session/src/config/cfg.rs +++ b/compiler/rustc_session/src/config/cfg.rs @@ -19,18 +19,17 @@ //! so that the compiler can know the cfg is expected //! - Add the feature gating in `compiler/rustc_feature/src/builtin_attrs.rs` +use std::hash::Hash; +use std::iter; + use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexSet}; use rustc_span::symbol::{sym, Symbol}; use rustc_target::abi::Align; -use rustc_target::spec::{PanicStrategy, RelocModel, SanitizerSet}; -use rustc_target::spec::{Target, TargetTriple, TARGETS}; +use rustc_target::spec::{PanicStrategy, RelocModel, SanitizerSet, Target, TargetTriple, TARGETS}; use crate::config::CrateType; use crate::Session; -use std::hash::Hash; -use std::iter; - /// The parsed `--cfg` options that define the compilation environment of the /// crate, used to drive conditional compilation. /// diff --git a/compiler/rustc_session/src/cstore.rs b/compiler/rustc_session/src/cstore.rs index 2c20c3f0e1a..da7a82fee94 100644 --- a/compiler/rustc_session/src/cstore.rs +++ b/compiler/rustc_session/src/cstore.rs @@ -2,8 +2,9 @@ //! are *mostly* used as a part of that interface, but these should //! probably get a better home if someone can find one. -use crate::search_paths::PathKind; -use crate::utils::NativeLibKind; +use std::any::Any; +use std::path::PathBuf; + use rustc_ast as ast; use rustc_data_structures::sync::{self, AppendOnlyIndexVec, FreezeLock}; use rustc_hir::def_id::{ @@ -15,8 +16,8 @@ use rustc_span::symbol::Symbol; use rustc_span::Span; use rustc_target::spec::abi::Abi; -use std::any::Any; -use std::path::PathBuf; +use crate::search_paths::PathKind; +use crate::utils::NativeLibKind; // lonely orphan structs and enums looking for a better home diff --git a/compiler/rustc_session/src/errors.rs b/compiler/rustc_session/src/errors.rs index 4cbc1b57022..5cc54a5855b 100644 --- a/compiler/rustc_session/src/errors.rs +++ b/compiler/rustc_session/src/errors.rs @@ -2,15 +2,17 @@ use std::num::NonZero; use rustc_ast::token; use rustc_ast::util::literal::LitError; +use rustc_errors::codes::*; use rustc_errors::{ - codes::*, Diag, DiagCtxtHandle, DiagMessage, Diagnostic, EmissionGuarantee, ErrorGuaranteed, - Level, MultiSpan, + Diag, DiagCtxtHandle, DiagMessage, Diagnostic, EmissionGuarantee, ErrorGuaranteed, Level, + MultiSpan, }; use rustc_macros::{Diagnostic, Subdiagnostic}; use rustc_span::{Span, Symbol}; use rustc_target::spec::{SplitDebuginfo, StackProtector, TargetTriple}; -use crate::{config::CrateType, parse::ParseSess}; +use crate::config::CrateType; +use crate::parse::ParseSess; pub(crate) struct FeatureGateError { pub(crate) span: MultiSpan, diff --git a/compiler/rustc_session/src/filesearch.rs b/compiler/rustc_session/src/filesearch.rs index 6f63776bedc..0c3ec36fed5 100644 --- a/compiler/rustc_session/src/filesearch.rs +++ b/compiler/rustc_session/src/filesearch.rs @@ -1,13 +1,14 @@ //! A module for searching for libraries -use crate::search_paths::{PathKind, SearchPath}; +use std::path::{Path, PathBuf}; +use std::{env, fs}; + use rustc_fs_util::{fix_windows_verbatim_for_gcc, try_canonicalize}; use smallvec::{smallvec, SmallVec}; -use std::env; -use std::fs; -use std::path::{Path, PathBuf}; use tracing::debug; +use crate::search_paths::{PathKind, SearchPath}; + #[derive(Clone)] pub struct FileSearch<'a> { sysroot: &'a Path, @@ -129,12 +130,10 @@ fn current_dll_path() -> Result<PathBuf, String> { use std::io; use std::os::windows::prelude::*; - use windows::{ - core::PCWSTR, - Win32::Foundation::HMODULE, - Win32::System::LibraryLoader::{ - GetModuleFileNameW, GetModuleHandleExW, GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, - }, + use windows::core::PCWSTR; + use windows::Win32::Foundation::HMODULE; + use windows::Win32::System::LibraryLoader::{ + GetModuleFileNameW, GetModuleHandleExW, GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, }; let mut module = HMODULE::default(); diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index 8fd1876ff1d..bf54aae1cfe 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -1,26 +1,26 @@ -use crate::config::*; -use crate::search_paths::SearchPath; -use crate::utils::NativeLib; -use crate::{lint, EarlyDiagCtxt}; +use std::collections::BTreeMap; +use std::hash::{DefaultHasher, Hasher}; +use std::num::{IntErrorKind, NonZero}; +use std::path::PathBuf; +use std::str; + use rustc_data_structures::fx::FxIndexMap; use rustc_data_structures::profiling::TimePassesFormat; use rustc_data_structures::stable_hasher::Hash64; -use rustc_errors::ColorConfig; -use rustc_errors::{LanguageIdentifier, TerminalUrl}; +use rustc_errors::{ColorConfig, LanguageIdentifier, TerminalUrl}; use rustc_feature::UnstableFeatures; use rustc_span::edition::Edition; -use rustc_span::RealFileName; -use rustc_span::SourceFileHashAlgorithm; +use rustc_span::{RealFileName, SourceFileHashAlgorithm}; use rustc_target::spec::{ CodeModel, FramePointer, LinkerFlavorCli, MergeFunctions, OnBrokenPipe, PanicStrategy, RelocModel, RelroLevel, SanitizerSet, SplitDebuginfo, StackProtector, TargetTriple, TlsModel, WasmCAbi, }; -use std::collections::BTreeMap; -use std::hash::{DefaultHasher, Hasher}; -use std::num::{IntErrorKind, NonZero}; -use std::path::PathBuf; -use std::str; + +use crate::config::*; +use crate::search_paths::SearchPath; +use crate::utils::NativeLib; +use crate::{lint, EarlyDiagCtxt}; macro_rules! insert { ($opt_name:ident, $opt_expr:expr, $sub_hashes:expr) => { @@ -447,9 +447,10 @@ mod desc { } mod parse { - pub(crate) use super::*; use std::str::FromStr; + pub(crate) use super::*; + /// This is for boolean options that don't take a value and start with /// `no-`. This style of option is deprecated. pub(crate) fn parse_no_flag(slot: &mut bool, v: Option<&str>) -> bool { diff --git a/compiler/rustc_session/src/output.rs b/compiler/rustc_session/src/output.rs index 9a5314312e5..c2ca19e563c 100644 --- a/compiler/rustc_session/src/output.rs +++ b/compiler/rustc_session/src/output.rs @@ -1,16 +1,18 @@ //! Related to out filenames of compilation (e.g. binaries). +use std::path::Path; + +use rustc_ast::{self as ast, attr}; +use rustc_errors::FatalError; +use rustc_span::symbol::sym; +use rustc_span::{Span, Symbol}; + use crate::config::{self, CrateType, Input, OutFileName, OutputFilenames, OutputType}; use crate::errors::{ self, CrateNameDoesNotMatch, CrateNameEmpty, CrateNameInvalid, FileIsNotWriteable, InvalidCharacterInCrateName, InvalidCrateNameHelp, }; use crate::Session; -use rustc_ast::{self as ast, attr}; -use rustc_errors::FatalError; -use rustc_span::symbol::sym; -use rustc_span::{Span, Symbol}; -use std::path::Path; pub fn out_filename( sess: &Session, diff --git a/compiler/rustc_session/src/parse.rs b/compiler/rustc_session/src/parse.rs index 200505aaea2..ebd5021dae1 100644 --- a/compiler/rustc_session/src/parse.rs +++ b/compiler/rustc_session/src/parse.rs @@ -1,15 +1,9 @@ //! Contains `ParseSess` which holds state living beyond what one `Parser` might. //! It also serves as an input to the parser itself. -use crate::config::{Cfg, CheckCfg}; -use crate::errors::{ - CliFeatureDiagnosticHelp, FeatureDiagnosticForIssue, FeatureDiagnosticHelp, - FeatureDiagnosticSuggestion, FeatureGateError, SuggestUpgradeCompiler, -}; -use crate::lint::{ - builtin::UNSTABLE_SYNTAX_PRE_EXPANSION, BufferedEarlyLint, BuiltinLintDiag, Lint, LintId, -}; -use crate::Session; +use std::str; + +use rustc_ast::attr::AttrIdGenerator; use rustc_ast::node_id::NodeId; use rustc_data_structures::fx::{FxHashMap, FxIndexMap, FxIndexSet}; use rustc_data_structures::sync::{AppendOnlyVec, Lock, Lrc}; @@ -24,8 +18,14 @@ use rustc_span::hygiene::ExpnId; use rustc_span::source_map::{FilePathMapping, SourceMap}; use rustc_span::{Span, Symbol}; -use rustc_ast::attr::AttrIdGenerator; -use std::str; +use crate::config::{Cfg, CheckCfg}; +use crate::errors::{ + CliFeatureDiagnosticHelp, FeatureDiagnosticForIssue, FeatureDiagnosticHelp, + FeatureDiagnosticSuggestion, FeatureGateError, SuggestUpgradeCompiler, +}; +use crate::lint::builtin::UNSTABLE_SYNTAX_PRE_EXPANSION; +use crate::lint::{BufferedEarlyLint, BuiltinLintDiag, Lint, LintId}; +use crate::Session; /// Collected spans during parsing for places where a certain feature was /// used and should be feature gated accordingly in `check_crate`. diff --git a/compiler/rustc_session/src/search_paths.rs b/compiler/rustc_session/src/search_paths.rs index 5e8adffc249..d65b1b8b3f1 100644 --- a/compiler/rustc_session/src/search_paths.rs +++ b/compiler/rustc_session/src/search_paths.rs @@ -1,8 +1,10 @@ -use crate::filesearch::make_target_lib_path; -use crate::EarlyDiagCtxt; +use std::path::{Path, PathBuf}; + use rustc_macros::{Decodable, Encodable, HashStable_Generic}; use rustc_target::spec::TargetTriple; -use std::path::{Path, PathBuf}; + +use crate::filesearch::make_target_lib_path; +use crate::EarlyDiagCtxt; #[derive(Clone, Debug)] pub struct SearchPath { diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index 89d029fa6e0..be67baf57f6 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -1,14 +1,11 @@ -use crate::code_stats::CodeStats; -pub use crate::code_stats::{DataTypeKind, FieldInfo, FieldKind, SizeKind, VariantInfo}; -use crate::config::{ - self, CoverageLevel, CrateType, FunctionReturn, InstrumentCoverage, OptLevel, OutFileName, - OutputType, RemapPathScopeComponents, SwitchWithOptPath, -}; -use crate::config::{ErrorOutputType, Input}; -use crate::errors; -use crate::parse::{add_feature_diagnostics, ParseSess}; -use crate::search_paths::{PathKind, SearchPath}; -use crate::{filesearch, lint}; +use std::any::Any; +use std::ops::{Div, Mul}; +use std::path::{Path, PathBuf}; +use std::str::FromStr; +use std::sync::atomic::AtomicBool; +use std::sync::atomic::Ordering::SeqCst; +use std::sync::Arc; +use std::{env, fmt, io}; use rustc_data_structures::flock; use rustc_data_structures::fx::{FxHashMap, FxIndexSet}; @@ -18,33 +15,34 @@ use rustc_data_structures::sync::{ AtomicU64, DynSend, DynSync, Lock, Lrc, MappedReadGuard, ReadGuard, RwLock, }; use rustc_errors::annotate_snippet_emitter_writer::AnnotateSnippetEmitter; +use rustc_errors::codes::*; use rustc_errors::emitter::{stderr_destination, DynEmitter, HumanEmitter, HumanReadableErrorType}; use rustc_errors::json::JsonEmitter; use rustc_errors::registry::Registry; use rustc_errors::{ - codes::*, fallback_fluent_bundle, Diag, DiagCtxt, DiagCtxtHandle, DiagMessage, Diagnostic, + fallback_fluent_bundle, Diag, DiagCtxt, DiagCtxtHandle, DiagMessage, Diagnostic, ErrorGuaranteed, FatalAbort, FluentBundle, LazyFallbackBundle, TerminalUrl, }; use rustc_macros::HashStable_Generic; pub use rustc_span::def_id::StableCrateId; use rustc_span::edition::Edition; use rustc_span::source_map::{FilePathMapping, SourceMap}; -use rustc_span::{FileNameDisplayPreference, RealFileName}; -use rustc_span::{Span, Symbol}; +use rustc_span::{FileNameDisplayPreference, RealFileName, Span, Symbol}; use rustc_target::asm::InlineAsmArch; -use rustc_target::spec::{CodeModel, PanicStrategy, RelocModel, RelroLevel}; use rustc_target::spec::{ - DebuginfoKind, SanitizerSet, SplitDebuginfo, StackProtector, Target, TargetTriple, TlsModel, + CodeModel, DebuginfoKind, PanicStrategy, RelocModel, RelroLevel, SanitizerSet, SplitDebuginfo, + StackProtector, Target, TargetTriple, TlsModel, }; -use std::any::Any; -use std::env; -use std::fmt; -use std::io; -use std::ops::{Div, Mul}; -use std::path::{Path, PathBuf}; -use std::str::FromStr; -use std::sync::{atomic::AtomicBool, atomic::Ordering::SeqCst, Arc}; +use crate::code_stats::CodeStats; +pub use crate::code_stats::{DataTypeKind, FieldInfo, FieldKind, SizeKind, VariantInfo}; +use crate::config::{ + self, CoverageLevel, CrateType, ErrorOutputType, FunctionReturn, Input, InstrumentCoverage, + OptLevel, OutFileName, OutputType, RemapPathScopeComponents, SwitchWithOptPath, +}; +use crate::parse::{add_feature_diagnostics, ParseSess}; +use crate::search_paths::{PathKind, SearchPath}; +use crate::{errors, filesearch, lint}; struct OptimizationFuel { /// If `-zfuel=crate=n` is specified, initially set to `n`, otherwise `0`. diff --git a/compiler/rustc_session/src/utils.rs b/compiler/rustc_session/src/utils.rs index f70a53eeb41..37528a4425f 100644 --- a/compiler/rustc_session/src/utils.rs +++ b/compiler/rustc_session/src/utils.rs @@ -1,11 +1,11 @@ -use crate::session::Session; +use std::path::{Path, PathBuf}; +use std::sync::OnceLock; + use rustc_data_structures::profiling::VerboseTimingGuard; use rustc_fs_util::try_canonicalize; use rustc_macros::{Decodable, Encodable, HashStable_Generic}; -use std::{ - path::{Path, PathBuf}, - sync::OnceLock, -}; + +use crate::session::Session; impl Session { pub fn timer(&self, what: &'static str) -> VerboseTimingGuard<'_> { diff --git a/compiler/rustc_session/src/version.rs b/compiler/rustc_session/src/version.rs index e244c77f7f9..79f97fd327a 100644 --- a/compiler/rustc_session/src/version.rs +++ b/compiler/rustc_session/src/version.rs @@ -1,10 +1,8 @@ -use rustc_macros::{current_rustc_version, Decodable, Encodable, HashStable_Generic}; -use std::{ - borrow::Cow, - fmt::{self, Display}, -}; +use std::borrow::Cow; +use std::fmt::{self, Display}; use rustc_errors::IntoDiagArg; +use rustc_macros::{current_rustc_version, Decodable, Encodable, HashStable_Generic}; #[derive(Encodable, Decodable, Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] #[derive(HashStable_Generic)] |
