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;
23 type CfgSpecs = FxHashSet<(String, Option<String>)>;
25 fn build_session_options_and_crate_config(matches: getopts::Matches) -> (Options, CfgSpecs) {
26 let sessopts = build_session_options(&matches);
27 let cfg = parse_cfgspecs(matches.opt_strs("cfg"));
31 fn mk_session(matches: getopts::Matches) -> (Session, CfgSpecs) {
32 let registry = registry::Registry::new(&[]);
33 let (sessopts, cfg) = build_session_options_and_crate_config(matches);
34 let sess = build_session(sessopts, None, registry);
38 fn new_public_extern_entry<S, I>(locations: I) -> ExternEntry
41 I: IntoIterator<Item = S>,
43 let locations: BTreeSet<_> = locations.into_iter().map(|s| s.into()).collect();
46 location: ExternLocation::ExactPaths(locations),
47 is_private_dep: false,
52 fn optgroups() -> getopts::Options {
53 let mut opts = getopts::Options::new();
54 for group in rustc_optgroups() {
55 (group.apply)(&mut opts);
60 fn mk_map<K: Ord, V>(entries: Vec<(K, V)>) -> BTreeMap<K, V> {
61 BTreeMap::from_iter(entries.into_iter())
64 // When the user supplies --test we should implicitly supply --cfg test
66 fn test_switch_implies_cfg_test() {
67 syntax::with_default_globals(|| {
68 let matches = optgroups().parse(&["--test".to_string()]).unwrap();
69 let (sess, cfg) = mk_session(matches);
70 let cfg = build_configuration(&sess, to_crate_config(cfg));
71 assert!(cfg.contains(&(sym::test, None)));
75 // When the user supplies --test and --cfg test, don't implicitly add another --cfg test
77 fn test_switch_implies_cfg_test_unless_cfg_test() {
78 syntax::with_default_globals(|| {
79 let matches = optgroups().parse(&["--test".to_string(), "--cfg=test".to_string()]).unwrap();
80 let (sess, cfg) = mk_session(matches);
81 let cfg = build_configuration(&sess, to_crate_config(cfg));
82 let mut test_items = cfg.iter().filter(|&&(name, _)| name == sym::test);
83 assert!(test_items.next().is_some());
84 assert!(test_items.next().is_none());
89 fn test_can_print_warnings() {
90 syntax::with_default_globals(|| {
91 let matches = optgroups().parse(&["-Awarnings".to_string()]).unwrap();
92 let (sess, _) = mk_session(matches);
93 assert!(!sess.diagnostic().can_emit_warnings());
96 syntax::with_default_globals(|| {
98 optgroups().parse(&["-Awarnings".to_string(), "-Dwarnings".to_string()]).unwrap();
99 let (sess, _) = mk_session(matches);
100 assert!(sess.diagnostic().can_emit_warnings());
103 syntax::with_default_globals(|| {
104 let matches = optgroups().parse(&["-Adead_code".to_string()]).unwrap();
105 let (sess, _) = mk_session(matches);
106 assert!(sess.diagnostic().can_emit_warnings());
111 fn test_output_types_tracking_hash_different_paths() {
112 let mut v1 = Options::default();
113 let mut v2 = Options::default();
114 let mut v3 = Options::default();
116 v1.output_types = OutputTypes::new(&[(OutputType::Exe, Some(PathBuf::from("./some/thing")))]);
117 v2.output_types = OutputTypes::new(&[(OutputType::Exe, Some(PathBuf::from("/some/thing")))]);
118 v3.output_types = OutputTypes::new(&[(OutputType::Exe, None)]);
120 assert!(v1.dep_tracking_hash() != v2.dep_tracking_hash());
121 assert!(v1.dep_tracking_hash() != v3.dep_tracking_hash());
122 assert!(v2.dep_tracking_hash() != v3.dep_tracking_hash());
125 assert_eq!(v1.dep_tracking_hash(), v1.clone().dep_tracking_hash());
126 assert_eq!(v2.dep_tracking_hash(), v2.clone().dep_tracking_hash());
127 assert_eq!(v3.dep_tracking_hash(), v3.clone().dep_tracking_hash());
131 fn test_output_types_tracking_hash_different_construction_order() {
132 let mut v1 = Options::default();
133 let mut v2 = Options::default();
135 v1.output_types = OutputTypes::new(&[
136 (OutputType::Exe, Some(PathBuf::from("./some/thing"))),
137 (OutputType::Bitcode, Some(PathBuf::from("./some/thing.bc"))),
140 v2.output_types = OutputTypes::new(&[
141 (OutputType::Bitcode, Some(PathBuf::from("./some/thing.bc"))),
142 (OutputType::Exe, Some(PathBuf::from("./some/thing"))),
145 assert_eq!(v1.dep_tracking_hash(), v2.dep_tracking_hash());
148 assert_eq!(v1.dep_tracking_hash(), v1.clone().dep_tracking_hash());
152 fn test_externs_tracking_hash_different_construction_order() {
153 let mut v1 = Options::default();
154 let mut v2 = Options::default();
155 let mut v3 = Options::default();
157 v1.externs = Externs::new(mk_map(vec![
158 (String::from("a"), new_public_extern_entry(vec!["b", "c"])),
159 (String::from("d"), new_public_extern_entry(vec!["e", "f"])),
162 v2.externs = Externs::new(mk_map(vec![
163 (String::from("d"), new_public_extern_entry(vec!["e", "f"])),
164 (String::from("a"), new_public_extern_entry(vec!["b", "c"])),
167 v3.externs = Externs::new(mk_map(vec![
168 (String::from("a"), new_public_extern_entry(vec!["b", "c"])),
169 (String::from("d"), new_public_extern_entry(vec!["f", "e"])),
172 assert_eq!(v1.dep_tracking_hash(), v2.dep_tracking_hash());
173 assert_eq!(v1.dep_tracking_hash(), v3.dep_tracking_hash());
174 assert_eq!(v2.dep_tracking_hash(), v3.dep_tracking_hash());
177 assert_eq!(v1.dep_tracking_hash(), v1.clone().dep_tracking_hash());
178 assert_eq!(v2.dep_tracking_hash(), v2.clone().dep_tracking_hash());
179 assert_eq!(v3.dep_tracking_hash(), v3.clone().dep_tracking_hash());
183 fn test_lints_tracking_hash_different_values() {
184 let mut v1 = Options::default();
185 let mut v2 = Options::default();
186 let mut v3 = Options::default();
189 (String::from("a"), Level::Allow),
190 (String::from("b"), Level::Warn),
191 (String::from("c"), Level::Deny),
192 (String::from("d"), Level::Forbid),
196 (String::from("a"), Level::Allow),
197 (String::from("b"), Level::Warn),
198 (String::from("X"), Level::Deny),
199 (String::from("d"), Level::Forbid),
203 (String::from("a"), Level::Allow),
204 (String::from("b"), Level::Warn),
205 (String::from("c"), Level::Forbid),
206 (String::from("d"), Level::Deny),
209 assert!(v1.dep_tracking_hash() != v2.dep_tracking_hash());
210 assert!(v1.dep_tracking_hash() != v3.dep_tracking_hash());
211 assert!(v2.dep_tracking_hash() != v3.dep_tracking_hash());
214 assert_eq!(v1.dep_tracking_hash(), v1.clone().dep_tracking_hash());
215 assert_eq!(v2.dep_tracking_hash(), v2.clone().dep_tracking_hash());
216 assert_eq!(v3.dep_tracking_hash(), v3.clone().dep_tracking_hash());
220 fn test_lints_tracking_hash_different_construction_order() {
221 let mut v1 = Options::default();
222 let mut v2 = 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("c"), Level::Deny),
234 (String::from("b"), Level::Warn),
235 (String::from("d"), Level::Forbid),
238 assert_eq!(v1.dep_tracking_hash(), v2.dep_tracking_hash());
241 assert_eq!(v1.dep_tracking_hash(), v1.clone().dep_tracking_hash());
242 assert_eq!(v2.dep_tracking_hash(), v2.clone().dep_tracking_hash());
246 fn test_search_paths_tracking_hash_different_order() {
247 let mut v1 = Options::default();
248 let mut v2 = Options::default();
249 let mut v3 = Options::default();
250 let mut v4 = Options::default();
252 const JSON: ErrorOutputType = ErrorOutputType::Json {
254 json_rendered: HumanReadableErrorType::Default(ColorConfig::Never),
258 v1.search_paths.push(SearchPath::from_cli_opt("native=abc", JSON));
259 v1.search_paths.push(SearchPath::from_cli_opt("crate=def", JSON));
260 v1.search_paths.push(SearchPath::from_cli_opt("dependency=ghi", JSON));
261 v1.search_paths.push(SearchPath::from_cli_opt("framework=jkl", JSON));
262 v1.search_paths.push(SearchPath::from_cli_opt("all=mno", JSON));
264 v2.search_paths.push(SearchPath::from_cli_opt("native=abc", JSON));
265 v2.search_paths.push(SearchPath::from_cli_opt("dependency=ghi", JSON));
266 v2.search_paths.push(SearchPath::from_cli_opt("crate=def", JSON));
267 v2.search_paths.push(SearchPath::from_cli_opt("framework=jkl", JSON));
268 v2.search_paths.push(SearchPath::from_cli_opt("all=mno", JSON));
270 v3.search_paths.push(SearchPath::from_cli_opt("crate=def", JSON));
271 v3.search_paths.push(SearchPath::from_cli_opt("framework=jkl", JSON));
272 v3.search_paths.push(SearchPath::from_cli_opt("native=abc", JSON));
273 v3.search_paths.push(SearchPath::from_cli_opt("dependency=ghi", JSON));
274 v3.search_paths.push(SearchPath::from_cli_opt("all=mno", JSON));
276 v4.search_paths.push(SearchPath::from_cli_opt("all=mno", JSON));
277 v4.search_paths.push(SearchPath::from_cli_opt("native=abc", JSON));
278 v4.search_paths.push(SearchPath::from_cli_opt("crate=def", JSON));
279 v4.search_paths.push(SearchPath::from_cli_opt("dependency=ghi", JSON));
280 v4.search_paths.push(SearchPath::from_cli_opt("framework=jkl", JSON));
282 assert!(v1.dep_tracking_hash() == v2.dep_tracking_hash());
283 assert!(v1.dep_tracking_hash() == v3.dep_tracking_hash());
284 assert!(v1.dep_tracking_hash() == v4.dep_tracking_hash());
287 assert_eq!(v1.dep_tracking_hash(), v1.clone().dep_tracking_hash());
288 assert_eq!(v2.dep_tracking_hash(), v2.clone().dep_tracking_hash());
289 assert_eq!(v3.dep_tracking_hash(), v3.clone().dep_tracking_hash());
290 assert_eq!(v4.dep_tracking_hash(), v4.clone().dep_tracking_hash());
294 fn test_native_libs_tracking_hash_different_values() {
295 let mut v1 = Options::default();
296 let mut v2 = Options::default();
297 let mut v3 = Options::default();
298 let mut v4 = Options::default();
302 (String::from("a"), None, Some(cstore::NativeStatic)),
303 (String::from("b"), None, Some(cstore::NativeFramework)),
304 (String::from("c"), None, Some(cstore::NativeUnknown)),
309 (String::from("a"), None, Some(cstore::NativeStatic)),
310 (String::from("X"), None, Some(cstore::NativeFramework)),
311 (String::from("c"), None, Some(cstore::NativeUnknown)),
316 (String::from("a"), None, Some(cstore::NativeStatic)),
317 (String::from("b"), None, Some(cstore::NativeStatic)),
318 (String::from("c"), None, Some(cstore::NativeUnknown)),
323 (String::from("a"), None, Some(cstore::NativeStatic)),
324 (String::from("b"), Some(String::from("X")), Some(cstore::NativeFramework)),
325 (String::from("c"), None, Some(cstore::NativeUnknown)),
328 assert!(v1.dep_tracking_hash() != v2.dep_tracking_hash());
329 assert!(v1.dep_tracking_hash() != v3.dep_tracking_hash());
330 assert!(v1.dep_tracking_hash() != v4.dep_tracking_hash());
333 assert_eq!(v1.dep_tracking_hash(), v1.clone().dep_tracking_hash());
334 assert_eq!(v2.dep_tracking_hash(), v2.clone().dep_tracking_hash());
335 assert_eq!(v3.dep_tracking_hash(), v3.clone().dep_tracking_hash());
336 assert_eq!(v4.dep_tracking_hash(), v4.clone().dep_tracking_hash());
340 fn test_native_libs_tracking_hash_different_order() {
341 let mut v1 = Options::default();
342 let mut v2 = Options::default();
343 let mut v3 = Options::default();
347 (String::from("a"), None, Some(cstore::NativeStatic)),
348 (String::from("b"), None, Some(cstore::NativeFramework)),
349 (String::from("c"), None, Some(cstore::NativeUnknown)),
353 (String::from("b"), None, Some(cstore::NativeFramework)),
354 (String::from("a"), None, Some(cstore::NativeStatic)),
355 (String::from("c"), None, Some(cstore::NativeUnknown)),
359 (String::from("c"), None, Some(cstore::NativeUnknown)),
360 (String::from("a"), None, Some(cstore::NativeStatic)),
361 (String::from("b"), None, Some(cstore::NativeFramework)),
364 assert!(v1.dep_tracking_hash() == v2.dep_tracking_hash());
365 assert!(v1.dep_tracking_hash() == v3.dep_tracking_hash());
366 assert!(v2.dep_tracking_hash() == v3.dep_tracking_hash());
369 assert_eq!(v1.dep_tracking_hash(), v1.clone().dep_tracking_hash());
370 assert_eq!(v2.dep_tracking_hash(), v2.clone().dep_tracking_hash());
371 assert_eq!(v3.dep_tracking_hash(), v3.clone().dep_tracking_hash());
375 fn test_codegen_options_tracking_hash() {
376 let reference = Options::default();
377 let mut opts = Options::default();
379 // Make sure the changing an [UNTRACKED] option leaves the hash unchanged
380 opts.cg.ar = Some(String::from("abc"));
381 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
383 opts.cg.linker = Some(PathBuf::from("linker"));
384 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
386 opts.cg.link_args = Some(vec![String::from("abc"), String::from("def")]);
387 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
389 opts.cg.link_dead_code = true;
390 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
392 opts.cg.rpath = true;
393 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
395 opts.cg.extra_filename = String::from("extra-filename");
396 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
398 opts.cg.codegen_units = Some(42);
399 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
401 opts.cg.remark = Passes::Some(vec![String::from("pass1"), String::from("pass2")]);
402 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
404 opts.cg.save_temps = true;
405 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
407 opts.cg.incremental = Some(String::from("abc"));
408 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
410 // Make sure changing a [TRACKED] option changes the hash
411 opts = reference.clone();
412 opts.cg.lto = LtoCli::Fat;
413 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
415 opts = reference.clone();
416 opts.cg.target_cpu = Some(String::from("abc"));
417 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
419 opts = reference.clone();
420 opts.cg.target_feature = String::from("all the features, all of them");
421 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
423 opts = reference.clone();
424 opts.cg.passes = vec![String::from("1"), String::from("2")];
425 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
427 opts = reference.clone();
428 opts.cg.llvm_args = vec![String::from("1"), String::from("2")];
429 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
431 opts = reference.clone();
432 opts.cg.overflow_checks = Some(true);
433 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
435 opts = reference.clone();
436 opts.cg.no_prepopulate_passes = true;
437 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
439 opts = reference.clone();
440 opts.cg.no_vectorize_loops = true;
441 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
443 opts = reference.clone();
444 opts.cg.no_vectorize_slp = true;
445 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
447 opts = reference.clone();
448 opts.cg.soft_float = true;
449 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
451 opts = reference.clone();
452 opts.cg.prefer_dynamic = true;
453 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
455 opts = reference.clone();
456 opts.cg.no_integrated_as = true;
457 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
459 opts = reference.clone();
460 opts.cg.no_redzone = Some(true);
461 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
463 opts = reference.clone();
464 opts.cg.relocation_model = Some(String::from("relocation model"));
465 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
467 opts = reference.clone();
468 opts.cg.code_model = Some(String::from("code model"));
469 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
471 opts = reference.clone();
472 opts.debugging_opts.tls_model = Some(String::from("tls model"));
473 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
475 opts = reference.clone();
476 opts.cg.profile_generate = SwitchWithOptPath::Enabled(None);
477 assert_ne!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
479 opts = reference.clone();
480 opts.cg.profile_use = Some(PathBuf::from("abc"));
481 assert_ne!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
483 opts = reference.clone();
484 opts.cg.metadata = vec![String::from("A"), String::from("B")];
485 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
487 opts = reference.clone();
488 opts.cg.debuginfo = Some(0xdeadbeef);
489 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
491 opts = reference.clone();
492 opts.cg.debuginfo = Some(0xba5eba11);
493 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
495 opts = reference.clone();
496 opts.cg.force_frame_pointers = Some(false);
497 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
499 opts = reference.clone();
500 opts.cg.debug_assertions = Some(true);
501 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
503 opts = reference.clone();
504 opts.cg.inline_threshold = Some(0xf007ba11);
505 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
507 opts = reference.clone();
508 opts.cg.panic = Some(PanicStrategy::Abort);
509 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
511 opts = reference.clone();
512 opts.cg.linker_plugin_lto = LinkerPluginLto::LinkerPluginAuto;
513 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
517 fn test_debugging_options_tracking_hash() {
518 let reference = Options::default();
519 let mut opts = Options::default();
521 // Make sure the changing an [UNTRACKED] option leaves the hash unchanged
522 opts.debugging_opts.verbose = true;
523 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
524 opts.debugging_opts.time_passes = true;
525 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
526 opts.debugging_opts.time_llvm_passes = true;
527 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
528 opts.debugging_opts.input_stats = true;
529 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
530 opts.debugging_opts.borrowck_stats = true;
531 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
532 opts.debugging_opts.meta_stats = true;
533 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
534 opts.debugging_opts.print_link_args = true;
535 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
536 opts.debugging_opts.print_llvm_passes = true;
537 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
538 opts.debugging_opts.ast_json = true;
539 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
540 opts.debugging_opts.ast_json_noexpand = true;
541 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
542 opts.debugging_opts.ls = true;
543 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
544 opts.debugging_opts.save_analysis = true;
545 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
546 opts.debugging_opts.print_region_graph = true;
547 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
548 opts.debugging_opts.parse_only = true;
549 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
550 opts.debugging_opts.incremental = Some(String::from("abc"));
551 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
552 opts.debugging_opts.dump_dep_graph = true;
553 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
554 opts.debugging_opts.query_dep_graph = true;
555 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
556 opts.debugging_opts.no_analysis = true;
557 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
558 opts.debugging_opts.unstable_options = true;
559 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
560 opts.debugging_opts.trace_macros = true;
561 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
562 opts.debugging_opts.keep_hygiene_data = true;
563 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
564 opts.debugging_opts.keep_ast = true;
565 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
566 opts.debugging_opts.print_mono_items = Some(String::from("abc"));
567 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
568 opts.debugging_opts.dump_mir = Some(String::from("abc"));
569 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
570 opts.debugging_opts.dump_mir_dir = String::from("abc");
571 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
572 opts.debugging_opts.dump_mir_graphviz = true;
573 assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
575 // Make sure changing a [TRACKED] option changes the hash
576 opts = reference.clone();
577 opts.debugging_opts.asm_comments = true;
578 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
580 opts = reference.clone();
581 opts.debugging_opts.verify_llvm_ir = true;
582 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
584 opts = reference.clone();
585 opts.debugging_opts.no_landing_pads = true;
586 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
588 opts = reference.clone();
589 opts.debugging_opts.fewer_names = true;
590 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
592 opts = reference.clone();
593 opts.debugging_opts.no_codegen = true;
594 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
596 opts = reference.clone();
597 opts.debugging_opts.treat_err_as_bug = Some(1);
598 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
600 opts = reference.clone();
601 opts.debugging_opts.report_delayed_bugs = true;
602 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
604 opts = reference.clone();
605 opts.debugging_opts.force_overflow_checks = Some(true);
606 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
608 opts = reference.clone();
609 opts.debugging_opts.show_span = Some(String::from("abc"));
610 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
612 opts = reference.clone();
613 opts.debugging_opts.mir_opt_level = 3;
614 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
616 opts = reference.clone();
617 opts.debugging_opts.relro_level = Some(RelroLevel::Full);
618 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
620 opts = reference.clone();
621 opts.debugging_opts.merge_functions = Some(MergeFunctions::Disabled);
622 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
624 opts = reference.clone();
625 opts.debugging_opts.allow_features = Some(vec![String::from("lang_items")]);
626 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
628 opts = reference.clone();
629 opts.debugging_opts.symbol_mangling_version = SymbolManglingVersion::V0;
630 assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
634 fn test_edition_parsing() {
635 // test default edition
636 let options = Options::default();
637 assert!(options.edition == DEFAULT_EDITION);
639 let matches = optgroups().parse(&["--edition=2018".to_string()]).unwrap();
640 let (sessopts, _) = build_session_options_and_crate_config(matches);
641 assert!(sessopts.edition == Edition::Edition2018)