1 use crate::interface
::parse_cfgspecs
;
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
::{ExternEntry, LinkerPluginLto, LtoCli, SwitchWithOptPath}
;
9 use rustc_session
::config
::{Externs, OutputType, OutputTypes, 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_target
::spec
::{MergeFunctions, PanicStrategy, RelroLevel}
;
17 use std
::collections
::{BTreeMap, BTreeSet}
;
18 use std
::iter
::FromIterator
;
19 use std
::path
::PathBuf
;
21 type CfgSpecs
= FxHashSet
<(String
, Option
<String
>)>;
23 fn build_session_options_and_crate_config(matches
: getopts
::Matches
) -> (Options
, CfgSpecs
) {
24 let sessopts
= build_session_options(&matches
);
25 let cfg
= parse_cfgspecs(matches
.opt_strs("cfg"));
29 fn mk_session(matches
: getopts
::Matches
) -> (Session
, CfgSpecs
) {
30 let registry
= registry
::Registry
::new(&[]);
31 let (sessopts
, cfg
) = build_session_options_and_crate_config(matches
);
32 let sess
= build_session(sessopts
, None
, registry
);
36 fn new_public_extern_entry
<S
, I
>(locations
: I
) -> ExternEntry
39 I
: IntoIterator
<Item
= S
>,
41 let locations
: BTreeSet
<_
> = locations
.into_iter().map(|s
| s
.into()).collect();
44 location
: ExternLocation
::ExactPaths(locations
),
45 is_private_dep
: false,
50 fn optgroups() -> getopts
::Options
{
51 let mut opts
= getopts
::Options
::new();
52 for group
in rustc_optgroups() {
53 (group
.apply
)(&mut opts
);
58 fn mk_map
<K
: Ord
, V
>(entries
: Vec
<(K
, V
)>) -> BTreeMap
<K
, V
> {
59 BTreeMap
::from_iter(entries
.into_iter())
62 // When the user supplies --test we should implicitly supply --cfg test
64 fn test_switch_implies_cfg_test() {
65 rustc_ast
::with_default_globals(|| {
66 let matches
= optgroups().parse(&["--test".to_string()]).unwrap();
67 let (sess
, cfg
) = mk_session(matches
);
68 let cfg
= build_configuration(&sess
, to_crate_config(cfg
));
69 assert
!(cfg
.contains(&(sym
::test
, None
)));
73 // When the user supplies --test and --cfg test, don't implicitly add another --cfg test
75 fn test_switch_implies_cfg_test_unless_cfg_test() {
76 rustc_ast
::with_default_globals(|| {
77 let matches
= optgroups().parse(&["--test".to_string(), "--cfg=test".to_string()]).unwrap();
78 let (sess
, cfg
) = mk_session(matches
);
79 let cfg
= build_configuration(&sess
, to_crate_config(cfg
));
80 let mut test_items
= cfg
.iter().filter(|&&(name
, _
)| name
== sym
::test
);
81 assert
!(test_items
.next().is_some());
82 assert
!(test_items
.next().is_none());
87 fn test_can_print_warnings() {
88 rustc_ast
::with_default_globals(|| {
89 let matches
= optgroups().parse(&["-Awarnings".to_string()]).unwrap();
90 let (sess
, _
) = mk_session(matches
);
91 assert
!(!sess
.diagnostic().can_emit_warnings());
94 rustc_ast
::with_default_globals(|| {
96 optgroups().parse(&["-Awarnings".to_string(), "-Dwarnings".to_string()]).unwrap();
97 let (sess
, _
) = mk_session(matches
);
98 assert
!(sess
.diagnostic().can_emit_warnings());
101 rustc_ast
::with_default_globals(|| {
102 let matches
= optgroups().parse(&["-Adead_code".to_string()]).unwrap();
103 let (sess
, _
) = mk_session(matches
);
104 assert
!(sess
.diagnostic().can_emit_warnings());
109 fn test_output_types_tracking_hash_different_paths() {
110 let mut v1
= Options
::default();
111 let mut v2
= Options
::default();
112 let mut v3
= Options
::default();
114 v1
.output_types
= OutputTypes
::new(&[(OutputType
::Exe
, Some(PathBuf
::from("./some/thing")))]);
115 v2
.output_types
= OutputTypes
::new(&[(OutputType
::Exe
, Some(PathBuf
::from("/some/thing")))]);
116 v3
.output_types
= OutputTypes
::new(&[(OutputType
::Exe
, None
)]);
118 assert
!(v1
.dep_tracking_hash() != v2
.dep_tracking_hash());
119 assert
!(v1
.dep_tracking_hash() != v3
.dep_tracking_hash());
120 assert
!(v2
.dep_tracking_hash() != v3
.dep_tracking_hash());
123 assert_eq
!(v1
.dep_tracking_hash(), v1
.clone().dep_tracking_hash());
124 assert_eq
!(v2
.dep_tracking_hash(), v2
.clone().dep_tracking_hash());
125 assert_eq
!(v3
.dep_tracking_hash(), v3
.clone().dep_tracking_hash());
129 fn test_output_types_tracking_hash_different_construction_order() {
130 let mut v1
= Options
::default();
131 let mut v2
= Options
::default();
133 v1
.output_types
= OutputTypes
::new(&[
134 (OutputType
::Exe
, Some(PathBuf
::from("./some/thing"))),
135 (OutputType
::Bitcode
, Some(PathBuf
::from("./some/thing.bc"))),
138 v2
.output_types
= OutputTypes
::new(&[
139 (OutputType
::Bitcode
, Some(PathBuf
::from("./some/thing.bc"))),
140 (OutputType
::Exe
, Some(PathBuf
::from("./some/thing"))),
143 assert_eq
!(v1
.dep_tracking_hash(), v2
.dep_tracking_hash());
146 assert_eq
!(v1
.dep_tracking_hash(), v1
.clone().dep_tracking_hash());
150 fn test_externs_tracking_hash_different_construction_order() {
151 let mut v1
= Options
::default();
152 let mut v2
= Options
::default();
153 let mut v3
= Options
::default();
155 v1
.externs
= Externs
::new(mk_map(vec
![
156 (String
::from("a"), new_public_extern_entry(vec
!["b", "c"])),
157 (String
::from("d"), new_public_extern_entry(vec
!["e", "f"])),
160 v2
.externs
= Externs
::new(mk_map(vec
![
161 (String
::from("d"), new_public_extern_entry(vec
!["e", "f"])),
162 (String
::from("a"), new_public_extern_entry(vec
!["b", "c"])),
165 v3
.externs
= Externs
::new(mk_map(vec
![
166 (String
::from("a"), new_public_extern_entry(vec
!["b", "c"])),
167 (String
::from("d"), new_public_extern_entry(vec
!["f", "e"])),
170 assert_eq
!(v1
.dep_tracking_hash(), v2
.dep_tracking_hash());
171 assert_eq
!(v1
.dep_tracking_hash(), v3
.dep_tracking_hash());
172 assert_eq
!(v2
.dep_tracking_hash(), v3
.dep_tracking_hash());
175 assert_eq
!(v1
.dep_tracking_hash(), v1
.clone().dep_tracking_hash());
176 assert_eq
!(v2
.dep_tracking_hash(), v2
.clone().dep_tracking_hash());
177 assert_eq
!(v3
.dep_tracking_hash(), v3
.clone().dep_tracking_hash());
181 fn test_lints_tracking_hash_different_values() {
182 let mut v1
= Options
::default();
183 let mut v2
= Options
::default();
184 let mut v3
= Options
::default();
187 (String
::from("a"), Level
::Allow
),
188 (String
::from("b"), Level
::Warn
),
189 (String
::from("c"), Level
::Deny
),
190 (String
::from("d"), Level
::Forbid
),
194 (String
::from("a"), Level
::Allow
),
195 (String
::from("b"), Level
::Warn
),
196 (String
::from("X"), Level
::Deny
),
197 (String
::from("d"), Level
::Forbid
),
201 (String
::from("a"), Level
::Allow
),
202 (String
::from("b"), Level
::Warn
),
203 (String
::from("c"), Level
::Forbid
),
204 (String
::from("d"), Level
::Deny
),
207 assert
!(v1
.dep_tracking_hash() != v2
.dep_tracking_hash());
208 assert
!(v1
.dep_tracking_hash() != v3
.dep_tracking_hash());
209 assert
!(v2
.dep_tracking_hash() != v3
.dep_tracking_hash());
212 assert_eq
!(v1
.dep_tracking_hash(), v1
.clone().dep_tracking_hash());
213 assert_eq
!(v2
.dep_tracking_hash(), v2
.clone().dep_tracking_hash());
214 assert_eq
!(v3
.dep_tracking_hash(), v3
.clone().dep_tracking_hash());
218 fn test_lints_tracking_hash_different_construction_order() {
219 let mut v1
= Options
::default();
220 let mut v2
= Options
::default();
223 (String
::from("a"), Level
::Allow
),
224 (String
::from("b"), Level
::Warn
),
225 (String
::from("c"), Level
::Deny
),
226 (String
::from("d"), Level
::Forbid
),
230 (String
::from("a"), Level
::Allow
),
231 (String
::from("c"), Level
::Deny
),
232 (String
::from("b"), Level
::Warn
),
233 (String
::from("d"), Level
::Forbid
),
236 assert_eq
!(v1
.dep_tracking_hash(), v2
.dep_tracking_hash());
239 assert_eq
!(v1
.dep_tracking_hash(), v1
.clone().dep_tracking_hash());
240 assert_eq
!(v2
.dep_tracking_hash(), v2
.clone().dep_tracking_hash());
244 fn test_search_paths_tracking_hash_different_order() {
245 let mut v1
= Options
::default();
246 let mut v2
= Options
::default();
247 let mut v3
= Options
::default();
248 let mut v4
= Options
::default();
250 const JSON
: ErrorOutputType
= ErrorOutputType
::Json
{
252 json_rendered
: HumanReadableErrorType
::Default(ColorConfig
::Never
),
256 v1
.search_paths
.push(SearchPath
::from_cli_opt("native=abc", JSON
));
257 v1
.search_paths
.push(SearchPath
::from_cli_opt("crate=def", JSON
));
258 v1
.search_paths
.push(SearchPath
::from_cli_opt("dependency=ghi", JSON
));
259 v1
.search_paths
.push(SearchPath
::from_cli_opt("framework=jkl", JSON
));
260 v1
.search_paths
.push(SearchPath
::from_cli_opt("all=mno", JSON
));
262 v2
.search_paths
.push(SearchPath
::from_cli_opt("native=abc", JSON
));
263 v2
.search_paths
.push(SearchPath
::from_cli_opt("dependency=ghi", JSON
));
264 v2
.search_paths
.push(SearchPath
::from_cli_opt("crate=def", JSON
));
265 v2
.search_paths
.push(SearchPath
::from_cli_opt("framework=jkl", JSON
));
266 v2
.search_paths
.push(SearchPath
::from_cli_opt("all=mno", JSON
));
268 v3
.search_paths
.push(SearchPath
::from_cli_opt("crate=def", JSON
));
269 v3
.search_paths
.push(SearchPath
::from_cli_opt("framework=jkl", JSON
));
270 v3
.search_paths
.push(SearchPath
::from_cli_opt("native=abc", JSON
));
271 v3
.search_paths
.push(SearchPath
::from_cli_opt("dependency=ghi", JSON
));
272 v3
.search_paths
.push(SearchPath
::from_cli_opt("all=mno", JSON
));
274 v4
.search_paths
.push(SearchPath
::from_cli_opt("all=mno", JSON
));
275 v4
.search_paths
.push(SearchPath
::from_cli_opt("native=abc", JSON
));
276 v4
.search_paths
.push(SearchPath
::from_cli_opt("crate=def", JSON
));
277 v4
.search_paths
.push(SearchPath
::from_cli_opt("dependency=ghi", JSON
));
278 v4
.search_paths
.push(SearchPath
::from_cli_opt("framework=jkl", JSON
));
280 assert
!(v1
.dep_tracking_hash() == v2
.dep_tracking_hash());
281 assert
!(v1
.dep_tracking_hash() == v3
.dep_tracking_hash());
282 assert
!(v1
.dep_tracking_hash() == v4
.dep_tracking_hash());
285 assert_eq
!(v1
.dep_tracking_hash(), v1
.clone().dep_tracking_hash());
286 assert_eq
!(v2
.dep_tracking_hash(), v2
.clone().dep_tracking_hash());
287 assert_eq
!(v3
.dep_tracking_hash(), v3
.clone().dep_tracking_hash());
288 assert_eq
!(v4
.dep_tracking_hash(), v4
.clone().dep_tracking_hash());
292 fn test_native_libs_tracking_hash_different_values() {
293 let mut v1
= Options
::default();
294 let mut v2
= Options
::default();
295 let mut v3
= Options
::default();
296 let mut v4
= Options
::default();
300 (String
::from("a"), None
, Some(cstore
::NativeStatic
)),
301 (String
::from("b"), None
, Some(cstore
::NativeFramework
)),
302 (String
::from("c"), None
, Some(cstore
::NativeUnknown
)),
307 (String
::from("a"), None
, Some(cstore
::NativeStatic
)),
308 (String
::from("X"), None
, Some(cstore
::NativeFramework
)),
309 (String
::from("c"), None
, Some(cstore
::NativeUnknown
)),
314 (String
::from("a"), None
, Some(cstore
::NativeStatic
)),
315 (String
::from("b"), None
, Some(cstore
::NativeStatic
)),
316 (String
::from("c"), None
, Some(cstore
::NativeUnknown
)),
321 (String
::from("a"), None
, Some(cstore
::NativeStatic
)),
322 (String
::from("b"), Some(String
::from("X")), Some(cstore
::NativeFramework
)),
323 (String
::from("c"), None
, Some(cstore
::NativeUnknown
)),
326 assert
!(v1
.dep_tracking_hash() != v2
.dep_tracking_hash());
327 assert
!(v1
.dep_tracking_hash() != v3
.dep_tracking_hash());
328 assert
!(v1
.dep_tracking_hash() != v4
.dep_tracking_hash());
331 assert_eq
!(v1
.dep_tracking_hash(), v1
.clone().dep_tracking_hash());
332 assert_eq
!(v2
.dep_tracking_hash(), v2
.clone().dep_tracking_hash());
333 assert_eq
!(v3
.dep_tracking_hash(), v3
.clone().dep_tracking_hash());
334 assert_eq
!(v4
.dep_tracking_hash(), v4
.clone().dep_tracking_hash());
338 fn test_native_libs_tracking_hash_different_order() {
339 let mut v1
= Options
::default();
340 let mut v2
= Options
::default();
341 let mut v3
= Options
::default();
345 (String
::from("a"), None
, Some(cstore
::NativeStatic
)),
346 (String
::from("b"), None
, Some(cstore
::NativeFramework
)),
347 (String
::from("c"), None
, Some(cstore
::NativeUnknown
)),
351 (String
::from("b"), None
, Some(cstore
::NativeFramework
)),
352 (String
::from("a"), None
, Some(cstore
::NativeStatic
)),
353 (String
::from("c"), None
, Some(cstore
::NativeUnknown
)),
357 (String
::from("c"), None
, Some(cstore
::NativeUnknown
)),
358 (String
::from("a"), None
, Some(cstore
::NativeStatic
)),
359 (String
::from("b"), None
, Some(cstore
::NativeFramework
)),
362 assert
!(v1
.dep_tracking_hash() == v2
.dep_tracking_hash());
363 assert
!(v1
.dep_tracking_hash() == v3
.dep_tracking_hash());
364 assert
!(v2
.dep_tracking_hash() == v3
.dep_tracking_hash());
367 assert_eq
!(v1
.dep_tracking_hash(), v1
.clone().dep_tracking_hash());
368 assert_eq
!(v2
.dep_tracking_hash(), v2
.clone().dep_tracking_hash());
369 assert_eq
!(v3
.dep_tracking_hash(), v3
.clone().dep_tracking_hash());
373 fn test_codegen_options_tracking_hash() {
374 let reference
= Options
::default();
375 let mut opts
= Options
::default();
377 // Make sure the changing an [UNTRACKED] option leaves the hash unchanged
378 opts
.cg
.ar
= String
::from("abc");
379 assert_eq
!(reference
.dep_tracking_hash(), opts
.dep_tracking_hash());
381 opts
.cg
.linker
= Some(PathBuf
::from("linker"));
382 assert_eq
!(reference
.dep_tracking_hash(), opts
.dep_tracking_hash());
384 opts
.cg
.link_args
= vec
![String
::from("abc"), String
::from("def")];
385 assert_eq
!(reference
.dep_tracking_hash(), opts
.dep_tracking_hash());
387 opts
.cg
.link_dead_code
= true;
388 assert_eq
!(reference
.dep_tracking_hash(), opts
.dep_tracking_hash());
390 opts
.cg
.rpath
= true;
391 assert_eq
!(reference
.dep_tracking_hash(), opts
.dep_tracking_hash());
393 opts
.cg
.extra_filename
= String
::from("extra-filename");
394 assert_eq
!(reference
.dep_tracking_hash(), opts
.dep_tracking_hash());
396 opts
.cg
.codegen_units
= Some(42);
397 assert_eq
!(reference
.dep_tracking_hash(), opts
.dep_tracking_hash());
399 opts
.cg
.remark
= Passes
::Some(vec
![String
::from("pass1"), String
::from("pass2")]);
400 assert_eq
!(reference
.dep_tracking_hash(), opts
.dep_tracking_hash());
402 opts
.cg
.save_temps
= true;
403 assert_eq
!(reference
.dep_tracking_hash(), opts
.dep_tracking_hash());
405 opts
.cg
.incremental
= Some(String
::from("abc"));
406 assert_eq
!(reference
.dep_tracking_hash(), opts
.dep_tracking_hash());
408 // Make sure changing a [TRACKED] option changes the hash
409 opts
= reference
.clone();
410 opts
.cg
.lto
= LtoCli
::Fat
;
411 assert
!(reference
.dep_tracking_hash() != opts
.dep_tracking_hash());
413 opts
= reference
.clone();
414 opts
.cg
.target_cpu
= Some(String
::from("abc"));
415 assert
!(reference
.dep_tracking_hash() != opts
.dep_tracking_hash());
417 opts
= reference
.clone();
418 opts
.cg
.target_feature
= String
::from("all the features, all of them");
419 assert
!(reference
.dep_tracking_hash() != opts
.dep_tracking_hash());
421 opts
= reference
.clone();
422 opts
.cg
.passes
= vec
![String
::from("1"), String
::from("2")];
423 assert
!(reference
.dep_tracking_hash() != opts
.dep_tracking_hash());
425 opts
= reference
.clone();
426 opts
.cg
.llvm_args
= vec
![String
::from("1"), String
::from("2")];
427 assert
!(reference
.dep_tracking_hash() != opts
.dep_tracking_hash());
429 opts
= reference
.clone();
430 opts
.cg
.overflow_checks
= Some(true);
431 assert
!(reference
.dep_tracking_hash() != opts
.dep_tracking_hash());
433 opts
= reference
.clone();
434 opts
.cg
.no_prepopulate_passes
= true;
435 assert
!(reference
.dep_tracking_hash() != opts
.dep_tracking_hash());
437 opts
= reference
.clone();
438 opts
.cg
.no_vectorize_loops
= true;
439 assert
!(reference
.dep_tracking_hash() != opts
.dep_tracking_hash());
441 opts
= reference
.clone();
442 opts
.cg
.no_vectorize_slp
= true;
443 assert
!(reference
.dep_tracking_hash() != opts
.dep_tracking_hash());
445 opts
= reference
.clone();
446 opts
.cg
.soft_float
= true;
447 assert
!(reference
.dep_tracking_hash() != opts
.dep_tracking_hash());
449 opts
= reference
.clone();
450 opts
.cg
.prefer_dynamic
= true;
451 assert
!(reference
.dep_tracking_hash() != opts
.dep_tracking_hash());
453 opts
= reference
.clone();
454 opts
.cg
.no_redzone
= Some(true);
455 assert
!(reference
.dep_tracking_hash() != opts
.dep_tracking_hash());
457 opts
= reference
.clone();
458 opts
.cg
.relocation_model
= Some(String
::from("relocation model"));
459 assert
!(reference
.dep_tracking_hash() != opts
.dep_tracking_hash());
461 opts
= reference
.clone();
462 opts
.cg
.code_model
= Some(String
::from("code model"));
463 assert
!(reference
.dep_tracking_hash() != opts
.dep_tracking_hash());
465 opts
= reference
.clone();
466 opts
.debugging_opts
.tls_model
= Some(String
::from("tls model"));
467 assert
!(reference
.dep_tracking_hash() != opts
.dep_tracking_hash());
469 opts
= reference
.clone();
470 opts
.cg
.profile_generate
= SwitchWithOptPath
::Enabled(None
);
471 assert_ne
!(reference
.dep_tracking_hash(), opts
.dep_tracking_hash());
473 opts
= reference
.clone();
474 opts
.cg
.profile_use
= Some(PathBuf
::from("abc"));
475 assert_ne
!(reference
.dep_tracking_hash(), opts
.dep_tracking_hash());
477 opts
= reference
.clone();
478 opts
.cg
.metadata
= vec
![String
::from("A"), String
::from("B")];
479 assert
!(reference
.dep_tracking_hash() != opts
.dep_tracking_hash());
481 opts
= reference
.clone();
482 opts
.cg
.debuginfo
= 0xdeadbeef;
483 assert
!(reference
.dep_tracking_hash() != opts
.dep_tracking_hash());
485 opts
= reference
.clone();
486 opts
.cg
.debuginfo
= 0xba5eba11;
487 assert
!(reference
.dep_tracking_hash() != opts
.dep_tracking_hash());
489 opts
= reference
.clone();
490 opts
.cg
.force_frame_pointers
= Some(false);
491 assert
!(reference
.dep_tracking_hash() != opts
.dep_tracking_hash());
493 opts
= reference
.clone();
494 opts
.cg
.debug_assertions
= Some(true);
495 assert
!(reference
.dep_tracking_hash() != opts
.dep_tracking_hash());
497 opts
= reference
.clone();
498 opts
.cg
.inline_threshold
= Some(0xf007ba11);
499 assert
!(reference
.dep_tracking_hash() != opts
.dep_tracking_hash());
501 opts
= reference
.clone();
502 opts
.cg
.panic
= Some(PanicStrategy
::Abort
);
503 assert
!(reference
.dep_tracking_hash() != opts
.dep_tracking_hash());
505 opts
= reference
.clone();
506 opts
.cg
.linker_plugin_lto
= LinkerPluginLto
::LinkerPluginAuto
;
507 assert
!(reference
.dep_tracking_hash() != opts
.dep_tracking_hash());
511 fn test_debugging_options_tracking_hash() {
512 let reference
= Options
::default();
513 let mut opts
= Options
::default();
515 // Make sure the changing an [UNTRACKED] option leaves the hash unchanged
516 opts
.debugging_opts
.verbose
= true;
517 assert_eq
!(reference
.dep_tracking_hash(), opts
.dep_tracking_hash());
518 opts
.debugging_opts
.time_passes
= true;
519 assert_eq
!(reference
.dep_tracking_hash(), opts
.dep_tracking_hash());
520 opts
.debugging_opts
.time_llvm_passes
= true;
521 assert_eq
!(reference
.dep_tracking_hash(), opts
.dep_tracking_hash());
522 opts
.debugging_opts
.input_stats
= true;
523 assert_eq
!(reference
.dep_tracking_hash(), opts
.dep_tracking_hash());
524 opts
.debugging_opts
.borrowck_stats
= true;
525 assert_eq
!(reference
.dep_tracking_hash(), opts
.dep_tracking_hash());
526 opts
.debugging_opts
.meta_stats
= true;
527 assert_eq
!(reference
.dep_tracking_hash(), opts
.dep_tracking_hash());
528 opts
.debugging_opts
.print_link_args
= true;
529 assert_eq
!(reference
.dep_tracking_hash(), opts
.dep_tracking_hash());
530 opts
.debugging_opts
.print_llvm_passes
= true;
531 assert_eq
!(reference
.dep_tracking_hash(), opts
.dep_tracking_hash());
532 opts
.debugging_opts
.ast_json
= true;
533 assert_eq
!(reference
.dep_tracking_hash(), opts
.dep_tracking_hash());
534 opts
.debugging_opts
.ast_json_noexpand
= true;
535 assert_eq
!(reference
.dep_tracking_hash(), opts
.dep_tracking_hash());
536 opts
.debugging_opts
.ls
= true;
537 assert_eq
!(reference
.dep_tracking_hash(), opts
.dep_tracking_hash());
538 opts
.debugging_opts
.save_analysis
= true;
539 assert_eq
!(reference
.dep_tracking_hash(), opts
.dep_tracking_hash());
540 opts
.debugging_opts
.print_region_graph
= true;
541 assert_eq
!(reference
.dep_tracking_hash(), opts
.dep_tracking_hash());
542 opts
.debugging_opts
.parse_only
= true;
543 assert_eq
!(reference
.dep_tracking_hash(), opts
.dep_tracking_hash());
544 opts
.debugging_opts
.dump_dep_graph
= true;
545 assert_eq
!(reference
.dep_tracking_hash(), opts
.dep_tracking_hash());
546 opts
.debugging_opts
.query_dep_graph
= true;
547 assert_eq
!(reference
.dep_tracking_hash(), opts
.dep_tracking_hash());
548 opts
.debugging_opts
.no_analysis
= true;
549 assert_eq
!(reference
.dep_tracking_hash(), opts
.dep_tracking_hash());
550 opts
.debugging_opts
.unstable_options
= true;
551 assert_eq
!(reference
.dep_tracking_hash(), opts
.dep_tracking_hash());
552 opts
.debugging_opts
.trace_macros
= true;
553 assert_eq
!(reference
.dep_tracking_hash(), opts
.dep_tracking_hash());
554 opts
.debugging_opts
.keep_hygiene_data
= true;
555 assert_eq
!(reference
.dep_tracking_hash(), opts
.dep_tracking_hash());
556 opts
.debugging_opts
.print_mono_items
= Some(String
::from("abc"));
557 assert_eq
!(reference
.dep_tracking_hash(), opts
.dep_tracking_hash());
558 opts
.debugging_opts
.dump_mir
= Some(String
::from("abc"));
559 assert_eq
!(reference
.dep_tracking_hash(), opts
.dep_tracking_hash());
560 opts
.debugging_opts
.dump_mir_dir
= String
::from("abc");
561 assert_eq
!(reference
.dep_tracking_hash(), opts
.dep_tracking_hash());
562 opts
.debugging_opts
.dump_mir_graphviz
= true;
563 assert_eq
!(reference
.dep_tracking_hash(), opts
.dep_tracking_hash());
564 opts
.debugging_opts
.dump_mir_dataflow
= true;
565 assert_eq
!(reference
.dep_tracking_hash(), opts
.dep_tracking_hash());
567 // Make sure changing a [TRACKED] option changes the hash
568 opts
= reference
.clone();
569 opts
.debugging_opts
.asm_comments
= true;
570 assert
!(reference
.dep_tracking_hash() != opts
.dep_tracking_hash());
572 opts
= reference
.clone();
573 opts
.debugging_opts
.verify_llvm_ir
= true;
574 assert
!(reference
.dep_tracking_hash() != opts
.dep_tracking_hash());
576 opts
= reference
.clone();
577 opts
.debugging_opts
.no_landing_pads
= true;
578 assert
!(reference
.dep_tracking_hash() != opts
.dep_tracking_hash());
580 opts
= reference
.clone();
581 opts
.debugging_opts
.fewer_names
= true;
582 assert
!(reference
.dep_tracking_hash() != opts
.dep_tracking_hash());
584 opts
= reference
.clone();
585 opts
.debugging_opts
.no_codegen
= true;
586 assert
!(reference
.dep_tracking_hash() != opts
.dep_tracking_hash());
588 opts
= reference
.clone();
589 opts
.debugging_opts
.treat_err_as_bug
= Some(1);
590 assert
!(reference
.dep_tracking_hash() != opts
.dep_tracking_hash());
592 opts
= reference
.clone();
593 opts
.debugging_opts
.report_delayed_bugs
= true;
594 assert
!(reference
.dep_tracking_hash() != opts
.dep_tracking_hash());
596 opts
= reference
.clone();
597 opts
.debugging_opts
.force_overflow_checks
= Some(true);
598 assert
!(reference
.dep_tracking_hash() != opts
.dep_tracking_hash());
600 opts
= reference
.clone();
601 opts
.debugging_opts
.show_span
= Some(String
::from("abc"));
602 assert
!(reference
.dep_tracking_hash() != opts
.dep_tracking_hash());
604 opts
= reference
.clone();
605 opts
.debugging_opts
.mir_opt_level
= 3;
606 assert
!(reference
.dep_tracking_hash() != opts
.dep_tracking_hash());
608 opts
= reference
.clone();
609 opts
.debugging_opts
.relro_level
= Some(RelroLevel
::Full
);
610 assert
!(reference
.dep_tracking_hash() != opts
.dep_tracking_hash());
612 opts
= reference
.clone();
613 opts
.debugging_opts
.merge_functions
= Some(MergeFunctions
::Disabled
);
614 assert
!(reference
.dep_tracking_hash() != opts
.dep_tracking_hash());
616 opts
= reference
.clone();
617 opts
.debugging_opts
.allow_features
= Some(vec
![String
::from("lang_items")]);
618 assert
!(reference
.dep_tracking_hash() != opts
.dep_tracking_hash());
620 opts
= reference
.clone();
621 opts
.debugging_opts
.symbol_mangling_version
= SymbolManglingVersion
::V0
;
622 assert
!(reference
.dep_tracking_hash() != opts
.dep_tracking_hash());
626 fn test_edition_parsing() {
627 // test default edition
628 let options
= Options
::default();
629 assert
!(options
.edition
== DEFAULT_EDITION
);
631 let matches
= optgroups().parse(&["--edition=2018".to_string()]).unwrap();
632 let (sessopts
, _
) = build_session_options_and_crate_config(matches
);
633 assert
!(sessopts
.edition
== Edition
::Edition2018
)