3 use crate::interface::parse_cfgspecs;
6 use rustc::middle::cstore;
7 use rustc::session::config::{build_configuration, build_session_options, to_crate_config};
8 use rustc::session::config::{LtoCli, LinkerPluginLto, SwitchWithOptPath, ExternEntry};
9 use rustc::session::config::{Externs, OutputType, OutputTypes, SymbolManglingVersion};
10 use rustc::session::config::{rustc_optgroups, Options, ErrorOutputType, Passes};
11 use rustc::session::build_session;
12 use rustc::session::search_paths::SearchPath;
13 use std::collections::{BTreeMap, BTreeSet};
14 use std::iter::FromIterator;
15 use std::path::PathBuf;
16 use rustc_target::spec::{MergeFunctions, PanicStrategy, RelroLevel};
17 use syntax::symbol::sym;
18 use syntax::edition::{Edition, DEFAULT_EDITION};
20 use rustc_data_structures::fx::FxHashSet;
21 use rustc_errors::{ColorConfig, emitter::HumanReadableErrorType, registry};
23 pub fn build_session_options_and_crate_config(
24 matches: &getopts::Matches,
25 ) -> (Options, FxHashSet<(String, Option<String>)>) {
27 build_session_options(matches),
28 parse_cfgspecs(matches.opt_strs("cfg")),
32 fn new_public_extern_entry<S, I>(locations: I) -> ExternEntry
35 I: IntoIterator<Item = Option<S>>,
37 let locations: BTreeSet<_> = locations.into_iter().map(|o| o.map(|s| s.into()))
46 fn optgroups() -> getopts::Options {
47 let mut opts = getopts::Options::new();
48 for group in rustc_optgroups() {
49 (group.apply)(&mut opts);
54 fn mk_map<K: Ord, V>(entries: Vec<(K, V)>) -> BTreeMap<K, V> {
55 BTreeMap::from_iter(entries.into_iter())
58 // When the user supplies --test we should implicitly supply --cfg test
60 fn test_switch_implies_cfg_test() {
61 syntax::with_default_globals(|| {
62 let matches = &match optgroups().parse(&["--test".to_string()]) {
64 Err(f) => panic!("test_switch_implies_cfg_test: {}", f),
66 let registry = registry::Registry::new(&[]);
67 let (sessopts, cfg) = build_session_options_and_crate_config(matches);
68 let sess = build_session(sessopts, None, registry);
69 let cfg = build_configuration(&sess, to_crate_config(cfg));
70 assert!(cfg.contains(&(sym::test, None)));
74 // When the user supplies --test and --cfg test, don't implicitly add
77 fn test_switch_implies_cfg_test_unless_cfg_test() {
78 syntax::with_default_globals(|| {
79 let matches = &match optgroups().parse(&["--test".to_string(),
80 "--cfg=test".to_string()]) {
82 Err(f) => panic!("test_switch_implies_cfg_test_unless_cfg_test: {}", f),
84 let registry = registry::Registry::new(&[]);
85 let (sessopts, cfg) = build_session_options_and_crate_config(matches);
86 let sess = build_session(sessopts, None, registry);
87 let cfg = build_configuration(&sess, to_crate_config(cfg));
88 let mut test_items = cfg.iter().filter(|&&(name, _)| name == sym::test);
89 assert!(test_items.next().is_some());
90 assert!(test_items.next().is_none());
95 fn test_can_print_warnings() {
96 syntax::with_default_globals(|| {
97 let matches = optgroups().parse(&["-Awarnings".to_string()]).unwrap();
98 let registry = registry::Registry::new(&[]);
99 let (sessopts, _) = build_session_options_and_crate_config(&matches);
100 let sess = build_session(sessopts, None, registry);
101 assert!(!sess.diagnostic().can_emit_warnings());
104 syntax::with_default_globals(|| {
105 let matches = optgroups()
106 .parse(&["-Awarnings".to_string(), "-Dwarnings".to_string()])
108 let registry = registry::Registry::new(&[]);
109 let (sessopts, _) = build_session_options_and_crate_config(&matches);
110 let sess = build_session(sessopts, None, registry);
111 assert!(sess.diagnostic().can_emit_warnings());
114 syntax::with_default_globals(|| {
115 let matches = optgroups().parse(&["-Adead_code".to_string()]).unwrap();
116 let registry = registry::Registry::new(&[]);
117 let (sessopts, _) = build_session_options_and_crate_config(&matches);
118 let sess = build_session(sessopts, None, registry);
119 assert!(sess.diagnostic().can_emit_warnings());
124 fn test_output_types_tracking_hash_different_paths() {
125 let mut v1 = Options::default();
126 let mut v2 = Options::default();
127 let mut v3 = Options::default();
130 OutputTypes::new(&[(OutputType::Exe, Some(PathBuf::from("./some/thing")))]);
132 OutputTypes::new(&[(OutputType::Exe, Some(PathBuf::from("/some/thing")))]);
133 v3.output_types = OutputTypes::new(&[(OutputType::Exe, None)]);
135 assert!(v1.dep_tracking_hash() != v2.dep_tracking_hash());
136 assert!(v1.dep_tracking_hash() != v3.dep_tracking_hash());
137 assert!(v2.dep_tracking_hash() != v3.dep_tracking_hash());
140 assert_eq!(v1.dep_tracking_hash(), v1.clone().dep_tracking_hash());
141 assert_eq!(v2.dep_tracking_hash(), v2.clone().dep_tracking_hash());
142 assert_eq!(v3.dep_tracking_hash(), v3.clone().dep_tracking_hash());
146 fn test_output_types_tracking_hash_different_construction_order() {
147 let mut v1 = Options::default();
148 let mut v2 = Options::default();
150 v1.output_types = OutputTypes::new(&[
151 (OutputType::Exe, Some(PathBuf::from("./some/thing"))),
152 (OutputType::Bitcode, Some(PathBuf::from("./some/thing.bc"))),
155 v2.output_types = OutputTypes::new(&[
156 (OutputType::Bitcode, Some(PathBuf::from("./some/thing.bc"))),
157 (OutputType::Exe, Some(PathBuf::from("./some/thing"))),
160 assert_eq!(v1.dep_tracking_hash(), v2.dep_tracking_hash());
163 assert_eq!(v1.dep_tracking_hash(), v1.clone().dep_tracking_hash());
167 fn test_externs_tracking_hash_different_construction_order() {
168 let mut v1 = Options::default();
169 let mut v2 = Options::default();
170 let mut v3 = Options::default();
172 v1.externs = Externs::new(mk_map(vec![
175 new_public_extern_entry(vec![Some("b"), Some("c")])
179 new_public_extern_entry(vec![Some("e"), Some("f")])
183 v2.externs = Externs::new(mk_map(vec![
186 new_public_extern_entry(vec![Some("e"), Some("f")])
190 new_public_extern_entry(vec![Some("b"), Some("c")])
194 v3.externs = Externs::new(mk_map(vec![
197 new_public_extern_entry(vec![Some("b"), Some("c")])
201 new_public_extern_entry(vec![Some("f"), Some("e")])
205 assert_eq!(v1.dep_tracking_hash(), v2.dep_tracking_hash());
206 assert_eq!(v1.dep_tracking_hash(), v3.dep_tracking_hash());
207 assert_eq!(v2.dep_tracking_hash(), v3.dep_tracking_hash());
210 assert_eq!(v1.dep_tracking_hash(), v1.clone().dep_tracking_hash());
211 assert_eq!(v2.dep_tracking_hash(), v2.clone().dep_tracking_hash());
212 assert_eq!(v3.dep_tracking_hash(), v3.clone().dep_tracking_hash());
216 fn test_lints_tracking_hash_different_values() {
217 let mut v1 = Options::default();
218 let mut v2 = Options::default();
219 let mut v3 = Options::default();
222 (String::from("a"), lint::Allow),
223 (String::from("b"), lint::Warn),
224 (String::from("c"), lint::Deny),
225 (String::from("d"), lint::Forbid),
229 (String::from("a"), lint::Allow),
230 (String::from("b"), lint::Warn),
231 (String::from("X"), lint::Deny),
232 (String::from("d"), lint::Forbid),
236 (String::from("a"), lint::Allow),
237 (String::from("b"), lint::Warn),
238 (String::from("c"), lint::Forbid),
239 (String::from("d"), lint::Deny),
242 assert!(v1.dep_tracking_hash() != v2.dep_tracking_hash());
243 assert!(v1.dep_tracking_hash() != v3.dep_tracking_hash());
244 assert!(v2.dep_tracking_hash() != v3.dep_tracking_hash());
247 assert_eq!(v1.dep_tracking_hash(), v1.clone().dep_tracking_hash());
248 assert_eq!(v2.dep_tracking_hash(), v2.clone().dep_tracking_hash());
249 assert_eq!(v3.dep_tracking_hash(), v3.clone().dep_tracking_hash());
253 fn test_lints_tracking_hash_different_construction_order() {
254 let mut v1 = Options::default();
255 let mut v2 = Options::default();
258 (String::from("a"), lint::Allow),
259 (String::from("b"), lint::Warn),
260 (String::from("c"), lint::Deny),
261 (String::from("d"), lint::Forbid),
265 (String::from("a"), lint::Allow),
266 (String::from("c"), lint::Deny),
267 (String::from("b"), lint::Warn),
268 (String::from("d"), lint::Forbid),
271 assert_eq!(v1.dep_tracking_hash(), v2.dep_tracking_hash());
274 assert_eq!(v1.dep_tracking_hash(), v1.clone().dep_tracking_hash());
275 assert_eq!(v2.dep_tracking_hash(), v2.clone().dep_tracking_hash());
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),
292 .push(SearchPath::from_cli_opt("native=abc", JSON));
294 .push(SearchPath::from_cli_opt("crate=def", JSON));
296 .push(SearchPath::from_cli_opt("dependency=ghi", JSON));
298 .push(SearchPath::from_cli_opt("framework=jkl", JSON));
300 .push(SearchPath::from_cli_opt("all=mno", JSON));
303 .push(SearchPath::from_cli_opt("native=abc", JSON));
305 .push(SearchPath::from_cli_opt("dependency=ghi", JSON));
307 .push(SearchPath::from_cli_opt("crate=def", JSON));
309 .push(SearchPath::from_cli_opt("framework=jkl", JSON));
311 .push(SearchPath::from_cli_opt("all=mno", JSON));
314 .push(SearchPath::from_cli_opt("crate=def", JSON));
316 .push(SearchPath::from_cli_opt("framework=jkl", JSON));
318 .push(SearchPath::from_cli_opt("native=abc", JSON));
320 .push(SearchPath::from_cli_opt("dependency=ghi", JSON));
322 .push(SearchPath::from_cli_opt("all=mno", JSON));
325 .push(SearchPath::from_cli_opt("all=mno", JSON));
327 .push(SearchPath::from_cli_opt("native=abc", JSON));
329 .push(SearchPath::from_cli_opt("crate=def", JSON));
331 .push(SearchPath::from_cli_opt("dependency=ghi", JSON));
333 .push(SearchPath::from_cli_opt("framework=jkl", JSON));
335 assert!(v1.dep_tracking_hash() == v2.dep_tracking_hash());
336 assert!(v1.dep_tracking_hash() == v3.dep_tracking_hash());
337 assert!(v1.dep_tracking_hash() == v4.dep_tracking_hash());
340 assert_eq!(v1.dep_tracking_hash(), v1.clone().dep_tracking_hash());
341 assert_eq!(v2.dep_tracking_hash(), v2.clone().dep_tracking_hash());
342 assert_eq!(v3.dep_tracking_hash(), v3.clone().dep_tracking_hash());
343 assert_eq!(v4.dep_tracking_hash(), v4.clone().dep_tracking_hash());
347 fn test_native_libs_tracking_hash_different_values() {
348 let mut v1 = Options::default();
349 let mut v2 = Options::default();
350 let mut v3 = Options::default();
351 let mut v4 = Options::default();
355 (String::from("a"), None, Some(cstore::NativeStatic)),
356 (String::from("b"), None, Some(cstore::NativeFramework)),
357 (String::from("c"), None, Some(cstore::NativeUnknown)),
362 (String::from("a"), None, Some(cstore::NativeStatic)),
363 (String::from("X"), None, Some(cstore::NativeFramework)),
364 (String::from("c"), None, Some(cstore::NativeUnknown)),
369 (String::from("a"), None, Some(cstore::NativeStatic)),
370 (String::from("b"), None, Some(cstore::NativeStatic)),
371 (String::from("c"), None, Some(cstore::NativeUnknown)),
376 (String::from("a"), None, Some(cstore::NativeStatic)),
379 Some(String::from("X")),
380 Some(cstore::NativeFramework),
382 (String::from("c"), None, Some(cstore::NativeUnknown)),
385 assert!(v1.dep_tracking_hash() != v2.dep_tracking_hash());
386 assert!(v1.dep_tracking_hash() != v3.dep_tracking_hash());
387 assert!(v1.dep_tracking_hash() != v4.dep_tracking_hash());
390 assert_eq!(v1.dep_tracking_hash(), v1.clone().dep_tracking_hash());
391 assert_eq!(v2.dep_tracking_hash(), v2.clone().dep_tracking_hash());
392 assert_eq!(v3.dep_tracking_hash(), v3.clone().dep_tracking_hash());
393 assert_eq!(v4.dep_tracking_hash(), v4.clone().dep_tracking_hash());
397 fn test_native_libs_tracking_hash_different_order() {
398 let mut v1 = Options::default();
399 let mut v2 = Options::default();
400 let mut v3 = Options::default();
404 (String::from("a"), None, Some(cstore::NativeStatic)),
405 (String::from("b"), None, Some(cstore::NativeFramework)),
406 (String::from("c"), None, Some(cstore::NativeUnknown)),
410 (String::from("b"), None, Some(cstore::NativeFramework)),
411 (String::from("a"), None, Some(cstore::NativeStatic)),
412 (String::from("c"), None, Some(cstore::NativeUnknown)),
416 (String::from("c"), None, Some(cstore::NativeUnknown)),
417 (String::from("a"), None, Some(cstore::NativeStatic)),
418 (String::from("b"), None, Some(cstore::NativeFramework)),
421 assert!(v1.dep_tracking_hash() == v2.dep_tracking_hash());
422 assert!(v1.dep_tracking_hash() == v3.dep_tracking_hash());
423 assert!(v2.dep_tracking_hash() == v3.dep_tracking_hash());
426 assert_eq!(v1.dep_tracking_hash(), v1.clone().dep_tracking_hash());
427 assert_eq!(v2.dep_tracking_hash(), v2.clone().dep_tracking_hash());
428 assert_eq!(v3.dep_tracking_hash(), v3.clone().dep_tracking_hash());
432 fn test_codegen_options_tracking_hash() {
433 let reference = Options::default();
434 let mut opts = Options::default();
436 // Make sure the changing an [UNTRACKED] option leaves the hash unchanged
437 opts.cg.ar = Some(String::from("abc"));
438 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
440 opts.cg.linker = Some(PathBuf::from("linker"));
441 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
443 opts.cg.link_args = Some(vec![String::from("abc"), String::from("def")]);
444 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
446 opts.cg.link_dead_code = true;
447 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
449 opts.cg.rpath = true;
450 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
452 opts.cg.extra_filename = String::from("extra-filename");
453 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
455 opts.cg.codegen_units = Some(42);
456 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
458 opts.cg.remark = Passes::Some(vec![String::from("pass1"), String::from("pass2")]);
459 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
461 opts.cg.save_temps = true;
462 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
464 opts.cg.incremental = Some(String::from("abc"));
465 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
467 // Make sure changing a [TRACKED] option changes the hash
468 opts = reference.clone();
469 opts.cg.lto = LtoCli::Fat;
470 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
472 opts = reference.clone();
473 opts.cg.target_cpu = Some(String::from("abc"));
474 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
476 opts = reference.clone();
477 opts.cg.target_feature = String::from("all the features, all of them");
478 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
480 opts = reference.clone();
481 opts.cg.passes = vec![String::from("1"), String::from("2")];
482 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
484 opts = reference.clone();
485 opts.cg.llvm_args = vec![String::from("1"), String::from("2")];
486 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
488 opts = reference.clone();
489 opts.cg.overflow_checks = Some(true);
490 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
492 opts = reference.clone();
493 opts.cg.no_prepopulate_passes = true;
494 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
496 opts = reference.clone();
497 opts.cg.no_vectorize_loops = true;
498 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
500 opts = reference.clone();
501 opts.cg.no_vectorize_slp = true;
502 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
504 opts = reference.clone();
505 opts.cg.soft_float = true;
506 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
508 opts = reference.clone();
509 opts.cg.prefer_dynamic = true;
510 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
512 opts = reference.clone();
513 opts.cg.no_integrated_as = true;
514 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
516 opts = reference.clone();
517 opts.cg.no_redzone = Some(true);
518 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
520 opts = reference.clone();
521 opts.cg.relocation_model = Some(String::from("relocation model"));
522 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
524 opts = reference.clone();
525 opts.cg.code_model = Some(String::from("code model"));
526 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
528 opts = reference.clone();
529 opts.debugging_opts.tls_model = Some(String::from("tls model"));
530 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
532 opts = reference.clone();
533 opts.cg.profile_generate = SwitchWithOptPath::Enabled(None);
534 assert_ne!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
536 opts = reference.clone();
537 opts.cg.profile_use = Some(PathBuf::from("abc"));
538 assert_ne!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
540 opts = reference.clone();
541 opts.cg.metadata = vec![String::from("A"), String::from("B")];
542 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
544 opts = reference.clone();
545 opts.cg.debuginfo = Some(0xdeadbeef);
546 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
548 opts = reference.clone();
549 opts.cg.debuginfo = Some(0xba5eba11);
550 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
552 opts = reference.clone();
553 opts.cg.force_frame_pointers = Some(false);
554 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
556 opts = reference.clone();
557 opts.cg.debug_assertions = Some(true);
558 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
560 opts = reference.clone();
561 opts.cg.inline_threshold = Some(0xf007ba11);
562 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
564 opts = reference.clone();
565 opts.cg.panic = Some(PanicStrategy::Abort);
566 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
568 opts = reference.clone();
569 opts.cg.linker_plugin_lto = LinkerPluginLto::LinkerPluginAuto;
570 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
574 fn test_debugging_options_tracking_hash() {
575 let reference = Options::default();
576 let mut opts = Options::default();
578 // Make sure the changing an [UNTRACKED] option leaves the hash unchanged
579 opts.debugging_opts.verbose = true;
580 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
581 opts.debugging_opts.time_passes = true;
582 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
583 opts.debugging_opts.time_llvm_passes = true;
584 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
585 opts.debugging_opts.input_stats = true;
586 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
587 opts.debugging_opts.borrowck_stats = true;
588 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
589 opts.debugging_opts.meta_stats = true;
590 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
591 opts.debugging_opts.print_link_args = true;
592 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
593 opts.debugging_opts.print_llvm_passes = true;
594 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
595 opts.debugging_opts.ast_json = true;
596 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
597 opts.debugging_opts.ast_json_noexpand = true;
598 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
599 opts.debugging_opts.ls = true;
600 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
601 opts.debugging_opts.save_analysis = true;
602 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
603 opts.debugging_opts.print_region_graph = true;
604 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
605 opts.debugging_opts.parse_only = true;
606 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
607 opts.debugging_opts.incremental = Some(String::from("abc"));
608 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
609 opts.debugging_opts.dump_dep_graph = true;
610 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
611 opts.debugging_opts.query_dep_graph = true;
612 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
613 opts.debugging_opts.no_analysis = true;
614 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
615 opts.debugging_opts.unstable_options = true;
616 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
617 opts.debugging_opts.trace_macros = true;
618 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
619 opts.debugging_opts.keep_hygiene_data = true;
620 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
621 opts.debugging_opts.keep_ast = true;
622 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
623 opts.debugging_opts.print_mono_items = Some(String::from("abc"));
624 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
625 opts.debugging_opts.dump_mir = Some(String::from("abc"));
626 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
627 opts.debugging_opts.dump_mir_dir = String::from("abc");
628 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
629 opts.debugging_opts.dump_mir_graphviz = true;
630 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
632 // Make sure changing a [TRACKED] option changes the hash
633 opts = reference.clone();
634 opts.debugging_opts.asm_comments = true;
635 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
637 opts = reference.clone();
638 opts.debugging_opts.verify_llvm_ir = true;
639 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
641 opts = reference.clone();
642 opts.debugging_opts.no_landing_pads = true;
643 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
645 opts = reference.clone();
646 opts.debugging_opts.fewer_names = true;
647 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
649 opts = reference.clone();
650 opts.debugging_opts.no_codegen = true;
651 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
653 opts = reference.clone();
654 opts.debugging_opts.treat_err_as_bug = Some(1);
655 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
657 opts = reference.clone();
658 opts.debugging_opts.report_delayed_bugs = true;
659 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
661 opts = reference.clone();
662 opts.debugging_opts.continue_parse_after_error = true;
663 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
665 opts = reference.clone();
666 opts.debugging_opts.extra_plugins = vec![String::from("plugin1"), String::from("plugin2")];
667 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
669 opts = reference.clone();
670 opts.debugging_opts.force_overflow_checks = Some(true);
671 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
673 opts = reference.clone();
674 opts.debugging_opts.show_span = Some(String::from("abc"));
675 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
677 opts = reference.clone();
678 opts.debugging_opts.mir_opt_level = 3;
679 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
681 opts = reference.clone();
682 opts.debugging_opts.relro_level = Some(RelroLevel::Full);
683 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
685 opts = reference.clone();
686 opts.debugging_opts.merge_functions = Some(MergeFunctions::Disabled);
687 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
689 opts = reference.clone();
690 opts.debugging_opts.allow_features = Some(vec![String::from("lang_items")]);
691 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
693 opts = reference.clone();
694 opts.debugging_opts.symbol_mangling_version = SymbolManglingVersion::V0;
695 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
699 fn test_edition_parsing() {
700 // test default edition
701 let options = Options::default();
702 assert!(options.edition == DEFAULT_EDITION);
704 let matches = optgroups()
705 .parse(&["--edition=2018".to_string()])
707 let (sessopts, _) = build_session_options_and_crate_config(&matches);
708 assert!(sessopts.edition == Edition::Edition2018)