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, OutputType, OutputTypes, PAuthKey, PacRet, SymbolManglingVersion,
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(
48 DiagnosticOutput::Default,
56 fn new_public_extern_entry<S, I>(locations: I) -> ExternEntry
59 I: IntoIterator<Item = S>,
61 let locations: BTreeSet<CanonicalizedPath> =
62 locations.into_iter().map(|s| CanonicalizedPath::new(Path::new(&s.into()))).collect();
65 location: ExternLocation::ExactPaths(locations),
66 is_private_dep: false,
71 fn optgroups() -> getopts::Options {
72 let mut opts = getopts::Options::new();
73 for group in rustc_optgroups() {
74 (group.apply)(&mut opts);
79 fn mk_map<K: Ord, V>(entries: Vec<(K, V)>) -> BTreeMap<K, V> {
80 BTreeMap::from_iter(entries.into_iter())
83 fn assert_same_clone(x: &Options) {
84 assert_eq!(x.dep_tracking_hash(true), x.clone().dep_tracking_hash(true));
85 assert_eq!(x.dep_tracking_hash(false), x.clone().dep_tracking_hash(false));
88 fn assert_same_hash(x: &Options, y: &Options) {
89 assert_eq!(x.dep_tracking_hash(true), y.dep_tracking_hash(true));
90 assert_eq!(x.dep_tracking_hash(false), y.dep_tracking_hash(false));
96 fn assert_different_hash(x: &Options, y: &Options) {
97 assert_ne!(x.dep_tracking_hash(true), y.dep_tracking_hash(true));
98 assert_ne!(x.dep_tracking_hash(false), y.dep_tracking_hash(false));
100 assert_same_clone(x);
101 assert_same_clone(y);
104 fn assert_non_crate_hash_different(x: &Options, y: &Options) {
105 assert_eq!(x.dep_tracking_hash(true), y.dep_tracking_hash(true));
106 assert_ne!(x.dep_tracking_hash(false), y.dep_tracking_hash(false));
108 assert_same_clone(x);
109 assert_same_clone(y);
112 // When the user supplies --test we should implicitly supply --cfg test
114 fn test_switch_implies_cfg_test() {
115 rustc_span::create_default_session_globals_then(|| {
116 let matches = optgroups().parse(&["--test".to_string()]).unwrap();
117 let (sess, cfg) = mk_session(matches);
118 let cfg = build_configuration(&sess, to_crate_config(cfg));
119 assert!(cfg.contains(&(sym::test, None)));
123 // When the user supplies --test and --cfg test, don't implicitly add another --cfg test
125 fn test_switch_implies_cfg_test_unless_cfg_test() {
126 rustc_span::create_default_session_globals_then(|| {
127 let matches = optgroups().parse(&["--test".to_string(), "--cfg=test".to_string()]).unwrap();
128 let (sess, cfg) = mk_session(matches);
129 let cfg = build_configuration(&sess, to_crate_config(cfg));
130 let mut test_items = cfg.iter().filter(|&&(name, _)| name == sym::test);
131 assert!(test_items.next().is_some());
132 assert!(test_items.next().is_none());
137 fn test_can_print_warnings() {
138 rustc_span::create_default_session_globals_then(|| {
139 let matches = optgroups().parse(&["-Awarnings".to_string()]).unwrap();
140 let (sess, _) = mk_session(matches);
141 assert!(!sess.diagnostic().can_emit_warnings());
144 rustc_span::create_default_session_globals_then(|| {
146 optgroups().parse(&["-Awarnings".to_string(), "-Dwarnings".to_string()]).unwrap();
147 let (sess, _) = mk_session(matches);
148 assert!(sess.diagnostic().can_emit_warnings());
151 rustc_span::create_default_session_globals_then(|| {
152 let matches = optgroups().parse(&["-Adead_code".to_string()]).unwrap();
153 let (sess, _) = mk_session(matches);
154 assert!(sess.diagnostic().can_emit_warnings());
159 fn test_output_types_tracking_hash_different_paths() {
160 let mut v1 = Options::default();
161 let mut v2 = Options::default();
162 let mut v3 = Options::default();
164 v1.output_types = OutputTypes::new(&[(OutputType::Exe, Some(PathBuf::from("./some/thing")))]);
165 v2.output_types = OutputTypes::new(&[(OutputType::Exe, Some(PathBuf::from("/some/thing")))]);
166 v3.output_types = OutputTypes::new(&[(OutputType::Exe, None)]);
168 assert_non_crate_hash_different(&v1, &v2);
169 assert_non_crate_hash_different(&v1, &v3);
170 assert_non_crate_hash_different(&v2, &v3);
174 fn test_output_types_tracking_hash_different_construction_order() {
175 let mut v1 = Options::default();
176 let mut v2 = Options::default();
178 v1.output_types = OutputTypes::new(&[
179 (OutputType::Exe, Some(PathBuf::from("./some/thing"))),
180 (OutputType::Bitcode, Some(PathBuf::from("./some/thing.bc"))),
183 v2.output_types = OutputTypes::new(&[
184 (OutputType::Bitcode, Some(PathBuf::from("./some/thing.bc"))),
185 (OutputType::Exe, Some(PathBuf::from("./some/thing"))),
188 assert_same_hash(&v1, &v2);
192 fn test_externs_tracking_hash_different_construction_order() {
193 let mut v1 = Options::default();
194 let mut v2 = Options::default();
195 let mut v3 = Options::default();
197 v1.externs = Externs::new(mk_map(vec![
198 (String::from("a"), new_public_extern_entry(vec!["b", "c"])),
199 (String::from("d"), new_public_extern_entry(vec!["e", "f"])),
202 v2.externs = Externs::new(mk_map(vec![
203 (String::from("d"), new_public_extern_entry(vec!["e", "f"])),
204 (String::from("a"), new_public_extern_entry(vec!["b", "c"])),
207 v3.externs = Externs::new(mk_map(vec![
208 (String::from("a"), new_public_extern_entry(vec!["b", "c"])),
209 (String::from("d"), new_public_extern_entry(vec!["f", "e"])),
212 assert_same_hash(&v1, &v2);
213 assert_same_hash(&v1, &v3);
214 assert_same_hash(&v2, &v3);
218 fn test_lints_tracking_hash_different_values() {
219 let mut v1 = Options::default();
220 let mut v2 = Options::default();
221 let mut v3 = Options::default();
224 (String::from("a"), Level::Allow),
225 (String::from("b"), Level::Warn),
226 (String::from("c"), Level::Deny),
227 (String::from("d"), Level::Forbid),
231 (String::from("a"), Level::Allow),
232 (String::from("b"), Level::Warn),
233 (String::from("X"), Level::Deny),
234 (String::from("d"), Level::Forbid),
238 (String::from("a"), Level::Allow),
239 (String::from("b"), Level::Warn),
240 (String::from("c"), Level::Forbid),
241 (String::from("d"), Level::Deny),
244 assert_non_crate_hash_different(&v1, &v2);
245 assert_non_crate_hash_different(&v1, &v3);
246 assert_non_crate_hash_different(&v2, &v3);
250 fn test_lints_tracking_hash_different_construction_order() {
251 let mut v1 = Options::default();
252 let mut v2 = Options::default();
255 (String::from("a"), Level::Allow),
256 (String::from("b"), Level::Warn),
257 (String::from("c"), Level::Deny),
258 (String::from("d"), Level::Forbid),
262 (String::from("a"), Level::Allow),
263 (String::from("c"), Level::Deny),
264 (String::from("b"), Level::Warn),
265 (String::from("d"), Level::Forbid),
268 // The hash should be order-dependent
269 assert_non_crate_hash_different(&v1, &v2);
273 fn test_lint_cap_hash_different() {
274 let mut v1 = Options::default();
275 let mut v2 = Options::default();
276 let v3 = Options::default();
278 v1.lint_cap = Some(Level::Forbid);
279 v2.lint_cap = Some(Level::Allow);
281 assert_non_crate_hash_different(&v1, &v2);
282 assert_non_crate_hash_different(&v1, &v3);
283 assert_non_crate_hash_different(&v2, &v3);
287 fn test_search_paths_tracking_hash_different_order() {
288 let mut v1 = Options::default();
289 let mut v2 = Options::default();
290 let mut v3 = Options::default();
291 let mut v4 = Options::default();
293 const JSON: ErrorOutputType = ErrorOutputType::Json {
295 json_rendered: HumanReadableErrorType::Default(ColorConfig::Never),
299 v1.search_paths.push(SearchPath::from_cli_opt("native=abc", JSON));
300 v1.search_paths.push(SearchPath::from_cli_opt("crate=def", JSON));
301 v1.search_paths.push(SearchPath::from_cli_opt("dependency=ghi", JSON));
302 v1.search_paths.push(SearchPath::from_cli_opt("framework=jkl", JSON));
303 v1.search_paths.push(SearchPath::from_cli_opt("all=mno", JSON));
305 v2.search_paths.push(SearchPath::from_cli_opt("native=abc", JSON));
306 v2.search_paths.push(SearchPath::from_cli_opt("dependency=ghi", JSON));
307 v2.search_paths.push(SearchPath::from_cli_opt("crate=def", JSON));
308 v2.search_paths.push(SearchPath::from_cli_opt("framework=jkl", JSON));
309 v2.search_paths.push(SearchPath::from_cli_opt("all=mno", JSON));
311 v3.search_paths.push(SearchPath::from_cli_opt("crate=def", JSON));
312 v3.search_paths.push(SearchPath::from_cli_opt("framework=jkl", JSON));
313 v3.search_paths.push(SearchPath::from_cli_opt("native=abc", JSON));
314 v3.search_paths.push(SearchPath::from_cli_opt("dependency=ghi", JSON));
315 v3.search_paths.push(SearchPath::from_cli_opt("all=mno", JSON));
317 v4.search_paths.push(SearchPath::from_cli_opt("all=mno", JSON));
318 v4.search_paths.push(SearchPath::from_cli_opt("native=abc", JSON));
319 v4.search_paths.push(SearchPath::from_cli_opt("crate=def", JSON));
320 v4.search_paths.push(SearchPath::from_cli_opt("dependency=ghi", JSON));
321 v4.search_paths.push(SearchPath::from_cli_opt("framework=jkl", JSON));
323 assert_same_hash(&v1, &v2);
324 assert_same_hash(&v1, &v3);
325 assert_same_hash(&v1, &v4);
329 fn test_native_libs_tracking_hash_different_values() {
330 let mut v1 = Options::default();
331 let mut v2 = Options::default();
332 let mut v3 = Options::default();
333 let mut v4 = Options::default();
334 let mut v5 = Options::default();
339 name: String::from("a"),
341 kind: NativeLibKind::Static { bundle: None, whole_archive: None },
345 name: String::from("b"),
347 kind: NativeLibKind::Framework { as_needed: None },
351 name: String::from("c"),
353 kind: NativeLibKind::Unspecified,
361 name: String::from("a"),
363 kind: NativeLibKind::Static { bundle: None, whole_archive: None },
367 name: String::from("X"),
369 kind: NativeLibKind::Framework { as_needed: None },
373 name: String::from("c"),
375 kind: NativeLibKind::Unspecified,
383 name: String::from("a"),
385 kind: NativeLibKind::Static { bundle: None, whole_archive: None },
389 name: String::from("b"),
391 kind: NativeLibKind::Static { bundle: None, whole_archive: None },
395 name: String::from("c"),
397 kind: NativeLibKind::Unspecified,
405 name: String::from("a"),
407 kind: NativeLibKind::Static { bundle: None, whole_archive: None },
411 name: String::from("b"),
412 new_name: Some(String::from("X")),
413 kind: NativeLibKind::Framework { as_needed: None },
417 name: String::from("c"),
419 kind: NativeLibKind::Unspecified,
427 name: String::from("a"),
429 kind: NativeLibKind::Static { bundle: None, whole_archive: None },
433 name: String::from("b"),
435 kind: NativeLibKind::Framework { as_needed: None },
436 verbatim: Some(true),
439 name: String::from("c"),
441 kind: NativeLibKind::Unspecified,
446 assert_different_hash(&v1, &v2);
447 assert_different_hash(&v1, &v3);
448 assert_different_hash(&v1, &v4);
449 assert_different_hash(&v1, &v5);
453 fn test_native_libs_tracking_hash_different_order() {
454 let mut v1 = Options::default();
455 let mut v2 = Options::default();
456 let mut v3 = Options::default();
461 name: String::from("a"),
463 kind: NativeLibKind::Static { bundle: None, whole_archive: None },
467 name: String::from("b"),
469 kind: NativeLibKind::Framework { as_needed: None },
473 name: String::from("c"),
475 kind: NativeLibKind::Unspecified,
482 name: String::from("b"),
484 kind: NativeLibKind::Framework { as_needed: None },
488 name: String::from("a"),
490 kind: NativeLibKind::Static { bundle: None, whole_archive: None },
494 name: String::from("c"),
496 kind: NativeLibKind::Unspecified,
503 name: String::from("c"),
505 kind: NativeLibKind::Unspecified,
509 name: String::from("a"),
511 kind: NativeLibKind::Static { bundle: None, whole_archive: None },
515 name: String::from("b"),
517 kind: NativeLibKind::Framework { as_needed: None },
522 // The hash should be order-dependent
523 assert_different_hash(&v1, &v2);
524 assert_different_hash(&v1, &v3);
525 assert_different_hash(&v2, &v3);
529 fn test_codegen_options_tracking_hash() {
530 let reference = Options::default();
531 let mut opts = Options::default();
533 macro_rules! untracked {
534 ($name: ident, $non_default_value: expr) => {
535 assert_ne!(opts.cg.$name, $non_default_value);
536 opts.cg.$name = $non_default_value;
537 assert_same_hash(&reference, &opts);
541 // Make sure that changing an [UNTRACKED] option leaves the hash unchanged.
542 // This list is in alphabetical order.
543 untracked!(ar, String::from("abc"));
544 untracked!(codegen_units, Some(42));
545 untracked!(default_linker_libraries, true);
546 untracked!(extra_filename, String::from("extra-filename"));
547 untracked!(incremental, Some(String::from("abc")));
548 // `link_arg` is omitted because it just forwards to `link_args`.
549 untracked!(link_args, vec![String::from("abc"), String::from("def")]);
550 untracked!(link_self_contained, Some(true));
551 untracked!(linker, Some(PathBuf::from("linker")));
552 untracked!(linker_flavor, Some(LinkerFlavor::Gcc));
553 untracked!(no_stack_check, true);
554 untracked!(remark, Passes::Some(vec![String::from("pass1"), String::from("pass2")]));
555 untracked!(rpath, true);
556 untracked!(save_temps, true);
557 untracked!(strip, Strip::Debuginfo);
559 macro_rules! tracked {
560 ($name: ident, $non_default_value: expr) => {
561 opts = reference.clone();
562 assert_ne!(opts.cg.$name, $non_default_value);
563 opts.cg.$name = $non_default_value;
564 assert_different_hash(&reference, &opts);
568 // Make sure that changing a [TRACKED] option changes the hash.
569 // This list is in alphabetical order.
570 tracked!(code_model, Some(CodeModel::Large));
571 tracked!(control_flow_guard, CFGuard::Checks);
572 tracked!(debug_assertions, Some(true));
573 tracked!(debuginfo, 0xdeadbeef);
574 tracked!(embed_bitcode, false);
575 tracked!(force_frame_pointers, Some(false));
576 tracked!(force_unwind_tables, Some(true));
577 tracked!(inline_threshold, Some(0xf007ba11));
578 tracked!(instrument_coverage, Some(InstrumentCoverage::All));
579 tracked!(linker_plugin_lto, LinkerPluginLto::LinkerPluginAuto);
580 tracked!(link_dead_code, Some(true));
581 tracked!(llvm_args, vec![String::from("1"), String::from("2")]);
582 tracked!(lto, LtoCli::Fat);
583 tracked!(metadata, vec![String::from("A"), String::from("B")]);
584 tracked!(no_prepopulate_passes, true);
585 tracked!(no_redzone, Some(true));
586 tracked!(no_vectorize_loops, true);
587 tracked!(no_vectorize_slp, true);
588 tracked!(opt_level, "3".to_string());
589 tracked!(overflow_checks, Some(true));
590 tracked!(panic, Some(PanicStrategy::Abort));
591 tracked!(passes, vec![String::from("1"), String::from("2")]);
592 tracked!(prefer_dynamic, true);
593 tracked!(profile_generate, SwitchWithOptPath::Enabled(None));
594 tracked!(profile_use, Some(PathBuf::from("abc")));
595 tracked!(relocation_model, Some(RelocModel::Pic));
596 tracked!(soft_float, true);
597 tracked!(split_debuginfo, Some(SplitDebuginfo::Packed));
598 tracked!(symbol_mangling_version, Some(SymbolManglingVersion::V0));
599 tracked!(target_cpu, Some(String::from("abc")));
600 tracked!(target_feature, String::from("all the features, all of them"));
604 fn test_top_level_options_tracked_no_crate() {
605 let reference = Options::default();
608 macro_rules! tracked {
609 ($name: ident, $non_default_value: expr) => {
610 opts = reference.clone();
611 assert_ne!(opts.$name, $non_default_value);
612 opts.$name = $non_default_value;
613 // The crate hash should be the same
614 assert_eq!(reference.dep_tracking_hash(true), opts.dep_tracking_hash(true));
615 // The incremental hash should be different
616 assert_ne!(reference.dep_tracking_hash(false), opts.dep_tracking_hash(false));
620 // Make sure that changing a [TRACKED_NO_CRATE_HASH] option leaves the crate hash unchanged but changes the incremental hash.
621 // This list is in alphabetical order.
622 tracked!(remap_path_prefix, vec![("/home/bors/rust".into(), "src".into())]);
624 real_rust_source_base_dir,
625 Some("/home/bors/rust/.rustup/toolchains/nightly/lib/rustlib/src/rust".into())
630 fn test_debugging_options_tracking_hash() {
631 let reference = Options::default();
632 let mut opts = Options::default();
634 macro_rules! untracked {
635 ($name: ident, $non_default_value: expr) => {
636 assert_ne!(opts.debugging_opts.$name, $non_default_value);
637 opts.debugging_opts.$name = $non_default_value;
638 assert_same_hash(&reference, &opts);
642 // Make sure that changing an [UNTRACKED] option leaves the hash unchanged.
643 // This list is in alphabetical order.
644 untracked!(assert_incr_state, Some(String::from("loaded")));
645 untracked!(ast_json, true);
646 untracked!(ast_json_noexpand, true);
647 untracked!(borrowck, String::from("other"));
648 untracked!(deduplicate_diagnostics, false);
649 untracked!(dep_tasks, true);
650 untracked!(dlltool, Some(PathBuf::from("custom_dlltool.exe")));
651 untracked!(dont_buffer_diagnostics, true);
652 untracked!(dump_dep_graph, true);
653 untracked!(dump_mir, Some(String::from("abc")));
654 untracked!(dump_mir_dataflow, true);
655 untracked!(dump_mir_dir, String::from("abc"));
656 untracked!(dump_mir_exclude_pass_number, true);
657 untracked!(dump_mir_graphviz, true);
658 untracked!(emit_stack_sizes, true);
659 untracked!(future_incompat_test, true);
660 untracked!(hir_stats, true);
661 untracked!(identify_regions, true);
662 untracked!(incremental_ignore_spans, true);
663 untracked!(incremental_info, true);
664 untracked!(incremental_verify_ich, true);
665 untracked!(input_stats, true);
666 untracked!(keep_hygiene_data, true);
667 untracked!(link_native_libraries, false);
668 untracked!(llvm_time_trace, true);
669 untracked!(ls, true);
670 untracked!(macro_backtrace, true);
671 untracked!(meta_stats, true);
672 untracked!(nll_facts, true);
673 untracked!(no_analysis, true);
674 untracked!(no_interleave_lints, true);
675 untracked!(no_leak_check, true);
676 untracked!(no_parallel_llvm, true);
677 untracked!(parse_only, true);
678 untracked!(perf_stats, true);
679 // `pre_link_arg` is omitted because it just forwards to `pre_link_args`.
680 untracked!(pre_link_args, vec![String::from("abc"), String::from("def")]);
681 untracked!(profile_closures, true);
682 untracked!(print_llvm_passes, true);
683 untracked!(print_mono_items, Some(String::from("abc")));
684 untracked!(print_type_sizes, true);
685 untracked!(proc_macro_backtrace, true);
686 untracked!(query_dep_graph, true);
687 untracked!(save_analysis, true);
688 untracked!(self_profile, SwitchWithOptPath::Enabled(None));
689 untracked!(self_profile_events, Some(vec![String::new()]));
690 untracked!(span_debug, true);
691 untracked!(span_free_formats, true);
692 untracked!(temps_dir, Some(String::from("abc")));
693 untracked!(terminal_width, Some(80));
694 untracked!(threads, 99);
695 untracked!(time, true);
696 untracked!(time_llvm_passes, true);
697 untracked!(time_passes, true);
698 untracked!(trace_macros, true);
699 untracked!(trim_diagnostic_paths, false);
700 untracked!(ui_testing, true);
701 untracked!(unpretty, Some("expanded".to_string()));
702 untracked!(unstable_options, true);
703 untracked!(validate_mir, true);
704 untracked!(verbose, true);
706 macro_rules! tracked {
707 ($name: ident, $non_default_value: expr) => {
708 opts = reference.clone();
709 assert_ne!(opts.debugging_opts.$name, $non_default_value);
710 opts.debugging_opts.$name = $non_default_value;
711 assert_different_hash(&reference, &opts);
715 // Make sure that changing a [TRACKED] option changes the hash.
716 // This list is in alphabetical order.
717 tracked!(allow_features, Some(vec![String::from("lang_items")]));
718 tracked!(always_encode_mir, true);
719 tracked!(asm_comments, true);
720 tracked!(assume_incomplete_release, true);
721 tracked!(binary_dep_depinfo, true);
724 BranchProtection { bti: true, pac_ret: Some(PacRet { leaf: true, key: PAuthKey::B }) }
726 tracked!(chalk, true);
727 tracked!(codegen_backend, Some("abc".to_string()));
728 tracked!(crate_attr, vec!["abc".to_string()]);
729 tracked!(debug_info_for_profiling, true);
730 tracked!(debug_macros, true);
731 tracked!(dep_info_omit_d_target, true);
732 tracked!(drop_tracking, true);
733 tracked!(dual_proc_macros, true);
734 tracked!(fewer_names, Some(true));
735 tracked!(force_unstable_if_unmarked, true);
736 tracked!(fuel, Some(("abc".to_string(), 99)));
737 tracked!(function_sections, Some(false));
738 tracked!(human_readable_cgu_names, true);
739 tracked!(inline_in_all_cgus, Some(true));
740 tracked!(inline_mir, Some(true));
741 tracked!(inline_mir_hint_threshold, Some(123));
742 tracked!(inline_mir_threshold, Some(123));
743 tracked!(instrument_coverage, Some(InstrumentCoverage::All));
744 tracked!(instrument_mcount, true);
745 tracked!(link_only, true);
746 tracked!(llvm_plugins, vec![String::from("plugin_name")]);
747 tracked!(location_detail, LocationDetail { file: true, line: false, column: false });
748 tracked!(merge_functions, Some(MergeFunctions::Disabled));
749 tracked!(mir_emit_retag, true);
750 tracked!(mir_opt_level, Some(4));
751 tracked!(move_size_limit, Some(4096));
752 tracked!(mutable_noalias, Some(true));
753 tracked!(new_llvm_pass_manager, Some(true));
754 tracked!(no_generate_arange_section, true);
755 tracked!(no_link, true);
756 tracked!(no_unique_section_names, true);
757 tracked!(no_profiler_runtime, true);
758 tracked!(osx_rpath_install_name, true);
759 tracked!(panic_abort_tests, true);
760 tracked!(panic_in_drop, PanicStrategy::Abort);
761 tracked!(partially_uninit_const_threshold, Some(123));
762 tracked!(pick_stable_methods_before_any_unstable, false);
763 tracked!(plt, Some(true));
764 tracked!(polonius, true);
765 tracked!(precise_enum_drop_elaboration, false);
766 tracked!(print_fuel, Some("abc".to_string()));
767 tracked!(profile, true);
768 tracked!(profile_emit, Some(PathBuf::from("abc")));
769 tracked!(profiler_runtime, "abc".to_string());
770 tracked!(profile_sample_use, Some(PathBuf::from("abc")));
771 tracked!(relax_elf_relocations, Some(true));
772 tracked!(relro_level, Some(RelroLevel::Full));
773 tracked!(remap_cwd_prefix, Some(PathBuf::from("abc")));
774 tracked!(report_delayed_bugs, true);
775 tracked!(sanitizer, SanitizerSet::ADDRESS);
776 tracked!(sanitizer_memory_track_origins, 2);
777 tracked!(sanitizer_recover, SanitizerSet::ADDRESS);
778 tracked!(saturating_float_casts, Some(true));
779 tracked!(share_generics, Some(true));
780 tracked!(show_span, Some(String::from("abc")));
781 tracked!(simulate_remapped_rust_src_base, Some(PathBuf::from("/rustc/abc")));
782 tracked!(src_hash_algorithm, Some(SourceFileHashAlgorithm::Sha1));
783 tracked!(stack_protector, StackProtector::All);
784 tracked!(symbol_mangling_version, Some(SymbolManglingVersion::V0));
785 tracked!(teach, true);
786 tracked!(thinlto, Some(true));
787 tracked!(thir_unsafeck, true);
788 tracked!(tls_model, Some(TlsModel::GeneralDynamic));
789 tracked!(trap_unreachable, Some(false));
790 tracked!(treat_err_as_bug, NonZeroUsize::new(1));
791 tracked!(tune_cpu, Some(String::from("abc")));
792 tracked!(unleash_the_miri_inside_of_you, true);
793 tracked!(use_ctors_section, Some(true));
794 tracked!(verify_llvm_ir, true);
795 tracked!(wasi_exec_model, Some(WasiExecModel::Reactor));
797 macro_rules! tracked_no_crate_hash {
798 ($name: ident, $non_default_value: expr) => {
799 opts = reference.clone();
800 assert_ne!(opts.debugging_opts.$name, $non_default_value);
801 opts.debugging_opts.$name = $non_default_value;
802 assert_non_crate_hash_different(&reference, &opts);
805 tracked_no_crate_hash!(no_codegen, true);
809 fn test_edition_parsing() {
810 // test default edition
811 let options = Options::default();
812 assert!(options.edition == DEFAULT_EDITION);
814 let matches = optgroups().parse(&["--edition=2018".to_string()]).unwrap();
815 let (sessopts, _) = build_session_options_and_crate_config(matches);
816 assert!(sessopts.edition == Edition::Edition2018)