3 use crate::interface::parse_cfgspecs;
5 use rustc::lint::Level;
6 use rustc::middle::cstore;
7 use rustc::session::config::{build_configuration, build_session_options, to_crate_config};
8 use rustc::session::config::{rustc_optgroups, ErrorOutputType, ExternLocation, Options, Passes};
9 use rustc::session::config::{ExternEntry, LinkerPluginLto, LtoCli, SwitchWithOptPath};
10 use rustc::session::config::{Externs, OutputType, OutputTypes, SymbolManglingVersion};
11 use rustc::session::search_paths::SearchPath;
12 use rustc::session::{build_session, Session};
13 use rustc_data_structures::fx::FxHashSet;
14 use rustc_errors::{emitter::HumanReadableErrorType, registry, ColorConfig};
15 use rustc_span::edition::{Edition, DEFAULT_EDITION};
16 use rustc_span::symbol::sym;
17 use rustc_target::spec::{MergeFunctions, PanicStrategy, RelroLevel};
18 use std::collections::{BTreeMap, BTreeSet};
19 use std::iter::FromIterator;
20 use std::path::PathBuf;
22 type CfgSpecs = FxHashSet<(String, Option<String>)>;
24 fn build_session_options_and_crate_config(matches: getopts::Matches) -> (Options, CfgSpecs) {
25 let sessopts = build_session_options(&matches);
26 let cfg = parse_cfgspecs(matches.opt_strs("cfg"));
30 fn mk_session(matches: getopts::Matches) -> (Session, CfgSpecs) {
31 let registry = registry::Registry::new(&[]);
32 let (sessopts, cfg) = build_session_options_and_crate_config(matches);
33 let sess = build_session(sessopts, None, registry);
37 fn new_public_extern_entry<S, I>(locations: I) -> ExternEntry
40 I: IntoIterator<Item = S>,
42 let locations: BTreeSet<_> = locations.into_iter().map(|s| s.into()).collect();
45 location: ExternLocation::ExactPaths(locations),
46 is_private_dep: false,
51 fn optgroups() -> getopts::Options {
52 let mut opts = getopts::Options::new();
53 for group in rustc_optgroups() {
54 (group.apply)(&mut opts);
59 fn mk_map<K: Ord, V>(entries: Vec<(K, V)>) -> BTreeMap<K, V> {
60 BTreeMap::from_iter(entries.into_iter())
63 // When the user supplies --test we should implicitly supply --cfg test
65 fn test_switch_implies_cfg_test() {
66 rustc_ast::with_default_globals(|| {
67 let matches = optgroups().parse(&["--test".to_string()]).unwrap();
68 let (sess, cfg) = mk_session(matches);
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 another --cfg test
76 fn test_switch_implies_cfg_test_unless_cfg_test() {
77 rustc_ast::with_default_globals(|| {
78 let matches = optgroups().parse(&["--test".to_string(), "--cfg=test".to_string()]).unwrap();
79 let (sess, cfg) = mk_session(matches);
80 let cfg = build_configuration(&sess, to_crate_config(cfg));
81 let mut test_items = cfg.iter().filter(|&&(name, _)| name == sym::test);
82 assert!(test_items.next().is_some());
83 assert!(test_items.next().is_none());
88 fn test_can_print_warnings() {
89 rustc_ast::with_default_globals(|| {
90 let matches = optgroups().parse(&["-Awarnings".to_string()]).unwrap();
91 let (sess, _) = mk_session(matches);
92 assert!(!sess.diagnostic().can_emit_warnings());
95 rustc_ast::with_default_globals(|| {
97 optgroups().parse(&["-Awarnings".to_string(), "-Dwarnings".to_string()]).unwrap();
98 let (sess, _) = mk_session(matches);
99 assert!(sess.diagnostic().can_emit_warnings());
102 rustc_ast::with_default_globals(|| {
103 let matches = optgroups().parse(&["-Adead_code".to_string()]).unwrap();
104 let (sess, _) = mk_session(matches);
105 assert!(sess.diagnostic().can_emit_warnings());
110 fn test_output_types_tracking_hash_different_paths() {
111 let mut v1 = Options::default();
112 let mut v2 = Options::default();
113 let mut v3 = Options::default();
115 v1.output_types = OutputTypes::new(&[(OutputType::Exe, Some(PathBuf::from("./some/thing")))]);
116 v2.output_types = OutputTypes::new(&[(OutputType::Exe, Some(PathBuf::from("/some/thing")))]);
117 v3.output_types = OutputTypes::new(&[(OutputType::Exe, None)]);
119 assert!(v1.dep_tracking_hash() != v2.dep_tracking_hash());
120 assert!(v1.dep_tracking_hash() != v3.dep_tracking_hash());
121 assert!(v2.dep_tracking_hash() != v3.dep_tracking_hash());
124 assert_eq!(v1.dep_tracking_hash(), v1.clone().dep_tracking_hash());
125 assert_eq!(v2.dep_tracking_hash(), v2.clone().dep_tracking_hash());
126 assert_eq!(v3.dep_tracking_hash(), v3.clone().dep_tracking_hash());
130 fn test_output_types_tracking_hash_different_construction_order() {
131 let mut v1 = Options::default();
132 let mut v2 = Options::default();
134 v1.output_types = OutputTypes::new(&[
135 (OutputType::Exe, Some(PathBuf::from("./some/thing"))),
136 (OutputType::Bitcode, Some(PathBuf::from("./some/thing.bc"))),
139 v2.output_types = OutputTypes::new(&[
140 (OutputType::Bitcode, Some(PathBuf::from("./some/thing.bc"))),
141 (OutputType::Exe, Some(PathBuf::from("./some/thing"))),
144 assert_eq!(v1.dep_tracking_hash(), v2.dep_tracking_hash());
147 assert_eq!(v1.dep_tracking_hash(), v1.clone().dep_tracking_hash());
151 fn test_externs_tracking_hash_different_construction_order() {
152 let mut v1 = Options::default();
153 let mut v2 = Options::default();
154 let mut v3 = Options::default();
156 v1.externs = Externs::new(mk_map(vec![
157 (String::from("a"), new_public_extern_entry(vec!["b", "c"])),
158 (String::from("d"), new_public_extern_entry(vec!["e", "f"])),
161 v2.externs = Externs::new(mk_map(vec![
162 (String::from("d"), new_public_extern_entry(vec!["e", "f"])),
163 (String::from("a"), new_public_extern_entry(vec!["b", "c"])),
166 v3.externs = Externs::new(mk_map(vec![
167 (String::from("a"), new_public_extern_entry(vec!["b", "c"])),
168 (String::from("d"), new_public_extern_entry(vec!["f", "e"])),
171 assert_eq!(v1.dep_tracking_hash(), v2.dep_tracking_hash());
172 assert_eq!(v1.dep_tracking_hash(), v3.dep_tracking_hash());
173 assert_eq!(v2.dep_tracking_hash(), v3.dep_tracking_hash());
176 assert_eq!(v1.dep_tracking_hash(), v1.clone().dep_tracking_hash());
177 assert_eq!(v2.dep_tracking_hash(), v2.clone().dep_tracking_hash());
178 assert_eq!(v3.dep_tracking_hash(), v3.clone().dep_tracking_hash());
182 fn test_lints_tracking_hash_different_values() {
183 let mut v1 = Options::default();
184 let mut v2 = Options::default();
185 let mut v3 = Options::default();
188 (String::from("a"), Level::Allow),
189 (String::from("b"), Level::Warn),
190 (String::from("c"), Level::Deny),
191 (String::from("d"), Level::Forbid),
195 (String::from("a"), Level::Allow),
196 (String::from("b"), Level::Warn),
197 (String::from("X"), Level::Deny),
198 (String::from("d"), Level::Forbid),
202 (String::from("a"), Level::Allow),
203 (String::from("b"), Level::Warn),
204 (String::from("c"), Level::Forbid),
205 (String::from("d"), Level::Deny),
208 assert!(v1.dep_tracking_hash() != v2.dep_tracking_hash());
209 assert!(v1.dep_tracking_hash() != v3.dep_tracking_hash());
210 assert!(v2.dep_tracking_hash() != v3.dep_tracking_hash());
213 assert_eq!(v1.dep_tracking_hash(), v1.clone().dep_tracking_hash());
214 assert_eq!(v2.dep_tracking_hash(), v2.clone().dep_tracking_hash());
215 assert_eq!(v3.dep_tracking_hash(), v3.clone().dep_tracking_hash());
219 fn test_lints_tracking_hash_different_construction_order() {
220 let mut v1 = Options::default();
221 let mut v2 = Options::default();
224 (String::from("a"), Level::Allow),
225 (String::from("b"), Level::Warn),
226 (String::from("c"), Level::Deny),
227 (String::from("d"), Level::Forbid),
231 (String::from("a"), Level::Allow),
232 (String::from("c"), Level::Deny),
233 (String::from("b"), Level::Warn),
234 (String::from("d"), Level::Forbid),
237 assert_eq!(v1.dep_tracking_hash(), v2.dep_tracking_hash());
240 assert_eq!(v1.dep_tracking_hash(), v1.clone().dep_tracking_hash());
241 assert_eq!(v2.dep_tracking_hash(), v2.clone().dep_tracking_hash());
245 fn test_search_paths_tracking_hash_different_order() {
246 let mut v1 = Options::default();
247 let mut v2 = Options::default();
248 let mut v3 = Options::default();
249 let mut v4 = Options::default();
251 const JSON: ErrorOutputType = ErrorOutputType::Json {
253 json_rendered: HumanReadableErrorType::Default(ColorConfig::Never),
257 v1.search_paths.push(SearchPath::from_cli_opt("native=abc", JSON));
258 v1.search_paths.push(SearchPath::from_cli_opt("crate=def", JSON));
259 v1.search_paths.push(SearchPath::from_cli_opt("dependency=ghi", JSON));
260 v1.search_paths.push(SearchPath::from_cli_opt("framework=jkl", JSON));
261 v1.search_paths.push(SearchPath::from_cli_opt("all=mno", JSON));
263 v2.search_paths.push(SearchPath::from_cli_opt("native=abc", JSON));
264 v2.search_paths.push(SearchPath::from_cli_opt("dependency=ghi", JSON));
265 v2.search_paths.push(SearchPath::from_cli_opt("crate=def", JSON));
266 v2.search_paths.push(SearchPath::from_cli_opt("framework=jkl", JSON));
267 v2.search_paths.push(SearchPath::from_cli_opt("all=mno", JSON));
269 v3.search_paths.push(SearchPath::from_cli_opt("crate=def", JSON));
270 v3.search_paths.push(SearchPath::from_cli_opt("framework=jkl", JSON));
271 v3.search_paths.push(SearchPath::from_cli_opt("native=abc", JSON));
272 v3.search_paths.push(SearchPath::from_cli_opt("dependency=ghi", JSON));
273 v3.search_paths.push(SearchPath::from_cli_opt("all=mno", JSON));
275 v4.search_paths.push(SearchPath::from_cli_opt("all=mno", JSON));
276 v4.search_paths.push(SearchPath::from_cli_opt("native=abc", JSON));
277 v4.search_paths.push(SearchPath::from_cli_opt("crate=def", JSON));
278 v4.search_paths.push(SearchPath::from_cli_opt("dependency=ghi", JSON));
279 v4.search_paths.push(SearchPath::from_cli_opt("framework=jkl", JSON));
281 assert!(v1.dep_tracking_hash() == v2.dep_tracking_hash());
282 assert!(v1.dep_tracking_hash() == v3.dep_tracking_hash());
283 assert!(v1.dep_tracking_hash() == v4.dep_tracking_hash());
286 assert_eq!(v1.dep_tracking_hash(), v1.clone().dep_tracking_hash());
287 assert_eq!(v2.dep_tracking_hash(), v2.clone().dep_tracking_hash());
288 assert_eq!(v3.dep_tracking_hash(), v3.clone().dep_tracking_hash());
289 assert_eq!(v4.dep_tracking_hash(), v4.clone().dep_tracking_hash());
293 fn test_native_libs_tracking_hash_different_values() {
294 let mut v1 = Options::default();
295 let mut v2 = Options::default();
296 let mut v3 = Options::default();
297 let mut v4 = Options::default();
301 (String::from("a"), None, Some(cstore::NativeStatic)),
302 (String::from("b"), None, Some(cstore::NativeFramework)),
303 (String::from("c"), None, Some(cstore::NativeUnknown)),
308 (String::from("a"), None, Some(cstore::NativeStatic)),
309 (String::from("X"), None, Some(cstore::NativeFramework)),
310 (String::from("c"), None, Some(cstore::NativeUnknown)),
315 (String::from("a"), None, Some(cstore::NativeStatic)),
316 (String::from("b"), None, Some(cstore::NativeStatic)),
317 (String::from("c"), None, Some(cstore::NativeUnknown)),
322 (String::from("a"), None, Some(cstore::NativeStatic)),
323 (String::from("b"), Some(String::from("X")), Some(cstore::NativeFramework)),
324 (String::from("c"), None, Some(cstore::NativeUnknown)),
327 assert!(v1.dep_tracking_hash() != v2.dep_tracking_hash());
328 assert!(v1.dep_tracking_hash() != v3.dep_tracking_hash());
329 assert!(v1.dep_tracking_hash() != v4.dep_tracking_hash());
332 assert_eq!(v1.dep_tracking_hash(), v1.clone().dep_tracking_hash());
333 assert_eq!(v2.dep_tracking_hash(), v2.clone().dep_tracking_hash());
334 assert_eq!(v3.dep_tracking_hash(), v3.clone().dep_tracking_hash());
335 assert_eq!(v4.dep_tracking_hash(), v4.clone().dep_tracking_hash());
339 fn test_native_libs_tracking_hash_different_order() {
340 let mut v1 = Options::default();
341 let mut v2 = Options::default();
342 let mut v3 = Options::default();
346 (String::from("a"), None, Some(cstore::NativeStatic)),
347 (String::from("b"), None, Some(cstore::NativeFramework)),
348 (String::from("c"), None, Some(cstore::NativeUnknown)),
352 (String::from("b"), None, Some(cstore::NativeFramework)),
353 (String::from("a"), None, Some(cstore::NativeStatic)),
354 (String::from("c"), None, Some(cstore::NativeUnknown)),
358 (String::from("c"), None, Some(cstore::NativeUnknown)),
359 (String::from("a"), None, Some(cstore::NativeStatic)),
360 (String::from("b"), None, Some(cstore::NativeFramework)),
363 assert!(v1.dep_tracking_hash() == v2.dep_tracking_hash());
364 assert!(v1.dep_tracking_hash() == v3.dep_tracking_hash());
365 assert!(v2.dep_tracking_hash() == v3.dep_tracking_hash());
368 assert_eq!(v1.dep_tracking_hash(), v1.clone().dep_tracking_hash());
369 assert_eq!(v2.dep_tracking_hash(), v2.clone().dep_tracking_hash());
370 assert_eq!(v3.dep_tracking_hash(), v3.clone().dep_tracking_hash());
374 fn test_codegen_options_tracking_hash() {
375 let reference = Options::default();
376 let mut opts = Options::default();
378 // Make sure the changing an [UNTRACKED] option leaves the hash unchanged
379 opts.cg.ar = Some(String::from("abc"));
380 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
382 opts.cg.linker = Some(PathBuf::from("linker"));
383 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
385 opts.cg.link_args = Some(vec![String::from("abc"), String::from("def")]);
386 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
388 opts.cg.link_dead_code = true;
389 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
391 opts.cg.rpath = true;
392 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
394 opts.cg.extra_filename = String::from("extra-filename");
395 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
397 opts.cg.codegen_units = Some(42);
398 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
400 opts.cg.remark = Passes::Some(vec![String::from("pass1"), String::from("pass2")]);
401 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
403 opts.cg.save_temps = true;
404 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
406 opts.cg.incremental = Some(String::from("abc"));
407 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
409 // Make sure changing a [TRACKED] option changes the hash
410 opts = reference.clone();
411 opts.cg.lto = LtoCli::Fat;
412 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
414 opts = reference.clone();
415 opts.cg.target_cpu = Some(String::from("abc"));
416 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
418 opts = reference.clone();
419 opts.cg.target_feature = String::from("all the features, all of them");
420 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
422 opts = reference.clone();
423 opts.cg.passes = vec![String::from("1"), String::from("2")];
424 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
426 opts = reference.clone();
427 opts.cg.llvm_args = vec![String::from("1"), String::from("2")];
428 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
430 opts = reference.clone();
431 opts.cg.overflow_checks = Some(true);
432 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
434 opts = reference.clone();
435 opts.cg.no_prepopulate_passes = true;
436 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
438 opts = reference.clone();
439 opts.cg.no_vectorize_loops = true;
440 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
442 opts = reference.clone();
443 opts.cg.no_vectorize_slp = true;
444 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
446 opts = reference.clone();
447 opts.cg.soft_float = true;
448 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
450 opts = reference.clone();
451 opts.cg.prefer_dynamic = true;
452 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
454 opts = reference.clone();
455 opts.cg.no_integrated_as = true;
456 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
458 opts = reference.clone();
459 opts.cg.no_redzone = Some(true);
460 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
462 opts = reference.clone();
463 opts.cg.relocation_model = Some(String::from("relocation model"));
464 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
466 opts = reference.clone();
467 opts.cg.code_model = Some(String::from("code model"));
468 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
470 opts = reference.clone();
471 opts.debugging_opts.tls_model = Some(String::from("tls model"));
472 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
474 opts = reference.clone();
475 opts.cg.profile_generate = SwitchWithOptPath::Enabled(None);
476 assert_ne!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
478 opts = reference.clone();
479 opts.cg.profile_use = Some(PathBuf::from("abc"));
480 assert_ne!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
482 opts = reference.clone();
483 opts.cg.metadata = vec![String::from("A"), String::from("B")];
484 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
486 opts = reference.clone();
487 opts.cg.debuginfo = Some(0xdeadbeef);
488 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
490 opts = reference.clone();
491 opts.cg.debuginfo = Some(0xba5eba11);
492 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
494 opts = reference.clone();
495 opts.cg.force_frame_pointers = Some(false);
496 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
498 opts = reference.clone();
499 opts.cg.debug_assertions = Some(true);
500 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
502 opts = reference.clone();
503 opts.cg.inline_threshold = Some(0xf007ba11);
504 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
506 opts = reference.clone();
507 opts.cg.panic = Some(PanicStrategy::Abort);
508 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
510 opts = reference.clone();
511 opts.cg.linker_plugin_lto = LinkerPluginLto::LinkerPluginAuto;
512 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
516 fn test_debugging_options_tracking_hash() {
517 let reference = Options::default();
518 let mut opts = Options::default();
520 // Make sure the changing an [UNTRACKED] option leaves the hash unchanged
521 opts.debugging_opts.verbose = true;
522 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
523 opts.debugging_opts.time_passes = true;
524 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
525 opts.debugging_opts.time_llvm_passes = true;
526 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
527 opts.debugging_opts.input_stats = true;
528 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
529 opts.debugging_opts.borrowck_stats = true;
530 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
531 opts.debugging_opts.meta_stats = true;
532 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
533 opts.debugging_opts.print_link_args = true;
534 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
535 opts.debugging_opts.print_llvm_passes = true;
536 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
537 opts.debugging_opts.ast_json = true;
538 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
539 opts.debugging_opts.ast_json_noexpand = true;
540 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
541 opts.debugging_opts.ls = true;
542 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
543 opts.debugging_opts.save_analysis = true;
544 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
545 opts.debugging_opts.print_region_graph = true;
546 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
547 opts.debugging_opts.parse_only = true;
548 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
549 opts.debugging_opts.incremental = Some(String::from("abc"));
550 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
551 opts.debugging_opts.dump_dep_graph = true;
552 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
553 opts.debugging_opts.query_dep_graph = true;
554 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
555 opts.debugging_opts.no_analysis = true;
556 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
557 opts.debugging_opts.unstable_options = true;
558 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
559 opts.debugging_opts.trace_macros = true;
560 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
561 opts.debugging_opts.keep_hygiene_data = true;
562 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
563 opts.debugging_opts.keep_ast = true;
564 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
565 opts.debugging_opts.print_mono_items = Some(String::from("abc"));
566 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
567 opts.debugging_opts.dump_mir = Some(String::from("abc"));
568 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
569 opts.debugging_opts.dump_mir_dir = String::from("abc");
570 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
571 opts.debugging_opts.dump_mir_graphviz = true;
572 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
574 // Make sure changing a [TRACKED] option changes the hash
575 opts = reference.clone();
576 opts.debugging_opts.asm_comments = true;
577 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
579 opts = reference.clone();
580 opts.debugging_opts.verify_llvm_ir = true;
581 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
583 opts = reference.clone();
584 opts.debugging_opts.no_landing_pads = true;
585 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
587 opts = reference.clone();
588 opts.debugging_opts.fewer_names = true;
589 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
591 opts = reference.clone();
592 opts.debugging_opts.no_codegen = true;
593 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
595 opts = reference.clone();
596 opts.debugging_opts.treat_err_as_bug = Some(1);
597 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
599 opts = reference.clone();
600 opts.debugging_opts.report_delayed_bugs = true;
601 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
603 opts = reference.clone();
604 opts.debugging_opts.force_overflow_checks = Some(true);
605 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
607 opts = reference.clone();
608 opts.debugging_opts.show_span = Some(String::from("abc"));
609 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
611 opts = reference.clone();
612 opts.debugging_opts.mir_opt_level = 3;
613 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
615 opts = reference.clone();
616 opts.debugging_opts.relro_level = Some(RelroLevel::Full);
617 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
619 opts = reference.clone();
620 opts.debugging_opts.merge_functions = Some(MergeFunctions::Disabled);
621 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
623 opts = reference.clone();
624 opts.debugging_opts.allow_features = Some(vec![String::from("lang_items")]);
625 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
627 opts = reference.clone();
628 opts.debugging_opts.symbol_mangling_version = SymbolManglingVersion::V0;
629 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
633 fn test_edition_parsing() {
634 // test default edition
635 let options = Options::default();
636 assert!(options.edition == DEFAULT_EDITION);
638 let matches = optgroups().parse(&["--edition=2018".to_string()]).unwrap();
639 let (sessopts, _) = build_session_options_and_crate_config(matches);
640 assert!(sessopts.edition == Edition::Edition2018)