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::{
24 RelocModel, RelroLevel, SanitizerSet, SplitDebuginfo, StackProtector, TlsModel,
27 use std::collections::{BTreeMap, BTreeSet};
28 use std::iter::FromIterator;
29 use std::num::NonZeroUsize;
30 use std::path::{Path, PathBuf};
32 type CfgSpecs = FxHashSet<(String, Option<String>)>;
34 fn build_session_options_and_crate_config(matches: getopts::Matches) -> (Options, CfgSpecs) {
35 let sessopts = build_session_options(&matches);
36 let cfg = parse_cfgspecs(matches.opt_strs("cfg"));
40 fn mk_session(matches: getopts::Matches) -> (Session, CfgSpecs) {
41 let registry = registry::Registry::new(&[]);
42 let (sessopts, cfg) = build_session_options_and_crate_config(matches);
43 let sess = build_session(
47 DiagnosticOutput::Default,
55 fn new_public_extern_entry<S, I>(locations: I) -> ExternEntry
58 I: IntoIterator<Item = S>,
60 let locations: BTreeSet<CanonicalizedPath> =
61 locations.into_iter().map(|s| CanonicalizedPath::new(Path::new(&s.into()))).collect();
64 location: ExternLocation::ExactPaths(locations),
65 is_private_dep: false,
70 fn optgroups() -> getopts::Options {
71 let mut opts = getopts::Options::new();
72 for group in rustc_optgroups() {
73 (group.apply)(&mut opts);
78 fn mk_map<K: Ord, V>(entries: Vec<(K, V)>) -> BTreeMap<K, V> {
79 BTreeMap::from_iter(entries.into_iter())
82 fn assert_same_clone(x: &Options) {
83 assert_eq!(x.dep_tracking_hash(true), x.clone().dep_tracking_hash(true));
84 assert_eq!(x.dep_tracking_hash(false), x.clone().dep_tracking_hash(false));
87 fn assert_same_hash(x: &Options, y: &Options) {
88 assert_eq!(x.dep_tracking_hash(true), y.dep_tracking_hash(true));
89 assert_eq!(x.dep_tracking_hash(false), y.dep_tracking_hash(false));
95 fn assert_different_hash(x: &Options, y: &Options) {
96 assert_ne!(x.dep_tracking_hash(true), y.dep_tracking_hash(true));
97 assert_ne!(x.dep_tracking_hash(false), y.dep_tracking_hash(false));
100 assert_same_clone(y);
103 fn assert_non_crate_hash_different(x: &Options, y: &Options) {
104 assert_eq!(x.dep_tracking_hash(true), y.dep_tracking_hash(true));
105 assert_ne!(x.dep_tracking_hash(false), y.dep_tracking_hash(false));
107 assert_same_clone(x);
108 assert_same_clone(y);
111 // When the user supplies --test we should implicitly supply --cfg test
113 fn test_switch_implies_cfg_test() {
114 rustc_span::create_default_session_globals_then(|| {
115 let matches = optgroups().parse(&["--test".to_string()]).unwrap();
116 let (sess, cfg) = mk_session(matches);
117 let cfg = build_configuration(&sess, to_crate_config(cfg));
118 assert!(cfg.contains(&(sym::test, None)));
122 // When the user supplies --test and --cfg test, don't implicitly add another --cfg test
124 fn test_switch_implies_cfg_test_unless_cfg_test() {
125 rustc_span::create_default_session_globals_then(|| {
126 let matches = optgroups().parse(&["--test".to_string(), "--cfg=test".to_string()]).unwrap();
127 let (sess, cfg) = mk_session(matches);
128 let cfg = build_configuration(&sess, to_crate_config(cfg));
129 let mut test_items = cfg.iter().filter(|&&(name, _)| name == sym::test);
130 assert!(test_items.next().is_some());
131 assert!(test_items.next().is_none());
136 fn test_can_print_warnings() {
137 rustc_span::create_default_session_globals_then(|| {
138 let matches = optgroups().parse(&["-Awarnings".to_string()]).unwrap();
139 let (sess, _) = mk_session(matches);
140 assert!(!sess.diagnostic().can_emit_warnings());
143 rustc_span::create_default_session_globals_then(|| {
145 optgroups().parse(&["-Awarnings".to_string(), "-Dwarnings".to_string()]).unwrap();
146 let (sess, _) = mk_session(matches);
147 assert!(sess.diagnostic().can_emit_warnings());
150 rustc_span::create_default_session_globals_then(|| {
151 let matches = optgroups().parse(&["-Adead_code".to_string()]).unwrap();
152 let (sess, _) = mk_session(matches);
153 assert!(sess.diagnostic().can_emit_warnings());
158 fn test_output_types_tracking_hash_different_paths() {
159 let mut v1 = Options::default();
160 let mut v2 = Options::default();
161 let mut v3 = Options::default();
163 v1.output_types = OutputTypes::new(&[(OutputType::Exe, Some(PathBuf::from("./some/thing")))]);
164 v2.output_types = OutputTypes::new(&[(OutputType::Exe, Some(PathBuf::from("/some/thing")))]);
165 v3.output_types = OutputTypes::new(&[(OutputType::Exe, None)]);
167 assert_non_crate_hash_different(&v1, &v2);
168 assert_non_crate_hash_different(&v1, &v3);
169 assert_non_crate_hash_different(&v2, &v3);
173 fn test_output_types_tracking_hash_different_construction_order() {
174 let mut v1 = Options::default();
175 let mut v2 = Options::default();
177 v1.output_types = OutputTypes::new(&[
178 (OutputType::Exe, Some(PathBuf::from("./some/thing"))),
179 (OutputType::Bitcode, Some(PathBuf::from("./some/thing.bc"))),
182 v2.output_types = OutputTypes::new(&[
183 (OutputType::Bitcode, Some(PathBuf::from("./some/thing.bc"))),
184 (OutputType::Exe, Some(PathBuf::from("./some/thing"))),
187 assert_same_hash(&v1, &v2);
191 fn test_externs_tracking_hash_different_construction_order() {
192 let mut v1 = Options::default();
193 let mut v2 = Options::default();
194 let mut v3 = Options::default();
196 v1.externs = Externs::new(mk_map(vec![
197 (String::from("a"), new_public_extern_entry(vec!["b", "c"])),
198 (String::from("d"), new_public_extern_entry(vec!["e", "f"])),
201 v2.externs = Externs::new(mk_map(vec![
202 (String::from("d"), new_public_extern_entry(vec!["e", "f"])),
203 (String::from("a"), new_public_extern_entry(vec!["b", "c"])),
206 v3.externs = Externs::new(mk_map(vec![
207 (String::from("a"), new_public_extern_entry(vec!["b", "c"])),
208 (String::from("d"), new_public_extern_entry(vec!["f", "e"])),
211 assert_same_hash(&v1, &v2);
212 assert_same_hash(&v1, &v3);
213 assert_same_hash(&v2, &v3);
217 fn test_lints_tracking_hash_different_values() {
218 let mut v1 = Options::default();
219 let mut v2 = Options::default();
220 let mut v3 = Options::default();
223 (String::from("a"), Level::Allow),
224 (String::from("b"), Level::Warn),
225 (String::from("c"), Level::Deny),
226 (String::from("d"), Level::Forbid),
230 (String::from("a"), Level::Allow),
231 (String::from("b"), Level::Warn),
232 (String::from("X"), Level::Deny),
233 (String::from("d"), Level::Forbid),
237 (String::from("a"), Level::Allow),
238 (String::from("b"), Level::Warn),
239 (String::from("c"), Level::Forbid),
240 (String::from("d"), Level::Deny),
243 assert_non_crate_hash_different(&v1, &v2);
244 assert_non_crate_hash_different(&v1, &v3);
245 assert_non_crate_hash_different(&v2, &v3);
249 fn test_lints_tracking_hash_different_construction_order() {
250 let mut v1 = Options::default();
251 let mut v2 = Options::default();
254 (String::from("a"), Level::Allow),
255 (String::from("b"), Level::Warn),
256 (String::from("c"), Level::Deny),
257 (String::from("d"), Level::Forbid),
261 (String::from("a"), Level::Allow),
262 (String::from("c"), Level::Deny),
263 (String::from("b"), Level::Warn),
264 (String::from("d"), Level::Forbid),
267 // The hash should be order-dependent
268 assert_non_crate_hash_different(&v1, &v2);
272 fn test_lint_cap_hash_different() {
273 let mut v1 = Options::default();
274 let mut v2 = Options::default();
275 let v3 = Options::default();
277 v1.lint_cap = Some(Level::Forbid);
278 v2.lint_cap = Some(Level::Allow);
280 assert_non_crate_hash_different(&v1, &v2);
281 assert_non_crate_hash_different(&v1, &v3);
282 assert_non_crate_hash_different(&v2, &v3);
286 fn test_search_paths_tracking_hash_different_order() {
287 let mut v1 = Options::default();
288 let mut v2 = Options::default();
289 let mut v3 = Options::default();
290 let mut v4 = Options::default();
292 const JSON: ErrorOutputType = ErrorOutputType::Json {
294 json_rendered: HumanReadableErrorType::Default(ColorConfig::Never),
298 v1.search_paths.push(SearchPath::from_cli_opt("native=abc", JSON));
299 v1.search_paths.push(SearchPath::from_cli_opt("crate=def", JSON));
300 v1.search_paths.push(SearchPath::from_cli_opt("dependency=ghi", JSON));
301 v1.search_paths.push(SearchPath::from_cli_opt("framework=jkl", JSON));
302 v1.search_paths.push(SearchPath::from_cli_opt("all=mno", JSON));
304 v2.search_paths.push(SearchPath::from_cli_opt("native=abc", JSON));
305 v2.search_paths.push(SearchPath::from_cli_opt("dependency=ghi", JSON));
306 v2.search_paths.push(SearchPath::from_cli_opt("crate=def", JSON));
307 v2.search_paths.push(SearchPath::from_cli_opt("framework=jkl", JSON));
308 v2.search_paths.push(SearchPath::from_cli_opt("all=mno", JSON));
310 v3.search_paths.push(SearchPath::from_cli_opt("crate=def", JSON));
311 v3.search_paths.push(SearchPath::from_cli_opt("framework=jkl", JSON));
312 v3.search_paths.push(SearchPath::from_cli_opt("native=abc", JSON));
313 v3.search_paths.push(SearchPath::from_cli_opt("dependency=ghi", JSON));
314 v3.search_paths.push(SearchPath::from_cli_opt("all=mno", JSON));
316 v4.search_paths.push(SearchPath::from_cli_opt("all=mno", JSON));
317 v4.search_paths.push(SearchPath::from_cli_opt("native=abc", JSON));
318 v4.search_paths.push(SearchPath::from_cli_opt("crate=def", JSON));
319 v4.search_paths.push(SearchPath::from_cli_opt("dependency=ghi", JSON));
320 v4.search_paths.push(SearchPath::from_cli_opt("framework=jkl", JSON));
322 assert_same_hash(&v1, &v2);
323 assert_same_hash(&v1, &v3);
324 assert_same_hash(&v1, &v4);
328 fn test_native_libs_tracking_hash_different_values() {
329 let mut v1 = Options::default();
330 let mut v2 = Options::default();
331 let mut v3 = Options::default();
332 let mut v4 = Options::default();
333 let mut v5 = Options::default();
338 name: String::from("a"),
340 kind: NativeLibKind::Static { bundle: None, whole_archive: None },
344 name: String::from("b"),
346 kind: NativeLibKind::Framework { as_needed: None },
350 name: String::from("c"),
352 kind: NativeLibKind::Unspecified,
360 name: String::from("a"),
362 kind: NativeLibKind::Static { bundle: None, whole_archive: None },
366 name: String::from("X"),
368 kind: NativeLibKind::Framework { as_needed: None },
372 name: String::from("c"),
374 kind: NativeLibKind::Unspecified,
382 name: String::from("a"),
384 kind: NativeLibKind::Static { bundle: None, whole_archive: None },
388 name: String::from("b"),
390 kind: NativeLibKind::Static { bundle: None, whole_archive: None },
394 name: String::from("c"),
396 kind: NativeLibKind::Unspecified,
404 name: String::from("a"),
406 kind: NativeLibKind::Static { bundle: None, whole_archive: None },
410 name: String::from("b"),
411 new_name: Some(String::from("X")),
412 kind: NativeLibKind::Framework { as_needed: None },
416 name: String::from("c"),
418 kind: NativeLibKind::Unspecified,
426 name: String::from("a"),
428 kind: NativeLibKind::Static { bundle: None, whole_archive: None },
432 name: String::from("b"),
434 kind: NativeLibKind::Framework { as_needed: None },
435 verbatim: Some(true),
438 name: String::from("c"),
440 kind: NativeLibKind::Unspecified,
445 assert_different_hash(&v1, &v2);
446 assert_different_hash(&v1, &v3);
447 assert_different_hash(&v1, &v4);
448 assert_different_hash(&v1, &v5);
452 fn test_native_libs_tracking_hash_different_order() {
453 let mut v1 = Options::default();
454 let mut v2 = Options::default();
455 let mut v3 = Options::default();
460 name: String::from("a"),
462 kind: NativeLibKind::Static { bundle: None, whole_archive: None },
466 name: String::from("b"),
468 kind: NativeLibKind::Framework { as_needed: None },
472 name: String::from("c"),
474 kind: NativeLibKind::Unspecified,
481 name: String::from("b"),
483 kind: NativeLibKind::Framework { as_needed: None },
487 name: String::from("a"),
489 kind: NativeLibKind::Static { bundle: None, whole_archive: None },
493 name: String::from("c"),
495 kind: NativeLibKind::Unspecified,
502 name: String::from("c"),
504 kind: NativeLibKind::Unspecified,
508 name: String::from("a"),
510 kind: NativeLibKind::Static { bundle: None, whole_archive: None },
514 name: String::from("b"),
516 kind: NativeLibKind::Framework { as_needed: None },
521 // The hash should be order-dependent
522 assert_different_hash(&v1, &v2);
523 assert_different_hash(&v1, &v3);
524 assert_different_hash(&v2, &v3);
528 fn test_codegen_options_tracking_hash() {
529 let reference = Options::default();
530 let mut opts = Options::default();
532 macro_rules! untracked {
533 ($name: ident, $non_default_value: expr) => {
534 assert_ne!(opts.cg.$name, $non_default_value);
535 opts.cg.$name = $non_default_value;
536 assert_same_hash(&reference, &opts);
540 // Make sure that changing an [UNTRACKED] option leaves the hash unchanged.
541 // This list is in alphabetical order.
542 untracked!(ar, String::from("abc"));
543 untracked!(codegen_units, Some(42));
544 untracked!(default_linker_libraries, true);
545 untracked!(extra_filename, String::from("extra-filename"));
546 untracked!(incremental, Some(String::from("abc")));
547 // `link_arg` is omitted because it just forwards to `link_args`.
548 untracked!(link_args, vec![String::from("abc"), String::from("def")]);
549 untracked!(link_self_contained, Some(true));
550 untracked!(linker, Some(PathBuf::from("linker")));
551 untracked!(linker_flavor, Some(LinkerFlavor::Gcc));
552 untracked!(no_stack_check, true);
553 untracked!(remark, Passes::Some(vec![String::from("pass1"), String::from("pass2")]));
554 untracked!(rpath, true);
555 untracked!(save_temps, true);
556 untracked!(strip, Strip::Debuginfo);
558 macro_rules! tracked {
559 ($name: ident, $non_default_value: expr) => {
560 opts = reference.clone();
561 assert_ne!(opts.cg.$name, $non_default_value);
562 opts.cg.$name = $non_default_value;
563 assert_different_hash(&reference, &opts);
567 // Make sure that changing a [TRACKED] option changes the hash.
568 // This list is in alphabetical order.
569 tracked!(code_model, Some(CodeModel::Large));
570 tracked!(control_flow_guard, CFGuard::Checks);
571 tracked!(debug_assertions, Some(true));
572 tracked!(debuginfo, 0xdeadbeef);
573 tracked!(embed_bitcode, false);
574 tracked!(force_frame_pointers, Some(false));
575 tracked!(force_unwind_tables, Some(true));
576 tracked!(inline_threshold, Some(0xf007ba11));
577 tracked!(linker_plugin_lto, LinkerPluginLto::LinkerPluginAuto);
578 tracked!(link_dead_code, Some(true));
579 tracked!(llvm_args, vec![String::from("1"), String::from("2")]);
580 tracked!(lto, LtoCli::Fat);
581 tracked!(metadata, vec![String::from("A"), String::from("B")]);
582 tracked!(no_prepopulate_passes, true);
583 tracked!(no_redzone, Some(true));
584 tracked!(no_vectorize_loops, true);
585 tracked!(no_vectorize_slp, true);
586 tracked!(opt_level, "3".to_string());
587 tracked!(overflow_checks, Some(true));
588 tracked!(panic, Some(PanicStrategy::Abort));
589 tracked!(passes, vec![String::from("1"), String::from("2")]);
590 tracked!(prefer_dynamic, true);
591 tracked!(profile_generate, SwitchWithOptPath::Enabled(None));
592 tracked!(profile_use, Some(PathBuf::from("abc")));
593 tracked!(relocation_model, Some(RelocModel::Pic));
594 tracked!(soft_float, true);
595 tracked!(split_debuginfo, Some(SplitDebuginfo::Packed));
596 tracked!(target_cpu, Some(String::from("abc")));
597 tracked!(target_feature, String::from("all the features, all of them"));
601 fn test_top_level_options_tracked_no_crate() {
602 let reference = Options::default();
605 macro_rules! tracked {
606 ($name: ident, $non_default_value: expr) => {
607 opts = reference.clone();
608 assert_ne!(opts.$name, $non_default_value);
609 opts.$name = $non_default_value;
610 // The crate hash should be the same
611 assert_eq!(reference.dep_tracking_hash(true), opts.dep_tracking_hash(true));
612 // The incremental hash should be different
613 assert_ne!(reference.dep_tracking_hash(false), opts.dep_tracking_hash(false));
617 // Make sure that changing a [TRACKED_NO_CRATE_HASH] option leaves the crate hash unchanged but changes the incremental hash.
618 // This list is in alphabetical order.
619 tracked!(remap_path_prefix, vec![("/home/bors/rust".into(), "src".into())]);
621 real_rust_source_base_dir,
622 Some("/home/bors/rust/.rustup/toolchains/nightly/lib/rustlib/src/rust".into())
627 fn test_debugging_options_tracking_hash() {
628 let reference = Options::default();
629 let mut opts = Options::default();
631 macro_rules! untracked {
632 ($name: ident, $non_default_value: expr) => {
633 assert_ne!(opts.debugging_opts.$name, $non_default_value);
634 opts.debugging_opts.$name = $non_default_value;
635 assert_same_hash(&reference, &opts);
639 // Make sure that changing an [UNTRACKED] option leaves the hash unchanged.
640 // This list is in alphabetical order.
641 untracked!(assert_incr_state, Some(String::from("loaded")));
642 untracked!(ast_json, true);
643 untracked!(ast_json_noexpand, true);
644 untracked!(borrowck, String::from("other"));
645 untracked!(deduplicate_diagnostics, false);
646 untracked!(dep_tasks, true);
647 untracked!(dont_buffer_diagnostics, true);
648 untracked!(dump_dep_graph, true);
649 untracked!(dump_mir, Some(String::from("abc")));
650 untracked!(dump_mir_dataflow, true);
651 untracked!(dump_mir_dir, String::from("abc"));
652 untracked!(dump_mir_exclude_pass_number, true);
653 untracked!(dump_mir_graphviz, true);
654 untracked!(emit_future_incompat_report, true);
655 untracked!(emit_stack_sizes, true);
656 untracked!(future_incompat_test, true);
657 untracked!(hir_stats, true);
658 untracked!(identify_regions, true);
659 untracked!(incremental_ignore_spans, true);
660 untracked!(incremental_info, true);
661 untracked!(incremental_verify_ich, true);
662 untracked!(input_stats, true);
663 untracked!(keep_hygiene_data, true);
664 untracked!(link_native_libraries, false);
665 untracked!(llvm_time_trace, true);
666 untracked!(ls, true);
667 untracked!(macro_backtrace, true);
668 untracked!(meta_stats, true);
669 untracked!(nll_facts, true);
670 untracked!(no_analysis, true);
671 untracked!(no_interleave_lints, true);
672 untracked!(no_leak_check, true);
673 untracked!(no_parallel_llvm, true);
674 untracked!(parse_only, true);
675 untracked!(perf_stats, true);
676 // `pre_link_arg` is omitted because it just forwards to `pre_link_args`.
677 untracked!(pre_link_args, vec![String::from("abc"), String::from("def")]);
678 untracked!(profile_closures, true);
679 untracked!(print_link_args, true);
680 untracked!(print_llvm_passes, true);
681 untracked!(print_mono_items, Some(String::from("abc")));
682 untracked!(print_type_sizes, true);
683 untracked!(proc_macro_backtrace, true);
684 untracked!(query_dep_graph, true);
685 untracked!(query_stats, 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);
721 tracked!(chalk, true);
722 tracked!(codegen_backend, Some("abc".to_string()));
723 tracked!(crate_attr, vec!["abc".to_string()]);
724 tracked!(debug_info_for_profiling, true);
725 tracked!(debug_macros, true);
726 tracked!(dep_info_omit_d_target, true);
727 tracked!(dual_proc_macros, true);
728 tracked!(fewer_names, Some(true));
729 tracked!(force_unstable_if_unmarked, true);
730 tracked!(fuel, Some(("abc".to_string(), 99)));
731 tracked!(function_sections, Some(false));
732 tracked!(human_readable_cgu_names, true);
733 tracked!(inline_in_all_cgus, Some(true));
734 tracked!(inline_mir, Some(true));
735 tracked!(inline_mir_hint_threshold, Some(123));
736 tracked!(inline_mir_threshold, Some(123));
737 tracked!(instrument_coverage, Some(InstrumentCoverage::All));
738 tracked!(instrument_mcount, true);
739 tracked!(link_only, true);
740 tracked!(llvm_plugins, vec![String::from("plugin_name")]);
741 tracked!(location_detail, LocationDetail { file: true, line: false, column: false });
742 tracked!(merge_functions, Some(MergeFunctions::Disabled));
743 tracked!(mir_emit_retag, true);
744 tracked!(mir_opt_level, Some(4));
745 tracked!(move_size_limit, Some(4096));
746 tracked!(mutable_noalias, Some(true));
747 tracked!(new_llvm_pass_manager, Some(true));
748 tracked!(no_generate_arange_section, true);
749 tracked!(no_link, true);
750 tracked!(no_unique_section_names, true);
751 tracked!(no_profiler_runtime, true);
752 tracked!(osx_rpath_install_name, true);
753 tracked!(panic_abort_tests, true);
754 tracked!(panic_in_drop, PanicStrategy::Abort);
755 tracked!(partially_uninit_const_threshold, Some(123));
756 tracked!(pick_stable_methods_before_any_unstable, false);
757 tracked!(plt, Some(true));
758 tracked!(polonius, true);
759 tracked!(precise_enum_drop_elaboration, false);
760 tracked!(print_fuel, Some("abc".to_string()));
761 tracked!(profile, true);
762 tracked!(profile_emit, Some(PathBuf::from("abc")));
763 tracked!(profiler_runtime, "abc".to_string());
764 tracked!(profile_sample_use, Some(PathBuf::from("abc")));
765 tracked!(relax_elf_relocations, Some(true));
766 tracked!(relro_level, Some(RelroLevel::Full));
767 tracked!(remap_cwd_prefix, Some(PathBuf::from("abc")));
768 tracked!(report_delayed_bugs, true);
769 tracked!(sanitizer, SanitizerSet::ADDRESS);
770 tracked!(sanitizer_memory_track_origins, 2);
771 tracked!(sanitizer_recover, SanitizerSet::ADDRESS);
772 tracked!(saturating_float_casts, Some(true));
773 tracked!(share_generics, Some(true));
774 tracked!(show_span, Some(String::from("abc")));
775 tracked!(simulate_remapped_rust_src_base, Some(PathBuf::from("/rustc/abc")));
776 tracked!(src_hash_algorithm, Some(SourceFileHashAlgorithm::Sha1));
777 tracked!(stack_protector, StackProtector::All);
778 tracked!(symbol_mangling_version, Some(SymbolManglingVersion::V0));
779 tracked!(teach, true);
780 tracked!(thinlto, Some(true));
781 tracked!(thir_unsafeck, true);
782 tracked!(tls_model, Some(TlsModel::GeneralDynamic));
783 tracked!(trap_unreachable, Some(false));
784 tracked!(treat_err_as_bug, NonZeroUsize::new(1));
785 tracked!(tune_cpu, Some(String::from("abc")));
786 tracked!(unleash_the_miri_inside_of_you, true);
787 tracked!(use_ctors_section, Some(true));
788 tracked!(verify_llvm_ir, true);
789 tracked!(wasi_exec_model, Some(WasiExecModel::Reactor));
791 macro_rules! tracked_no_crate_hash {
792 ($name: ident, $non_default_value: expr) => {
793 opts = reference.clone();
794 assert_ne!(opts.debugging_opts.$name, $non_default_value);
795 opts.debugging_opts.$name = $non_default_value;
796 assert_non_crate_hash_different(&reference, &opts);
799 tracked_no_crate_hash!(no_codegen, true);
803 fn test_edition_parsing() {
804 // test default edition
805 let options = Options::default();
806 assert!(options.edition == DEFAULT_EDITION);
808 let matches = optgroups().parse(&["--edition=2018".to_string()]).unwrap();
809 let (sessopts, _) = build_session_options_and_crate_config(matches);
810 assert!(sessopts.edition == Edition::Edition2018)