summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_interface/src/tests.rs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_interface/src/tests.rs')
-rw-r--r--compiler/rustc_interface/src/tests.rs104
1 files changed, 53 insertions, 51 deletions
diff --git a/compiler/rustc_interface/src/tests.rs b/compiler/rustc_interface/src/tests.rs
index d30816955..04a7714d4 100644
--- a/compiler/rustc_interface/src/tests.rs
+++ b/compiler/rustc_interface/src/tests.rs
@@ -5,15 +5,15 @@ use rustc_errors::{emitter::HumanReadableErrorType, registry, ColorConfig};
use rustc_session::config::{
build_configuration, build_session_options, rustc_optgroups, BranchProtection, CFGuard, Cfg,
DebugInfo, DumpMonoStatsFormat, ErrorOutputType, ExternEntry, ExternLocation, Externs,
- InliningThreshold, Input, InstrumentCoverage, InstrumentXRay, LinkSelfContained,
- LinkerPluginLto, LocationDetail, LtoCli, MirSpanview, OomStrategy, Options, OutFileName,
- OutputType, OutputTypes, PAuthKey, PacRet, Passes, Polonius, ProcMacroExecutionStrategy, Strip,
- SwitchWithOptPath, SymbolManglingVersion, TraitSolver, WasiExecModel,
+ FunctionReturn, InliningThreshold, Input, InstrumentCoverage, InstrumentXRay,
+ LinkSelfContained, LinkerPluginLto, LocationDetail, LtoCli, MirSpanview, NextSolverConfig,
+ OomStrategy, Options, OutFileName, OutputType, OutputTypes, PAuthKey, PacRet, Passes, Polonius,
+ ProcMacroExecutionStrategy, Strip, SwitchWithOptPath, SymbolManglingVersion, WasiExecModel,
};
use rustc_session::lint::Level;
use rustc_session::search_paths::SearchPath;
use rustc_session::utils::{CanonicalizedPath, NativeLib, NativeLibKind};
-use rustc_session::{build_session, getopts, CompilerIO, EarlyErrorHandler, Session};
+use rustc_session::{build_session, getopts, CompilerIO, EarlyDiagCtxt, Session};
use rustc_span::edition::{Edition, DEFAULT_EDITION};
use rustc_span::symbol::sym;
use rustc_span::{FileName, SourceFileHashAlgorithm};
@@ -24,10 +24,12 @@ use std::num::NonZeroUsize;
use std::path::{Path, PathBuf};
use std::sync::Arc;
-fn mk_session(handler: &mut EarlyErrorHandler, matches: getopts::Matches) -> (Session, Cfg) {
+fn mk_session(matches: getopts::Matches) -> (Session, Cfg) {
+ let mut early_dcx = EarlyDiagCtxt::new(ErrorOutputType::default());
+ early_dcx.initialize_checked_jobserver();
+
let registry = registry::Registry::new(&[]);
- let sessopts = build_session_options(handler, &matches);
- let cfg = parse_cfg(handler, matches.opt_strs("cfg"));
+ let sessopts = build_session_options(&mut early_dcx, &matches);
let temps_dir = sessopts.unstable_opts.temps_dir.as_deref().map(PathBuf::from);
let io = CompilerIO {
input: Input::Str { name: FileName::Custom(String::new()), input: String::new() },
@@ -36,7 +38,7 @@ fn mk_session(handler: &mut EarlyErrorHandler, matches: getopts::Matches) -> (Se
temps_dir,
};
let sess = build_session(
- handler,
+ early_dcx,
sessopts,
io,
None,
@@ -50,6 +52,7 @@ fn mk_session(handler: &mut EarlyErrorHandler, matches: getopts::Matches) -> (Se
Arc::default(),
Default::default(),
);
+ let cfg = parse_cfg(&sess.dcx(), matches.opt_strs("cfg"));
(sess, cfg)
}
@@ -116,8 +119,7 @@ fn assert_non_crate_hash_different(x: &Options, y: &Options) {
fn test_switch_implies_cfg_test() {
rustc_span::create_default_session_globals_then(|| {
let matches = optgroups().parse(&["--test".to_string()]).unwrap();
- let mut handler = EarlyErrorHandler::new(ErrorOutputType::default());
- let (sess, cfg) = mk_session(&mut handler, matches);
+ let (sess, cfg) = mk_session(matches);
let cfg = build_configuration(&sess, cfg);
assert!(cfg.contains(&(sym::test, None)));
});
@@ -128,8 +130,7 @@ fn test_switch_implies_cfg_test() {
fn test_switch_implies_cfg_test_unless_cfg_test() {
rustc_span::create_default_session_globals_then(|| {
let matches = optgroups().parse(&["--test".to_string(), "--cfg=test".to_string()]).unwrap();
- let mut handler = EarlyErrorHandler::new(ErrorOutputType::default());
- let (sess, cfg) = mk_session(&mut handler, matches);
+ let (sess, cfg) = mk_session(matches);
let cfg = build_configuration(&sess, cfg);
let mut test_items = cfg.iter().filter(|&&(name, _)| name == sym::test);
assert!(test_items.next().is_some());
@@ -141,24 +142,21 @@ fn test_switch_implies_cfg_test_unless_cfg_test() {
fn test_can_print_warnings() {
rustc_span::create_default_session_globals_then(|| {
let matches = optgroups().parse(&["-Awarnings".to_string()]).unwrap();
- let mut handler = EarlyErrorHandler::new(ErrorOutputType::default());
- let (sess, _) = mk_session(&mut handler, matches);
- assert!(!sess.diagnostic().can_emit_warnings());
+ let (sess, _) = mk_session(matches);
+ assert!(!sess.dcx().can_emit_warnings());
});
rustc_span::create_default_session_globals_then(|| {
let matches =
optgroups().parse(&["-Awarnings".to_string(), "-Dwarnings".to_string()]).unwrap();
- let mut handler = EarlyErrorHandler::new(ErrorOutputType::default());
- let (sess, _) = mk_session(&mut handler, matches);
- assert!(sess.diagnostic().can_emit_warnings());
+ let (sess, _) = mk_session(matches);
+ assert!(sess.dcx().can_emit_warnings());
});
rustc_span::create_default_session_globals_then(|| {
let matches = optgroups().parse(&["-Adead_code".to_string()]).unwrap();
- let mut handler = EarlyErrorHandler::new(ErrorOutputType::default());
- let (sess, _) = mk_session(&mut handler, matches);
- assert!(sess.diagnostic().can_emit_warnings());
+ let (sess, _) = mk_session(matches);
+ assert!(sess.dcx().can_emit_warnings());
});
}
@@ -303,36 +301,36 @@ fn test_search_paths_tracking_hash_different_order() {
let mut v3 = Options::default();
let mut v4 = Options::default();
- let handler = EarlyErrorHandler::new(JSON);
+ let early_dcx = EarlyDiagCtxt::new(JSON);
const JSON: ErrorOutputType = ErrorOutputType::Json {
pretty: false,
json_rendered: HumanReadableErrorType::Default(ColorConfig::Never),
};
// Reference
- v1.search_paths.push(SearchPath::from_cli_opt(&handler, "native=abc"));
- v1.search_paths.push(SearchPath::from_cli_opt(&handler, "crate=def"));
- v1.search_paths.push(SearchPath::from_cli_opt(&handler, "dependency=ghi"));
- v1.search_paths.push(SearchPath::from_cli_opt(&handler, "framework=jkl"));
- v1.search_paths.push(SearchPath::from_cli_opt(&handler, "all=mno"));
-
- v2.search_paths.push(SearchPath::from_cli_opt(&handler, "native=abc"));
- v2.search_paths.push(SearchPath::from_cli_opt(&handler, "dependency=ghi"));
- v2.search_paths.push(SearchPath::from_cli_opt(&handler, "crate=def"));
- v2.search_paths.push(SearchPath::from_cli_opt(&handler, "framework=jkl"));
- v2.search_paths.push(SearchPath::from_cli_opt(&handler, "all=mno"));
-
- v3.search_paths.push(SearchPath::from_cli_opt(&handler, "crate=def"));
- v3.search_paths.push(SearchPath::from_cli_opt(&handler, "framework=jkl"));
- v3.search_paths.push(SearchPath::from_cli_opt(&handler, "native=abc"));
- v3.search_paths.push(SearchPath::from_cli_opt(&handler, "dependency=ghi"));
- v3.search_paths.push(SearchPath::from_cli_opt(&handler, "all=mno"));
-
- v4.search_paths.push(SearchPath::from_cli_opt(&handler, "all=mno"));
- v4.search_paths.push(SearchPath::from_cli_opt(&handler, "native=abc"));
- v4.search_paths.push(SearchPath::from_cli_opt(&handler, "crate=def"));
- v4.search_paths.push(SearchPath::from_cli_opt(&handler, "dependency=ghi"));
- v4.search_paths.push(SearchPath::from_cli_opt(&handler, "framework=jkl"));
+ v1.search_paths.push(SearchPath::from_cli_opt(&early_dcx, "native=abc"));
+ v1.search_paths.push(SearchPath::from_cli_opt(&early_dcx, "crate=def"));
+ v1.search_paths.push(SearchPath::from_cli_opt(&early_dcx, "dependency=ghi"));
+ v1.search_paths.push(SearchPath::from_cli_opt(&early_dcx, "framework=jkl"));
+ v1.search_paths.push(SearchPath::from_cli_opt(&early_dcx, "all=mno"));
+
+ v2.search_paths.push(SearchPath::from_cli_opt(&early_dcx, "native=abc"));
+ v2.search_paths.push(SearchPath::from_cli_opt(&early_dcx, "dependency=ghi"));
+ v2.search_paths.push(SearchPath::from_cli_opt(&early_dcx, "crate=def"));
+ v2.search_paths.push(SearchPath::from_cli_opt(&early_dcx, "framework=jkl"));
+ v2.search_paths.push(SearchPath::from_cli_opt(&early_dcx, "all=mno"));
+
+ v3.search_paths.push(SearchPath::from_cli_opt(&early_dcx, "crate=def"));
+ v3.search_paths.push(SearchPath::from_cli_opt(&early_dcx, "framework=jkl"));
+ v3.search_paths.push(SearchPath::from_cli_opt(&early_dcx, "native=abc"));
+ v3.search_paths.push(SearchPath::from_cli_opt(&early_dcx, "dependency=ghi"));
+ v3.search_paths.push(SearchPath::from_cli_opt(&early_dcx, "all=mno"));
+
+ v4.search_paths.push(SearchPath::from_cli_opt(&early_dcx, "all=mno"));
+ v4.search_paths.push(SearchPath::from_cli_opt(&early_dcx, "native=abc"));
+ v4.search_paths.push(SearchPath::from_cli_opt(&early_dcx, "crate=def"));
+ v4.search_paths.push(SearchPath::from_cli_opt(&early_dcx, "dependency=ghi"));
+ v4.search_paths.push(SearchPath::from_cli_opt(&early_dcx, "framework=jkl"));
assert_same_hash(&v1, &v2);
assert_same_hash(&v1, &v3);
@@ -679,7 +677,6 @@ fn test_unstable_options_tracking_hash() {
untracked!(incremental_info, true);
untracked!(incremental_verify_ich, true);
untracked!(input_stats, true);
- untracked!(keep_hygiene_data, true);
untracked!(link_native_libraries, false);
untracked!(llvm_time_trace, true);
untracked!(ls, vec!["all".to_owned()]);
@@ -691,7 +688,6 @@ fn test_unstable_options_tracking_hash() {
untracked!(no_leak_check, true);
untracked!(no_parallel_llvm, true);
untracked!(parse_only, true);
- untracked!(perf_stats, true);
// `pre_link_arg` is omitted because it just forwards to `pre_link_args`.
untracked!(pre_link_args, vec![String::from("abc"), String::from("def")]);
untracked!(print_codegen_stats, true);
@@ -751,6 +747,7 @@ fn test_unstable_options_tracking_hash() {
tracked!(cross_crate_inline_threshold, InliningThreshold::Always);
tracked!(debug_info_for_profiling, true);
tracked!(debug_macros, true);
+ tracked!(default_hidden_visibility, Some(true));
tracked!(dep_info_omit_d_target, true);
tracked!(dual_proc_macros, true);
tracked!(dwarf_version, Some(5));
@@ -760,6 +757,7 @@ fn test_unstable_options_tracking_hash() {
tracked!(flatten_format_args, false);
tracked!(force_unstable_if_unmarked, true);
tracked!(fuel, Some(("abc".to_string(), 99)));
+ tracked!(function_return, FunctionReturn::ThunkExtern);
tracked!(function_sections, Some(false));
tracked!(human_readable_cgu_names, true);
tracked!(incremental_ignore_spans, true);
@@ -771,6 +769,7 @@ fn test_unstable_options_tracking_hash() {
tracked!(instrument_xray, Some(InstrumentXRay::default()));
tracked!(link_directives, false);
tracked!(link_only, true);
+ tracked!(llvm_module_flag, vec![("bar".to_string(), 123, "max".to_string())]);
tracked!(llvm_plugins, vec![String::from("plugin_name")]);
tracked!(location_detail, LocationDetail { file: true, line: false, column: false });
tracked!(maximal_hir_to_mir_coverage, true);
@@ -781,6 +780,10 @@ fn test_unstable_options_tracking_hash() {
tracked!(mir_opt_level, Some(4));
tracked!(move_size_limit, Some(4096));
tracked!(mutable_noalias, false);
+ tracked!(
+ next_solver,
+ Some(NextSolverConfig { coherence: true, globally: false, dump_tree: Default::default() })
+ );
tracked!(no_generate_arange_section, true);
tracked!(no_jump_tables, true);
tracked!(no_link, true);
@@ -822,7 +825,6 @@ fn test_unstable_options_tracking_hash() {
tracked!(thir_unsafeck, true);
tracked!(tiny_const_eval_limit, true);
tracked!(tls_model, Some(TlsModel::GeneralDynamic));
- tracked!(trait_solver, TraitSolver::NextCoherence);
tracked!(translate_remapped_path_to_local_path, false);
tracked!(trap_unreachable, Some(false));
tracked!(treat_err_as_bug, NonZeroUsize::new(1));
@@ -852,9 +854,9 @@ fn test_edition_parsing() {
let options = Options::default();
assert!(options.edition == DEFAULT_EDITION);
- let mut handler = EarlyErrorHandler::new(ErrorOutputType::default());
+ let mut early_dcx = EarlyDiagCtxt::new(ErrorOutputType::default());
let matches = optgroups().parse(&["--edition=2018".to_string()]).unwrap();
- let sessopts = build_session_options(&mut handler, &matches);
+ let sessopts = build_session_options(&mut early_dcx, &matches);
assert!(sessopts.edition == Edition::Edition2018)
}