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::{CFGuard, ExternEntry, LinkerPluginLto, LtoCli, SwitchWithOptPath};
12 use rustc_session::config::{
13 Externs, OutputType, OutputTypes, SymbolManglingVersion, WasiExecModel,
15 use rustc_session::lint::Level;
16 use rustc_session::search_paths::SearchPath;
17 use rustc_session::utils::{CanonicalizedPath, NativeLib, NativeLibKind};
18 use rustc_session::{build_session, getopts, DiagnosticOutput, Session};
19 use rustc_span::edition::{Edition, DEFAULT_EDITION};
20 use rustc_span::symbol::sym;
21 use rustc_span::SourceFileHashAlgorithm;
22 use rustc_target::spec::{CodeModel, LinkerFlavor, MergeFunctions, PanicStrategy};
23 use rustc_target::spec::{RelocModel, RelroLevel, SanitizerSet, SplitDebuginfo, TlsModel};
25 use std::collections::{BTreeMap, BTreeSet};
26 use std::iter::FromIterator;
27 use std::num::NonZeroUsize;
28 use std::path::{Path, PathBuf};
30 type CfgSpecs = FxHashSet<(String, Option<String>)>;
32 fn build_session_options_and_crate_config(matches: getopts::Matches) -> (Options, CfgSpecs) {
33 let sessopts = build_session_options(&matches);
34 let cfg = parse_cfgspecs(matches.opt_strs("cfg"));
38 fn mk_session(matches: getopts::Matches) -> (Session, CfgSpecs) {
39 let registry = registry::Registry::new(&[]);
40 let (sessopts, cfg) = build_session_options_and_crate_config(matches);
41 let sess = build_session(
45 DiagnosticOutput::Default,
53 fn new_public_extern_entry<S, I>(locations: I) -> ExternEntry
56 I: IntoIterator<Item = S>,
58 let locations: BTreeSet<CanonicalizedPath> =
59 locations.into_iter().map(|s| CanonicalizedPath::new(Path::new(&s.into()))).collect();
62 location: ExternLocation::ExactPaths(locations),
63 is_private_dep: false,
68 fn optgroups() -> getopts::Options {
69 let mut opts = getopts::Options::new();
70 for group in rustc_optgroups() {
71 (group.apply)(&mut opts);
76 fn mk_map<K: Ord, V>(entries: Vec<(K, V)>) -> BTreeMap<K, V> {
77 BTreeMap::from_iter(entries.into_iter())
80 fn assert_same_clone(x: &Options) {
81 assert_eq!(x.dep_tracking_hash(true), x.clone().dep_tracking_hash(true));
82 assert_eq!(x.dep_tracking_hash(false), x.clone().dep_tracking_hash(false));
85 fn assert_same_hash(x: &Options, y: &Options) {
86 assert_eq!(x.dep_tracking_hash(true), y.dep_tracking_hash(true));
87 assert_eq!(x.dep_tracking_hash(false), y.dep_tracking_hash(false));
93 fn assert_different_hash(x: &Options, y: &Options) {
94 assert_ne!(x.dep_tracking_hash(true), y.dep_tracking_hash(true));
95 assert_ne!(x.dep_tracking_hash(false), y.dep_tracking_hash(false));
101 fn assert_non_crate_hash_different(x: &Options, y: &Options) {
102 assert_eq!(x.dep_tracking_hash(true), y.dep_tracking_hash(true));
103 assert_ne!(x.dep_tracking_hash(false), y.dep_tracking_hash(false));
105 assert_same_clone(x);
106 assert_same_clone(y);
109 // When the user supplies --test we should implicitly supply --cfg test
111 fn test_switch_implies_cfg_test() {
112 rustc_span::create_default_session_globals_then(|| {
113 let matches = optgroups().parse(&["--test".to_string()]).unwrap();
114 let (sess, cfg) = mk_session(matches);
115 let cfg = build_configuration(&sess, to_crate_config(cfg));
116 assert!(cfg.contains(&(sym::test, None)));
120 // When the user supplies --test and --cfg test, don't implicitly add another --cfg test
122 fn test_switch_implies_cfg_test_unless_cfg_test() {
123 rustc_span::create_default_session_globals_then(|| {
124 let matches = optgroups().parse(&["--test".to_string(), "--cfg=test".to_string()]).unwrap();
125 let (sess, cfg) = mk_session(matches);
126 let cfg = build_configuration(&sess, to_crate_config(cfg));
127 let mut test_items = cfg.iter().filter(|&&(name, _)| name == sym::test);
128 assert!(test_items.next().is_some());
129 assert!(test_items.next().is_none());
134 fn test_can_print_warnings() {
135 rustc_span::create_default_session_globals_then(|| {
136 let matches = optgroups().parse(&["-Awarnings".to_string()]).unwrap();
137 let (sess, _) = mk_session(matches);
138 assert!(!sess.diagnostic().can_emit_warnings());
141 rustc_span::create_default_session_globals_then(|| {
143 optgroups().parse(&["-Awarnings".to_string(), "-Dwarnings".to_string()]).unwrap();
144 let (sess, _) = mk_session(matches);
145 assert!(sess.diagnostic().can_emit_warnings());
148 rustc_span::create_default_session_globals_then(|| {
149 let matches = optgroups().parse(&["-Adead_code".to_string()]).unwrap();
150 let (sess, _) = mk_session(matches);
151 assert!(sess.diagnostic().can_emit_warnings());
156 fn test_output_types_tracking_hash_different_paths() {
157 let mut v1 = Options::default();
158 let mut v2 = Options::default();
159 let mut v3 = Options::default();
161 v1.output_types = OutputTypes::new(&[(OutputType::Exe, Some(PathBuf::from("./some/thing")))]);
162 v2.output_types = OutputTypes::new(&[(OutputType::Exe, Some(PathBuf::from("/some/thing")))]);
163 v3.output_types = OutputTypes::new(&[(OutputType::Exe, None)]);
165 assert_non_crate_hash_different(&v1, &v2);
166 assert_non_crate_hash_different(&v1, &v3);
167 assert_non_crate_hash_different(&v2, &v3);
171 fn test_output_types_tracking_hash_different_construction_order() {
172 let mut v1 = Options::default();
173 let mut v2 = Options::default();
175 v1.output_types = OutputTypes::new(&[
176 (OutputType::Exe, Some(PathBuf::from("./some/thing"))),
177 (OutputType::Bitcode, Some(PathBuf::from("./some/thing.bc"))),
180 v2.output_types = OutputTypes::new(&[
181 (OutputType::Bitcode, Some(PathBuf::from("./some/thing.bc"))),
182 (OutputType::Exe, Some(PathBuf::from("./some/thing"))),
185 assert_same_hash(&v1, &v2);
189 fn test_externs_tracking_hash_different_construction_order() {
190 let mut v1 = Options::default();
191 let mut v2 = Options::default();
192 let mut v3 = Options::default();
194 v1.externs = Externs::new(mk_map(vec![
195 (String::from("a"), new_public_extern_entry(vec!["b", "c"])),
196 (String::from("d"), new_public_extern_entry(vec!["e", "f"])),
199 v2.externs = Externs::new(mk_map(vec![
200 (String::from("d"), new_public_extern_entry(vec!["e", "f"])),
201 (String::from("a"), new_public_extern_entry(vec!["b", "c"])),
204 v3.externs = Externs::new(mk_map(vec![
205 (String::from("a"), new_public_extern_entry(vec!["b", "c"])),
206 (String::from("d"), new_public_extern_entry(vec!["f", "e"])),
209 assert_same_hash(&v1, &v2);
210 assert_same_hash(&v1, &v3);
211 assert_same_hash(&v2, &v3);
215 fn test_lints_tracking_hash_different_values() {
216 let mut v1 = Options::default();
217 let mut v2 = Options::default();
218 let mut v3 = Options::default();
221 (String::from("a"), Level::Allow),
222 (String::from("b"), Level::Warn),
223 (String::from("c"), Level::Deny),
224 (String::from("d"), Level::Forbid),
228 (String::from("a"), Level::Allow),
229 (String::from("b"), Level::Warn),
230 (String::from("X"), Level::Deny),
231 (String::from("d"), Level::Forbid),
235 (String::from("a"), Level::Allow),
236 (String::from("b"), Level::Warn),
237 (String::from("c"), Level::Forbid),
238 (String::from("d"), Level::Deny),
241 assert_non_crate_hash_different(&v1, &v2);
242 assert_non_crate_hash_different(&v1, &v3);
243 assert_non_crate_hash_different(&v2, &v3);
247 fn test_lints_tracking_hash_different_construction_order() {
248 let mut v1 = Options::default();
249 let mut v2 = Options::default();
252 (String::from("a"), Level::Allow),
253 (String::from("b"), Level::Warn),
254 (String::from("c"), Level::Deny),
255 (String::from("d"), Level::Forbid),
259 (String::from("a"), Level::Allow),
260 (String::from("c"), Level::Deny),
261 (String::from("b"), Level::Warn),
262 (String::from("d"), Level::Forbid),
265 // The hash should be order-dependent
266 assert_non_crate_hash_different(&v1, &v2);
270 fn test_lint_cap_hash_different() {
271 let mut v1 = Options::default();
272 let mut v2 = Options::default();
273 let v3 = Options::default();
275 v1.lint_cap = Some(Level::Forbid);
276 v2.lint_cap = Some(Level::Allow);
278 assert_non_crate_hash_different(&v1, &v2);
279 assert_non_crate_hash_different(&v1, &v3);
280 assert_non_crate_hash_different(&v2, &v3);
284 fn test_search_paths_tracking_hash_different_order() {
285 let mut v1 = Options::default();
286 let mut v2 = Options::default();
287 let mut v3 = Options::default();
288 let mut v4 = Options::default();
290 const JSON: ErrorOutputType = ErrorOutputType::Json {
292 json_rendered: HumanReadableErrorType::Default(ColorConfig::Never),
296 v1.search_paths.push(SearchPath::from_cli_opt("native=abc", JSON));
297 v1.search_paths.push(SearchPath::from_cli_opt("crate=def", JSON));
298 v1.search_paths.push(SearchPath::from_cli_opt("dependency=ghi", JSON));
299 v1.search_paths.push(SearchPath::from_cli_opt("framework=jkl", JSON));
300 v1.search_paths.push(SearchPath::from_cli_opt("all=mno", JSON));
302 v2.search_paths.push(SearchPath::from_cli_opt("native=abc", JSON));
303 v2.search_paths.push(SearchPath::from_cli_opt("dependency=ghi", JSON));
304 v2.search_paths.push(SearchPath::from_cli_opt("crate=def", JSON));
305 v2.search_paths.push(SearchPath::from_cli_opt("framework=jkl", JSON));
306 v2.search_paths.push(SearchPath::from_cli_opt("all=mno", JSON));
308 v3.search_paths.push(SearchPath::from_cli_opt("crate=def", JSON));
309 v3.search_paths.push(SearchPath::from_cli_opt("framework=jkl", JSON));
310 v3.search_paths.push(SearchPath::from_cli_opt("native=abc", JSON));
311 v3.search_paths.push(SearchPath::from_cli_opt("dependency=ghi", JSON));
312 v3.search_paths.push(SearchPath::from_cli_opt("all=mno", JSON));
314 v4.search_paths.push(SearchPath::from_cli_opt("all=mno", JSON));
315 v4.search_paths.push(SearchPath::from_cli_opt("native=abc", JSON));
316 v4.search_paths.push(SearchPath::from_cli_opt("crate=def", JSON));
317 v4.search_paths.push(SearchPath::from_cli_opt("dependency=ghi", JSON));
318 v4.search_paths.push(SearchPath::from_cli_opt("framework=jkl", JSON));
320 assert_same_hash(&v1, &v2);
321 assert_same_hash(&v1, &v3);
322 assert_same_hash(&v1, &v4);
326 fn test_native_libs_tracking_hash_different_values() {
327 let mut v1 = Options::default();
328 let mut v2 = Options::default();
329 let mut v3 = Options::default();
330 let mut v4 = Options::default();
331 let mut v5 = Options::default();
336 name: String::from("a"),
338 kind: NativeLibKind::Static { bundle: None, whole_archive: None },
342 name: String::from("b"),
344 kind: NativeLibKind::Framework { as_needed: None },
348 name: String::from("c"),
350 kind: NativeLibKind::Unspecified,
358 name: String::from("a"),
360 kind: NativeLibKind::Static { bundle: None, whole_archive: None },
364 name: String::from("X"),
366 kind: NativeLibKind::Framework { as_needed: None },
370 name: String::from("c"),
372 kind: NativeLibKind::Unspecified,
380 name: String::from("a"),
382 kind: NativeLibKind::Static { bundle: None, whole_archive: None },
386 name: String::from("b"),
388 kind: NativeLibKind::Static { bundle: None, whole_archive: None },
392 name: String::from("c"),
394 kind: NativeLibKind::Unspecified,
402 name: String::from("a"),
404 kind: NativeLibKind::Static { bundle: None, whole_archive: None },
408 name: String::from("b"),
409 new_name: Some(String::from("X")),
410 kind: NativeLibKind::Framework { as_needed: None },
414 name: String::from("c"),
416 kind: NativeLibKind::Unspecified,
424 name: String::from("a"),
426 kind: NativeLibKind::Static { bundle: None, whole_archive: None },
430 name: String::from("b"),
432 kind: NativeLibKind::Framework { as_needed: None },
433 verbatim: Some(true),
436 name: String::from("c"),
438 kind: NativeLibKind::Unspecified,
443 assert_different_hash(&v1, &v2);
444 assert_different_hash(&v1, &v3);
445 assert_different_hash(&v1, &v4);
446 assert_different_hash(&v1, &v5);
450 fn test_native_libs_tracking_hash_different_order() {
451 let mut v1 = Options::default();
452 let mut v2 = Options::default();
453 let mut v3 = Options::default();
458 name: String::from("a"),
460 kind: NativeLibKind::Static { bundle: None, whole_archive: None },
464 name: String::from("b"),
466 kind: NativeLibKind::Framework { as_needed: None },
470 name: String::from("c"),
472 kind: NativeLibKind::Unspecified,
479 name: String::from("b"),
481 kind: NativeLibKind::Framework { as_needed: None },
485 name: String::from("a"),
487 kind: NativeLibKind::Static { bundle: None, whole_archive: None },
491 name: String::from("c"),
493 kind: NativeLibKind::Unspecified,
500 name: String::from("c"),
502 kind: NativeLibKind::Unspecified,
506 name: String::from("a"),
508 kind: NativeLibKind::Static { bundle: None, whole_archive: None },
512 name: String::from("b"),
514 kind: NativeLibKind::Framework { as_needed: None },
519 // The hash should be order-dependent
520 assert_different_hash(&v1, &v2);
521 assert_different_hash(&v1, &v3);
522 assert_different_hash(&v2, &v3);
526 fn test_codegen_options_tracking_hash() {
527 let reference = Options::default();
528 let mut opts = Options::default();
530 macro_rules! untracked {
531 ($name: ident, $non_default_value: expr) => {
532 assert_ne!(opts.cg.$name, $non_default_value);
533 opts.cg.$name = $non_default_value;
534 assert_same_hash(&reference, &opts);
538 // Make sure that changing an [UNTRACKED] option leaves the hash unchanged.
539 // This list is in alphabetical order.
540 untracked!(ar, String::from("abc"));
541 untracked!(codegen_units, Some(42));
542 untracked!(default_linker_libraries, true);
543 untracked!(extra_filename, String::from("extra-filename"));
544 untracked!(incremental, Some(String::from("abc")));
545 // `link_arg` is omitted because it just forwards to `link_args`.
546 untracked!(link_args, vec![String::from("abc"), String::from("def")]);
547 untracked!(link_self_contained, Some(true));
548 untracked!(linker, Some(PathBuf::from("linker")));
549 untracked!(linker_flavor, Some(LinkerFlavor::Gcc));
550 untracked!(no_stack_check, true);
551 untracked!(remark, Passes::Some(vec![String::from("pass1"), String::from("pass2")]));
552 untracked!(rpath, true);
553 untracked!(save_temps, true);
555 macro_rules! tracked {
556 ($name: ident, $non_default_value: expr) => {
557 opts = reference.clone();
558 assert_ne!(opts.cg.$name, $non_default_value);
559 opts.cg.$name = $non_default_value;
560 assert_different_hash(&reference, &opts);
564 // Make sure that changing a [TRACKED] option changes the hash.
565 // This list is in alphabetical order.
566 tracked!(code_model, Some(CodeModel::Large));
567 tracked!(control_flow_guard, CFGuard::Checks);
568 tracked!(debug_assertions, Some(true));
569 tracked!(debuginfo, 0xdeadbeef);
570 tracked!(embed_bitcode, false);
571 tracked!(force_frame_pointers, Some(false));
572 tracked!(force_unwind_tables, Some(true));
573 tracked!(inline_threshold, Some(0xf007ba11));
574 tracked!(linker_plugin_lto, LinkerPluginLto::LinkerPluginAuto);
575 tracked!(link_dead_code, Some(true));
576 tracked!(llvm_args, vec![String::from("1"), String::from("2")]);
577 tracked!(lto, LtoCli::Fat);
578 tracked!(metadata, vec![String::from("A"), String::from("B")]);
579 tracked!(no_prepopulate_passes, true);
580 tracked!(no_redzone, Some(true));
581 tracked!(no_vectorize_loops, true);
582 tracked!(no_vectorize_slp, true);
583 tracked!(opt_level, "3".to_string());
584 tracked!(overflow_checks, Some(true));
585 tracked!(panic, Some(PanicStrategy::Abort));
586 tracked!(passes, vec![String::from("1"), String::from("2")]);
587 tracked!(prefer_dynamic, true);
588 tracked!(profile_generate, SwitchWithOptPath::Enabled(None));
589 tracked!(profile_use, Some(PathBuf::from("abc")));
590 tracked!(relocation_model, Some(RelocModel::Pic));
591 tracked!(soft_float, true);
592 tracked!(split_debuginfo, Some(SplitDebuginfo::Packed));
593 tracked!(target_cpu, Some(String::from("abc")));
594 tracked!(target_feature, String::from("all the features, all of them"));
598 fn test_top_level_options_tracked_no_crate() {
599 let reference = Options::default();
602 macro_rules! tracked {
603 ($name: ident, $non_default_value: expr) => {
604 opts = reference.clone();
605 assert_ne!(opts.$name, $non_default_value);
606 opts.$name = $non_default_value;
607 // The crate hash should be the same
608 assert_eq!(reference.dep_tracking_hash(true), opts.dep_tracking_hash(true));
609 // The incremental hash should be different
610 assert_ne!(reference.dep_tracking_hash(false), opts.dep_tracking_hash(false));
614 // Make sure that changing a [TRACKED_NO_CRATE_HASH] option leaves the crate hash unchanged but changes the incremental hash.
615 // This list is in alphabetical order.
616 tracked!(remap_path_prefix, vec![("/home/bors/rust".into(), "src".into())]);
618 real_rust_source_base_dir,
619 Some("/home/bors/rust/.rustup/toolchains/nightly/lib/rustlib/src/rust".into())
624 fn test_debugging_options_tracking_hash() {
625 let reference = Options::default();
626 let mut opts = Options::default();
628 macro_rules! untracked {
629 ($name: ident, $non_default_value: expr) => {
630 assert_ne!(opts.debugging_opts.$name, $non_default_value);
631 opts.debugging_opts.$name = $non_default_value;
632 assert_same_hash(&reference, &opts);
636 // Make sure that changing an [UNTRACKED] option leaves the hash unchanged.
637 // This list is in alphabetical order.
638 untracked!(ast_json, true);
639 untracked!(ast_json_noexpand, true);
640 untracked!(borrowck, String::from("other"));
641 untracked!(deduplicate_diagnostics, false);
642 untracked!(dep_tasks, true);
643 untracked!(dont_buffer_diagnostics, true);
644 untracked!(dump_dep_graph, true);
645 untracked!(dump_mir, Some(String::from("abc")));
646 untracked!(dump_mir_dataflow, true);
647 untracked!(dump_mir_dir, String::from("abc"));
648 untracked!(dump_mir_exclude_pass_number, true);
649 untracked!(dump_mir_graphviz, true);
650 untracked!(emit_future_incompat_report, true);
651 untracked!(emit_stack_sizes, true);
652 untracked!(future_incompat_test, true);
653 untracked!(hir_stats, true);
654 untracked!(identify_regions, true);
655 untracked!(incremental_ignore_spans, true);
656 untracked!(incremental_info, true);
657 untracked!(incremental_verify_ich, true);
658 untracked!(input_stats, true);
659 untracked!(keep_hygiene_data, true);
660 untracked!(link_native_libraries, false);
661 untracked!(llvm_time_trace, true);
662 untracked!(ls, true);
663 untracked!(macro_backtrace, true);
664 untracked!(meta_stats, true);
665 untracked!(nll_facts, true);
666 untracked!(no_analysis, true);
667 untracked!(no_interleave_lints, true);
668 untracked!(no_leak_check, true);
669 untracked!(no_parallel_llvm, true);
670 untracked!(parse_only, true);
671 untracked!(perf_stats, true);
672 // `pre_link_arg` is omitted because it just forwards to `pre_link_args`.
673 untracked!(pre_link_args, vec![String::from("abc"), String::from("def")]);
674 untracked!(profile_closures, true);
675 untracked!(print_link_args, true);
676 untracked!(print_llvm_passes, true);
677 untracked!(print_mono_items, Some(String::from("abc")));
678 untracked!(print_type_sizes, true);
679 untracked!(proc_macro_backtrace, true);
680 untracked!(query_dep_graph, true);
681 untracked!(query_stats, true);
682 untracked!(save_analysis, true);
683 untracked!(self_profile, SwitchWithOptPath::Enabled(None));
684 untracked!(self_profile_events, Some(vec![String::new()]));
685 untracked!(span_debug, true);
686 untracked!(span_free_formats, true);
687 untracked!(strip, Strip::Debuginfo);
688 untracked!(terminal_width, Some(80));
689 untracked!(threads, 99);
690 untracked!(time, true);
691 untracked!(time_llvm_passes, true);
692 untracked!(time_passes, true);
693 untracked!(trace_macros, true);
694 untracked!(trim_diagnostic_paths, false);
695 untracked!(ui_testing, true);
696 untracked!(unpretty, Some("expanded".to_string()));
697 untracked!(unstable_options, true);
698 untracked!(validate_mir, true);
699 untracked!(verbose, true);
701 macro_rules! tracked {
702 ($name: ident, $non_default_value: expr) => {
703 opts = reference.clone();
704 assert_ne!(opts.debugging_opts.$name, $non_default_value);
705 opts.debugging_opts.$name = $non_default_value;
706 assert_different_hash(&reference, &opts);
710 // Make sure that changing a [TRACKED] option changes the hash.
711 // This list is in alphabetical order.
712 tracked!(allow_features, Some(vec![String::from("lang_items")]));
713 tracked!(always_encode_mir, true);
714 tracked!(assume_incomplete_release, true);
715 tracked!(asm_comments, true);
716 tracked!(binary_dep_depinfo, true);
717 tracked!(chalk, true);
718 tracked!(codegen_backend, Some("abc".to_string()));
719 tracked!(crate_attr, vec!["abc".to_string()]);
720 tracked!(debug_info_for_profiling, true);
721 tracked!(debug_macros, true);
722 tracked!(dep_info_omit_d_target, true);
723 tracked!(dual_proc_macros, true);
724 tracked!(fewer_names, Some(true));
725 tracked!(force_overflow_checks, Some(true));
726 tracked!(force_unstable_if_unmarked, true);
727 tracked!(fuel, Some(("abc".to_string(), 99)));
728 tracked!(function_sections, Some(false));
729 tracked!(human_readable_cgu_names, true);
730 tracked!(inline_in_all_cgus, Some(true));
731 tracked!(inline_mir, Some(true));
732 tracked!(inline_mir_threshold, Some(123));
733 tracked!(inline_mir_hint_threshold, Some(123));
734 tracked!(instrument_coverage, Some(InstrumentCoverage::All));
735 tracked!(instrument_mcount, true);
736 tracked!(link_only, true);
737 tracked!(llvm_plugins, vec![String::from("plugin_name")]);
738 tracked!(location_detail, LocationDetail { file: true, line: false, column: false });
739 tracked!(merge_functions, Some(MergeFunctions::Disabled));
740 tracked!(mir_emit_retag, true);
741 tracked!(mir_opt_level, Some(4));
742 tracked!(move_size_limit, Some(4096));
743 tracked!(mutable_noalias, Some(true));
744 tracked!(new_llvm_pass_manager, Some(true));
745 tracked!(no_generate_arange_section, true);
746 tracked!(no_link, true);
747 tracked!(no_unique_section_names, true);
748 tracked!(no_profiler_runtime, true);
749 tracked!(osx_rpath_install_name, true);
750 tracked!(panic_abort_tests, true);
751 tracked!(panic_in_drop, PanicStrategy::Abort);
752 tracked!(partially_uninit_const_threshold, Some(123));
753 tracked!(plt, Some(true));
754 tracked!(polonius, true);
755 tracked!(precise_enum_drop_elaboration, false);
756 tracked!(print_fuel, Some("abc".to_string()));
757 tracked!(profile, true);
758 tracked!(profile_emit, Some(PathBuf::from("abc")));
759 tracked!(profiler_runtime, "abc".to_string());
760 tracked!(profile_sample_use, Some(PathBuf::from("abc")));
761 tracked!(relax_elf_relocations, Some(true));
762 tracked!(relro_level, Some(RelroLevel::Full));
763 tracked!(remap_cwd_prefix, Some(PathBuf::from("abc")));
764 tracked!(simulate_remapped_rust_src_base, Some(PathBuf::from("/rustc/abc")));
765 tracked!(report_delayed_bugs, true);
766 tracked!(sanitizer, SanitizerSet::ADDRESS);
767 tracked!(sanitizer_memory_track_origins, 2);
768 tracked!(sanitizer_recover, SanitizerSet::ADDRESS);
769 tracked!(saturating_float_casts, Some(true));
770 tracked!(share_generics, Some(true));
771 tracked!(show_span, Some(String::from("abc")));
772 tracked!(src_hash_algorithm, Some(SourceFileHashAlgorithm::Sha1));
773 tracked!(symbol_mangling_version, Some(SymbolManglingVersion::V0));
774 tracked!(teach, true);
775 tracked!(thinlto, Some(true));
776 tracked!(thir_unsafeck, true);
777 tracked!(tune_cpu, Some(String::from("abc")));
778 tracked!(tls_model, Some(TlsModel::GeneralDynamic));
779 tracked!(trap_unreachable, Some(false));
780 tracked!(treat_err_as_bug, NonZeroUsize::new(1));
781 tracked!(unleash_the_miri_inside_of_you, true);
782 tracked!(use_ctors_section, Some(true));
783 tracked!(verify_llvm_ir, true);
784 tracked!(wasi_exec_model, Some(WasiExecModel::Reactor));
786 macro_rules! tracked_no_crate_hash {
787 ($name: ident, $non_default_value: expr) => {
788 opts = reference.clone();
789 assert_ne!(opts.debugging_opts.$name, $non_default_value);
790 opts.debugging_opts.$name = $non_default_value;
791 assert_non_crate_hash_different(&reference, &opts);
794 tracked_no_crate_hash!(no_codegen, true);
798 fn test_edition_parsing() {
799 // test default edition
800 let options = Options::default();
801 assert!(options.edition == DEFAULT_EDITION);
803 let matches = optgroups().parse(&["--edition=2018".to_string()]).unwrap();
804 let (sessopts, _) = build_session_options_and_crate_config(matches);
805 assert!(sessopts.edition == Edition::Edition2018)