Skip to content

Commit 580cc89

Browse files
committed
rustc_session: remove huge error imports
1 parent 394fa19 commit 580cc89

File tree

1 file changed

+23
-29
lines changed

1 file changed

+23
-29
lines changed

compiler/rustc_session/src/session.rs

+23-29
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,7 @@ use crate::code_stats::CodeStats;
33
pub use crate::code_stats::{DataTypeKind, FieldInfo, FieldKind, SizeKind, VariantInfo};
44
use crate::config::Input;
55
use crate::config::{self, CrateType, InstrumentCoverage, OptLevel, OutputType, SwitchWithOptPath};
6-
use crate::errors::{
7-
BranchProtectionRequiresAArch64, CannotEnableCrtStaticLinux, CannotMixAndMatchSanitizers,
8-
LinkerPluginToWindowsNotSupported, NotCircumventFeature, OptimisationFuelExhausted,
9-
ProfileSampleUseFileDoesNotExist, ProfileUseFileDoesNotExist, SanitizerCfiEnabled,
10-
SanitizerNotSupported, SanitizersNotSupported, SkippingConstChecks,
11-
SplitDebugInfoUnstablePlatform, StackProtectorNotSupportedForTarget,
12-
TargetRequiresUnwindTables, UnleashedFeatureHelp, UnstableVirtualFunctionElimination,
13-
UnsupportedDwarfVersion,
14-
};
6+
use crate::errors;
157
use crate::parse::{add_feature_diagnostics, ParseSess};
168
use crate::search_paths::{PathKind, SearchPath};
179
use crate::{filesearch, lint};
@@ -246,23 +238,23 @@ impl Session {
246238
if !unleashed_features.is_empty() {
247239
let mut must_err = false;
248240
// Create a diagnostic pointing at where things got unleashed.
249-
self.emit_warning(SkippingConstChecks {
241+
self.emit_warning(errors::SkippingConstChecks {
250242
unleashed_features: unleashed_features
251243
.iter()
252244
.map(|(span, gate)| {
253245
gate.map(|gate| {
254246
must_err = true;
255-
UnleashedFeatureHelp::Named { span: *span, gate }
247+
errors::UnleashedFeatureHelp::Named { span: *span, gate }
256248
})
257-
.unwrap_or(UnleashedFeatureHelp::Unnamed { span: *span })
249+
.unwrap_or(errors::UnleashedFeatureHelp::Unnamed { span: *span })
258250
})
259251
.collect(),
260252
});
261253

262254
// If we should err, make sure we did.
263255
if must_err && self.has_errors().is_none() {
264256
// We have skipped a feature gate, and not run into other errors... reject.
265-
self.emit_err(NotCircumventFeature);
257+
self.emit_err(errors::NotCircumventFeature);
266258
}
267259
}
268260
}
@@ -901,7 +893,7 @@ impl Session {
901893
// We only call `msg` in case we can actually emit warnings.
902894
// Otherwise, this could cause a `delay_good_path_bug` to
903895
// trigger (issue #79546).
904-
self.emit_warning(OptimisationFuelExhausted { msg: msg() });
896+
self.emit_warning(errors::OptimisationFuelExhausted { msg: msg() });
905897
}
906898
fuel.out_of_fuel = true;
907899
} else if fuel.remaining > 0 {
@@ -1502,28 +1494,28 @@ fn validate_commandline_args_with_session_available(sess: &Session) {
15021494
&& sess.opts.cg.prefer_dynamic
15031495
&& sess.target.is_like_windows
15041496
{
1505-
sess.emit_err(LinkerPluginToWindowsNotSupported);
1497+
sess.emit_err(errors::LinkerPluginToWindowsNotSupported);
15061498
}
15071499

15081500
// Make sure that any given profiling data actually exists so LLVM can't
15091501
// decide to silently skip PGO.
15101502
if let Some(ref path) = sess.opts.cg.profile_use {
15111503
if !path.exists() {
1512-
sess.emit_err(ProfileUseFileDoesNotExist { path });
1504+
sess.emit_err(errors::ProfileUseFileDoesNotExist { path });
15131505
}
15141506
}
15151507

15161508
// Do the same for sample profile data.
15171509
if let Some(ref path) = sess.opts.unstable_opts.profile_sample_use {
15181510
if !path.exists() {
1519-
sess.emit_err(ProfileSampleUseFileDoesNotExist { path });
1511+
sess.emit_err(errors::ProfileSampleUseFileDoesNotExist { path });
15201512
}
15211513
}
15221514

15231515
// Unwind tables cannot be disabled if the target requires them.
15241516
if let Some(include_uwtables) = sess.opts.cg.force_unwind_tables {
15251517
if sess.target.requires_uwtable && !include_uwtables {
1526-
sess.emit_err(TargetRequiresUnwindTables);
1518+
sess.emit_err(errors::TargetRequiresUnwindTables);
15271519
}
15281520
}
15291521

@@ -1533,67 +1525,69 @@ fn validate_commandline_args_with_session_available(sess: &Session) {
15331525
match unsupported_sanitizers.into_iter().count() {
15341526
0 => {}
15351527
1 => {
1536-
sess.emit_err(SanitizerNotSupported { us: unsupported_sanitizers.to_string() });
1528+
sess.emit_err(errors::SanitizerNotSupported { us: unsupported_sanitizers.to_string() });
15371529
}
15381530
_ => {
1539-
sess.emit_err(SanitizersNotSupported { us: unsupported_sanitizers.to_string() });
1531+
sess.emit_err(errors::SanitizersNotSupported {
1532+
us: unsupported_sanitizers.to_string(),
1533+
});
15401534
}
15411535
}
15421536
// Cannot mix and match sanitizers.
15431537
let mut sanitizer_iter = sess.opts.unstable_opts.sanitizer.into_iter();
15441538
if let (Some(first), Some(second)) = (sanitizer_iter.next(), sanitizer_iter.next()) {
1545-
sess.emit_err(CannotMixAndMatchSanitizers {
1539+
sess.emit_err(errors::CannotMixAndMatchSanitizers {
15461540
first: first.to_string(),
15471541
second: second.to_string(),
15481542
});
15491543
}
15501544

15511545
// Cannot enable crt-static with sanitizers on Linux
15521546
if sess.crt_static(None) && !sess.opts.unstable_opts.sanitizer.is_empty() {
1553-
sess.emit_err(CannotEnableCrtStaticLinux);
1547+
sess.emit_err(errors::CannotEnableCrtStaticLinux);
15541548
}
15551549

15561550
// LLVM CFI and VFE both require LTO.
15571551
if sess.lto() != config::Lto::Fat {
15581552
if sess.is_sanitizer_cfi_enabled() {
1559-
sess.emit_err(SanitizerCfiEnabled);
1553+
sess.emit_err(errors::SanitizerCfiEnabled);
15601554
}
15611555
if sess.opts.unstable_opts.virtual_function_elimination {
1562-
sess.emit_err(UnstableVirtualFunctionElimination);
1556+
sess.emit_err(errors::UnstableVirtualFunctionElimination);
15631557
}
15641558
}
15651559

15661560
// LLVM CFI and KCFI are mutually exclusive
15671561
if sess.is_sanitizer_cfi_enabled() && sess.is_sanitizer_kcfi_enabled() {
1568-
sess.emit_err(CannotMixAndMatchSanitizers {
1562+
sess.emit_err(errors::CannotMixAndMatchSanitizers {
15691563
first: "cfi".to_string(),
15701564
second: "kcfi".to_string(),
15711565
});
15721566
}
15731567

15741568
if sess.opts.unstable_opts.stack_protector != StackProtector::None {
15751569
if !sess.target.options.supports_stack_protector {
1576-
sess.emit_warning(StackProtectorNotSupportedForTarget {
1570+
sess.emit_warning(errors::StackProtectorNotSupportedForTarget {
15771571
stack_protector: sess.opts.unstable_opts.stack_protector,
15781572
target_triple: &sess.opts.target_triple,
15791573
});
15801574
}
15811575
}
15821576

15831577
if sess.opts.unstable_opts.branch_protection.is_some() && sess.target.arch != "aarch64" {
1584-
sess.emit_err(BranchProtectionRequiresAArch64);
1578+
sess.emit_err(errors::BranchProtectionRequiresAArch64);
15851579
}
15861580

15871581
if let Some(dwarf_version) = sess.opts.unstable_opts.dwarf_version {
15881582
if dwarf_version > 5 {
1589-
sess.emit_err(UnsupportedDwarfVersion { dwarf_version });
1583+
sess.emit_err(errors::UnsupportedDwarfVersion { dwarf_version });
15901584
}
15911585
}
15921586

15931587
if !sess.target.options.supported_split_debuginfo.contains(&sess.split_debuginfo())
15941588
&& !sess.opts.unstable_opts.unstable_options
15951589
{
1596-
sess.emit_err(SplitDebugInfoUnstablePlatform { debuginfo: sess.split_debuginfo() });
1590+
sess.emit_err(errors::SplitDebugInfoUnstablePlatform { debuginfo: sess.split_debuginfo() });
15971591
}
15981592
}
15991593

0 commit comments

Comments
 (0)