]> git.lizzy.rs Git - rust.git/blob - src/librustc_interface/tests.rs
Rollup merge of #71459 - divergentdave:pointer-offset-0x, r=RalfJung
[rust.git] / src / librustc_interface / tests.rs
1 use crate::interface::parse_cfgspecs;
2
3 use rustc_data_structures::fx::FxHashSet;
4 use rustc_errors::{emitter::HumanReadableErrorType, registry, ColorConfig};
5 use rustc_middle::middle::cstore;
6 use rustc_session::config::{build_configuration, build_session_options, to_crate_config};
7 use rustc_session::config::{rustc_optgroups, ErrorOutputType, ExternLocation, Options, Passes};
8 use rustc_session::config::{CFGuard, ExternEntry, LinkerPluginLto, LtoCli, SwitchWithOptPath};
9 use rustc_session::config::{Externs, OutputType, OutputTypes, Sanitizer, SymbolManglingVersion};
10 use rustc_session::getopts;
11 use rustc_session::lint::Level;
12 use rustc_session::search_paths::SearchPath;
13 use rustc_session::{build_session, Session};
14 use rustc_span::edition::{Edition, DEFAULT_EDITION};
15 use rustc_span::symbol::sym;
16 use rustc_span::SourceFileHashAlgorithm;
17 use rustc_target::spec::{LinkerFlavor, MergeFunctions, PanicStrategy, RelroLevel};
18 use std::collections::{BTreeMap, BTreeSet};
19 use std::iter::FromIterator;
20 use std::path::PathBuf;
21
22 type CfgSpecs = FxHashSet<(String, Option<String>)>;
23
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"));
27     (sessopts, cfg)
28 }
29
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);
34     (sess, cfg)
35 }
36
37 fn new_public_extern_entry<S, I>(locations: I) -> ExternEntry
38 where
39     S: Into<String>,
40     I: IntoIterator<Item = S>,
41 {
42     let locations: BTreeSet<_> = locations.into_iter().map(|s| s.into()).collect();
43
44     ExternEntry {
45         location: ExternLocation::ExactPaths(locations),
46         is_private_dep: false,
47         add_prelude: true,
48     }
49 }
50
51 fn optgroups() -> getopts::Options {
52     let mut opts = getopts::Options::new();
53     for group in rustc_optgroups() {
54         (group.apply)(&mut opts);
55     }
56     return opts;
57 }
58
59 fn mk_map<K: Ord, V>(entries: Vec<(K, V)>) -> BTreeMap<K, V> {
60     BTreeMap::from_iter(entries.into_iter())
61 }
62
63 // When the user supplies --test we should implicitly supply --cfg test
64 #[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)));
71     });
72 }
73
74 // When the user supplies --test and --cfg test, don't implicitly add another --cfg test
75 #[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());
84     });
85 }
86
87 #[test]
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());
93     });
94
95     rustc_ast::with_default_globals(|| {
96         let matches =
97             optgroups().parse(&["-Awarnings".to_string(), "-Dwarnings".to_string()]).unwrap();
98         let (sess, _) = mk_session(matches);
99         assert!(sess.diagnostic().can_emit_warnings());
100     });
101
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());
106     });
107 }
108
109 #[test]
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();
114
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)]);
118
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());
122
123     // Check clone
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());
127 }
128
129 #[test]
130 fn test_output_types_tracking_hash_different_construction_order() {
131     let mut v1 = Options::default();
132     let mut v2 = Options::default();
133
134     v1.output_types = OutputTypes::new(&[
135         (OutputType::Exe, Some(PathBuf::from("./some/thing"))),
136         (OutputType::Bitcode, Some(PathBuf::from("./some/thing.bc"))),
137     ]);
138
139     v2.output_types = OutputTypes::new(&[
140         (OutputType::Bitcode, Some(PathBuf::from("./some/thing.bc"))),
141         (OutputType::Exe, Some(PathBuf::from("./some/thing"))),
142     ]);
143
144     assert_eq!(v1.dep_tracking_hash(), v2.dep_tracking_hash());
145
146     // Check clone
147     assert_eq!(v1.dep_tracking_hash(), v1.clone().dep_tracking_hash());
148 }
149
150 #[test]
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();
155
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"])),
159     ]));
160
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"])),
164     ]));
165
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"])),
169     ]));
170
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());
174
175     // Check clone
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());
179 }
180
181 #[test]
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();
186
187     v1.lint_opts = vec![
188         (String::from("a"), Level::Allow),
189         (String::from("b"), Level::Warn),
190         (String::from("c"), Level::Deny),
191         (String::from("d"), Level::Forbid),
192     ];
193
194     v2.lint_opts = vec![
195         (String::from("a"), Level::Allow),
196         (String::from("b"), Level::Warn),
197         (String::from("X"), Level::Deny),
198         (String::from("d"), Level::Forbid),
199     ];
200
201     v3.lint_opts = vec![
202         (String::from("a"), Level::Allow),
203         (String::from("b"), Level::Warn),
204         (String::from("c"), Level::Forbid),
205         (String::from("d"), Level::Deny),
206     ];
207
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());
211
212     // Check clone
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());
216 }
217
218 #[test]
219 fn test_lints_tracking_hash_different_construction_order() {
220     let mut v1 = Options::default();
221     let mut v2 = Options::default();
222
223     v1.lint_opts = vec![
224         (String::from("a"), Level::Allow),
225         (String::from("b"), Level::Warn),
226         (String::from("c"), Level::Deny),
227         (String::from("d"), Level::Forbid),
228     ];
229
230     v2.lint_opts = vec![
231         (String::from("a"), Level::Allow),
232         (String::from("c"), Level::Deny),
233         (String::from("b"), Level::Warn),
234         (String::from("d"), Level::Forbid),
235     ];
236
237     assert_eq!(v1.dep_tracking_hash(), v2.dep_tracking_hash());
238
239     // Check clone
240     assert_eq!(v1.dep_tracking_hash(), v1.clone().dep_tracking_hash());
241     assert_eq!(v2.dep_tracking_hash(), v2.clone().dep_tracking_hash());
242 }
243
244 #[test]
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();
250
251     const JSON: ErrorOutputType = ErrorOutputType::Json {
252         pretty: false,
253         json_rendered: HumanReadableErrorType::Default(ColorConfig::Never),
254     };
255
256     // Reference
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));
262
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));
268
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));
274
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));
280
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());
284
285     // Check clone
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());
290 }
291
292 #[test]
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();
298
299     // Reference
300     v1.libs = vec![
301         (String::from("a"), None, Some(cstore::NativeStatic)),
302         (String::from("b"), None, Some(cstore::NativeFramework)),
303         (String::from("c"), None, Some(cstore::NativeUnknown)),
304     ];
305
306     // Change label
307     v2.libs = vec![
308         (String::from("a"), None, Some(cstore::NativeStatic)),
309         (String::from("X"), None, Some(cstore::NativeFramework)),
310         (String::from("c"), None, Some(cstore::NativeUnknown)),
311     ];
312
313     // Change kind
314     v3.libs = vec![
315         (String::from("a"), None, Some(cstore::NativeStatic)),
316         (String::from("b"), None, Some(cstore::NativeStatic)),
317         (String::from("c"), None, Some(cstore::NativeUnknown)),
318     ];
319
320     // Change new-name
321     v4.libs = vec![
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)),
325     ];
326
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());
330
331     // Check clone
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());
336 }
337
338 #[test]
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();
343
344     // Reference
345     v1.libs = vec![
346         (String::from("a"), None, Some(cstore::NativeStatic)),
347         (String::from("b"), None, Some(cstore::NativeFramework)),
348         (String::from("c"), None, Some(cstore::NativeUnknown)),
349     ];
350
351     v2.libs = vec![
352         (String::from("b"), None, Some(cstore::NativeFramework)),
353         (String::from("a"), None, Some(cstore::NativeStatic)),
354         (String::from("c"), None, Some(cstore::NativeUnknown)),
355     ];
356
357     v3.libs = vec![
358         (String::from("c"), None, Some(cstore::NativeUnknown)),
359         (String::from("a"), None, Some(cstore::NativeStatic)),
360         (String::from("b"), None, Some(cstore::NativeFramework)),
361     ];
362
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());
366
367     // Check clone
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());
371 }
372
373 #[test]
374 fn test_codegen_options_tracking_hash() {
375     let reference = Options::default();
376     let mut opts = Options::default();
377
378     macro_rules! untracked {
379         ($name: ident, $non_default_value: expr) => {
380             opts.cg.$name = $non_default_value;
381             assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
382         };
383     }
384
385     // Make sure that changing an [UNTRACKED] option leaves the hash unchanged.
386     // This list is in alphabetical order.
387     untracked!(ar, String::from("abc"));
388     untracked!(codegen_units, Some(42));
389     untracked!(default_linker_libraries, true);
390     untracked!(extra_filename, String::from("extra-filename"));
391     untracked!(incremental, Some(String::from("abc")));
392     // `link_arg` is omitted because it just forwards to `link_args`.
393     untracked!(link_args, vec![String::from("abc"), String::from("def")]);
394     untracked!(link_dead_code, true);
395     untracked!(linker, Some(PathBuf::from("linker")));
396     untracked!(linker_flavor, Some(LinkerFlavor::Gcc));
397     untracked!(no_stack_check, true);
398     untracked!(remark, Passes::Some(vec![String::from("pass1"), String::from("pass2")]));
399     untracked!(rpath, true);
400     untracked!(save_temps, true);
401
402     macro_rules! tracked {
403         ($name: ident, $non_default_value: expr) => {
404             opts = reference.clone();
405             opts.cg.$name = $non_default_value;
406             assert_ne!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
407         };
408     }
409
410     // Make sure that changing a [TRACKED] option changes the hash.
411     // This list is in alphabetical order.
412     tracked!(bitcode_in_rlib, false);
413     tracked!(code_model, Some(String::from("code model")));
414     tracked!(debug_assertions, Some(true));
415     tracked!(debuginfo, 0xdeadbeef);
416     tracked!(force_frame_pointers, Some(false));
417     tracked!(inline_threshold, Some(0xf007ba11));
418     tracked!(linker_plugin_lto, LinkerPluginLto::LinkerPluginAuto);
419     tracked!(llvm_args, vec![String::from("1"), String::from("2")]);
420     tracked!(lto, LtoCli::Fat);
421     tracked!(metadata, vec![String::from("A"), String::from("B")]);
422     tracked!(no_prepopulate_passes, true);
423     tracked!(no_redzone, Some(true));
424     tracked!(no_vectorize_loops, true);
425     tracked!(no_vectorize_slp, true);
426     tracked!(opt_level, "3".to_string());
427     tracked!(overflow_checks, Some(true));
428     tracked!(panic, Some(PanicStrategy::Abort));
429     tracked!(passes, vec![String::from("1"), String::from("2")]);
430     tracked!(prefer_dynamic, true);
431     tracked!(profile_generate, SwitchWithOptPath::Enabled(None));
432     tracked!(profile_use, Some(PathBuf::from("abc")));
433     tracked!(relocation_model, Some(String::from("relocation model")));
434     tracked!(soft_float, true);
435     tracked!(target_cpu, Some(String::from("abc")));
436     tracked!(target_feature, String::from("all the features, all of them"));
437 }
438
439 #[test]
440 fn test_debugging_options_tracking_hash() {
441     let reference = Options::default();
442     let mut opts = Options::default();
443
444     macro_rules! untracked {
445         ($name: ident, $non_default_value: expr) => {
446             opts.debugging_opts.$name = $non_default_value;
447             assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
448         };
449     }
450
451     // Make sure that changing an [UNTRACKED] option leaves the hash unchanged.
452     // This list is in alphabetical order.
453     untracked!(ast_json, true);
454     untracked!(ast_json_noexpand, true);
455     untracked!(borrowck, String::from("other"));
456     untracked!(borrowck_stats, true);
457     untracked!(control_flow_guard, CFGuard::Checks);
458     untracked!(deduplicate_diagnostics, true);
459     untracked!(dep_tasks, true);
460     untracked!(dont_buffer_diagnostics, true);
461     untracked!(dump_dep_graph, true);
462     untracked!(dump_mir, Some(String::from("abc")));
463     untracked!(dump_mir_dataflow, true);
464     untracked!(dump_mir_dir, String::from("abc"));
465     untracked!(dump_mir_exclude_pass_number, true);
466     untracked!(dump_mir_graphviz, true);
467     untracked!(emit_stack_sizes, true);
468     untracked!(hir_stats, true);
469     untracked!(identify_regions, true);
470     untracked!(incremental_ignore_spans, true);
471     untracked!(incremental_info, true);
472     untracked!(incremental_verify_ich, true);
473     untracked!(input_stats, true);
474     untracked!(keep_hygiene_data, true);
475     untracked!(link_native_libraries, false);
476     untracked!(llvm_time_trace, true);
477     untracked!(ls, true);
478     untracked!(macro_backtrace, true);
479     untracked!(meta_stats, true);
480     untracked!(nll_facts, true);
481     untracked!(no_analysis, true);
482     untracked!(no_interleave_lints, true);
483     untracked!(no_leak_check, true);
484     untracked!(no_parallel_llvm, true);
485     untracked!(parse_only, true);
486     untracked!(perf_stats, true);
487     untracked!(polonius, true);
488     // `pre_link_arg` is omitted because it just forwards to `pre_link_args`.
489     untracked!(pre_link_args, vec![String::from("abc"), String::from("def")]);
490     untracked!(print_link_args, true);
491     untracked!(print_llvm_passes, true);
492     untracked!(print_mono_items, Some(String::from("abc")));
493     untracked!(print_region_graph, true);
494     untracked!(print_type_sizes, true);
495     untracked!(query_dep_graph, true);
496     untracked!(query_stats, true);
497     untracked!(save_analysis, true);
498     untracked!(self_profile, SwitchWithOptPath::Enabled(None));
499     untracked!(self_profile_events, Some(vec![String::new()]));
500     untracked!(span_free_formats, true);
501     untracked!(terminal_width, Some(80));
502     untracked!(threads, 99);
503     untracked!(time, true);
504     untracked!(time_llvm_passes, true);
505     untracked!(time_passes, true);
506     untracked!(trace_macros, true);
507     untracked!(ui_testing, true);
508     untracked!(unpretty, Some("expanded".to_string()));
509     untracked!(unstable_options, true);
510     untracked!(verbose, true);
511
512     macro_rules! tracked {
513         ($name: ident, $non_default_value: expr) => {
514             opts = reference.clone();
515             opts.debugging_opts.$name = $non_default_value;
516             assert_ne!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
517         };
518     }
519
520     // Make sure that changing a [TRACKED] option changes the hash.
521     // This list is in alphabetical order.
522     tracked!(allow_features, Some(vec![String::from("lang_items")]));
523     tracked!(always_encode_mir, true);
524     tracked!(asm_comments, true);
525     tracked!(binary_dep_depinfo, true);
526     tracked!(codegen_backend, Some("abc".to_string()));
527     tracked!(crate_attr, vec!["abc".to_string()]);
528     tracked!(debug_macros, true);
529     tracked!(dep_info_omit_d_target, true);
530     tracked!(dual_proc_macros, true);
531     tracked!(embed_bitcode, true);
532     tracked!(fewer_names, true);
533     tracked!(force_overflow_checks, Some(true));
534     tracked!(force_unstable_if_unmarked, true);
535     tracked!(fuel, Some(("abc".to_string(), 99)));
536     tracked!(human_readable_cgu_names, true);
537     tracked!(inline_in_all_cgus, Some(true));
538     tracked!(insert_sideeffect, true);
539     tracked!(instrument_mcount, true);
540     tracked!(link_only, true);
541     tracked!(merge_functions, Some(MergeFunctions::Disabled));
542     tracked!(mir_emit_retag, true);
543     tracked!(mir_opt_level, 3);
544     tracked!(mutable_noalias, true);
545     tracked!(new_llvm_pass_manager, true);
546     tracked!(no_codegen, true);
547     tracked!(no_generate_arange_section, true);
548     tracked!(no_landing_pads, true);
549     tracked!(no_link, true);
550     tracked!(no_profiler_runtime, true);
551     tracked!(osx_rpath_install_name, true);
552     tracked!(panic_abort_tests, true);
553     tracked!(plt, Some(true));
554     tracked!(print_fuel, Some("abc".to_string()));
555     tracked!(profile, true);
556     tracked!(relro_level, Some(RelroLevel::Full));
557     tracked!(report_delayed_bugs, true);
558     tracked!(run_dsymutil, false);
559     tracked!(sanitizer, Some(Sanitizer::Address));
560     tracked!(sanitizer_memory_track_origins, 2);
561     tracked!(sanitizer_recover, vec![Sanitizer::Address]);
562     tracked!(saturating_float_casts, true);
563     tracked!(share_generics, Some(true));
564     tracked!(show_span, Some(String::from("abc")));
565     tracked!(src_hash_algorithm, Some(SourceFileHashAlgorithm::Sha1));
566     tracked!(strip_debuginfo_if_disabled, true);
567     tracked!(symbol_mangling_version, SymbolManglingVersion::V0);
568     tracked!(teach, true);
569     tracked!(thinlto, Some(true));
570     tracked!(tls_model, Some(String::from("tls model")));
571     tracked!(treat_err_as_bug, Some(1));
572     tracked!(unleash_the_miri_inside_of_you, true);
573     tracked!(verify_llvm_ir, true);
574 }
575
576 #[test]
577 fn test_edition_parsing() {
578     // test default edition
579     let options = Options::default();
580     assert!(options.edition == DEFAULT_EDITION);
581
582     let matches = optgroups().parse(&["--edition=2018".to_string()]).unwrap();
583     let (sessopts, _) = build_session_options_and_crate_config(matches);
584     assert!(sessopts.edition == Edition::Edition2018)
585 }