@@ -8,23 +8,19 @@ use crate::search_paths::SearchPath;
8
8
use crate :: utils:: { CanonicalizedPath , NativeLib , NativeLibKind } ;
9
9
use crate :: { lint, HashStableContext } ;
10
10
use crate :: { EarlyErrorHandler , Session } ;
11
-
12
11
use rustc_data_structures:: fx:: { FxHashMap , FxHashSet , FxIndexSet } ;
13
12
use 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 } ;
19
15
use rustc_feature:: UnstableFeatures ;
20
16
use rustc_span:: edition:: { Edition , DEFAULT_EDITION , EDITION_NAME_LIST , LATEST_STABLE_EDITION } ;
21
17
use rustc_span:: source_map:: FilePathMapping ;
22
18
use rustc_span:: symbol:: { sym, Symbol } ;
23
19
use 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 } ;
28
24
use std:: collections:: btree_map:: {
29
25
Iter as BTreeMapIter , Keys as BTreeMapKeysIter , Values as BTreeMapValuesIter ,
30
26
} ;
@@ -1250,7 +1246,7 @@ fn default_configuration(sess: &Session) -> Cfg {
1250
1246
// NOTE: This should be kept in sync with `CheckCfg::fill_well_known` below.
1251
1247
let end = & sess. target . endian ;
1252
1248
let arch = & sess. target . arch ;
1253
- let wordsz = sess. target . pointer_width . to_string ( ) ;
1249
+ let wordsz = sess. target . pointer_width as u64 ;
1254
1250
let os = & sess. target . os ;
1255
1251
let env = & sess. target . env ;
1256
1252
let abi = & sess. target . abi ;
@@ -1277,7 +1273,7 @@ fn default_configuration(sess: &Session) -> Cfg {
1277
1273
}
1278
1274
ret. insert ( ( sym:: target_arch, Some ( Symbol :: intern ( arch) ) ) ) ;
1279
1275
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) ) ) ) ;
1281
1277
ret. insert ( ( sym:: target_env, Some ( Symbol :: intern ( env) ) ) ) ;
1282
1278
ret. insert ( ( sym:: target_abi, Some ( Symbol :: intern ( abi) ) ) ) ;
1283
1279
if sess. is_nightly_build ( ) {
@@ -1297,19 +1293,18 @@ fn default_configuration(sess: &Session) -> Cfg {
1297
1293
] {
1298
1294
if i >= min_atomic_width && i <= max_atomic_width {
1299
1295
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 ) ) ) ;
1302
1298
if atomic_cas {
1303
- ret. insert ( ( sym:: target_has_atomic, Some ( Symbol :: intern ( s ) ) ) ) ;
1299
+ ret. insert ( ( sym:: target_has_atomic, Some ( sym ) ) ) ;
1304
1300
}
1305
1301
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 ) ) ) ;
1307
1303
}
1308
1304
} ;
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 ) ;
1313
1308
}
1314
1309
}
1315
1310
}
@@ -2150,25 +2145,27 @@ fn collect_print_requests(
2150
2145
}
2151
2146
2152
2147
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 ) ,
2153
2153
( "crate-name" , PrintKind :: CrateName ) ,
2154
+ ( "deployment-target" , PrintKind :: DeploymentTarget ) ,
2154
2155
( "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 ) ,
2155
2161
( "sysroot" , PrintKind :: Sysroot ) ,
2156
- ( "target-libdir" , PrintKind :: TargetLibdir ) ,
2157
- ( "cfg" , PrintKind :: Cfg ) ,
2158
- ( "calling-conventions" , PrintKind :: CallingConventions ) ,
2159
- ( "target-list" , PrintKind :: TargetList ) ,
2160
2162
( "target-cpus" , PrintKind :: TargetCPUs ) ,
2161
2163
( "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 ) ,
2167
2166
( "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
2172
2169
] ;
2173
2170
2174
2171
// 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
2297
2294
if max_g > max_c { DebugInfo :: Full } else { cg. debuginfo }
2298
2295
}
2299
2296
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 (
2308
2298
handler : & EarlyErrorHandler ,
2309
2299
opt_assertion : & Option < String > ,
2310
2300
) -> Option < IncrementalStateAssertion > {
@@ -2460,6 +2450,17 @@ pub fn parse_externs(
2460
2450
matches : & getopts:: Matches ,
2461
2451
unstable_opts : & UnstableOptions ,
2462
2452
) -> 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
+
2463
2464
let is_unstable_enabled = unstable_opts. unstable_options ;
2464
2465
let mut externs: BTreeMap < String , ExternEntry > = BTreeMap :: new ( ) ;
2465
2466
for arg in matches. opt_strs ( "extern" ) {
@@ -2472,12 +2473,12 @@ pub fn parse_externs(
2472
2473
Some ( ( opts, name) ) => ( Some ( opts) , name. to_string ( ) ) ,
2473
2474
} ;
2474
2475
2475
- if !crate :: utils :: is_ascii_ident ( & name) {
2476
+ if !is_ascii_ident ( & name) {
2476
2477
let mut error = handler. early_struct_error ( format ! (
2477
2478
"crate name `{name}` passed to `--extern` is not a valid ASCII identifier"
2478
2479
) ) ;
2479
2480
let adjusted_name = name. replace ( '-' , "_" ) ;
2480
- if crate :: utils :: is_ascii_ident ( & adjusted_name) {
2481
+ if is_ascii_ident ( & adjusted_name) {
2481
2482
error. help ( format ! (
2482
2483
"consider replacing the dashes with underscores: `{adjusted_name}`"
2483
2484
) ) ;
@@ -2791,8 +2792,7 @@ pub fn build_session_options(
2791
2792
// for more details.
2792
2793
let debug_assertions = cg. debug_assertions . unwrap_or ( opt_level == OptLevel :: No ) ;
2793
2794
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 ;
2796
2796
2797
2797
let mut search_paths = vec ! [ ] ;
2798
2798
for s in & matches. opt_strs ( "L" ) {
@@ -3143,6 +3143,12 @@ impl PpMode {
3143
3143
}
3144
3144
}
3145
3145
3146
+ #[ derive( Clone , Hash , PartialEq , Eq , Debug ) ]
3147
+ pub enum WasiExecModel {
3148
+ Command ,
3149
+ Reactor ,
3150
+ }
3151
+
3146
3152
/// Command-line arguments passed to the compiler have to be incorporated with
3147
3153
/// the dependency tracking system for incremental compilation. This module
3148
3154
/// provides some utilities to make this more convenient.
@@ -3168,9 +3174,9 @@ pub(crate) mod dep_tracking {
3168
3174
LinkerPluginLto , LocationDetail , LtoCli , OomStrategy , OptLevel , OutFileName , OutputType ,
3169
3175
OutputTypes , Polonius , RemapPathScopeComponents , ResolveDocLinks , SourceFileHashAlgorithm ,
3170
3176
SplitDwarfKind , SwitchWithOptPath , SymbolManglingVersion , TraitSolver , TrimmedDefPaths ,
3177
+ WasiExecModel ,
3171
3178
} ;
3172
3179
use crate :: lint;
3173
- use crate :: options:: WasiExecModel ;
3174
3180
use crate :: utils:: NativeLib ;
3175
3181
use rustc_data_structures:: stable_hasher:: Hash64 ;
3176
3182
use rustc_errors:: LanguageIdentifier ;
0 commit comments