1 #![allow(rustc::bad_opt_access)]
2 use crate::interface::parse_cfgspecs;
4 use rustc_data_structures::fx::FxHashSet;
5 use rustc_errors::{emitter::HumanReadableErrorType, registry, ColorConfig};
6 use rustc_session::config::rustc_optgroups;
7 use rustc_session::config::Input;
8 use rustc_session::config::TraitSolver;
9 use rustc_session::config::{build_configuration, build_session_options, to_crate_config};
10 use rustc_session::config::{
11 BranchProtection, Externs, OomStrategy, OutputType, OutputTypes, PAuthKey, PacRet,
12 ProcMacroExecutionStrategy, SymbolManglingVersion, WasiExecModel,
14 use rustc_session::config::{CFGuard, ExternEntry, LinkerPluginLto, LtoCli, SwitchWithOptPath};
15 use rustc_session::config::{DumpMonoStatsFormat, MirSpanview};
16 use rustc_session::config::{ErrorOutputType, ExternLocation, LocationDetail, Options, Strip};
17 use rustc_session::config::{InstrumentCoverage, Passes};
18 use rustc_session::lint::Level;
19 use rustc_session::search_paths::SearchPath;
20 use rustc_session::utils::{CanonicalizedPath, NativeLib, NativeLibKind};
21 use rustc_session::CompilerIO;
22 use rustc_session::{build_session, getopts, Session};
23 use rustc_span::edition::{Edition, DEFAULT_EDITION};
24 use rustc_span::symbol::sym;
25 use rustc_span::FileName;
26 use rustc_span::SourceFileHashAlgorithm;
27 use rustc_target::spec::{CodeModel, LinkerFlavorCli, MergeFunctions, PanicStrategy, RelocModel};
28 use rustc_target::spec::{RelroLevel, SanitizerSet, SplitDebuginfo, StackProtector, TlsModel};
30 use std::collections::{BTreeMap, BTreeSet};
31 use std::num::NonZeroUsize;
32 use std::path::{Path, PathBuf};
34 type CfgSpecs = FxHashSet<(String, Option<String>)>;
36 fn build_session_options_and_crate_config(matches: getopts::Matches) -> (Options, CfgSpecs) {
37 let sessopts = build_session_options(&matches);
38 let cfg = parse_cfgspecs(matches.opt_strs("cfg"));
42 fn mk_session(matches: getopts::Matches) -> (Session, CfgSpecs) {
43 let registry = registry::Registry::new(&[]);
44 let (sessopts, cfg) = build_session_options_and_crate_config(matches);
45 let temps_dir = sessopts.unstable_opts.temps_dir.as_deref().map(PathBuf::from);
47 input: Input::Str { name: FileName::Custom(String::new()), input: String::new() },
52 let sess = build_session(sessopts, io, None, registry, Default::default(), None, None);
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,
72 fn optgroups() -> getopts::Options {
73 let mut opts = getopts::Options::new();
74 for group in rustc_optgroups() {
75 (group.apply)(&mut opts);
80 fn mk_map<K: Ord, V>(entries: Vec<(K, V)>) -> BTreeMap<K, V> {
81 BTreeMap::from_iter(entries.into_iter())
84 fn assert_same_clone(x: &Options) {
85 assert_eq!(x.dep_tracking_hash(true), x.clone().dep_tracking_hash(true));
86 assert_eq!(x.dep_tracking_hash(false), x.clone().dep_tracking_hash(false));
89 fn assert_same_hash(x: &Options, y: &Options) {
90 assert_eq!(x.dep_tracking_hash(true), y.dep_tracking_hash(true));
91 assert_eq!(x.dep_tracking_hash(false), y.dep_tracking_hash(false));
97 fn assert_different_hash(x: &Options, y: &Options) {
98 assert_ne!(x.dep_tracking_hash(true), y.dep_tracking_hash(true));
99 assert_ne!(x.dep_tracking_hash(false), y.dep_tracking_hash(false));
101 assert_same_clone(x);
102 assert_same_clone(y);
105 fn assert_non_crate_hash_different(x: &Options, y: &Options) {
106 assert_eq!(x.dep_tracking_hash(true), y.dep_tracking_hash(true));
107 assert_ne!(x.dep_tracking_hash(false), y.dep_tracking_hash(false));
109 assert_same_clone(x);
110 assert_same_clone(y);
113 // When the user supplies --test we should implicitly supply --cfg test
115 fn test_switch_implies_cfg_test() {
116 rustc_span::create_default_session_globals_then(|| {
117 let matches = optgroups().parse(&["--test".to_string()]).unwrap();
118 let (sess, cfg) = mk_session(matches);
119 let cfg = build_configuration(&sess, to_crate_config(cfg));
120 assert!(cfg.contains(&(sym::test, None)));
124 // When the user supplies --test and --cfg test, don't implicitly add another --cfg test
126 fn test_switch_implies_cfg_test_unless_cfg_test() {
127 rustc_span::create_default_session_globals_then(|| {
128 let matches = optgroups().parse(&["--test".to_string(), "--cfg=test".to_string()]).unwrap();
129 let (sess, cfg) = mk_session(matches);
130 let cfg = build_configuration(&sess, to_crate_config(cfg));
131 let mut test_items = cfg.iter().filter(|&&(name, _)| name == sym::test);
132 assert!(test_items.next().is_some());
133 assert!(test_items.next().is_none());
138 fn test_can_print_warnings() {
139 rustc_span::create_default_session_globals_then(|| {
140 let matches = optgroups().parse(&["-Awarnings".to_string()]).unwrap();
141 let (sess, _) = mk_session(matches);
142 assert!(!sess.diagnostic().can_emit_warnings());
145 rustc_span::create_default_session_globals_then(|| {
147 optgroups().parse(&["-Awarnings".to_string(), "-Dwarnings".to_string()]).unwrap();
148 let (sess, _) = mk_session(matches);
149 assert!(sess.diagnostic().can_emit_warnings());
152 rustc_span::create_default_session_globals_then(|| {
153 let matches = optgroups().parse(&["-Adead_code".to_string()]).unwrap();
154 let (sess, _) = mk_session(matches);
155 assert!(sess.diagnostic().can_emit_warnings());
160 fn test_output_types_tracking_hash_different_paths() {
161 let mut v1 = Options::default();
162 let mut v2 = Options::default();
163 let mut v3 = Options::default();
165 v1.output_types = OutputTypes::new(&[(OutputType::Exe, Some(PathBuf::from("./some/thing")))]);
166 v2.output_types = OutputTypes::new(&[(OutputType::Exe, Some(PathBuf::from("/some/thing")))]);
167 v3.output_types = OutputTypes::new(&[(OutputType::Exe, None)]);
169 assert_non_crate_hash_different(&v1, &v2);
170 assert_non_crate_hash_different(&v1, &v3);
171 assert_non_crate_hash_different(&v2, &v3);
175 fn test_output_types_tracking_hash_different_construction_order() {
176 let mut v1 = Options::default();
177 let mut v2 = Options::default();
179 v1.output_types = OutputTypes::new(&[
180 (OutputType::Exe, Some(PathBuf::from("./some/thing"))),
181 (OutputType::Bitcode, Some(PathBuf::from("./some/thing.bc"))),
184 v2.output_types = OutputTypes::new(&[
185 (OutputType::Bitcode, Some(PathBuf::from("./some/thing.bc"))),
186 (OutputType::Exe, Some(PathBuf::from("./some/thing"))),
189 assert_same_hash(&v1, &v2);
193 fn test_externs_tracking_hash_different_construction_order() {
194 let mut v1 = Options::default();
195 let mut v2 = Options::default();
196 let mut v3 = Options::default();
198 v1.externs = Externs::new(mk_map(vec![
199 (String::from("a"), new_public_extern_entry(vec!["b", "c"])),
200 (String::from("d"), new_public_extern_entry(vec!["e", "f"])),
203 v2.externs = Externs::new(mk_map(vec![
204 (String::from("d"), new_public_extern_entry(vec!["e", "f"])),
205 (String::from("a"), new_public_extern_entry(vec!["b", "c"])),
208 v3.externs = Externs::new(mk_map(vec![
209 (String::from("a"), new_public_extern_entry(vec!["b", "c"])),
210 (String::from("d"), new_public_extern_entry(vec!["f", "e"])),
213 assert_same_hash(&v1, &v2);
214 assert_same_hash(&v1, &v3);
215 assert_same_hash(&v2, &v3);
219 fn test_lints_tracking_hash_different_values() {
220 let mut v1 = Options::default();
221 let mut v2 = Options::default();
222 let mut v3 = Options::default();
225 (String::from("a"), Level::Allow),
226 (String::from("b"), Level::Warn),
227 (String::from("c"), Level::Deny),
228 (String::from("d"), Level::Forbid),
232 (String::from("a"), Level::Allow),
233 (String::from("b"), Level::Warn),
234 (String::from("X"), Level::Deny),
235 (String::from("d"), Level::Forbid),
239 (String::from("a"), Level::Allow),
240 (String::from("b"), Level::Warn),
241 (String::from("c"), Level::Forbid),
242 (String::from("d"), Level::Deny),
245 assert_non_crate_hash_different(&v1, &v2);
246 assert_non_crate_hash_different(&v1, &v3);
247 assert_non_crate_hash_different(&v2, &v3);
251 fn test_lints_tracking_hash_different_construction_order() {
252 let mut v1 = Options::default();
253 let mut v2 = Options::default();
256 (String::from("a"), Level::Allow),
257 (String::from("b"), Level::Warn),
258 (String::from("c"), Level::Deny),
259 (String::from("d"), Level::Forbid),
263 (String::from("a"), Level::Allow),
264 (String::from("c"), Level::Deny),
265 (String::from("b"), Level::Warn),
266 (String::from("d"), Level::Forbid),
269 // The hash should be order-dependent
270 assert_non_crate_hash_different(&v1, &v2);
274 fn test_lint_cap_hash_different() {
275 let mut v1 = Options::default();
276 let mut v2 = Options::default();
277 let v3 = Options::default();
279 v1.lint_cap = Some(Level::Forbid);
280 v2.lint_cap = Some(Level::Allow);
282 assert_non_crate_hash_different(&v1, &v2);
283 assert_non_crate_hash_different(&v1, &v3);
284 assert_non_crate_hash_different(&v2, &v3);
288 fn test_search_paths_tracking_hash_different_order() {
289 let mut v1 = Options::default();
290 let mut v2 = Options::default();
291 let mut v3 = Options::default();
292 let mut v4 = Options::default();
294 const JSON: ErrorOutputType = ErrorOutputType::Json {
296 json_rendered: HumanReadableErrorType::Default(ColorConfig::Never),
300 v1.search_paths.push(SearchPath::from_cli_opt("native=abc", JSON));
301 v1.search_paths.push(SearchPath::from_cli_opt("crate=def", JSON));
302 v1.search_paths.push(SearchPath::from_cli_opt("dependency=ghi", JSON));
303 v1.search_paths.push(SearchPath::from_cli_opt("framework=jkl", JSON));
304 v1.search_paths.push(SearchPath::from_cli_opt("all=mno", JSON));
306 v2.search_paths.push(SearchPath::from_cli_opt("native=abc", JSON));
307 v2.search_paths.push(SearchPath::from_cli_opt("dependency=ghi", JSON));
308 v2.search_paths.push(SearchPath::from_cli_opt("crate=def", JSON));
309 v2.search_paths.push(SearchPath::from_cli_opt("framework=jkl", JSON));
310 v2.search_paths.push(SearchPath::from_cli_opt("all=mno", JSON));
312 v3.search_paths.push(SearchPath::from_cli_opt("crate=def", JSON));
313 v3.search_paths.push(SearchPath::from_cli_opt("framework=jkl", JSON));
314 v3.search_paths.push(SearchPath::from_cli_opt("native=abc", JSON));
315 v3.search_paths.push(SearchPath::from_cli_opt("dependency=ghi", JSON));
316 v3.search_paths.push(SearchPath::from_cli_opt("all=mno", JSON));
318 v4.search_paths.push(SearchPath::from_cli_opt("all=mno", JSON));
319 v4.search_paths.push(SearchPath::from_cli_opt("native=abc", JSON));
320 v4.search_paths.push(SearchPath::from_cli_opt("crate=def", JSON));
321 v4.search_paths.push(SearchPath::from_cli_opt("dependency=ghi", JSON));
322 v4.search_paths.push(SearchPath::from_cli_opt("framework=jkl", JSON));
324 assert_same_hash(&v1, &v2);
325 assert_same_hash(&v1, &v3);
326 assert_same_hash(&v1, &v4);
330 fn test_native_libs_tracking_hash_different_values() {
331 let mut v1 = Options::default();
332 let mut v2 = Options::default();
333 let mut v3 = Options::default();
334 let mut v4 = Options::default();
335 let mut v5 = Options::default();
340 name: String::from("a"),
342 kind: NativeLibKind::Static { bundle: None, whole_archive: None },
346 name: String::from("b"),
348 kind: NativeLibKind::Framework { as_needed: None },
352 name: String::from("c"),
354 kind: NativeLibKind::Unspecified,
362 name: String::from("a"),
364 kind: NativeLibKind::Static { bundle: None, whole_archive: None },
368 name: String::from("X"),
370 kind: NativeLibKind::Framework { as_needed: None },
374 name: String::from("c"),
376 kind: NativeLibKind::Unspecified,
384 name: String::from("a"),
386 kind: NativeLibKind::Static { bundle: None, whole_archive: None },
390 name: String::from("b"),
392 kind: NativeLibKind::Static { bundle: None, whole_archive: None },
396 name: String::from("c"),
398 kind: NativeLibKind::Unspecified,
406 name: String::from("a"),
408 kind: NativeLibKind::Static { bundle: None, whole_archive: None },
412 name: String::from("b"),
413 new_name: Some(String::from("X")),
414 kind: NativeLibKind::Framework { as_needed: None },
418 name: String::from("c"),
420 kind: NativeLibKind::Unspecified,
428 name: String::from("a"),
430 kind: NativeLibKind::Static { bundle: None, whole_archive: None },
434 name: String::from("b"),
436 kind: NativeLibKind::Framework { as_needed: None },
437 verbatim: Some(true),
440 name: String::from("c"),
442 kind: NativeLibKind::Unspecified,
447 assert_different_hash(&v1, &v2);
448 assert_different_hash(&v1, &v3);
449 assert_different_hash(&v1, &v4);
450 assert_different_hash(&v1, &v5);
454 fn test_native_libs_tracking_hash_different_order() {
455 let mut v1 = Options::default();
456 let mut v2 = Options::default();
457 let mut v3 = Options::default();
462 name: String::from("a"),
464 kind: NativeLibKind::Static { bundle: None, whole_archive: None },
468 name: String::from("b"),
470 kind: NativeLibKind::Framework { as_needed: None },
474 name: String::from("c"),
476 kind: NativeLibKind::Unspecified,
483 name: String::from("b"),
485 kind: NativeLibKind::Framework { as_needed: None },
489 name: String::from("a"),
491 kind: NativeLibKind::Static { bundle: None, whole_archive: None },
495 name: String::from("c"),
497 kind: NativeLibKind::Unspecified,
504 name: String::from("c"),
506 kind: NativeLibKind::Unspecified,
510 name: String::from("a"),
512 kind: NativeLibKind::Static { bundle: None, whole_archive: None },
516 name: String::from("b"),
518 kind: NativeLibKind::Framework { as_needed: None },
523 // The hash should be order-dependent
524 assert_different_hash(&v1, &v2);
525 assert_different_hash(&v1, &v3);
526 assert_different_hash(&v2, &v3);
530 fn test_codegen_options_tracking_hash() {
531 let reference = Options::default();
532 let mut opts = Options::default();
534 macro_rules! untracked {
535 ($name: ident, $non_default_value: expr) => {
536 assert_ne!(opts.cg.$name, $non_default_value);
537 opts.cg.$name = $non_default_value;
538 assert_same_hash(&reference, &opts);
542 // Make sure that changing an [UNTRACKED] option leaves the hash unchanged.
543 // tidy-alphabetical-start
544 untracked!(ar, String::from("abc"));
545 untracked!(codegen_units, Some(42));
546 untracked!(default_linker_libraries, true);
547 untracked!(extra_filename, String::from("extra-filename"));
548 untracked!(incremental, Some(String::from("abc")));
549 // `link_arg` is omitted because it just forwards to `link_args`.
550 untracked!(link_args, vec![String::from("abc"), String::from("def")]);
551 untracked!(link_self_contained, Some(true));
552 untracked!(linker, Some(PathBuf::from("linker")));
553 untracked!(linker_flavor, Some(LinkerFlavorCli::Gcc));
554 untracked!(no_stack_check, true);
555 untracked!(remark, Passes::Some(vec![String::from("pass1"), String::from("pass2")]));
556 untracked!(rpath, true);
557 untracked!(save_temps, true);
558 untracked!(strip, Strip::Debuginfo);
559 // tidy-alphabetical-end
561 macro_rules! tracked {
562 ($name: ident, $non_default_value: expr) => {
563 opts = reference.clone();
564 assert_ne!(opts.cg.$name, $non_default_value);
565 opts.cg.$name = $non_default_value;
566 assert_different_hash(&reference, &opts);
570 // Make sure that changing a [TRACKED] option changes the hash.
571 // tidy-alphabetical-start
572 tracked!(code_model, Some(CodeModel::Large));
573 tracked!(control_flow_guard, CFGuard::Checks);
574 tracked!(debug_assertions, Some(true));
575 tracked!(debuginfo, 0xdeadbeef);
576 tracked!(embed_bitcode, false);
577 tracked!(force_frame_pointers, Some(false));
578 tracked!(force_unwind_tables, Some(true));
579 tracked!(inline_threshold, Some(0xf007ba11));
580 tracked!(instrument_coverage, Some(InstrumentCoverage::All));
581 tracked!(link_dead_code, Some(true));
582 tracked!(linker_plugin_lto, LinkerPluginLto::LinkerPluginAuto);
583 tracked!(llvm_args, vec![String::from("1"), String::from("2")]);
584 tracked!(lto, LtoCli::Fat);
585 tracked!(metadata, vec![String::from("A"), String::from("B")]);
586 tracked!(no_prepopulate_passes, true);
587 tracked!(no_redzone, Some(true));
588 tracked!(no_vectorize_loops, true);
589 tracked!(no_vectorize_slp, true);
590 tracked!(opt_level, "3".to_string());
591 tracked!(overflow_checks, Some(true));
592 tracked!(panic, Some(PanicStrategy::Abort));
593 tracked!(passes, vec![String::from("1"), String::from("2")]);
594 tracked!(prefer_dynamic, true);
595 tracked!(profile_generate, SwitchWithOptPath::Enabled(None));
596 tracked!(profile_use, Some(PathBuf::from("abc")));
597 tracked!(relocation_model, Some(RelocModel::Pic));
598 tracked!(soft_float, true);
599 tracked!(split_debuginfo, Some(SplitDebuginfo::Packed));
600 tracked!(symbol_mangling_version, Some(SymbolManglingVersion::V0));
601 tracked!(target_cpu, Some(String::from("abc")));
602 tracked!(target_feature, String::from("all the features, all of them"));
603 // tidy-alphabetical-end
607 fn test_top_level_options_tracked_no_crate() {
608 let reference = Options::default();
611 macro_rules! tracked {
612 ($name: ident, $non_default_value: expr) => {
613 opts = reference.clone();
614 assert_ne!(opts.$name, $non_default_value);
615 opts.$name = $non_default_value;
616 // The crate hash should be the same
617 assert_eq!(reference.dep_tracking_hash(true), opts.dep_tracking_hash(true));
618 // The incremental hash should be different
619 assert_ne!(reference.dep_tracking_hash(false), opts.dep_tracking_hash(false));
623 // Make sure that changing a [TRACKED_NO_CRATE_HASH] option leaves the crate hash unchanged but changes the incremental hash.
624 // tidy-alphabetical-start
626 real_rust_source_base_dir,
627 Some("/home/bors/rust/.rustup/toolchains/nightly/lib/rustlib/src/rust".into())
629 tracked!(remap_path_prefix, vec![("/home/bors/rust".into(), "src".into())]);
630 // tidy-alphabetical-end
634 fn test_unstable_options_tracking_hash() {
635 let reference = Options::default();
636 let mut opts = Options::default();
638 macro_rules! untracked {
639 ($name: ident, $non_default_value: expr) => {
640 assert_ne!(opts.unstable_opts.$name, $non_default_value);
641 opts.unstable_opts.$name = $non_default_value;
642 assert_same_hash(&reference, &opts);
646 // Make sure that changing an [UNTRACKED] option leaves the hash unchanged.
647 // tidy-alphabetical-start
648 untracked!(assert_incr_state, Some(String::from("loaded")));
649 untracked!(deduplicate_diagnostics, false);
650 untracked!(dep_tasks, true);
651 untracked!(dlltool, Some(PathBuf::from("custom_dlltool.exe")));
652 untracked!(dont_buffer_diagnostics, true);
653 untracked!(dump_dep_graph, true);
654 untracked!(dump_drop_tracking_cfg, Some("cfg.dot".to_string()));
655 untracked!(dump_mir, Some(String::from("abc")));
656 untracked!(dump_mir_dataflow, true);
657 untracked!(dump_mir_dir, String::from("abc"));
658 untracked!(dump_mir_exclude_pass_number, true);
659 untracked!(dump_mir_graphviz, true);
660 untracked!(dump_mir_spanview, Some(MirSpanview::Statement));
661 untracked!(dump_mono_stats, SwitchWithOptPath::Enabled(Some("mono-items-dir/".into())));
662 untracked!(dump_mono_stats_format, DumpMonoStatsFormat::Json);
663 untracked!(dylib_lto, true);
664 untracked!(emit_stack_sizes, true);
665 untracked!(future_incompat_test, true);
666 untracked!(hir_stats, true);
667 untracked!(identify_regions, true);
668 untracked!(incremental_info, true);
669 untracked!(incremental_verify_ich, true);
670 untracked!(input_stats, true);
671 untracked!(keep_hygiene_data, true);
672 untracked!(link_native_libraries, false);
673 untracked!(llvm_time_trace, true);
674 untracked!(ls, true);
675 untracked!(macro_backtrace, true);
676 untracked!(meta_stats, true);
677 untracked!(mir_pretty_relative_line_numbers, true);
678 untracked!(nll_facts, true);
679 untracked!(no_analysis, true);
680 untracked!(no_leak_check, true);
681 untracked!(no_parallel_llvm, true);
682 untracked!(parse_only, true);
683 untracked!(perf_stats, true);
684 // `pre_link_arg` is omitted because it just forwards to `pre_link_args`.
685 untracked!(pre_link_args, vec![String::from("abc"), String::from("def")]);
686 untracked!(print_llvm_passes, true);
687 untracked!(print_mono_items, Some(String::from("abc")));
688 untracked!(print_type_sizes, true);
689 untracked!(proc_macro_backtrace, true);
690 untracked!(proc_macro_execution_strategy, ProcMacroExecutionStrategy::CrossThread);
691 untracked!(profile_closures, true);
692 untracked!(query_dep_graph, true);
693 untracked!(save_analysis, true);
694 untracked!(self_profile, SwitchWithOptPath::Enabled(None));
695 untracked!(self_profile_events, Some(vec![String::new()]));
696 untracked!(span_debug, true);
697 untracked!(span_free_formats, true);
698 untracked!(temps_dir, Some(String::from("abc")));
699 untracked!(threads, 99);
700 untracked!(time_llvm_passes, true);
701 untracked!(time_passes, true);
702 untracked!(trace_macros, true);
703 untracked!(track_diagnostics, true);
704 untracked!(trim_diagnostic_paths, false);
705 untracked!(ui_testing, true);
706 untracked!(unpretty, Some("expanded".to_string()));
707 untracked!(unstable_options, true);
708 untracked!(validate_mir, true);
709 untracked!(verbose, true);
710 // tidy-alphabetical-end
712 macro_rules! tracked {
713 ($name: ident, $non_default_value: expr) => {
714 opts = reference.clone();
715 assert_ne!(opts.unstable_opts.$name, $non_default_value);
716 opts.unstable_opts.$name = $non_default_value;
717 assert_different_hash(&reference, &opts);
721 // Make sure that changing a [TRACKED] option changes the hash.
722 // tidy-alphabetical-start
723 tracked!(allow_features, Some(vec![String::from("lang_items")]));
724 tracked!(always_encode_mir, true);
725 tracked!(asm_comments, true);
726 tracked!(assume_incomplete_release, true);
727 tracked!(binary_dep_depinfo, true);
728 tracked!(box_noalias, false);
731 Some(BranchProtection {
733 pac_ret: Some(PacRet { leaf: true, key: PAuthKey::B })
736 tracked!(codegen_backend, Some("abc".to_string()));
737 tracked!(crate_attr, vec!["abc".to_string()]);
738 tracked!(debug_info_for_profiling, true);
739 tracked!(debug_macros, true);
740 tracked!(dep_info_omit_d_target, true);
741 tracked!(drop_tracking, true);
742 tracked!(dual_proc_macros, true);
743 tracked!(dwarf_version, Some(5));
744 tracked!(emit_thin_lto, false);
745 tracked!(export_executable_symbols, true);
746 tracked!(fewer_names, Some(true));
747 tracked!(force_unstable_if_unmarked, true);
748 tracked!(fuel, Some(("abc".to_string(), 99)));
749 tracked!(function_sections, Some(false));
750 tracked!(human_readable_cgu_names, true);
751 tracked!(incremental_ignore_spans, true);
752 tracked!(inline_in_all_cgus, Some(true));
753 tracked!(inline_mir, Some(true));
754 tracked!(inline_mir_hint_threshold, Some(123));
755 tracked!(inline_mir_threshold, Some(123));
756 tracked!(instrument_coverage, Some(InstrumentCoverage::All));
757 tracked!(instrument_mcount, true);
758 tracked!(link_only, true);
759 tracked!(llvm_plugins, vec![String::from("plugin_name")]);
760 tracked!(location_detail, LocationDetail { file: true, line: false, column: false });
761 tracked!(log_backtrace, Some("filter".to_string()));
762 tracked!(maximal_hir_to_mir_coverage, true);
763 tracked!(merge_functions, Some(MergeFunctions::Disabled));
764 tracked!(mir_emit_retag, true);
765 tracked!(mir_enable_passes, vec![("DestProp".to_string(), false)]);
766 tracked!(mir_opt_level, Some(4));
767 tracked!(move_size_limit, Some(4096));
768 tracked!(mutable_noalias, false);
769 tracked!(no_generate_arange_section, true);
770 tracked!(no_jump_tables, true);
771 tracked!(no_link, true);
772 tracked!(no_profiler_runtime, true);
773 tracked!(no_unique_section_names, true);
774 tracked!(oom, OomStrategy::Panic);
775 tracked!(osx_rpath_install_name, true);
776 tracked!(packed_bundled_libs, true);
777 tracked!(panic_abort_tests, true);
778 tracked!(panic_in_drop, PanicStrategy::Abort);
779 tracked!(pick_stable_methods_before_any_unstable, false);
780 tracked!(plt, Some(true));
781 tracked!(polonius, true);
782 tracked!(precise_enum_drop_elaboration, false);
783 tracked!(print_fuel, Some("abc".to_string()));
784 tracked!(profile, true);
785 tracked!(profile_emit, Some(PathBuf::from("abc")));
786 tracked!(profile_sample_use, Some(PathBuf::from("abc")));
787 tracked!(profiler_runtime, "abc".to_string());
788 tracked!(relax_elf_relocations, Some(true));
789 tracked!(relro_level, Some(RelroLevel::Full));
790 tracked!(remap_cwd_prefix, Some(PathBuf::from("abc")));
791 tracked!(report_delayed_bugs, true);
792 tracked!(sanitizer, SanitizerSet::ADDRESS);
793 tracked!(sanitizer_memory_track_origins, 2);
794 tracked!(sanitizer_recover, SanitizerSet::ADDRESS);
795 tracked!(saturating_float_casts, Some(true));
796 tracked!(share_generics, Some(true));
797 tracked!(show_span, Some(String::from("abc")));
798 tracked!(simulate_remapped_rust_src_base, Some(PathBuf::from("/rustc/abc")));
799 tracked!(src_hash_algorithm, Some(SourceFileHashAlgorithm::Sha1));
800 tracked!(stack_protector, StackProtector::All);
801 tracked!(symbol_mangling_version, Some(SymbolManglingVersion::V0));
802 tracked!(teach, true);
803 tracked!(thinlto, Some(true));
804 tracked!(thir_unsafeck, true);
805 tracked!(tls_model, Some(TlsModel::GeneralDynamic));
806 tracked!(trait_solver, TraitSolver::Chalk);
807 tracked!(translate_remapped_path_to_local_path, false);
808 tracked!(trap_unreachable, Some(false));
809 tracked!(treat_err_as_bug, NonZeroUsize::new(1));
810 tracked!(tune_cpu, Some(String::from("abc")));
811 tracked!(uninit_const_chunk_threshold, 123);
812 tracked!(unleash_the_miri_inside_of_you, true);
813 tracked!(use_ctors_section, Some(true));
814 tracked!(verify_llvm_ir, true);
815 tracked!(virtual_function_elimination, true);
816 tracked!(wasi_exec_model, Some(WasiExecModel::Reactor));
817 // tidy-alphabetical-end
819 macro_rules! tracked_no_crate_hash {
820 ($name: ident, $non_default_value: expr) => {
821 opts = reference.clone();
822 assert_ne!(opts.unstable_opts.$name, $non_default_value);
823 opts.unstable_opts.$name = $non_default_value;
824 assert_non_crate_hash_different(&reference, &opts);
827 tracked_no_crate_hash!(no_codegen, true);
831 fn test_edition_parsing() {
832 // test default edition
833 let options = Options::default();
834 assert!(options.edition == DEFAULT_EDITION);
836 let matches = optgroups().parse(&["--edition=2018".to_string()]).unwrap();
837 let (sessopts, _) = build_session_options_and_crate_config(matches);
838 assert!(sessopts.edition == Edition::Edition2018)