@@ -8,23 +8,19 @@ use crate::search_paths::SearchPath;
88use crate::utils::{CanonicalizedPath, NativeLib, NativeLibKind};
99use crate::{lint, HashStableContext};
1010use crate::{EarlyErrorHandler, Session};
11-
1211use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexSet};
1312use rustc_data_structures::stable_hasher::{StableOrd, ToStableHashKey};
14- use rustc_target::abi::Align;
15- use rustc_target::spec::LinkSelfContainedComponents;
16- use rustc_target::spec::{PanicStrategy, RelocModel, SanitizerSet, SplitDebuginfo};
17- use rustc_target::spec::{Target, TargetTriple, TargetWarnings, TARGETS};
18-
13+ use rustc_errors::emitter::HumanReadableErrorType;
14+ use rustc_errors::{ColorConfig, DiagnosticArgValue, HandlerFlags, IntoDiagnosticArg};
1915use rustc_feature::UnstableFeatures;
2016use rustc_span::edition::{Edition, DEFAULT_EDITION, EDITION_NAME_LIST, LATEST_STABLE_EDITION};
2117use rustc_span::source_map::FilePathMapping;
2218use rustc_span::symbol::{sym, Symbol};
2319use rustc_span::{FileName, FileNameDisplayPreference, RealFileName, SourceFileHashAlgorithm};
24-
25- use rustc_errors::emitter::HumanReadableErrorType ;
26- use rustc_errors::{ColorConfig, DiagnosticArgValue, HandlerFlags, IntoDiagnosticArg };
27-
20+ use rustc_target::abi::Align;
21+ use rustc_target::spec::LinkSelfContainedComponents ;
22+ use rustc_target::spec::{PanicStrategy, RelocModel, SanitizerSet, SplitDebuginfo };
23+ use rustc_target::spec::{Target, TargetTriple, TargetWarnings, TARGETS};
2824use std::collections::btree_map::{
2925 Iter as BTreeMapIter, Keys as BTreeMapKeysIter, Values as BTreeMapValuesIter,
3026};
@@ -1250,7 +1246,7 @@ fn default_configuration(sess: &Session) -> Cfg {
12501246 // NOTE: This should be kept in sync with `CheckCfg::fill_well_known` below.
12511247 let end = &sess.target.endian;
12521248 let arch = &sess.target.arch;
1253- let wordsz = sess.target.pointer_width.to_string() ;
1249+ let wordsz = sess.target.pointer_width as u64 ;
12541250 let os = &sess.target.os;
12551251 let env = &sess.target.env;
12561252 let abi = &sess.target.abi;
@@ -1277,7 +1273,7 @@ fn default_configuration(sess: &Session) -> Cfg {
12771273 }
12781274 ret.insert((sym::target_arch, Some(Symbol::intern(arch))));
12791275 ret.insert((sym::target_endian, Some(Symbol::intern(end.as_str()))));
1280- ret.insert((sym::target_pointer_width, Some(Symbol::intern(& wordsz))));
1276+ ret.insert((sym::target_pointer_width, Some(sym::integer( wordsz))));
12811277 ret.insert((sym::target_env, Some(Symbol::intern(env))));
12821278 ret.insert((sym::target_abi, Some(Symbol::intern(abi))));
12831279 if sess.is_nightly_build() {
@@ -1297,19 +1293,18 @@ fn default_configuration(sess: &Session) -> Cfg {
12971293 ] {
12981294 if i >= min_atomic_width && i <= max_atomic_width {
12991295 has_atomic = true;
1300- let mut insert_atomic = |s , align: Align| {
1301- ret.insert((sym::target_has_atomic_load_store, Some(Symbol::intern(s) )));
1296+ let mut insert_atomic = |sym , align: Align| {
1297+ ret.insert((sym::target_has_atomic_load_store, Some(sym )));
13021298 if atomic_cas {
1303- ret.insert((sym::target_has_atomic, Some(Symbol::intern(s) )));
1299+ ret.insert((sym::target_has_atomic, Some(sym )));
13041300 }
13051301 if align.bits() == i {
1306- ret.insert((sym::target_has_atomic_equal_alignment, Some(Symbol::intern(s) )));
1302+ ret.insert((sym::target_has_atomic_equal_alignment, Some(sym )));
13071303 }
13081304 };
1309- let s = i.to_string();
1310- insert_atomic(&s, align);
1311- if s == wordsz {
1312- insert_atomic("ptr", layout.pointer_align.abi);
1305+ insert_atomic(sym::integer(i), align);
1306+ if wordsz == i {
1307+ insert_atomic(sym::ptr, layout.pointer_align.abi);
13131308 }
13141309 }
13151310 }
@@ -2150,25 +2145,27 @@ fn collect_print_requests(
21502145 }
21512146
21522147 const PRINT_KINDS: &[(&str, PrintKind)] = &[
2148+ // tidy-alphabetical-start
2149+ ("all-target-specs-json", PrintKind::AllTargetSpecs),
2150+ ("calling-conventions", PrintKind::CallingConventions),
2151+ ("cfg", PrintKind::Cfg),
2152+ ("code-models", PrintKind::CodeModels),
21532153 ("crate-name", PrintKind::CrateName),
2154+ ("deployment-target", PrintKind::DeploymentTarget),
21542155 ("file-names", PrintKind::FileNames),
2156+ ("link-args", PrintKind::LinkArgs),
2157+ ("native-static-libs", PrintKind::NativeStaticLibs),
2158+ ("relocation-models", PrintKind::RelocationModels),
2159+ ("split-debuginfo", PrintKind::SplitDebuginfo),
2160+ ("stack-protector-strategies", PrintKind::StackProtectorStrategies),
21552161 ("sysroot", PrintKind::Sysroot),
2156- ("target-libdir", PrintKind::TargetLibdir),
2157- ("cfg", PrintKind::Cfg),
2158- ("calling-conventions", PrintKind::CallingConventions),
2159- ("target-list", PrintKind::TargetList),
21602162 ("target-cpus", PrintKind::TargetCPUs),
21612163 ("target-features", PrintKind::TargetFeatures),
2162- ("relocation-models", PrintKind::RelocationModels),
2163- ("code-models", PrintKind::CodeModels),
2164- ("tls-models", PrintKind::TlsModels),
2165- ("native-static-libs", PrintKind::NativeStaticLibs),
2166- ("stack-protector-strategies", PrintKind::StackProtectorStrategies),
2164+ ("target-libdir", PrintKind::TargetLibdir),
2165+ ("target-list", PrintKind::TargetList),
21672166 ("target-spec-json", PrintKind::TargetSpec),
2168- ("all-target-specs-json", PrintKind::AllTargetSpecs),
2169- ("link-args", PrintKind::LinkArgs),
2170- ("split-debuginfo", PrintKind::SplitDebuginfo),
2171- ("deployment-target", PrintKind::DeploymentTarget),
2167+ ("tls-models", PrintKind::TlsModels),
2168+ // tidy-alphabetical-end
21722169 ];
21732170
21742171 // We disallow reusing the same path in multiple prints, such as `--print
@@ -2297,14 +2294,7 @@ fn select_debuginfo(matches: &getopts::Matches, cg: &CodegenOptions) -> DebugInf
22972294 if max_g > max_c { DebugInfo::Full } else { cg.debuginfo }
22982295}
22992296
2300- fn select_debuginfo_compression(
2301- _handler: &EarlyErrorHandler,
2302- unstable_opts: &UnstableOptions,
2303- ) -> DebugInfoCompression {
2304- unstable_opts.debuginfo_compression
2305- }
2306-
2307- pub(crate) fn parse_assert_incr_state(
2297+ fn parse_assert_incr_state(
23082298 handler: &EarlyErrorHandler,
23092299 opt_assertion: &Option<String>,
23102300) -> Option<IncrementalStateAssertion> {
@@ -2460,6 +2450,17 @@ pub fn parse_externs(
24602450 matches: &getopts::Matches,
24612451 unstable_opts: &UnstableOptions,
24622452) -> Externs {
2453+ fn is_ascii_ident(string: &str) -> bool {
2454+ let mut chars = string.chars();
2455+ if let Some(start) = chars.next()
2456+ && (start.is_ascii_alphabetic() || start == '_')
2457+ {
2458+ chars.all(|char| char.is_ascii_alphanumeric() || char == '_')
2459+ } else {
2460+ false
2461+ }
2462+ }
2463+
24632464 let is_unstable_enabled = unstable_opts.unstable_options;
24642465 let mut externs: BTreeMap<String, ExternEntry> = BTreeMap::new();
24652466 for arg in matches.opt_strs("extern") {
@@ -2472,12 +2473,12 @@ pub fn parse_externs(
24722473 Some((opts, name)) => (Some(opts), name.to_string()),
24732474 };
24742475
2475- if !crate::utils:: is_ascii_ident(&name) {
2476+ if !is_ascii_ident(&name) {
24762477 let mut error = handler.early_struct_error(format!(
24772478 "crate name `{name}` passed to `--extern` is not a valid ASCII identifier"
24782479 ));
24792480 let adjusted_name = name.replace('-', "_");
2480- if crate::utils:: is_ascii_ident(&adjusted_name) {
2481+ if is_ascii_ident(&adjusted_name) {
24812482 error.help(format!(
24822483 "consider replacing the dashes with underscores: `{adjusted_name}`"
24832484 ));
@@ -2791,8 +2792,7 @@ pub fn build_session_options(
27912792 // for more details.
27922793 let debug_assertions = cg.debug_assertions.unwrap_or(opt_level == OptLevel::No);
27932794 let debuginfo = select_debuginfo(matches, &cg);
2794- let debuginfo_compression: DebugInfoCompression =
2795- select_debuginfo_compression(handler, &unstable_opts);
2795+ let debuginfo_compression = unstable_opts.debuginfo_compression;
27962796
27972797 let mut search_paths = vec![];
27982798 for s in &matches.opt_strs("L") {
@@ -3143,6 +3143,12 @@ impl PpMode {
31433143 }
31443144}
31453145
3146+ #[derive(Clone, Hash, PartialEq, Eq, Debug)]
3147+ pub enum WasiExecModel {
3148+ Command,
3149+ Reactor,
3150+ }
3151+
31463152/// Command-line arguments passed to the compiler have to be incorporated with
31473153/// the dependency tracking system for incremental compilation. This module
31483154/// provides some utilities to make this more convenient.
@@ -3168,9 +3174,9 @@ pub(crate) mod dep_tracking {
31683174 LinkerPluginLto, LocationDetail, LtoCli, OomStrategy, OptLevel, OutFileName, OutputType,
31693175 OutputTypes, Polonius, RemapPathScopeComponents, ResolveDocLinks, SourceFileHashAlgorithm,
31703176 SplitDwarfKind, SwitchWithOptPath, SymbolManglingVersion, TraitSolver, TrimmedDefPaths,
3177+ WasiExecModel,
31713178 };
31723179 use crate::lint;
3173- use crate::options::WasiExecModel;
31743180 use crate::utils::NativeLib;
31753181 use rustc_data_structures::stable_hasher::Hash64;
31763182 use rustc_errors::LanguageIdentifier;
0 commit comments