1 use crate::interface
::parse_cfgspecs
;
3 use rustc_data_structures
::fx
::FxHashSet
;
4 use rustc_errors
::{emitter::HumanReadableErrorType, registry, ColorConfig}
;
5 use rustc_session
::config
::InstrumentCoverage
;
6 use rustc_session
::config
::Strip
;
7 use rustc_session
::config
::{build_configuration, build_session_options, to_crate_config}
;
8 use rustc_session
::config
::{
9 rustc_optgroups
, ErrorOutputType
, ExternLocation
, LocationDetail
, Options
, Passes
,
11 use rustc_session
::config
::{
12 BranchProtection
, Externs
, OomStrategy
, OutputType
, OutputTypes
, PAuthKey
, PacRet
,
13 SymbolManglingVersion
, WasiExecModel
,
15 use rustc_session
::config
::{CFGuard, ExternEntry, LinkerPluginLto, LtoCli, SwitchWithOptPath}
;
16 use rustc_session
::lint
::Level
;
17 use rustc_session
::search_paths
::SearchPath
;
18 use rustc_session
::utils
::{CanonicalizedPath, NativeLib, NativeLibKind}
;
19 use rustc_session
::{build_session, getopts, DiagnosticOutput, Session}
;
20 use rustc_span
::edition
::{Edition, DEFAULT_EDITION}
;
21 use rustc_span
::symbol
::sym
;
22 use rustc_span
::SourceFileHashAlgorithm
;
23 use rustc_target
::spec
::{CodeModel, LinkerFlavor, MergeFunctions, PanicStrategy}
;
24 use rustc_target
::spec
::{
25 RelocModel
, RelroLevel
, SanitizerSet
, SplitDebuginfo
, StackProtector
, TlsModel
,
28 use std
::collections
::{BTreeMap, BTreeSet}
;
29 use std
::iter
::FromIterator
;
30 use std
::num
::NonZeroUsize
;
31 use std
::path
::{Path, PathBuf}
;
33 type CfgSpecs
= FxHashSet
<(String
, Option
<String
>)>;
35 fn build_session_options_and_crate_config(matches
: getopts
::Matches
) -> (Options
, CfgSpecs
) {
36 let sessopts
= build_session_options(&matches
);
37 let cfg
= parse_cfgspecs(matches
.opt_strs("cfg"));
41 fn mk_session(matches
: getopts
::Matches
) -> (Session
, CfgSpecs
) {
42 let registry
= registry
::Registry
::new(&[]);
43 let (sessopts
, cfg
) = build_session_options_and_crate_config(matches
);
44 let sess
= build_session(
49 DiagnosticOutput
::Default
,
57 fn new_public_extern_entry
<S
, I
>(locations
: I
) -> ExternEntry
60 I
: IntoIterator
<Item
= S
>,
62 let locations
: BTreeSet
<CanonicalizedPath
> =
63 locations
.into_iter().map(|s
| CanonicalizedPath
::new(Path
::new(&s
.into()))).collect();
66 location
: ExternLocation
::ExactPaths(locations
),
67 is_private_dep
: false,
73 fn optgroups() -> getopts
::Options
{
74 let mut opts
= getopts
::Options
::new();
75 for group
in rustc_optgroups() {
76 (group
.apply
)(&mut opts
);
81 fn mk_map
<K
: Ord
, V
>(entries
: Vec
<(K
, V
)>) -> BTreeMap
<K
, V
> {
82 BTreeMap
::from_iter(entries
.into_iter())
85 fn assert_same_clone(x
: &Options
) {
86 assert_eq
!(x
.dep_tracking_hash(true), x
.clone().dep_tracking_hash(true));
87 assert_eq
!(x
.dep_tracking_hash(false), x
.clone().dep_tracking_hash(false));
90 fn assert_same_hash(x
: &Options
, y
: &Options
) {
91 assert_eq
!(x
.dep_tracking_hash(true), y
.dep_tracking_hash(true));
92 assert_eq
!(x
.dep_tracking_hash(false), y
.dep_tracking_hash(false));
98 fn assert_different_hash(x
: &Options
, y
: &Options
) {
99 assert_ne
!(x
.dep_tracking_hash(true), y
.dep_tracking_hash(true));
100 assert_ne
!(x
.dep_tracking_hash(false), y
.dep_tracking_hash(false));
102 assert_same_clone(x
);
103 assert_same_clone(y
);
106 fn assert_non_crate_hash_different(x
: &Options
, y
: &Options
) {
107 assert_eq
!(x
.dep_tracking_hash(true), y
.dep_tracking_hash(true));
108 assert_ne
!(x
.dep_tracking_hash(false), y
.dep_tracking_hash(false));
110 assert_same_clone(x
);
111 assert_same_clone(y
);
114 // When the user supplies --test we should implicitly supply --cfg test
116 fn test_switch_implies_cfg_test() {
117 rustc_span
::create_default_session_globals_then(|| {
118 let matches
= optgroups().parse(&["--test".to_string()]).unwrap();
119 let (sess
, cfg
) = mk_session(matches
);
120 let cfg
= build_configuration(&sess
, to_crate_config(cfg
));
121 assert
!(cfg
.contains(&(sym
::test
, None
)));
125 // When the user supplies --test and --cfg test, don't implicitly add another --cfg test
127 fn test_switch_implies_cfg_test_unless_cfg_test() {
128 rustc_span
::create_default_session_globals_then(|| {
129 let matches
= optgroups().parse(&["--test".to_string(), "--cfg=test".to_string()]).unwrap();
130 let (sess
, cfg
) = mk_session(matches
);
131 let cfg
= build_configuration(&sess
, to_crate_config(cfg
));
132 let mut test_items
= cfg
.iter().filter(|&&(name
, _
)| name
== sym
::test
);
133 assert
!(test_items
.next().is_some());
134 assert
!(test_items
.next().is_none());
139 fn test_can_print_warnings() {
140 rustc_span
::create_default_session_globals_then(|| {
141 let matches
= optgroups().parse(&["-Awarnings".to_string()]).unwrap();
142 let (sess
, _
) = mk_session(matches
);
143 assert
!(!sess
.diagnostic().can_emit_warnings());
146 rustc_span
::create_default_session_globals_then(|| {
148 optgroups().parse(&["-Awarnings".to_string(), "-Dwarnings".to_string()]).unwrap();
149 let (sess
, _
) = mk_session(matches
);
150 assert
!(sess
.diagnostic().can_emit_warnings());
153 rustc_span
::create_default_session_globals_then(|| {
154 let matches
= optgroups().parse(&["-Adead_code".to_string()]).unwrap();
155 let (sess
, _
) = mk_session(matches
);
156 assert
!(sess
.diagnostic().can_emit_warnings());
161 fn test_output_types_tracking_hash_different_paths() {
162 let mut v1
= Options
::default();
163 let mut v2
= Options
::default();
164 let mut v3
= Options
::default();
166 v1
.output_types
= OutputTypes
::new(&[(OutputType
::Exe
, Some(PathBuf
::from("./some/thing")))]);
167 v2
.output_types
= OutputTypes
::new(&[(OutputType
::Exe
, Some(PathBuf
::from("/some/thing")))]);
168 v3
.output_types
= OutputTypes
::new(&[(OutputType
::Exe
, None
)]);
170 assert_non_crate_hash_different(&v1
, &v2
);
171 assert_non_crate_hash_different(&v1
, &v3
);
172 assert_non_crate_hash_different(&v2
, &v3
);
176 fn test_output_types_tracking_hash_different_construction_order() {
177 let mut v1
= Options
::default();
178 let mut v2
= Options
::default();
180 v1
.output_types
= OutputTypes
::new(&[
181 (OutputType
::Exe
, Some(PathBuf
::from("./some/thing"))),
182 (OutputType
::Bitcode
, Some(PathBuf
::from("./some/thing.bc"))),
185 v2
.output_types
= OutputTypes
::new(&[
186 (OutputType
::Bitcode
, Some(PathBuf
::from("./some/thing.bc"))),
187 (OutputType
::Exe
, Some(PathBuf
::from("./some/thing"))),
190 assert_same_hash(&v1
, &v2
);
194 fn test_externs_tracking_hash_different_construction_order() {
195 let mut v1
= Options
::default();
196 let mut v2
= Options
::default();
197 let mut v3
= Options
::default();
199 v1
.externs
= Externs
::new(mk_map(vec
![
200 (String
::from("a"), new_public_extern_entry(vec
!["b", "c"])),
201 (String
::from("d"), new_public_extern_entry(vec
!["e", "f"])),
204 v2
.externs
= Externs
::new(mk_map(vec
![
205 (String
::from("d"), new_public_extern_entry(vec
!["e", "f"])),
206 (String
::from("a"), new_public_extern_entry(vec
!["b", "c"])),
209 v3
.externs
= Externs
::new(mk_map(vec
![
210 (String
::from("a"), new_public_extern_entry(vec
!["b", "c"])),
211 (String
::from("d"), new_public_extern_entry(vec
!["f", "e"])),
214 assert_same_hash(&v1
, &v2
);
215 assert_same_hash(&v1
, &v3
);
216 assert_same_hash(&v2
, &v3
);
220 fn test_lints_tracking_hash_different_values() {
221 let mut v1
= Options
::default();
222 let mut v2
= Options
::default();
223 let mut v3
= Options
::default();
226 (String
::from("a"), Level
::Allow
),
227 (String
::from("b"), Level
::Warn
),
228 (String
::from("c"), Level
::Deny
),
229 (String
::from("d"), Level
::Forbid
),
233 (String
::from("a"), Level
::Allow
),
234 (String
::from("b"), Level
::Warn
),
235 (String
::from("X"), Level
::Deny
),
236 (String
::from("d"), Level
::Forbid
),
240 (String
::from("a"), Level
::Allow
),
241 (String
::from("b"), Level
::Warn
),
242 (String
::from("c"), Level
::Forbid
),
243 (String
::from("d"), Level
::Deny
),
246 assert_non_crate_hash_different(&v1
, &v2
);
247 assert_non_crate_hash_different(&v1
, &v3
);
248 assert_non_crate_hash_different(&v2
, &v3
);
252 fn test_lints_tracking_hash_different_construction_order() {
253 let mut v1
= Options
::default();
254 let mut v2
= Options
::default();
257 (String
::from("a"), Level
::Allow
),
258 (String
::from("b"), Level
::Warn
),
259 (String
::from("c"), Level
::Deny
),
260 (String
::from("d"), Level
::Forbid
),
264 (String
::from("a"), Level
::Allow
),
265 (String
::from("c"), Level
::Deny
),
266 (String
::from("b"), Level
::Warn
),
267 (String
::from("d"), Level
::Forbid
),
270 // The hash should be order-dependent
271 assert_non_crate_hash_different(&v1
, &v2
);
275 fn test_lint_cap_hash_different() {
276 let mut v1
= Options
::default();
277 let mut v2
= Options
::default();
278 let v3
= Options
::default();
280 v1
.lint_cap
= Some(Level
::Forbid
);
281 v2
.lint_cap
= Some(Level
::Allow
);
283 assert_non_crate_hash_different(&v1
, &v2
);
284 assert_non_crate_hash_different(&v1
, &v3
);
285 assert_non_crate_hash_different(&v2
, &v3
);
289 fn test_search_paths_tracking_hash_different_order() {
290 let mut v1
= Options
::default();
291 let mut v2
= Options
::default();
292 let mut v3
= Options
::default();
293 let mut v4
= Options
::default();
295 const JSON
: ErrorOutputType
= ErrorOutputType
::Json
{
297 json_rendered
: HumanReadableErrorType
::Default(ColorConfig
::Never
),
301 v1
.search_paths
.push(SearchPath
::from_cli_opt("native=abc", JSON
));
302 v1
.search_paths
.push(SearchPath
::from_cli_opt("crate=def", JSON
));
303 v1
.search_paths
.push(SearchPath
::from_cli_opt("dependency=ghi", JSON
));
304 v1
.search_paths
.push(SearchPath
::from_cli_opt("framework=jkl", JSON
));
305 v1
.search_paths
.push(SearchPath
::from_cli_opt("all=mno", JSON
));
307 v2
.search_paths
.push(SearchPath
::from_cli_opt("native=abc", JSON
));
308 v2
.search_paths
.push(SearchPath
::from_cli_opt("dependency=ghi", JSON
));
309 v2
.search_paths
.push(SearchPath
::from_cli_opt("crate=def", JSON
));
310 v2
.search_paths
.push(SearchPath
::from_cli_opt("framework=jkl", JSON
));
311 v2
.search_paths
.push(SearchPath
::from_cli_opt("all=mno", JSON
));
313 v3
.search_paths
.push(SearchPath
::from_cli_opt("crate=def", JSON
));
314 v3
.search_paths
.push(SearchPath
::from_cli_opt("framework=jkl", JSON
));
315 v3
.search_paths
.push(SearchPath
::from_cli_opt("native=abc", JSON
));
316 v3
.search_paths
.push(SearchPath
::from_cli_opt("dependency=ghi", JSON
));
317 v3
.search_paths
.push(SearchPath
::from_cli_opt("all=mno", JSON
));
319 v4
.search_paths
.push(SearchPath
::from_cli_opt("all=mno", JSON
));
320 v4
.search_paths
.push(SearchPath
::from_cli_opt("native=abc", JSON
));
321 v4
.search_paths
.push(SearchPath
::from_cli_opt("crate=def", JSON
));
322 v4
.search_paths
.push(SearchPath
::from_cli_opt("dependency=ghi", JSON
));
323 v4
.search_paths
.push(SearchPath
::from_cli_opt("framework=jkl", JSON
));
325 assert_same_hash(&v1
, &v2
);
326 assert_same_hash(&v1
, &v3
);
327 assert_same_hash(&v1
, &v4
);
331 fn test_native_libs_tracking_hash_different_values() {
332 let mut v1
= Options
::default();
333 let mut v2
= Options
::default();
334 let mut v3
= Options
::default();
335 let mut v4
= Options
::default();
336 let mut v5
= Options
::default();
341 name
: String
::from("a"),
343 kind
: NativeLibKind
::Static { bundle: None, whole_archive: None }
,
347 name
: String
::from("b"),
349 kind
: NativeLibKind
::Framework { as_needed: None }
,
353 name
: String
::from("c"),
355 kind
: NativeLibKind
::Unspecified
,
363 name
: String
::from("a"),
365 kind
: NativeLibKind
::Static { bundle: None, whole_archive: None }
,
369 name
: String
::from("X"),
371 kind
: NativeLibKind
::Framework { as_needed: None }
,
375 name
: String
::from("c"),
377 kind
: NativeLibKind
::Unspecified
,
385 name
: String
::from("a"),
387 kind
: NativeLibKind
::Static { bundle: None, whole_archive: None }
,
391 name
: String
::from("b"),
393 kind
: NativeLibKind
::Static { bundle: None, whole_archive: None }
,
397 name
: String
::from("c"),
399 kind
: NativeLibKind
::Unspecified
,
407 name
: String
::from("a"),
409 kind
: NativeLibKind
::Static { bundle: None, whole_archive: None }
,
413 name
: String
::from("b"),
414 new_name
: Some(String
::from("X")),
415 kind
: NativeLibKind
::Framework { as_needed: None }
,
419 name
: String
::from("c"),
421 kind
: NativeLibKind
::Unspecified
,
429 name
: String
::from("a"),
431 kind
: NativeLibKind
::Static { bundle: None, whole_archive: None }
,
435 name
: String
::from("b"),
437 kind
: NativeLibKind
::Framework { as_needed: None }
,
438 verbatim
: Some(true),
441 name
: String
::from("c"),
443 kind
: NativeLibKind
::Unspecified
,
448 assert_different_hash(&v1
, &v2
);
449 assert_different_hash(&v1
, &v3
);
450 assert_different_hash(&v1
, &v4
);
451 assert_different_hash(&v1
, &v5
);
455 fn test_native_libs_tracking_hash_different_order() {
456 let mut v1
= Options
::default();
457 let mut v2
= Options
::default();
458 let mut v3
= Options
::default();
463 name
: String
::from("a"),
465 kind
: NativeLibKind
::Static { bundle: None, whole_archive: None }
,
469 name
: String
::from("b"),
471 kind
: NativeLibKind
::Framework { as_needed: None }
,
475 name
: String
::from("c"),
477 kind
: NativeLibKind
::Unspecified
,
484 name
: String
::from("b"),
486 kind
: NativeLibKind
::Framework { as_needed: None }
,
490 name
: String
::from("a"),
492 kind
: NativeLibKind
::Static { bundle: None, whole_archive: None }
,
496 name
: String
::from("c"),
498 kind
: NativeLibKind
::Unspecified
,
505 name
: String
::from("c"),
507 kind
: NativeLibKind
::Unspecified
,
511 name
: String
::from("a"),
513 kind
: NativeLibKind
::Static { bundle: None, whole_archive: None }
,
517 name
: String
::from("b"),
519 kind
: NativeLibKind
::Framework { as_needed: None }
,
524 // The hash should be order-dependent
525 assert_different_hash(&v1
, &v2
);
526 assert_different_hash(&v1
, &v3
);
527 assert_different_hash(&v2
, &v3
);
531 fn test_codegen_options_tracking_hash() {
532 let reference
= Options
::default();
533 let mut opts
= Options
::default();
535 macro_rules
! untracked
{
536 ($name
: ident
, $non_default_value
: expr
) => {
537 assert_ne
!(opts
.cg
.$name
, $non_default_value
);
538 opts
.cg
.$name
= $non_default_value
;
539 assert_same_hash(&reference
, &opts
);
543 // Make sure that changing an [UNTRACKED] option leaves the hash unchanged.
544 // This list is in alphabetical order.
545 untracked
!(ar
, String
::from("abc"));
546 untracked
!(codegen_units
, Some(42));
547 untracked
!(default_linker_libraries
, true);
548 untracked
!(extra_filename
, String
::from("extra-filename"));
549 untracked
!(incremental
, Some(String
::from("abc")));
550 // `link_arg` is omitted because it just forwards to `link_args`.
551 untracked
!(link_args
, vec
![String
::from("abc"), String
::from("def")]);
552 untracked
!(link_self_contained
, Some(true));
553 untracked
!(linker
, Some(PathBuf
::from("linker")));
554 untracked
!(linker_flavor
, Some(LinkerFlavor
::Gcc
));
555 untracked
!(no_stack_check
, true);
556 untracked
!(remark
, Passes
::Some(vec
![String
::from("pass1"), String
::from("pass2")]));
557 untracked
!(rpath
, true);
558 untracked
!(save_temps
, true);
559 untracked
!(strip
, Strip
::Debuginfo
);
561 macro_rules
! tracked
{
562 ($name
: ident
, $non_default_value
: expr
) => {
563 opts
= reference
.clone();
564 assert_ne
!(opts
.cg
.$name
, $non_default_value
);
565 opts
.cg
.$name
= $non_default_value
;
566 assert_different_hash(&reference
, &opts
);
570 // Make sure that changing a [TRACKED] option changes the hash.
571 // This list is in alphabetical order.
572 tracked
!(code_model
, Some(CodeModel
::Large
));
573 tracked
!(control_flow_guard
, CFGuard
::Checks
);
574 tracked
!(debug_assertions
, Some(true));
575 tracked
!(debuginfo
, 0xdeadbeef);
576 tracked
!(embed_bitcode
, false);
577 tracked
!(force_frame_pointers
, Some(false));
578 tracked
!(force_unwind_tables
, Some(true));
579 tracked
!(inline_threshold
, Some(0xf007ba11));
580 tracked
!(instrument_coverage
, Some(InstrumentCoverage
::All
));
581 tracked
!(linker_plugin_lto
, LinkerPluginLto
::LinkerPluginAuto
);
582 tracked
!(link_dead_code
, Some(true));
583 tracked
!(llvm_args
, vec
![String
::from("1"), String
::from("2")]);
584 tracked
!(lto
, LtoCli
::Fat
);
585 tracked
!(metadata
, vec
![String
::from("A"), String
::from("B")]);
586 tracked
!(no_prepopulate_passes
, true);
587 tracked
!(no_redzone
, Some(true));
588 tracked
!(no_vectorize_loops
, true);
589 tracked
!(no_vectorize_slp
, true);
590 tracked
!(opt_level
, "3".to_string());
591 tracked
!(overflow_checks
, Some(true));
592 tracked
!(panic
, Some(PanicStrategy
::Abort
));
593 tracked
!(passes
, vec
![String
::from("1"), String
::from("2")]);
594 tracked
!(prefer_dynamic
, true);
595 tracked
!(profile_generate
, SwitchWithOptPath
::Enabled(None
));
596 tracked
!(profile_use
, Some(PathBuf
::from("abc")));
597 tracked
!(relocation_model
, Some(RelocModel
::Pic
));
598 tracked
!(soft_float
, true);
599 tracked
!(split_debuginfo
, Some(SplitDebuginfo
::Packed
));
600 tracked
!(symbol_mangling_version
, Some(SymbolManglingVersion
::V0
));
601 tracked
!(target_cpu
, Some(String
::from("abc")));
602 tracked
!(target_feature
, String
::from("all the features, all of them"));
606 fn test_top_level_options_tracked_no_crate() {
607 let reference
= Options
::default();
610 macro_rules
! tracked
{
611 ($name
: ident
, $non_default_value
: expr
) => {
612 opts
= reference
.clone();
613 assert_ne
!(opts
.$name
, $non_default_value
);
614 opts
.$name
= $non_default_value
;
615 // The crate hash should be the same
616 assert_eq
!(reference
.dep_tracking_hash(true), opts
.dep_tracking_hash(true));
617 // The incremental hash should be different
618 assert_ne
!(reference
.dep_tracking_hash(false), opts
.dep_tracking_hash(false));
622 // Make sure that changing a [TRACKED_NO_CRATE_HASH] option leaves the crate hash unchanged but changes the incremental hash.
623 // This list is in alphabetical order.
624 tracked
!(remap_path_prefix
, vec
![("/home/bors/rust".into(), "src".into())]);
626 real_rust_source_base_dir
,
627 Some("/home/bors/rust/.rustup/toolchains/nightly/lib/rustlib/src/rust".into())
632 fn test_debugging_options_tracking_hash() {
633 let reference
= Options
::default();
634 let mut opts
= Options
::default();
636 macro_rules
! untracked
{
637 ($name
: ident
, $non_default_value
: expr
) => {
638 assert_ne
!(opts
.debugging_opts
.$name
, $non_default_value
);
639 opts
.debugging_opts
.$name
= $non_default_value
;
640 assert_same_hash(&reference
, &opts
);
644 // Make sure that changing an [UNTRACKED] option leaves the hash unchanged.
645 // This list is in alphabetical order.
646 untracked
!(assert_incr_state
, Some(String
::from("loaded")));
647 untracked
!(deduplicate_diagnostics
, false);
648 untracked
!(dep_tasks
, true);
649 untracked
!(dlltool
, Some(PathBuf
::from("custom_dlltool.exe")));
650 untracked
!(dont_buffer_diagnostics
, true);
651 untracked
!(dump_dep_graph
, true);
652 untracked
!(dump_mir
, Some(String
::from("abc")));
653 untracked
!(dump_mir_dataflow
, true);
654 untracked
!(dump_mir_dir
, String
::from("abc"));
655 untracked
!(dump_mir_exclude_pass_number
, true);
656 untracked
!(dump_mir_graphviz
, true);
657 untracked
!(emit_stack_sizes
, true);
658 untracked
!(future_incompat_test
, true);
659 untracked
!(hir_stats
, true);
660 untracked
!(identify_regions
, true);
661 untracked
!(incremental_ignore_spans
, true);
662 untracked
!(incremental_info
, true);
663 untracked
!(incremental_verify_ich
, true);
664 untracked
!(input_stats
, true);
665 untracked
!(keep_hygiene_data
, true);
666 untracked
!(link_native_libraries
, false);
667 untracked
!(llvm_time_trace
, true);
668 untracked
!(ls
, true);
669 untracked
!(macro_backtrace
, true);
670 untracked
!(meta_stats
, true);
671 untracked
!(nll_facts
, true);
672 untracked
!(no_analysis
, true);
673 untracked
!(no_interleave_lints
, true);
674 untracked
!(no_leak_check
, true);
675 untracked
!(no_parallel_llvm
, true);
676 untracked
!(parse_only
, true);
677 untracked
!(perf_stats
, true);
678 // `pre_link_arg` is omitted because it just forwards to `pre_link_args`.
679 untracked
!(pre_link_args
, vec
![String
::from("abc"), String
::from("def")]);
680 untracked
!(profile_closures
, true);
681 untracked
!(print_llvm_passes
, true);
682 untracked
!(print_mono_items
, Some(String
::from("abc")));
683 untracked
!(print_type_sizes
, true);
684 untracked
!(proc_macro_backtrace
, true);
685 untracked
!(query_dep_graph
, true);
686 untracked
!(save_analysis
, true);
687 untracked
!(self_profile
, SwitchWithOptPath
::Enabled(None
));
688 untracked
!(self_profile_events
, Some(vec
![String
::new()]));
689 untracked
!(span_debug
, true);
690 untracked
!(span_free_formats
, true);
691 untracked
!(temps_dir
, Some(String
::from("abc")));
692 untracked
!(terminal_width
, Some(80));
693 untracked
!(threads
, 99);
694 untracked
!(time
, true);
695 untracked
!(time_llvm_passes
, true);
696 untracked
!(time_passes
, true);
697 untracked
!(trace_macros
, true);
698 untracked
!(trim_diagnostic_paths
, false);
699 untracked
!(ui_testing
, true);
700 untracked
!(unpretty
, Some("expanded".to_string()));
701 untracked
!(unstable_options
, true);
702 untracked
!(validate_mir
, true);
703 untracked
!(verbose
, true);
705 macro_rules
! tracked
{
706 ($name
: ident
, $non_default_value
: expr
) => {
707 opts
= reference
.clone();
708 assert_ne
!(opts
.debugging_opts
.$name
, $non_default_value
);
709 opts
.debugging_opts
.$name
= $non_default_value
;
710 assert_different_hash(&reference
, &opts
);
714 // Make sure that changing a [TRACKED] option changes the hash.
715 // This list is in alphabetical order.
716 tracked
!(allow_features
, Some(vec
![String
::from("lang_items")]));
717 tracked
!(always_encode_mir
, true);
718 tracked
!(asm_comments
, true);
719 tracked
!(assume_incomplete_release
, true);
720 tracked
!(binary_dep_depinfo
, true);
723 Some(BranchProtection
{
725 pac_ret
: Some(PacRet { leaf: true, key: PAuthKey::B }
)
728 tracked
!(chalk
, true);
729 tracked
!(codegen_backend
, Some("abc".to_string()));
730 tracked
!(crate_attr
, vec
!["abc".to_string()]);
731 tracked
!(debug_info_for_profiling
, true);
732 tracked
!(debug_macros
, true);
733 tracked
!(dep_info_omit_d_target
, true);
734 tracked
!(drop_tracking
, true);
735 tracked
!(dual_proc_macros
, true);
736 tracked
!(fewer_names
, Some(true));
737 tracked
!(force_unstable_if_unmarked
, true);
738 tracked
!(fuel
, Some(("abc".to_string(), 99)));
739 tracked
!(function_sections
, Some(false));
740 tracked
!(human_readable_cgu_names
, true);
741 tracked
!(inline_in_all_cgus
, Some(true));
742 tracked
!(inline_mir
, Some(true));
743 tracked
!(inline_mir_hint_threshold
, Some(123));
744 tracked
!(inline_mir_threshold
, Some(123));
745 tracked
!(instrument_coverage
, Some(InstrumentCoverage
::All
));
746 tracked
!(instrument_mcount
, true);
747 tracked
!(link_only
, true);
748 tracked
!(llvm_plugins
, vec
![String
::from("plugin_name")]);
749 tracked
!(location_detail
, LocationDetail { file: true, line: false, column: false }
);
750 tracked
!(merge_functions
, Some(MergeFunctions
::Disabled
));
751 tracked
!(mir_emit_retag
, true);
752 tracked
!(mir_enable_passes
, vec
![("DestProp".to_string(), false)]);
753 tracked
!(mir_opt_level
, Some(4));
754 tracked
!(move_size_limit
, Some(4096));
755 tracked
!(mutable_noalias
, Some(true));
756 tracked
!(new_llvm_pass_manager
, Some(true));
757 tracked
!(no_generate_arange_section
, true);
758 tracked
!(no_link
, true);
759 tracked
!(no_unique_section_names
, true);
760 tracked
!(no_profiler_runtime
, true);
761 tracked
!(oom
, OomStrategy
::Panic
);
762 tracked
!(osx_rpath_install_name
, true);
763 tracked
!(panic_abort_tests
, true);
764 tracked
!(panic_in_drop
, PanicStrategy
::Abort
);
765 tracked
!(pick_stable_methods_before_any_unstable
, false);
766 tracked
!(plt
, Some(true));
767 tracked
!(polonius
, true);
768 tracked
!(precise_enum_drop_elaboration
, false);
769 tracked
!(print_fuel
, Some("abc".to_string()));
770 tracked
!(profile
, true);
771 tracked
!(profile_emit
, Some(PathBuf
::from("abc")));
772 tracked
!(profiler_runtime
, "abc".to_string());
773 tracked
!(profile_sample_use
, Some(PathBuf
::from("abc")));
774 tracked
!(relax_elf_relocations
, Some(true));
775 tracked
!(relro_level
, Some(RelroLevel
::Full
));
776 tracked
!(remap_cwd_prefix
, Some(PathBuf
::from("abc")));
777 tracked
!(report_delayed_bugs
, true);
778 tracked
!(sanitizer
, SanitizerSet
::ADDRESS
);
779 tracked
!(sanitizer_memory_track_origins
, 2);
780 tracked
!(sanitizer_recover
, SanitizerSet
::ADDRESS
);
781 tracked
!(saturating_float_casts
, Some(true));
782 tracked
!(share_generics
, Some(true));
783 tracked
!(show_span
, Some(String
::from("abc")));
784 tracked
!(simulate_remapped_rust_src_base
, Some(PathBuf
::from("/rustc/abc")));
785 tracked
!(src_hash_algorithm
, Some(SourceFileHashAlgorithm
::Sha1
));
786 tracked
!(stack_protector
, StackProtector
::All
);
787 tracked
!(symbol_mangling_version
, Some(SymbolManglingVersion
::V0
));
788 tracked
!(teach
, true);
789 tracked
!(thinlto
, Some(true));
790 tracked
!(thir_unsafeck
, true);
791 tracked
!(tls_model
, Some(TlsModel
::GeneralDynamic
));
792 tracked
!(translate_remapped_path_to_local_path
, false);
793 tracked
!(trap_unreachable
, Some(false));
794 tracked
!(treat_err_as_bug
, NonZeroUsize
::new(1));
795 tracked
!(tune_cpu
, Some(String
::from("abc")));
796 tracked
!(uninit_const_chunk_threshold
, 123);
797 tracked
!(unleash_the_miri_inside_of_you
, true);
798 tracked
!(use_ctors_section
, Some(true));
799 tracked
!(verify_llvm_ir
, true);
800 tracked
!(virtual_function_elimination
, true);
801 tracked
!(wasi_exec_model
, Some(WasiExecModel
::Reactor
));
803 macro_rules
! tracked_no_crate_hash
{
804 ($name
: ident
, $non_default_value
: expr
) => {
805 opts
= reference
.clone();
806 assert_ne
!(opts
.debugging_opts
.$name
, $non_default_value
);
807 opts
.debugging_opts
.$name
= $non_default_value
;
808 assert_non_crate_hash_different(&reference
, &opts
);
811 tracked_no_crate_hash
!(no_codegen
, true);
815 fn test_edition_parsing() {
816 // test default edition
817 let options
= Options
::default();
818 assert
!(options
.edition
== DEFAULT_EDITION
);
820 let matches
= optgroups().parse(&["--edition=2018".to_string()]).unwrap();
821 let (sessopts
, _
) = build_session_options_and_crate_config(matches
);
822 assert
!(sessopts
.edition
== Edition
::Edition2018
)