]> git.lizzy.rs Git - rust.git/blob - src/librustc_interface/tests.rs
Rollup merge of #72399 - Lucretiel:ipv4-display-fast, r=kennytm
[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_session::config::Strip;
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::utils::NativeLibKind;
14 use rustc_session::{build_session, Session};
15 use rustc_span::edition::{Edition, DEFAULT_EDITION};
16 use rustc_span::symbol::sym;
17 use rustc_span::SourceFileHashAlgorithm;
18 use rustc_target::spec::{CodeModel, LinkerFlavor, MergeFunctions, PanicStrategy};
19 use rustc_target::spec::{RelocModel, RelroLevel, TlsModel};
20 use std::collections::{BTreeMap, BTreeSet};
21 use std::iter::FromIterator;
22 use std::path::PathBuf;
23
24 type CfgSpecs = FxHashSet<(String, Option<String>)>;
25
26 fn build_session_options_and_crate_config(matches: getopts::Matches) -> (Options, CfgSpecs) {
27     let sessopts = build_session_options(&matches);
28     let cfg = parse_cfgspecs(matches.opt_strs("cfg"));
29     (sessopts, cfg)
30 }
31
32 fn mk_session(matches: getopts::Matches) -> (Session, CfgSpecs) {
33     let registry = registry::Registry::new(&[]);
34     let (sessopts, cfg) = build_session_options_and_crate_config(matches);
35     let sess = build_session(sessopts, None, registry);
36     (sess, cfg)
37 }
38
39 fn new_public_extern_entry<S, I>(locations: I) -> ExternEntry
40 where
41     S: Into<String>,
42     I: IntoIterator<Item = S>,
43 {
44     let locations: BTreeSet<_> = locations.into_iter().map(|s| s.into()).collect();
45
46     ExternEntry {
47         location: ExternLocation::ExactPaths(locations),
48         is_private_dep: false,
49         add_prelude: true,
50     }
51 }
52
53 fn optgroups() -> getopts::Options {
54     let mut opts = getopts::Options::new();
55     for group in rustc_optgroups() {
56         (group.apply)(&mut opts);
57     }
58     return opts;
59 }
60
61 fn mk_map<K: Ord, V>(entries: Vec<(K, V)>) -> BTreeMap<K, V> {
62     BTreeMap::from_iter(entries.into_iter())
63 }
64
65 // When the user supplies --test we should implicitly supply --cfg test
66 #[test]
67 fn test_switch_implies_cfg_test() {
68     rustc_ast::with_default_globals(|| {
69         let matches = optgroups().parse(&["--test".to_string()]).unwrap();
70         let (sess, cfg) = mk_session(matches);
71         let cfg = build_configuration(&sess, to_crate_config(cfg));
72         assert!(cfg.contains(&(sym::test, None)));
73     });
74 }
75
76 // When the user supplies --test and --cfg test, don't implicitly add another --cfg test
77 #[test]
78 fn test_switch_implies_cfg_test_unless_cfg_test() {
79     rustc_ast::with_default_globals(|| {
80         let matches = optgroups().parse(&["--test".to_string(), "--cfg=test".to_string()]).unwrap();
81         let (sess, cfg) = mk_session(matches);
82         let cfg = build_configuration(&sess, to_crate_config(cfg));
83         let mut test_items = cfg.iter().filter(|&&(name, _)| name == sym::test);
84         assert!(test_items.next().is_some());
85         assert!(test_items.next().is_none());
86     });
87 }
88
89 #[test]
90 fn test_can_print_warnings() {
91     rustc_ast::with_default_globals(|| {
92         let matches = optgroups().parse(&["-Awarnings".to_string()]).unwrap();
93         let (sess, _) = mk_session(matches);
94         assert!(!sess.diagnostic().can_emit_warnings());
95     });
96
97     rustc_ast::with_default_globals(|| {
98         let matches =
99             optgroups().parse(&["-Awarnings".to_string(), "-Dwarnings".to_string()]).unwrap();
100         let (sess, _) = mk_session(matches);
101         assert!(sess.diagnostic().can_emit_warnings());
102     });
103
104     rustc_ast::with_default_globals(|| {
105         let matches = optgroups().parse(&["-Adead_code".to_string()]).unwrap();
106         let (sess, _) = mk_session(matches);
107         assert!(sess.diagnostic().can_emit_warnings());
108     });
109 }
110
111 #[test]
112 fn test_output_types_tracking_hash_different_paths() {
113     let mut v1 = Options::default();
114     let mut v2 = Options::default();
115     let mut v3 = Options::default();
116
117     v1.output_types = OutputTypes::new(&[(OutputType::Exe, Some(PathBuf::from("./some/thing")))]);
118     v2.output_types = OutputTypes::new(&[(OutputType::Exe, Some(PathBuf::from("/some/thing")))]);
119     v3.output_types = OutputTypes::new(&[(OutputType::Exe, None)]);
120
121     assert!(v1.dep_tracking_hash() != v2.dep_tracking_hash());
122     assert!(v1.dep_tracking_hash() != v3.dep_tracking_hash());
123     assert!(v2.dep_tracking_hash() != v3.dep_tracking_hash());
124
125     // Check clone
126     assert_eq!(v1.dep_tracking_hash(), v1.clone().dep_tracking_hash());
127     assert_eq!(v2.dep_tracking_hash(), v2.clone().dep_tracking_hash());
128     assert_eq!(v3.dep_tracking_hash(), v3.clone().dep_tracking_hash());
129 }
130
131 #[test]
132 fn test_output_types_tracking_hash_different_construction_order() {
133     let mut v1 = Options::default();
134     let mut v2 = Options::default();
135
136     v1.output_types = OutputTypes::new(&[
137         (OutputType::Exe, Some(PathBuf::from("./some/thing"))),
138         (OutputType::Bitcode, Some(PathBuf::from("./some/thing.bc"))),
139     ]);
140
141     v2.output_types = OutputTypes::new(&[
142         (OutputType::Bitcode, Some(PathBuf::from("./some/thing.bc"))),
143         (OutputType::Exe, Some(PathBuf::from("./some/thing"))),
144     ]);
145
146     assert_eq!(v1.dep_tracking_hash(), v2.dep_tracking_hash());
147
148     // Check clone
149     assert_eq!(v1.dep_tracking_hash(), v1.clone().dep_tracking_hash());
150 }
151
152 #[test]
153 fn test_externs_tracking_hash_different_construction_order() {
154     let mut v1 = Options::default();
155     let mut v2 = Options::default();
156     let mut v3 = Options::default();
157
158     v1.externs = Externs::new(mk_map(vec![
159         (String::from("a"), new_public_extern_entry(vec!["b", "c"])),
160         (String::from("d"), new_public_extern_entry(vec!["e", "f"])),
161     ]));
162
163     v2.externs = Externs::new(mk_map(vec![
164         (String::from("d"), new_public_extern_entry(vec!["e", "f"])),
165         (String::from("a"), new_public_extern_entry(vec!["b", "c"])),
166     ]));
167
168     v3.externs = Externs::new(mk_map(vec![
169         (String::from("a"), new_public_extern_entry(vec!["b", "c"])),
170         (String::from("d"), new_public_extern_entry(vec!["f", "e"])),
171     ]));
172
173     assert_eq!(v1.dep_tracking_hash(), v2.dep_tracking_hash());
174     assert_eq!(v1.dep_tracking_hash(), v3.dep_tracking_hash());
175     assert_eq!(v2.dep_tracking_hash(), v3.dep_tracking_hash());
176
177     // Check clone
178     assert_eq!(v1.dep_tracking_hash(), v1.clone().dep_tracking_hash());
179     assert_eq!(v2.dep_tracking_hash(), v2.clone().dep_tracking_hash());
180     assert_eq!(v3.dep_tracking_hash(), v3.clone().dep_tracking_hash());
181 }
182
183 #[test]
184 fn test_lints_tracking_hash_different_values() {
185     let mut v1 = Options::default();
186     let mut v2 = Options::default();
187     let mut v3 = Options::default();
188
189     v1.lint_opts = vec![
190         (String::from("a"), Level::Allow),
191         (String::from("b"), Level::Warn),
192         (String::from("c"), Level::Deny),
193         (String::from("d"), Level::Forbid),
194     ];
195
196     v2.lint_opts = vec![
197         (String::from("a"), Level::Allow),
198         (String::from("b"), Level::Warn),
199         (String::from("X"), Level::Deny),
200         (String::from("d"), Level::Forbid),
201     ];
202
203     v3.lint_opts = vec![
204         (String::from("a"), Level::Allow),
205         (String::from("b"), Level::Warn),
206         (String::from("c"), Level::Forbid),
207         (String::from("d"), Level::Deny),
208     ];
209
210     assert!(v1.dep_tracking_hash() != v2.dep_tracking_hash());
211     assert!(v1.dep_tracking_hash() != v3.dep_tracking_hash());
212     assert!(v2.dep_tracking_hash() != v3.dep_tracking_hash());
213
214     // Check clone
215     assert_eq!(v1.dep_tracking_hash(), v1.clone().dep_tracking_hash());
216     assert_eq!(v2.dep_tracking_hash(), v2.clone().dep_tracking_hash());
217     assert_eq!(v3.dep_tracking_hash(), v3.clone().dep_tracking_hash());
218 }
219
220 #[test]
221 fn test_lints_tracking_hash_different_construction_order() {
222     let mut v1 = Options::default();
223     let mut v2 = Options::default();
224
225     v1.lint_opts = vec![
226         (String::from("a"), Level::Allow),
227         (String::from("b"), Level::Warn),
228         (String::from("c"), Level::Deny),
229         (String::from("d"), Level::Forbid),
230     ];
231
232     v2.lint_opts = vec![
233         (String::from("a"), Level::Allow),
234         (String::from("c"), Level::Deny),
235         (String::from("b"), Level::Warn),
236         (String::from("d"), Level::Forbid),
237     ];
238
239     assert_eq!(v1.dep_tracking_hash(), v2.dep_tracking_hash());
240
241     // Check clone
242     assert_eq!(v1.dep_tracking_hash(), v1.clone().dep_tracking_hash());
243     assert_eq!(v2.dep_tracking_hash(), v2.clone().dep_tracking_hash());
244 }
245
246 #[test]
247 fn test_search_paths_tracking_hash_different_order() {
248     let mut v1 = Options::default();
249     let mut v2 = Options::default();
250     let mut v3 = Options::default();
251     let mut v4 = Options::default();
252
253     const JSON: ErrorOutputType = ErrorOutputType::Json {
254         pretty: false,
255         json_rendered: HumanReadableErrorType::Default(ColorConfig::Never),
256     };
257
258     // Reference
259     v1.search_paths.push(SearchPath::from_cli_opt("native=abc", JSON));
260     v1.search_paths.push(SearchPath::from_cli_opt("crate=def", JSON));
261     v1.search_paths.push(SearchPath::from_cli_opt("dependency=ghi", JSON));
262     v1.search_paths.push(SearchPath::from_cli_opt("framework=jkl", JSON));
263     v1.search_paths.push(SearchPath::from_cli_opt("all=mno", JSON));
264
265     v2.search_paths.push(SearchPath::from_cli_opt("native=abc", JSON));
266     v2.search_paths.push(SearchPath::from_cli_opt("dependency=ghi", JSON));
267     v2.search_paths.push(SearchPath::from_cli_opt("crate=def", JSON));
268     v2.search_paths.push(SearchPath::from_cli_opt("framework=jkl", JSON));
269     v2.search_paths.push(SearchPath::from_cli_opt("all=mno", JSON));
270
271     v3.search_paths.push(SearchPath::from_cli_opt("crate=def", JSON));
272     v3.search_paths.push(SearchPath::from_cli_opt("framework=jkl", JSON));
273     v3.search_paths.push(SearchPath::from_cli_opt("native=abc", JSON));
274     v3.search_paths.push(SearchPath::from_cli_opt("dependency=ghi", JSON));
275     v3.search_paths.push(SearchPath::from_cli_opt("all=mno", JSON));
276
277     v4.search_paths.push(SearchPath::from_cli_opt("all=mno", JSON));
278     v4.search_paths.push(SearchPath::from_cli_opt("native=abc", JSON));
279     v4.search_paths.push(SearchPath::from_cli_opt("crate=def", JSON));
280     v4.search_paths.push(SearchPath::from_cli_opt("dependency=ghi", JSON));
281     v4.search_paths.push(SearchPath::from_cli_opt("framework=jkl", JSON));
282
283     assert!(v1.dep_tracking_hash() == v2.dep_tracking_hash());
284     assert!(v1.dep_tracking_hash() == v3.dep_tracking_hash());
285     assert!(v1.dep_tracking_hash() == v4.dep_tracking_hash());
286
287     // Check clone
288     assert_eq!(v1.dep_tracking_hash(), v1.clone().dep_tracking_hash());
289     assert_eq!(v2.dep_tracking_hash(), v2.clone().dep_tracking_hash());
290     assert_eq!(v3.dep_tracking_hash(), v3.clone().dep_tracking_hash());
291     assert_eq!(v4.dep_tracking_hash(), v4.clone().dep_tracking_hash());
292 }
293
294 #[test]
295 fn test_native_libs_tracking_hash_different_values() {
296     let mut v1 = Options::default();
297     let mut v2 = Options::default();
298     let mut v3 = Options::default();
299     let mut v4 = Options::default();
300
301     // Reference
302     v1.libs = vec![
303         (String::from("a"), None, NativeLibKind::StaticBundle),
304         (String::from("b"), None, NativeLibKind::Framework),
305         (String::from("c"), None, NativeLibKind::Unspecified),
306     ];
307
308     // Change label
309     v2.libs = vec![
310         (String::from("a"), None, NativeLibKind::StaticBundle),
311         (String::from("X"), None, NativeLibKind::Framework),
312         (String::from("c"), None, NativeLibKind::Unspecified),
313     ];
314
315     // Change kind
316     v3.libs = vec![
317         (String::from("a"), None, NativeLibKind::StaticBundle),
318         (String::from("b"), None, NativeLibKind::StaticBundle),
319         (String::from("c"), None, NativeLibKind::Unspecified),
320     ];
321
322     // Change new-name
323     v4.libs = vec![
324         (String::from("a"), None, NativeLibKind::StaticBundle),
325         (String::from("b"), Some(String::from("X")), NativeLibKind::Framework),
326         (String::from("c"), None, NativeLibKind::Unspecified),
327     ];
328
329     assert!(v1.dep_tracking_hash() != v2.dep_tracking_hash());
330     assert!(v1.dep_tracking_hash() != v3.dep_tracking_hash());
331     assert!(v1.dep_tracking_hash() != v4.dep_tracking_hash());
332
333     // Check clone
334     assert_eq!(v1.dep_tracking_hash(), v1.clone().dep_tracking_hash());
335     assert_eq!(v2.dep_tracking_hash(), v2.clone().dep_tracking_hash());
336     assert_eq!(v3.dep_tracking_hash(), v3.clone().dep_tracking_hash());
337     assert_eq!(v4.dep_tracking_hash(), v4.clone().dep_tracking_hash());
338 }
339
340 #[test]
341 fn test_native_libs_tracking_hash_different_order() {
342     let mut v1 = Options::default();
343     let mut v2 = Options::default();
344     let mut v3 = Options::default();
345
346     // Reference
347     v1.libs = vec![
348         (String::from("a"), None, NativeLibKind::StaticBundle),
349         (String::from("b"), None, NativeLibKind::Framework),
350         (String::from("c"), None, NativeLibKind::Unspecified),
351     ];
352
353     v2.libs = vec![
354         (String::from("b"), None, NativeLibKind::Framework),
355         (String::from("a"), None, NativeLibKind::StaticBundle),
356         (String::from("c"), None, NativeLibKind::Unspecified),
357     ];
358
359     v3.libs = vec![
360         (String::from("c"), None, NativeLibKind::Unspecified),
361         (String::from("a"), None, NativeLibKind::StaticBundle),
362         (String::from("b"), None, NativeLibKind::Framework),
363     ];
364
365     assert!(v1.dep_tracking_hash() == v2.dep_tracking_hash());
366     assert!(v1.dep_tracking_hash() == v3.dep_tracking_hash());
367     assert!(v2.dep_tracking_hash() == v3.dep_tracking_hash());
368
369     // Check clone
370     assert_eq!(v1.dep_tracking_hash(), v1.clone().dep_tracking_hash());
371     assert_eq!(v2.dep_tracking_hash(), v2.clone().dep_tracking_hash());
372     assert_eq!(v3.dep_tracking_hash(), v3.clone().dep_tracking_hash());
373 }
374
375 #[test]
376 fn test_codegen_options_tracking_hash() {
377     let reference = Options::default();
378     let mut opts = Options::default();
379
380     macro_rules! untracked {
381         ($name: ident, $non_default_value: expr) => {
382             opts.cg.$name = $non_default_value;
383             assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
384         };
385     }
386
387     // Make sure that changing an [UNTRACKED] option leaves the hash unchanged.
388     // This list is in alphabetical order.
389     untracked!(ar, String::from("abc"));
390     untracked!(codegen_units, Some(42));
391     untracked!(default_linker_libraries, true);
392     untracked!(extra_filename, String::from("extra-filename"));
393     untracked!(incremental, Some(String::from("abc")));
394     // `link_arg` is omitted because it just forwards to `link_args`.
395     untracked!(link_args, vec![String::from("abc"), String::from("def")]);
396     untracked!(link_dead_code, true);
397     untracked!(linker, Some(PathBuf::from("linker")));
398     untracked!(linker_flavor, Some(LinkerFlavor::Gcc));
399     untracked!(no_stack_check, true);
400     untracked!(remark, Passes::Some(vec![String::from("pass1"), String::from("pass2")]));
401     untracked!(rpath, true);
402     untracked!(save_temps, true);
403
404     macro_rules! tracked {
405         ($name: ident, $non_default_value: expr) => {
406             opts = reference.clone();
407             opts.cg.$name = $non_default_value;
408             assert_ne!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
409         };
410     }
411
412     // Make sure that changing a [TRACKED] option changes the hash.
413     // This list is in alphabetical order.
414     tracked!(code_model, Some(CodeModel::Large));
415     tracked!(debug_assertions, Some(true));
416     tracked!(debuginfo, 0xdeadbeef);
417     tracked!(embed_bitcode, false);
418     tracked!(force_frame_pointers, Some(false));
419     tracked!(force_unwind_tables, Some(true));
420     tracked!(inline_threshold, Some(0xf007ba11));
421     tracked!(linker_plugin_lto, LinkerPluginLto::LinkerPluginAuto);
422     tracked!(llvm_args, vec![String::from("1"), String::from("2")]);
423     tracked!(lto, LtoCli::Fat);
424     tracked!(metadata, vec![String::from("A"), String::from("B")]);
425     tracked!(no_prepopulate_passes, true);
426     tracked!(no_redzone, Some(true));
427     tracked!(no_vectorize_loops, true);
428     tracked!(no_vectorize_slp, true);
429     tracked!(opt_level, "3".to_string());
430     tracked!(overflow_checks, Some(true));
431     tracked!(panic, Some(PanicStrategy::Abort));
432     tracked!(passes, vec![String::from("1"), String::from("2")]);
433     tracked!(prefer_dynamic, true);
434     tracked!(profile_generate, SwitchWithOptPath::Enabled(None));
435     tracked!(profile_use, Some(PathBuf::from("abc")));
436     tracked!(relocation_model, Some(RelocModel::Pic));
437     tracked!(soft_float, true);
438     tracked!(target_cpu, Some(String::from("abc")));
439     tracked!(target_feature, String::from("all the features, all of them"));
440 }
441
442 #[test]
443 fn test_debugging_options_tracking_hash() {
444     let reference = Options::default();
445     let mut opts = Options::default();
446
447     macro_rules! untracked {
448         ($name: ident, $non_default_value: expr) => {
449             opts.debugging_opts.$name = $non_default_value;
450             assert_eq!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
451         };
452     }
453
454     // Make sure that changing an [UNTRACKED] option leaves the hash unchanged.
455     // This list is in alphabetical order.
456     untracked!(ast_json, true);
457     untracked!(ast_json_noexpand, true);
458     untracked!(borrowck, String::from("other"));
459     untracked!(borrowck_stats, true);
460     untracked!(control_flow_guard, CFGuard::Checks);
461     untracked!(deduplicate_diagnostics, true);
462     untracked!(dep_tasks, true);
463     untracked!(dont_buffer_diagnostics, true);
464     untracked!(dump_dep_graph, true);
465     untracked!(dump_mir, Some(String::from("abc")));
466     untracked!(dump_mir_dataflow, true);
467     untracked!(dump_mir_dir, String::from("abc"));
468     untracked!(dump_mir_exclude_pass_number, true);
469     untracked!(dump_mir_graphviz, true);
470     untracked!(emit_stack_sizes, true);
471     untracked!(hir_stats, true);
472     untracked!(identify_regions, true);
473     untracked!(incremental_ignore_spans, true);
474     untracked!(incremental_info, true);
475     untracked!(incremental_verify_ich, true);
476     untracked!(input_stats, true);
477     untracked!(keep_hygiene_data, true);
478     untracked!(link_native_libraries, false);
479     untracked!(llvm_time_trace, true);
480     untracked!(ls, true);
481     untracked!(macro_backtrace, true);
482     untracked!(meta_stats, true);
483     untracked!(nll_facts, true);
484     untracked!(no_analysis, true);
485     untracked!(no_interleave_lints, true);
486     untracked!(no_leak_check, true);
487     untracked!(no_parallel_llvm, true);
488     untracked!(parse_only, true);
489     untracked!(perf_stats, true);
490     untracked!(polonius, true);
491     // `pre_link_arg` is omitted because it just forwards to `pre_link_args`.
492     untracked!(pre_link_args, vec![String::from("abc"), String::from("def")]);
493     untracked!(print_link_args, true);
494     untracked!(print_llvm_passes, true);
495     untracked!(print_mono_items, Some(String::from("abc")));
496     untracked!(print_region_graph, true);
497     untracked!(print_type_sizes, true);
498     untracked!(query_dep_graph, true);
499     untracked!(query_stats, true);
500     untracked!(save_analysis, true);
501     untracked!(self_profile, SwitchWithOptPath::Enabled(None));
502     untracked!(self_profile_events, Some(vec![String::new()]));
503     untracked!(span_free_formats, true);
504     untracked!(strip, Strip::None);
505     untracked!(terminal_width, Some(80));
506     untracked!(threads, 99);
507     untracked!(time, true);
508     untracked!(time_llvm_passes, true);
509     untracked!(time_passes, true);
510     untracked!(trace_macros, true);
511     untracked!(ui_testing, true);
512     untracked!(unpretty, Some("expanded".to_string()));
513     untracked!(unstable_options, true);
514     untracked!(verbose, true);
515
516     macro_rules! tracked {
517         ($name: ident, $non_default_value: expr) => {
518             opts = reference.clone();
519             opts.debugging_opts.$name = $non_default_value;
520             assert_ne!(reference.dep_tracking_hash(), opts.dep_tracking_hash());
521         };
522     }
523
524     // Make sure that changing a [TRACKED] option changes the hash.
525     // This list is in alphabetical order.
526     tracked!(allow_features, Some(vec![String::from("lang_items")]));
527     tracked!(always_encode_mir, true);
528     tracked!(asm_comments, true);
529     tracked!(binary_dep_depinfo, true);
530     tracked!(chalk, true);
531     tracked!(codegen_backend, Some("abc".to_string()));
532     tracked!(crate_attr, vec!["abc".to_string()]);
533     tracked!(debug_macros, true);
534     tracked!(dep_info_omit_d_target, true);
535     tracked!(dual_proc_macros, true);
536     tracked!(fewer_names, true);
537     tracked!(force_overflow_checks, Some(true));
538     tracked!(force_unstable_if_unmarked, true);
539     tracked!(fuel, Some(("abc".to_string(), 99)));
540     tracked!(human_readable_cgu_names, true);
541     tracked!(inline_in_all_cgus, Some(true));
542     tracked!(insert_sideeffect, true);
543     tracked!(instrument_mcount, true);
544     tracked!(link_only, true);
545     tracked!(merge_functions, Some(MergeFunctions::Disabled));
546     tracked!(mir_emit_retag, true);
547     tracked!(mir_opt_level, 3);
548     tracked!(mutable_noalias, true);
549     tracked!(new_llvm_pass_manager, true);
550     tracked!(no_codegen, true);
551     tracked!(no_generate_arange_section, true);
552     tracked!(no_link, true);
553     tracked!(no_profiler_runtime, true);
554     tracked!(osx_rpath_install_name, true);
555     tracked!(panic_abort_tests, true);
556     tracked!(plt, Some(true));
557     tracked!(print_fuel, Some("abc".to_string()));
558     tracked!(profile, true);
559     tracked!(relro_level, Some(RelroLevel::Full));
560     tracked!(report_delayed_bugs, true);
561     tracked!(run_dsymutil, false);
562     tracked!(sanitizer, Some(Sanitizer::Address));
563     tracked!(sanitizer_memory_track_origins, 2);
564     tracked!(sanitizer_recover, vec![Sanitizer::Address]);
565     tracked!(saturating_float_casts, Some(true));
566     tracked!(share_generics, Some(true));
567     tracked!(show_span, Some(String::from("abc")));
568     tracked!(src_hash_algorithm, Some(SourceFileHashAlgorithm::Sha1));
569     tracked!(symbol_mangling_version, SymbolManglingVersion::V0);
570     tracked!(teach, true);
571     tracked!(thinlto, Some(true));
572     tracked!(tls_model, Some(TlsModel::GeneralDynamic));
573     tracked!(treat_err_as_bug, Some(1));
574     tracked!(unleash_the_miri_inside_of_you, true);
575     tracked!(use_ctors_section, Some(true));
576     tracked!(verify_llvm_ir, true);
577 }
578
579 #[test]
580 fn test_edition_parsing() {
581     // test default edition
582     let options = Options::default();
583     assert!(options.edition == DEFAULT_EDITION);
584
585     let matches = optgroups().parse(&["--edition=2018".to_string()]).unwrap();
586     let (sessopts, _) = build_session_options_and_crate_config(matches);
587     assert!(sessopts.edition == Edition::Edition2018)
588 }