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
::{rustc_optgroups, ErrorOutputType, ExternLocation, Options, Passes}
;
9 use rustc_session
::config
::{CFGuard, ExternEntry, LinkerPluginLto, LtoCli, SwitchWithOptPath}
;
10 use rustc_session
::config
::{
11 Externs
, OutputType
, OutputTypes
, SymbolManglingVersion
, WasiExecModel
,
13 use rustc_session
::lint
::Level
;
14 use rustc_session
::search_paths
::SearchPath
;
15 use rustc_session
::utils
::{CanonicalizedPath, NativeLib, NativeLibKind}
;
16 use rustc_session
::{build_session, getopts, DiagnosticOutput, Session}
;
17 use rustc_span
::edition
::{Edition, DEFAULT_EDITION}
;
18 use rustc_span
::symbol
::sym
;
19 use rustc_span
::SourceFileHashAlgorithm
;
20 use rustc_target
::spec
::{CodeModel, LinkerFlavor, MergeFunctions, PanicStrategy}
;
21 use rustc_target
::spec
::{RelocModel, RelroLevel, SanitizerSet, SplitDebuginfo, TlsModel}
;
23 use std
::collections
::{BTreeMap, BTreeSet}
;
24 use std
::iter
::FromIterator
;
25 use std
::num
::NonZeroUsize
;
26 use std
::path
::{Path, PathBuf}
;
28 type CfgSpecs
= FxHashSet
<(String
, Option
<String
>)>;
30 fn build_session_options_and_crate_config(matches
: getopts
::Matches
) -> (Options
, CfgSpecs
) {
31 let sessopts
= build_session_options(&matches
);
32 let cfg
= parse_cfgspecs(matches
.opt_strs("cfg"));
36 fn mk_session(matches
: getopts
::Matches
) -> (Session
, CfgSpecs
) {
37 let registry
= registry
::Registry
::new(&[]);
38 let (sessopts
, cfg
) = build_session_options_and_crate_config(matches
);
39 let sess
= build_session(
43 DiagnosticOutput
::Default
,
51 fn new_public_extern_entry
<S
, I
>(locations
: I
) -> ExternEntry
54 I
: IntoIterator
<Item
= S
>,
56 let locations
: BTreeSet
<CanonicalizedPath
> =
57 locations
.into_iter().map(|s
| CanonicalizedPath
::new(Path
::new(&s
.into()))).collect();
60 location
: ExternLocation
::ExactPaths(locations
),
61 is_private_dep
: false,
66 fn optgroups() -> getopts
::Options
{
67 let mut opts
= getopts
::Options
::new();
68 for group
in rustc_optgroups() {
69 (group
.apply
)(&mut opts
);
74 fn mk_map
<K
: Ord
, V
>(entries
: Vec
<(K
, V
)>) -> BTreeMap
<K
, V
> {
75 BTreeMap
::from_iter(entries
.into_iter())
78 fn assert_same_clone(x
: &Options
) {
79 assert_eq
!(x
.dep_tracking_hash(true), x
.clone().dep_tracking_hash(true));
80 assert_eq
!(x
.dep_tracking_hash(false), x
.clone().dep_tracking_hash(false));
83 fn assert_same_hash(x
: &Options
, y
: &Options
) {
84 assert_eq
!(x
.dep_tracking_hash(true), y
.dep_tracking_hash(true));
85 assert_eq
!(x
.dep_tracking_hash(false), y
.dep_tracking_hash(false));
91 fn assert_different_hash(x
: &Options
, y
: &Options
) {
92 assert_ne
!(x
.dep_tracking_hash(true), y
.dep_tracking_hash(true));
93 assert_ne
!(x
.dep_tracking_hash(false), y
.dep_tracking_hash(false));
99 fn assert_non_crate_hash_different(x
: &Options
, y
: &Options
) {
100 assert_eq
!(x
.dep_tracking_hash(true), y
.dep_tracking_hash(true));
101 assert_ne
!(x
.dep_tracking_hash(false), y
.dep_tracking_hash(false));
103 assert_same_clone(x
);
104 assert_same_clone(y
);
107 // When the user supplies --test we should implicitly supply --cfg test
109 fn test_switch_implies_cfg_test() {
110 rustc_span
::create_default_session_globals_then(|| {
111 let matches
= optgroups().parse(&["--test".to_string()]).unwrap();
112 let (sess
, cfg
) = mk_session(matches
);
113 let cfg
= build_configuration(&sess
, to_crate_config(cfg
));
114 assert
!(cfg
.contains(&(sym
::test
, None
)));
118 // When the user supplies --test and --cfg test, don't implicitly add another --cfg test
120 fn test_switch_implies_cfg_test_unless_cfg_test() {
121 rustc_span
::create_default_session_globals_then(|| {
122 let matches
= optgroups().parse(&["--test".to_string(), "--cfg=test".to_string()]).unwrap();
123 let (sess
, cfg
) = mk_session(matches
);
124 let cfg
= build_configuration(&sess
, to_crate_config(cfg
));
125 let mut test_items
= cfg
.iter().filter(|&&(name
, _
)| name
== sym
::test
);
126 assert
!(test_items
.next().is_some());
127 assert
!(test_items
.next().is_none());
132 fn test_can_print_warnings() {
133 rustc_span
::create_default_session_globals_then(|| {
134 let matches
= optgroups().parse(&["-Awarnings".to_string()]).unwrap();
135 let (sess
, _
) = mk_session(matches
);
136 assert
!(!sess
.diagnostic().can_emit_warnings());
139 rustc_span
::create_default_session_globals_then(|| {
141 optgroups().parse(&["-Awarnings".to_string(), "-Dwarnings".to_string()]).unwrap();
142 let (sess
, _
) = mk_session(matches
);
143 assert
!(sess
.diagnostic().can_emit_warnings());
146 rustc_span
::create_default_session_globals_then(|| {
147 let matches
= optgroups().parse(&["-Adead_code".to_string()]).unwrap();
148 let (sess
, _
) = mk_session(matches
);
149 assert
!(sess
.diagnostic().can_emit_warnings());
154 fn test_output_types_tracking_hash_different_paths() {
155 let mut v1
= Options
::default();
156 let mut v2
= Options
::default();
157 let mut v3
= Options
::default();
159 v1
.output_types
= OutputTypes
::new(&[(OutputType
::Exe
, Some(PathBuf
::from("./some/thing")))]);
160 v2
.output_types
= OutputTypes
::new(&[(OutputType
::Exe
, Some(PathBuf
::from("/some/thing")))]);
161 v3
.output_types
= OutputTypes
::new(&[(OutputType
::Exe
, None
)]);
163 assert_non_crate_hash_different(&v1
, &v2
);
164 assert_non_crate_hash_different(&v1
, &v3
);
165 assert_non_crate_hash_different(&v2
, &v3
);
169 fn test_output_types_tracking_hash_different_construction_order() {
170 let mut v1
= Options
::default();
171 let mut v2
= Options
::default();
173 v1
.output_types
= OutputTypes
::new(&[
174 (OutputType
::Exe
, Some(PathBuf
::from("./some/thing"))),
175 (OutputType
::Bitcode
, Some(PathBuf
::from("./some/thing.bc"))),
178 v2
.output_types
= OutputTypes
::new(&[
179 (OutputType
::Bitcode
, Some(PathBuf
::from("./some/thing.bc"))),
180 (OutputType
::Exe
, Some(PathBuf
::from("./some/thing"))),
183 assert_same_hash(&v1
, &v2
);
187 fn test_externs_tracking_hash_different_construction_order() {
188 let mut v1
= Options
::default();
189 let mut v2
= Options
::default();
190 let mut v3
= Options
::default();
192 v1
.externs
= Externs
::new(mk_map(vec
![
193 (String
::from("a"), new_public_extern_entry(vec
!["b", "c"])),
194 (String
::from("d"), new_public_extern_entry(vec
!["e", "f"])),
197 v2
.externs
= Externs
::new(mk_map(vec
![
198 (String
::from("d"), new_public_extern_entry(vec
!["e", "f"])),
199 (String
::from("a"), new_public_extern_entry(vec
!["b", "c"])),
202 v3
.externs
= Externs
::new(mk_map(vec
![
203 (String
::from("a"), new_public_extern_entry(vec
!["b", "c"])),
204 (String
::from("d"), new_public_extern_entry(vec
!["f", "e"])),
207 assert_same_hash(&v1
, &v2
);
208 assert_same_hash(&v1
, &v3
);
209 assert_same_hash(&v2
, &v3
);
213 fn test_lints_tracking_hash_different_values() {
214 let mut v1
= Options
::default();
215 let mut v2
= Options
::default();
216 let mut v3
= Options
::default();
219 (String
::from("a"), Level
::Allow
),
220 (String
::from("b"), Level
::Warn
),
221 (String
::from("c"), Level
::Deny
),
222 (String
::from("d"), Level
::Forbid
),
226 (String
::from("a"), Level
::Allow
),
227 (String
::from("b"), Level
::Warn
),
228 (String
::from("X"), Level
::Deny
),
229 (String
::from("d"), Level
::Forbid
),
233 (String
::from("a"), Level
::Allow
),
234 (String
::from("b"), Level
::Warn
),
235 (String
::from("c"), Level
::Forbid
),
236 (String
::from("d"), Level
::Deny
),
239 assert_non_crate_hash_different(&v1
, &v2
);
240 assert_non_crate_hash_different(&v1
, &v3
);
241 assert_non_crate_hash_different(&v2
, &v3
);
245 fn test_lints_tracking_hash_different_construction_order() {
246 let mut v1
= Options
::default();
247 let mut v2
= Options
::default();
250 (String
::from("a"), Level
::Allow
),
251 (String
::from("b"), Level
::Warn
),
252 (String
::from("c"), Level
::Deny
),
253 (String
::from("d"), Level
::Forbid
),
257 (String
::from("a"), Level
::Allow
),
258 (String
::from("c"), Level
::Deny
),
259 (String
::from("b"), Level
::Warn
),
260 (String
::from("d"), Level
::Forbid
),
263 // The hash should be order-dependent
264 assert_non_crate_hash_different(&v1
, &v2
);
268 fn test_lint_cap_hash_different() {
269 let mut v1
= Options
::default();
270 let mut v2
= Options
::default();
271 let v3
= Options
::default();
273 v1
.lint_cap
= Some(Level
::Forbid
);
274 v2
.lint_cap
= Some(Level
::Allow
);
276 assert_non_crate_hash_different(&v1
, &v2
);
277 assert_non_crate_hash_different(&v1
, &v3
);
278 assert_non_crate_hash_different(&v2
, &v3
);
282 fn test_search_paths_tracking_hash_different_order() {
283 let mut v1
= Options
::default();
284 let mut v2
= Options
::default();
285 let mut v3
= Options
::default();
286 let mut v4
= Options
::default();
288 const JSON
: ErrorOutputType
= ErrorOutputType
::Json
{
290 json_rendered
: HumanReadableErrorType
::Default(ColorConfig
::Never
),
294 v1
.search_paths
.push(SearchPath
::from_cli_opt("native=abc", JSON
));
295 v1
.search_paths
.push(SearchPath
::from_cli_opt("crate=def", JSON
));
296 v1
.search_paths
.push(SearchPath
::from_cli_opt("dependency=ghi", JSON
));
297 v1
.search_paths
.push(SearchPath
::from_cli_opt("framework=jkl", JSON
));
298 v1
.search_paths
.push(SearchPath
::from_cli_opt("all=mno", JSON
));
300 v2
.search_paths
.push(SearchPath
::from_cli_opt("native=abc", JSON
));
301 v2
.search_paths
.push(SearchPath
::from_cli_opt("dependency=ghi", JSON
));
302 v2
.search_paths
.push(SearchPath
::from_cli_opt("crate=def", JSON
));
303 v2
.search_paths
.push(SearchPath
::from_cli_opt("framework=jkl", JSON
));
304 v2
.search_paths
.push(SearchPath
::from_cli_opt("all=mno", JSON
));
306 v3
.search_paths
.push(SearchPath
::from_cli_opt("crate=def", JSON
));
307 v3
.search_paths
.push(SearchPath
::from_cli_opt("framework=jkl", JSON
));
308 v3
.search_paths
.push(SearchPath
::from_cli_opt("native=abc", JSON
));
309 v3
.search_paths
.push(SearchPath
::from_cli_opt("dependency=ghi", JSON
));
310 v3
.search_paths
.push(SearchPath
::from_cli_opt("all=mno", JSON
));
312 v4
.search_paths
.push(SearchPath
::from_cli_opt("all=mno", JSON
));
313 v4
.search_paths
.push(SearchPath
::from_cli_opt("native=abc", JSON
));
314 v4
.search_paths
.push(SearchPath
::from_cli_opt("crate=def", JSON
));
315 v4
.search_paths
.push(SearchPath
::from_cli_opt("dependency=ghi", JSON
));
316 v4
.search_paths
.push(SearchPath
::from_cli_opt("framework=jkl", JSON
));
318 assert_same_hash(&v1
, &v2
);
319 assert_same_hash(&v1
, &v3
);
320 assert_same_hash(&v1
, &v4
);
324 fn test_native_libs_tracking_hash_different_values() {
325 let mut v1
= Options
::default();
326 let mut v2
= Options
::default();
327 let mut v3
= Options
::default();
328 let mut v4
= Options
::default();
329 let mut v5
= Options
::default();
334 name
: String
::from("a"),
336 kind
: NativeLibKind
::Static { bundle: None, whole_archive: None }
,
340 name
: String
::from("b"),
342 kind
: NativeLibKind
::Framework { as_needed: None }
,
346 name
: String
::from("c"),
348 kind
: NativeLibKind
::Unspecified
,
356 name
: String
::from("a"),
358 kind
: NativeLibKind
::Static { bundle: None, whole_archive: None }
,
362 name
: String
::from("X"),
364 kind
: NativeLibKind
::Framework { as_needed: None }
,
368 name
: String
::from("c"),
370 kind
: NativeLibKind
::Unspecified
,
378 name
: String
::from("a"),
380 kind
: NativeLibKind
::Static { bundle: None, whole_archive: None }
,
384 name
: String
::from("b"),
386 kind
: NativeLibKind
::Static { bundle: None, whole_archive: None }
,
390 name
: String
::from("c"),
392 kind
: NativeLibKind
::Unspecified
,
400 name
: String
::from("a"),
402 kind
: NativeLibKind
::Static { bundle: None, whole_archive: None }
,
406 name
: String
::from("b"),
407 new_name
: Some(String
::from("X")),
408 kind
: NativeLibKind
::Framework { as_needed: None }
,
412 name
: String
::from("c"),
414 kind
: NativeLibKind
::Unspecified
,
422 name
: String
::from("a"),
424 kind
: NativeLibKind
::Static { bundle: None, whole_archive: None }
,
428 name
: String
::from("b"),
430 kind
: NativeLibKind
::Framework { as_needed: None }
,
431 verbatim
: Some(true),
434 name
: String
::from("c"),
436 kind
: NativeLibKind
::Unspecified
,
441 assert_different_hash(&v1
, &v2
);
442 assert_different_hash(&v1
, &v3
);
443 assert_different_hash(&v1
, &v4
);
444 assert_different_hash(&v1
, &v5
);
448 fn test_native_libs_tracking_hash_different_order() {
449 let mut v1
= Options
::default();
450 let mut v2
= Options
::default();
451 let mut v3
= Options
::default();
456 name
: String
::from("a"),
458 kind
: NativeLibKind
::Static { bundle: None, whole_archive: None }
,
462 name
: String
::from("b"),
464 kind
: NativeLibKind
::Framework { as_needed: None }
,
468 name
: String
::from("c"),
470 kind
: NativeLibKind
::Unspecified
,
477 name
: String
::from("b"),
479 kind
: NativeLibKind
::Framework { as_needed: None }
,
483 name
: String
::from("a"),
485 kind
: NativeLibKind
::Static { bundle: None, whole_archive: None }
,
489 name
: String
::from("c"),
491 kind
: NativeLibKind
::Unspecified
,
498 name
: String
::from("c"),
500 kind
: NativeLibKind
::Unspecified
,
504 name
: String
::from("a"),
506 kind
: NativeLibKind
::Static { bundle: None, whole_archive: None }
,
510 name
: String
::from("b"),
512 kind
: NativeLibKind
::Framework { as_needed: None }
,
517 // The hash should be order-dependent
518 assert_different_hash(&v1
, &v2
);
519 assert_different_hash(&v1
, &v3
);
520 assert_different_hash(&v2
, &v3
);
524 fn test_codegen_options_tracking_hash() {
525 let reference
= Options
::default();
526 let mut opts
= Options
::default();
528 macro_rules
! untracked
{
529 ($name
: ident
, $non_default_value
: expr
) => {
530 assert_ne
!(opts
.cg
.$name
, $non_default_value
);
531 opts
.cg
.$name
= $non_default_value
;
532 assert_same_hash(&reference
, &opts
);
536 // Make sure that changing an [UNTRACKED] option leaves the hash unchanged.
537 // This list is in alphabetical order.
538 untracked
!(ar
, String
::from("abc"));
539 untracked
!(codegen_units
, Some(42));
540 untracked
!(default_linker_libraries
, true);
541 untracked
!(extra_filename
, String
::from("extra-filename"));
542 untracked
!(incremental
, Some(String
::from("abc")));
543 // `link_arg` is omitted because it just forwards to `link_args`.
544 untracked
!(link_args
, vec
![String
::from("abc"), String
::from("def")]);
545 untracked
!(link_self_contained
, Some(true));
546 untracked
!(linker
, Some(PathBuf
::from("linker")));
547 untracked
!(linker_flavor
, Some(LinkerFlavor
::Gcc
));
548 untracked
!(no_stack_check
, true);
549 untracked
!(remark
, Passes
::Some(vec
![String
::from("pass1"), String
::from("pass2")]));
550 untracked
!(rpath
, true);
551 untracked
!(save_temps
, true);
553 macro_rules
! tracked
{
554 ($name
: ident
, $non_default_value
: expr
) => {
555 opts
= reference
.clone();
556 assert_ne
!(opts
.cg
.$name
, $non_default_value
);
557 opts
.cg
.$name
= $non_default_value
;
558 assert_different_hash(&reference
, &opts
);
562 // Make sure that changing a [TRACKED] option changes the hash.
563 // This list is in alphabetical order.
564 tracked
!(code_model
, Some(CodeModel
::Large
));
565 tracked
!(control_flow_guard
, CFGuard
::Checks
);
566 tracked
!(debug_assertions
, Some(true));
567 tracked
!(debuginfo
, 0xdeadbeef);
568 tracked
!(embed_bitcode
, false);
569 tracked
!(force_frame_pointers
, Some(false));
570 tracked
!(force_unwind_tables
, Some(true));
571 tracked
!(inline_threshold
, Some(0xf007ba11));
572 tracked
!(linker_plugin_lto
, LinkerPluginLto
::LinkerPluginAuto
);
573 tracked
!(link_dead_code
, Some(true));
574 tracked
!(llvm_args
, vec
![String
::from("1"), String
::from("2")]);
575 tracked
!(lto
, LtoCli
::Fat
);
576 tracked
!(metadata
, vec
![String
::from("A"), String
::from("B")]);
577 tracked
!(no_prepopulate_passes
, true);
578 tracked
!(no_redzone
, Some(true));
579 tracked
!(no_vectorize_loops
, true);
580 tracked
!(no_vectorize_slp
, true);
581 tracked
!(opt_level
, "3".to_string());
582 tracked
!(overflow_checks
, Some(true));
583 tracked
!(panic
, Some(PanicStrategy
::Abort
));
584 tracked
!(passes
, vec
![String
::from("1"), String
::from("2")]);
585 tracked
!(prefer_dynamic
, true);
586 tracked
!(profile_generate
, SwitchWithOptPath
::Enabled(None
));
587 tracked
!(profile_use
, Some(PathBuf
::from("abc")));
588 tracked
!(relocation_model
, Some(RelocModel
::Pic
));
589 tracked
!(soft_float
, true);
590 tracked
!(split_debuginfo
, Some(SplitDebuginfo
::Packed
));
591 tracked
!(target_cpu
, Some(String
::from("abc")));
592 tracked
!(target_feature
, String
::from("all the features, all of them"));
596 fn test_top_level_options_tracked_no_crate() {
597 let reference
= Options
::default();
600 macro_rules
! tracked
{
601 ($name
: ident
, $non_default_value
: expr
) => {
602 opts
= reference
.clone();
603 assert_ne
!(opts
.$name
, $non_default_value
);
604 opts
.$name
= $non_default_value
;
605 // The crate hash should be the same
606 assert_eq
!(reference
.dep_tracking_hash(true), opts
.dep_tracking_hash(true));
607 // The incremental hash should be different
608 assert_ne
!(reference
.dep_tracking_hash(false), opts
.dep_tracking_hash(false));
612 // Make sure that changing a [TRACKED_NO_CRATE_HASH] option leaves the crate hash unchanged but changes the incremental hash.
613 // This list is in alphabetical order.
614 tracked
!(remap_path_prefix
, vec
![("/home/bors/rust".into(), "src".into())]);
616 real_rust_source_base_dir
,
617 Some("/home/bors/rust/.rustup/toolchains/nightly/lib/rustlib/src/rust".into())
622 fn test_debugging_options_tracking_hash() {
623 let reference
= Options
::default();
624 let mut opts
= Options
::default();
626 macro_rules
! untracked
{
627 ($name
: ident
, $non_default_value
: expr
) => {
628 assert_ne
!(opts
.debugging_opts
.$name
, $non_default_value
);
629 opts
.debugging_opts
.$name
= $non_default_value
;
630 assert_same_hash(&reference
, &opts
);
634 // Make sure that changing an [UNTRACKED] option leaves the hash unchanged.
635 // This list is in alphabetical order.
636 untracked
!(ast_json
, true);
637 untracked
!(ast_json_noexpand
, true);
638 untracked
!(borrowck
, String
::from("other"));
639 untracked
!(deduplicate_diagnostics
, false);
640 untracked
!(dep_tasks
, true);
641 untracked
!(dont_buffer_diagnostics
, true);
642 untracked
!(dump_dep_graph
, true);
643 untracked
!(dump_mir
, Some(String
::from("abc")));
644 untracked
!(dump_mir_dataflow
, true);
645 untracked
!(dump_mir_dir
, String
::from("abc"));
646 untracked
!(dump_mir_exclude_pass_number
, true);
647 untracked
!(dump_mir_graphviz
, true);
648 untracked
!(emit_future_incompat_report
, true);
649 untracked
!(emit_stack_sizes
, true);
650 untracked
!(future_incompat_test
, true);
651 untracked
!(hir_stats
, true);
652 untracked
!(identify_regions
, true);
653 untracked
!(incremental_ignore_spans
, true);
654 untracked
!(incremental_info
, true);
655 untracked
!(incremental_verify_ich
, true);
656 untracked
!(input_stats
, true);
657 untracked
!(keep_hygiene_data
, true);
658 untracked
!(link_native_libraries
, false);
659 untracked
!(llvm_time_trace
, true);
660 untracked
!(ls
, true);
661 untracked
!(macro_backtrace
, true);
662 untracked
!(meta_stats
, true);
663 untracked
!(nll_facts
, true);
664 untracked
!(no_analysis
, true);
665 untracked
!(no_interleave_lints
, true);
666 untracked
!(no_leak_check
, true);
667 untracked
!(no_parallel_llvm
, true);
668 untracked
!(parse_only
, true);
669 untracked
!(perf_stats
, true);
670 // `pre_link_arg` is omitted because it just forwards to `pre_link_args`.
671 untracked
!(pre_link_args
, vec
![String
::from("abc"), String
::from("def")]);
672 untracked
!(profile_closures
, true);
673 untracked
!(print_link_args
, true);
674 untracked
!(print_llvm_passes
, true);
675 untracked
!(print_mono_items
, Some(String
::from("abc")));
676 untracked
!(print_type_sizes
, true);
677 untracked
!(proc_macro_backtrace
, true);
678 untracked
!(query_dep_graph
, true);
679 untracked
!(query_stats
, true);
680 untracked
!(save_analysis
, true);
681 untracked
!(self_profile
, SwitchWithOptPath
::Enabled(None
));
682 untracked
!(self_profile_events
, Some(vec
![String
::new()]));
683 untracked
!(span_debug
, true);
684 untracked
!(span_free_formats
, true);
685 untracked
!(strip
, Strip
::Debuginfo
);
686 untracked
!(terminal_width
, Some(80));
687 untracked
!(threads
, 99);
688 untracked
!(time
, true);
689 untracked
!(time_llvm_passes
, true);
690 untracked
!(time_passes
, true);
691 untracked
!(trace_macros
, true);
692 untracked
!(trim_diagnostic_paths
, false);
693 untracked
!(ui_testing
, true);
694 untracked
!(unpretty
, Some("expanded".to_string()));
695 untracked
!(unstable_options
, true);
696 untracked
!(validate_mir
, true);
697 untracked
!(verbose
, true);
699 macro_rules
! tracked
{
700 ($name
: ident
, $non_default_value
: expr
) => {
701 opts
= reference
.clone();
702 assert_ne
!(opts
.debugging_opts
.$name
, $non_default_value
);
703 opts
.debugging_opts
.$name
= $non_default_value
;
704 assert_different_hash(&reference
, &opts
);
708 // Make sure that changing a [TRACKED] option changes the hash.
709 // This list is in alphabetical order.
710 tracked
!(allow_features
, Some(vec
![String
::from("lang_items")]));
711 tracked
!(always_encode_mir
, true);
712 tracked
!(assume_incomplete_release
, true);
713 tracked
!(asm_comments
, true);
714 tracked
!(binary_dep_depinfo
, true);
715 tracked
!(chalk
, true);
716 tracked
!(codegen_backend
, Some("abc".to_string()));
717 tracked
!(crate_attr
, vec
!["abc".to_string()]);
718 tracked
!(debug_macros
, true);
719 tracked
!(dep_info_omit_d_target
, true);
720 tracked
!(dual_proc_macros
, true);
721 tracked
!(fewer_names
, Some(true));
722 tracked
!(force_overflow_checks
, Some(true));
723 tracked
!(force_unstable_if_unmarked
, true);
724 tracked
!(fuel
, Some(("abc".to_string(), 99)));
725 tracked
!(function_sections
, Some(false));
726 tracked
!(human_readable_cgu_names
, true);
727 tracked
!(inline_in_all_cgus
, Some(true));
728 tracked
!(inline_mir
, Some(true));
729 tracked
!(inline_mir_threshold
, Some(123));
730 tracked
!(inline_mir_hint_threshold
, Some(123));
731 tracked
!(instrument_coverage
, Some(InstrumentCoverage
::All
));
732 tracked
!(instrument_mcount
, true);
733 tracked
!(link_only
, true);
734 tracked
!(llvm_plugins
, vec
![String
::from("plugin_name")]);
735 tracked
!(merge_functions
, Some(MergeFunctions
::Disabled
));
736 tracked
!(mir_emit_retag
, true);
737 tracked
!(mir_opt_level
, Some(4));
738 tracked
!(mutable_noalias
, Some(true));
739 tracked
!(new_llvm_pass_manager
, Some(true));
740 tracked
!(no_generate_arange_section
, true);
741 tracked
!(no_link
, true);
742 tracked
!(osx_rpath_install_name
, true);
743 tracked
!(panic_abort_tests
, true);
744 tracked
!(plt
, Some(true));
745 tracked
!(polonius
, true);
746 tracked
!(precise_enum_drop_elaboration
, false);
747 tracked
!(print_fuel
, Some("abc".to_string()));
748 tracked
!(profile
, true);
749 tracked
!(profile_emit
, Some(PathBuf
::from("abc")));
750 tracked
!(profiler_runtime
, None
);
751 tracked
!(relax_elf_relocations
, Some(true));
752 tracked
!(relro_level
, Some(RelroLevel
::Full
));
753 tracked
!(simulate_remapped_rust_src_base
, Some(PathBuf
::from("/rustc/abc")));
754 tracked
!(report_delayed_bugs
, true);
755 tracked
!(sanitizer
, SanitizerSet
::ADDRESS
);
756 tracked
!(sanitizer_memory_track_origins
, 2);
757 tracked
!(sanitizer_recover
, SanitizerSet
::ADDRESS
);
758 tracked
!(saturating_float_casts
, Some(true));
759 tracked
!(share_generics
, Some(true));
760 tracked
!(show_span
, Some(String
::from("abc")));
761 tracked
!(src_hash_algorithm
, Some(SourceFileHashAlgorithm
::Sha1
));
762 tracked
!(symbol_mangling_version
, Some(SymbolManglingVersion
::V0
));
763 tracked
!(teach
, true);
764 tracked
!(thinlto
, Some(true));
765 tracked
!(thir_unsafeck
, true);
766 tracked
!(tune_cpu
, Some(String
::from("abc")));
767 tracked
!(tls_model
, Some(TlsModel
::GeneralDynamic
));
768 tracked
!(trap_unreachable
, Some(false));
769 tracked
!(treat_err_as_bug
, NonZeroUsize
::new(1));
770 tracked
!(unleash_the_miri_inside_of_you
, true);
771 tracked
!(use_ctors_section
, Some(true));
772 tracked
!(verify_llvm_ir
, true);
773 tracked
!(wasi_exec_model
, Some(WasiExecModel
::Reactor
));
775 macro_rules
! tracked_no_crate_hash
{
776 ($name
: ident
, $non_default_value
: expr
) => {
777 opts
= reference
.clone();
778 assert_ne
!(opts
.debugging_opts
.$name
, $non_default_value
);
779 opts
.debugging_opts
.$name
= $non_default_value
;
780 assert_non_crate_hash_different(&reference
, &opts
);
783 tracked_no_crate_hash
!(no_codegen
, true);
787 fn test_edition_parsing() {
788 // test default edition
789 let options
= Options
::default();
790 assert
!(options
.edition
== DEFAULT_EDITION
);
792 let matches
= optgroups().parse(&["--edition=2018".to_string()]).unwrap();
793 let (sessopts
, _
) = build_session_options_and_crate_config(matches
);
794 assert
!(sessopts
.edition
== Edition
::Edition2018
)