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::InstrumentCoverage;
7 use rustc_session::config::Strip;
8 use rustc_session::config::{build_configuration, build_session_options, to_crate_config};
9 use rustc_session::config::{
10 rustc_optgroups, ErrorOutputType, ExternLocation, LocationDetail, Options, Passes,
12 use rustc_session::config::{
13 BranchProtection, Externs, OomStrategy, OutputType, OutputTypes, PAuthKey, PacRet,
14 ProcMacroExecutionStrategy, SymbolManglingVersion, WasiExecModel,
16 use rustc_session::config::{CFGuard, ExternEntry, LinkerPluginLto, LtoCli, SwitchWithOptPath};
17 use rustc_session::lint::Level;
18 use rustc_session::search_paths::SearchPath;
19 use rustc_session::utils::{CanonicalizedPath, NativeLib, NativeLibKind};
20 use rustc_session::{build_session, getopts, Session};
21 use rustc_span::edition::{Edition, DEFAULT_EDITION};
22 use rustc_span::symbol::sym;
23 use rustc_span::SourceFileHashAlgorithm;
24 use rustc_target::spec::{CodeModel, LinkerFlavorCli, MergeFunctions, PanicStrategy, RelocModel};
25 use rustc_target::spec::{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(sessopts, None, None, registry, Default::default(), None, None);
47 fn new_public_extern_entry<S, I>(locations: I) -> ExternEntry
50 I: IntoIterator<Item = S>,
52 let locations: BTreeSet<CanonicalizedPath> =
53 locations.into_iter().map(|s| CanonicalizedPath::new(Path::new(&s.into()))).collect();
56 location: ExternLocation::ExactPaths(locations),
57 is_private_dep: false,
63 fn optgroups() -> getopts::Options {
64 let mut opts = getopts::Options::new();
65 for group in rustc_optgroups() {
66 (group.apply)(&mut opts);
71 fn mk_map<K: Ord, V>(entries: Vec<(K, V)>) -> BTreeMap<K, V> {
72 BTreeMap::from_iter(entries.into_iter())
75 fn assert_same_clone(x: &Options) {
76 assert_eq!(x.dep_tracking_hash(true), x.clone().dep_tracking_hash(true));
77 assert_eq!(x.dep_tracking_hash(false), x.clone().dep_tracking_hash(false));
80 fn assert_same_hash(x: &Options, y: &Options) {
81 assert_eq!(x.dep_tracking_hash(true), y.dep_tracking_hash(true));
82 assert_eq!(x.dep_tracking_hash(false), y.dep_tracking_hash(false));
88 fn assert_different_hash(x: &Options, y: &Options) {
89 assert_ne!(x.dep_tracking_hash(true), y.dep_tracking_hash(true));
90 assert_ne!(x.dep_tracking_hash(false), y.dep_tracking_hash(false));
96 fn assert_non_crate_hash_different(x: &Options, y: &Options) {
97 assert_eq!(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 // When the user supplies --test we should implicitly supply --cfg test
106 fn test_switch_implies_cfg_test() {
107 rustc_span::create_default_session_globals_then(|| {
108 let matches = optgroups().parse(&["--test".to_string()]).unwrap();
109 let (sess, cfg) = mk_session(matches);
110 let cfg = build_configuration(&sess, to_crate_config(cfg));
111 assert!(cfg.contains(&(sym::test, None)));
115 // When the user supplies --test and --cfg test, don't implicitly add another --cfg test
117 fn test_switch_implies_cfg_test_unless_cfg_test() {
118 rustc_span::create_default_session_globals_then(|| {
119 let matches = optgroups().parse(&["--test".to_string(), "--cfg=test".to_string()]).unwrap();
120 let (sess, cfg) = mk_session(matches);
121 let cfg = build_configuration(&sess, to_crate_config(cfg));
122 let mut test_items = cfg.iter().filter(|&&(name, _)| name == sym::test);
123 assert!(test_items.next().is_some());
124 assert!(test_items.next().is_none());
129 fn test_can_print_warnings() {
130 rustc_span::create_default_session_globals_then(|| {
131 let matches = optgroups().parse(&["-Awarnings".to_string()]).unwrap();
132 let (sess, _) = mk_session(matches);
133 assert!(!sess.diagnostic().can_emit_warnings());
136 rustc_span::create_default_session_globals_then(|| {
138 optgroups().parse(&["-Awarnings".to_string(), "-Dwarnings".to_string()]).unwrap();
139 let (sess, _) = mk_session(matches);
140 assert!(sess.diagnostic().can_emit_warnings());
143 rustc_span::create_default_session_globals_then(|| {
144 let matches = optgroups().parse(&["-Adead_code".to_string()]).unwrap();
145 let (sess, _) = mk_session(matches);
146 assert!(sess.diagnostic().can_emit_warnings());
151 fn test_output_types_tracking_hash_different_paths() {
152 let mut v1 = Options::default();
153 let mut v2 = Options::default();
154 let mut v3 = Options::default();
156 v1.output_types = OutputTypes::new(&[(OutputType::Exe, Some(PathBuf::from("./some/thing")))]);
157 v2.output_types = OutputTypes::new(&[(OutputType::Exe, Some(PathBuf::from("/some/thing")))]);
158 v3.output_types = OutputTypes::new(&[(OutputType::Exe, None)]);
160 assert_non_crate_hash_different(&v1, &v2);
161 assert_non_crate_hash_different(&v1, &v3);
162 assert_non_crate_hash_different(&v2, &v3);
166 fn test_output_types_tracking_hash_different_construction_order() {
167 let mut v1 = Options::default();
168 let mut v2 = Options::default();
170 v1.output_types = OutputTypes::new(&[
171 (OutputType::Exe, Some(PathBuf::from("./some/thing"))),
172 (OutputType::Bitcode, Some(PathBuf::from("./some/thing.bc"))),
175 v2.output_types = OutputTypes::new(&[
176 (OutputType::Bitcode, Some(PathBuf::from("./some/thing.bc"))),
177 (OutputType::Exe, Some(PathBuf::from("./some/thing"))),
180 assert_same_hash(&v1, &v2);
184 fn test_externs_tracking_hash_different_construction_order() {
185 let mut v1 = Options::default();
186 let mut v2 = Options::default();
187 let mut v3 = Options::default();
189 v1.externs = Externs::new(mk_map(vec![
190 (String::from("a"), new_public_extern_entry(vec!["b", "c"])),
191 (String::from("d"), new_public_extern_entry(vec!["e", "f"])),
194 v2.externs = Externs::new(mk_map(vec![
195 (String::from("d"), new_public_extern_entry(vec!["e", "f"])),
196 (String::from("a"), new_public_extern_entry(vec!["b", "c"])),
199 v3.externs = Externs::new(mk_map(vec![
200 (String::from("a"), new_public_extern_entry(vec!["b", "c"])),
201 (String::from("d"), new_public_extern_entry(vec!["f", "e"])),
204 assert_same_hash(&v1, &v2);
205 assert_same_hash(&v1, &v3);
206 assert_same_hash(&v2, &v3);
210 fn test_lints_tracking_hash_different_values() {
211 let mut v1 = Options::default();
212 let mut v2 = Options::default();
213 let mut v3 = Options::default();
216 (String::from("a"), Level::Allow),
217 (String::from("b"), Level::Warn),
218 (String::from("c"), Level::Deny),
219 (String::from("d"), Level::Forbid),
223 (String::from("a"), Level::Allow),
224 (String::from("b"), Level::Warn),
225 (String::from("X"), Level::Deny),
226 (String::from("d"), Level::Forbid),
230 (String::from("a"), Level::Allow),
231 (String::from("b"), Level::Warn),
232 (String::from("c"), Level::Forbid),
233 (String::from("d"), Level::Deny),
236 assert_non_crate_hash_different(&v1, &v2);
237 assert_non_crate_hash_different(&v1, &v3);
238 assert_non_crate_hash_different(&v2, &v3);
242 fn test_lints_tracking_hash_different_construction_order() {
243 let mut v1 = Options::default();
244 let mut v2 = Options::default();
247 (String::from("a"), Level::Allow),
248 (String::from("b"), Level::Warn),
249 (String::from("c"), Level::Deny),
250 (String::from("d"), Level::Forbid),
254 (String::from("a"), Level::Allow),
255 (String::from("c"), Level::Deny),
256 (String::from("b"), Level::Warn),
257 (String::from("d"), Level::Forbid),
260 // The hash should be order-dependent
261 assert_non_crate_hash_different(&v1, &v2);
265 fn test_lint_cap_hash_different() {
266 let mut v1 = Options::default();
267 let mut v2 = Options::default();
268 let v3 = Options::default();
270 v1.lint_cap = Some(Level::Forbid);
271 v2.lint_cap = Some(Level::Allow);
273 assert_non_crate_hash_different(&v1, &v2);
274 assert_non_crate_hash_different(&v1, &v3);
275 assert_non_crate_hash_different(&v2, &v3);
279 fn test_search_paths_tracking_hash_different_order() {
280 let mut v1 = Options::default();
281 let mut v2 = Options::default();
282 let mut v3 = Options::default();
283 let mut v4 = Options::default();
285 const JSON: ErrorOutputType = ErrorOutputType::Json {
287 json_rendered: HumanReadableErrorType::Default(ColorConfig::Never),
291 v1.search_paths.push(SearchPath::from_cli_opt("native=abc", JSON));
292 v1.search_paths.push(SearchPath::from_cli_opt("crate=def", JSON));
293 v1.search_paths.push(SearchPath::from_cli_opt("dependency=ghi", JSON));
294 v1.search_paths.push(SearchPath::from_cli_opt("framework=jkl", JSON));
295 v1.search_paths.push(SearchPath::from_cli_opt("all=mno", JSON));
297 v2.search_paths.push(SearchPath::from_cli_opt("native=abc", JSON));
298 v2.search_paths.push(SearchPath::from_cli_opt("dependency=ghi", JSON));
299 v2.search_paths.push(SearchPath::from_cli_opt("crate=def", JSON));
300 v2.search_paths.push(SearchPath::from_cli_opt("framework=jkl", JSON));
301 v2.search_paths.push(SearchPath::from_cli_opt("all=mno", JSON));
303 v3.search_paths.push(SearchPath::from_cli_opt("crate=def", JSON));
304 v3.search_paths.push(SearchPath::from_cli_opt("framework=jkl", JSON));
305 v3.search_paths.push(SearchPath::from_cli_opt("native=abc", JSON));
306 v3.search_paths.push(SearchPath::from_cli_opt("dependency=ghi", JSON));
307 v3.search_paths.push(SearchPath::from_cli_opt("all=mno", JSON));
309 v4.search_paths.push(SearchPath::from_cli_opt("all=mno", JSON));
310 v4.search_paths.push(SearchPath::from_cli_opt("native=abc", JSON));
311 v4.search_paths.push(SearchPath::from_cli_opt("crate=def", JSON));
312 v4.search_paths.push(SearchPath::from_cli_opt("dependency=ghi", JSON));
313 v4.search_paths.push(SearchPath::from_cli_opt("framework=jkl", JSON));
315 assert_same_hash(&v1, &v2);
316 assert_same_hash(&v1, &v3);
317 assert_same_hash(&v1, &v4);
321 fn test_native_libs_tracking_hash_different_values() {
322 let mut v1 = Options::default();
323 let mut v2 = Options::default();
324 let mut v3 = Options::default();
325 let mut v4 = Options::default();
326 let mut v5 = Options::default();
331 name: String::from("a"),
333 kind: NativeLibKind::Static { bundle: None, whole_archive: None },
337 name: String::from("b"),
339 kind: NativeLibKind::Framework { as_needed: None },
343 name: String::from("c"),
345 kind: NativeLibKind::Unspecified,
353 name: String::from("a"),
355 kind: NativeLibKind::Static { bundle: None, whole_archive: None },
359 name: String::from("X"),
361 kind: NativeLibKind::Framework { as_needed: None },
365 name: String::from("c"),
367 kind: NativeLibKind::Unspecified,
375 name: String::from("a"),
377 kind: NativeLibKind::Static { bundle: None, whole_archive: None },
381 name: String::from("b"),
383 kind: NativeLibKind::Static { bundle: None, whole_archive: None },
387 name: String::from("c"),
389 kind: NativeLibKind::Unspecified,
397 name: String::from("a"),
399 kind: NativeLibKind::Static { bundle: None, whole_archive: None },
403 name: String::from("b"),
404 new_name: Some(String::from("X")),
405 kind: NativeLibKind::Framework { as_needed: None },
409 name: String::from("c"),
411 kind: NativeLibKind::Unspecified,
419 name: String::from("a"),
421 kind: NativeLibKind::Static { bundle: None, whole_archive: None },
425 name: String::from("b"),
427 kind: NativeLibKind::Framework { as_needed: None },
428 verbatim: Some(true),
431 name: String::from("c"),
433 kind: NativeLibKind::Unspecified,
438 assert_different_hash(&v1, &v2);
439 assert_different_hash(&v1, &v3);
440 assert_different_hash(&v1, &v4);
441 assert_different_hash(&v1, &v5);
445 fn test_native_libs_tracking_hash_different_order() {
446 let mut v1 = Options::default();
447 let mut v2 = Options::default();
448 let mut v3 = Options::default();
453 name: String::from("a"),
455 kind: NativeLibKind::Static { bundle: None, whole_archive: None },
459 name: String::from("b"),
461 kind: NativeLibKind::Framework { as_needed: None },
465 name: String::from("c"),
467 kind: NativeLibKind::Unspecified,
474 name: String::from("b"),
476 kind: NativeLibKind::Framework { as_needed: None },
480 name: String::from("a"),
482 kind: NativeLibKind::Static { bundle: None, whole_archive: None },
486 name: String::from("c"),
488 kind: NativeLibKind::Unspecified,
495 name: String::from("c"),
497 kind: NativeLibKind::Unspecified,
501 name: String::from("a"),
503 kind: NativeLibKind::Static { bundle: None, whole_archive: None },
507 name: String::from("b"),
509 kind: NativeLibKind::Framework { as_needed: None },
514 // The hash should be order-dependent
515 assert_different_hash(&v1, &v2);
516 assert_different_hash(&v1, &v3);
517 assert_different_hash(&v2, &v3);
521 fn test_codegen_options_tracking_hash() {
522 let reference = Options::default();
523 let mut opts = Options::default();
525 macro_rules! untracked {
526 ($name: ident, $non_default_value: expr) => {
527 assert_ne!(opts.cg.$name, $non_default_value);
528 opts.cg.$name = $non_default_value;
529 assert_same_hash(&reference, &opts);
533 // Make sure that changing an [UNTRACKED] option leaves the hash unchanged.
534 // tidy-alphabetical-start
535 untracked!(ar, String::from("abc"));
536 untracked!(codegen_units, Some(42));
537 untracked!(default_linker_libraries, true);
538 untracked!(extra_filename, String::from("extra-filename"));
539 untracked!(incremental, Some(String::from("abc")));
540 // `link_arg` is omitted because it just forwards to `link_args`.
541 untracked!(link_args, vec![String::from("abc"), String::from("def")]);
542 untracked!(link_self_contained, Some(true));
543 untracked!(linker, Some(PathBuf::from("linker")));
544 untracked!(linker_flavor, Some(LinkerFlavorCli::Gcc));
545 untracked!(no_stack_check, true);
546 untracked!(remark, Passes::Some(vec![String::from("pass1"), String::from("pass2")]));
547 untracked!(rpath, true);
548 untracked!(save_temps, true);
549 untracked!(strip, Strip::Debuginfo);
550 // tidy-alphabetical-end
552 macro_rules! tracked {
553 ($name: ident, $non_default_value: expr) => {
554 opts = reference.clone();
555 assert_ne!(opts.cg.$name, $non_default_value);
556 opts.cg.$name = $non_default_value;
557 assert_different_hash(&reference, &opts);
561 // Make sure that changing a [TRACKED] option changes the hash.
562 // tidy-alphabetical-start
563 tracked!(code_model, Some(CodeModel::Large));
564 tracked!(control_flow_guard, CFGuard::Checks);
565 tracked!(debug_assertions, Some(true));
566 tracked!(debuginfo, 0xdeadbeef);
567 tracked!(embed_bitcode, false);
568 tracked!(force_frame_pointers, Some(false));
569 tracked!(force_unwind_tables, Some(true));
570 tracked!(inline_threshold, Some(0xf007ba11));
571 tracked!(instrument_coverage, Some(InstrumentCoverage::All));
572 tracked!(link_dead_code, Some(true));
573 tracked!(linker_plugin_lto, LinkerPluginLto::LinkerPluginAuto);
574 tracked!(llvm_args, vec![String::from("1"), String::from("2")]);
575 tracked!(lto, LtoCli::Fat);
576 tracked!(metadata, vec![String::from("A"), String::from("B")]);
577 tracked!(no_prepopulate_passes, true);
578 tracked!(no_redzone, Some(true));
579 tracked!(no_vectorize_loops, true);
580 tracked!(no_vectorize_slp, true);
581 tracked!(opt_level, "3".to_string());
582 tracked!(overflow_checks, Some(true));
583 tracked!(panic, Some(PanicStrategy::Abort));
584 tracked!(passes, vec![String::from("1"), String::from("2")]);
585 tracked!(prefer_dynamic, true);
586 tracked!(profile_generate, SwitchWithOptPath::Enabled(None));
587 tracked!(profile_use, Some(PathBuf::from("abc")));
588 tracked!(relocation_model, Some(RelocModel::Pic));
589 tracked!(soft_float, true);
590 tracked!(split_debuginfo, Some(SplitDebuginfo::Packed));
591 tracked!(symbol_mangling_version, Some(SymbolManglingVersion::V0));
592 tracked!(target_cpu, Some(String::from("abc")));
593 tracked!(target_feature, String::from("all the features, all of them"));
594 // tidy-alphabetical-end
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 // tidy-alphabetical-start
617 real_rust_source_base_dir,
618 Some("/home/bors/rust/.rustup/toolchains/nightly/lib/rustlib/src/rust".into())
620 tracked!(remap_path_prefix, vec![("/home/bors/rust".into(), "src".into())]);
621 // tidy-alphabetical-end
625 fn test_unstable_options_tracking_hash() {
626 let reference = Options::default();
627 let mut opts = Options::default();
629 macro_rules! untracked {
630 ($name: ident, $non_default_value: expr) => {
631 assert_ne!(opts.unstable_opts.$name, $non_default_value);
632 opts.unstable_opts.$name = $non_default_value;
633 assert_same_hash(&reference, &opts);
637 // Make sure that changing an [UNTRACKED] option leaves the hash unchanged.
638 // tidy-alphabetical-start
639 untracked!(assert_incr_state, Some(String::from("loaded")));
640 untracked!(deduplicate_diagnostics, false);
641 untracked!(dep_tasks, true);
642 untracked!(dlltool, Some(PathBuf::from("custom_dlltool.exe")));
643 untracked!(dont_buffer_diagnostics, true);
644 untracked!(dump_dep_graph, true);
645 untracked!(dump_drop_tracking_cfg, Some("cfg.dot".to_string()));
646 untracked!(dump_mir, Some(String::from("abc")));
647 untracked!(dump_mir_dataflow, true);
648 untracked!(dump_mir_dir, String::from("abc"));
649 untracked!(dump_mir_exclude_pass_number, true);
650 untracked!(dump_mir_graphviz, 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!(mir_pretty_relative_line_numbers, true);
666 untracked!(nll_facts, true);
667 untracked!(no_analysis, true);
668 untracked!(no_interleave_lints, true);
669 untracked!(no_leak_check, true);
670 untracked!(no_parallel_llvm, true);
671 untracked!(parse_only, true);
672 untracked!(perf_stats, true);
673 // `pre_link_arg` is omitted because it just forwards to `pre_link_args`.
674 untracked!(pre_link_args, vec![String::from("abc"), String::from("def")]);
675 untracked!(print_llvm_passes, true);
676 untracked!(print_mono_items, Some(String::from("abc")));
677 untracked!(print_type_sizes, true);
678 untracked!(proc_macro_backtrace, true);
679 untracked!(proc_macro_execution_strategy, ProcMacroExecutionStrategy::CrossThread);
680 untracked!(profile_closures, true);
681 untracked!(query_dep_graph, 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!(temps_dir, Some(String::from("abc")));
688 untracked!(threads, 99);
689 untracked!(time_llvm_passes, true);
690 untracked!(time_passes, true);
691 untracked!(trace_macros, true);
692 untracked!(trim_diagnostic_paths, false);
693 untracked!(ui_testing, true);
694 untracked!(unpretty, Some("expanded".to_string()));
695 untracked!(unstable_options, true);
696 untracked!(validate_mir, true);
697 untracked!(verbose, true);
698 // tidy-alphabetical-end
700 macro_rules! tracked {
701 ($name: ident, $non_default_value: expr) => {
702 opts = reference.clone();
703 assert_ne!(opts.unstable_opts.$name, $non_default_value);
704 opts.unstable_opts.$name = $non_default_value;
705 assert_different_hash(&reference, &opts);
709 // Make sure that changing a [TRACKED] option changes the hash.
710 // tidy-alphabetical-start
711 tracked!(allow_features, Some(vec![String::from("lang_items")]));
712 tracked!(always_encode_mir, true);
713 tracked!(asm_comments, true);
714 tracked!(assume_incomplete_release, true);
715 tracked!(binary_dep_depinfo, true);
716 tracked!(box_noalias, Some(false));
719 Some(BranchProtection {
721 pac_ret: Some(PacRet { leaf: true, key: PAuthKey::B })
724 tracked!(chalk, true);
725 tracked!(codegen_backend, Some("abc".to_string()));
726 tracked!(crate_attr, vec!["abc".to_string()]);
727 tracked!(debug_info_for_profiling, true);
728 tracked!(debug_macros, true);
729 tracked!(dep_info_omit_d_target, true);
730 tracked!(drop_tracking, true);
731 tracked!(dual_proc_macros, true);
732 tracked!(dwarf_version, Some(5));
733 tracked!(emit_thin_lto, false);
734 tracked!(export_executable_symbols, true);
735 tracked!(fewer_names, Some(true));
736 tracked!(force_unstable_if_unmarked, true);
737 tracked!(fuel, Some(("abc".to_string(), 99)));
738 tracked!(function_sections, Some(false));
739 tracked!(human_readable_cgu_names, true);
740 tracked!(inline_in_all_cgus, Some(true));
741 tracked!(inline_mir, Some(true));
742 tracked!(inline_mir_hint_threshold, Some(123));
743 tracked!(inline_mir_threshold, Some(123));
744 tracked!(instrument_coverage, Some(InstrumentCoverage::All));
745 tracked!(instrument_mcount, true);
746 tracked!(link_only, true);
747 tracked!(llvm_plugins, vec![String::from("plugin_name")]);
748 tracked!(location_detail, LocationDetail { file: true, line: false, column: false });
749 tracked!(merge_functions, Some(MergeFunctions::Disabled));
750 tracked!(mir_emit_retag, true);
751 tracked!(mir_enable_passes, vec![("DestProp".to_string(), false)]);
752 tracked!(mir_opt_level, Some(4));
753 tracked!(move_size_limit, Some(4096));
754 tracked!(mutable_noalias, Some(true));
755 tracked!(no_generate_arange_section, true);
756 tracked!(no_link, true);
757 tracked!(no_profiler_runtime, true);
758 tracked!(no_unique_section_names, true);
759 tracked!(oom, OomStrategy::Panic);
760 tracked!(osx_rpath_install_name, true);
761 tracked!(packed_bundled_libs, true);
762 tracked!(panic_abort_tests, true);
763 tracked!(panic_in_drop, PanicStrategy::Abort);
764 tracked!(pick_stable_methods_before_any_unstable, false);
765 tracked!(plt, Some(true));
766 tracked!(polonius, true);
767 tracked!(precise_enum_drop_elaboration, false);
768 tracked!(print_fuel, Some("abc".to_string()));
769 tracked!(profile, true);
770 tracked!(profile_emit, Some(PathBuf::from("abc")));
771 tracked!(profile_sample_use, Some(PathBuf::from("abc")));
772 tracked!(profiler_runtime, "abc".to_string());
773 tracked!(relax_elf_relocations, Some(true));
774 tracked!(relro_level, Some(RelroLevel::Full));
775 tracked!(remap_cwd_prefix, Some(PathBuf::from("abc")));
776 tracked!(report_delayed_bugs, true);
777 tracked!(sanitizer, SanitizerSet::ADDRESS);
778 tracked!(sanitizer_memory_track_origins, 2);
779 tracked!(sanitizer_recover, SanitizerSet::ADDRESS);
780 tracked!(saturating_float_casts, Some(true));
781 tracked!(share_generics, Some(true));
782 tracked!(show_span, Some(String::from("abc")));
783 tracked!(simulate_remapped_rust_src_base, Some(PathBuf::from("/rustc/abc")));
784 tracked!(src_hash_algorithm, Some(SourceFileHashAlgorithm::Sha1));
785 tracked!(stack_protector, StackProtector::All);
786 tracked!(symbol_mangling_version, Some(SymbolManglingVersion::V0));
787 tracked!(teach, true);
788 tracked!(thinlto, Some(true));
789 tracked!(thir_unsafeck, true);
790 tracked!(tls_model, Some(TlsModel::GeneralDynamic));
791 tracked!(translate_remapped_path_to_local_path, false);
792 tracked!(trap_unreachable, Some(false));
793 tracked!(treat_err_as_bug, NonZeroUsize::new(1));
794 tracked!(tune_cpu, Some(String::from("abc")));
795 tracked!(uninit_const_chunk_threshold, 123);
796 tracked!(unleash_the_miri_inside_of_you, true);
797 tracked!(use_ctors_section, Some(true));
798 tracked!(verify_llvm_ir, true);
799 tracked!(virtual_function_elimination, true);
800 tracked!(wasi_exec_model, Some(WasiExecModel::Reactor));
801 // tidy-alphabetical-end
803 macro_rules! tracked_no_crate_hash {
804 ($name: ident, $non_default_value: expr) => {
805 opts = reference.clone();
806 assert_ne!(opts.unstable_opts.$name, $non_default_value);
807 opts.unstable_opts.$name = $non_default_value;
808 assert_non_crate_hash_different(&reference, &opts);
811 tracked_no_crate_hash!(no_codegen, true);
815 fn test_edition_parsing() {
816 // test default edition
817 let options = Options::default();
818 assert!(options.edition == DEFAULT_EDITION);
820 let matches = optgroups().parse(&["--edition=2018".to_string()]).unwrap();
821 let (sessopts, _) = build_session_options_and_crate_config(matches);
822 assert!(sessopts.edition == Edition::Edition2018)