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