Skip to content

Commit b4a20ab

Browse files
committed
rustc_interface: remove huge error imports
1 parent a399f0c commit b4a20ab

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

compiler/rustc_interface/src/passes.rs

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
use crate::errors::{
2-
CantEmitMIR, EmojiIdentifier, ErrorWritingDependencies, FerrisIdentifier,
3-
GeneratedFileConflictsWithDirectory, InputFileWouldBeOverWritten, MixedBinCrate,
4-
MixedProcMacroCrate, OutDirError, ProcMacroCratePanicAbort, ProcMacroDocWithoutArg,
5-
TempsDirError,
6-
};
1+
use crate::errors;
72
use crate::interface::{Compiler, Result};
83
use crate::proc_macro_decls;
94
use crate::util;
@@ -374,15 +369,15 @@ pub fn configure_and_expand(
374369

375370
if crate_types.len() > 1 {
376371
if is_executable_crate {
377-
sess.emit_err(MixedBinCrate);
372+
sess.emit_err(errors::MixedBinCrate);
378373
}
379374
if is_proc_macro_crate {
380-
sess.emit_err(MixedProcMacroCrate);
375+
sess.emit_err(errors::MixedProcMacroCrate);
381376
}
382377
}
383378

384379
if is_proc_macro_crate && sess.panic_strategy() == PanicStrategy::Abort {
385-
sess.emit_warning(ProcMacroCratePanicAbort);
380+
sess.emit_warning(errors::ProcMacroCratePanicAbort);
386381
}
387382

388383
// For backwards compatibility, we don't try to run proc macro injection
@@ -392,7 +387,7 @@ pub fn configure_and_expand(
392387
// However, we do emit a warning, to let such users know that they should
393388
// start passing '--crate-type proc-macro'
394389
if has_proc_macro_decls && sess.opts.actually_rustdoc && !is_proc_macro_crate {
395-
sess.emit_warning(ProcMacroDocWithoutArg);
390+
sess.emit_warning(errors::ProcMacroDocWithoutArg);
396391
} else {
397392
krate = sess.time("maybe_create_a_macro_crate", || {
398393
let is_test_crate = sess.opts.test;
@@ -441,9 +436,9 @@ pub fn configure_and_expand(
441436
spans.sort();
442437
if ident == sym::ferris {
443438
let first_span = spans[0];
444-
sess.emit_err(FerrisIdentifier { spans, first_span });
439+
sess.emit_err(errors::FerrisIdentifier { spans, first_span });
445440
} else {
446-
sess.emit_err(EmojiIdentifier { spans, ident });
441+
sess.emit_err(errors::EmojiIdentifier { spans, ident });
447442
}
448443
}
449444
});
@@ -655,7 +650,7 @@ fn write_out_deps(
655650
}
656651
}
657652
Err(error) => {
658-
sess.emit_fatal(ErrorWritingDependencies { path: &deps_filename, error });
653+
sess.emit_fatal(errors::ErrorWritingDependencies { path: &deps_filename, error });
659654
}
660655
}
661656
}
@@ -676,17 +671,20 @@ fn output_filenames(tcx: TyCtxt<'_>, (): ()) -> Arc<OutputFilenames> {
676671
if let Some(ref input_path) = sess.io.input.opt_path() {
677672
if sess.opts.will_create_output_file() {
678673
if output_contains_path(&output_paths, input_path) {
679-
sess.emit_fatal(InputFileWouldBeOverWritten { path: input_path });
674+
sess.emit_fatal(errors::InputFileWouldBeOverWritten { path: input_path });
680675
}
681676
if let Some(ref dir_path) = output_conflicts_with_dir(&output_paths) {
682-
sess.emit_fatal(GeneratedFileConflictsWithDirectory { input_path, dir_path });
677+
sess.emit_fatal(errors::GeneratedFileConflictsWithDirectory {
678+
input_path,
679+
dir_path,
680+
});
683681
}
684682
}
685683
}
686684

687685
if let Some(ref dir) = sess.io.temps_dir {
688686
if fs::create_dir_all(dir).is_err() {
689-
sess.emit_fatal(TempsDirError);
687+
sess.emit_fatal(errors::TempsDirError);
690688
}
691689
}
692690

@@ -698,7 +696,7 @@ fn output_filenames(tcx: TyCtxt<'_>, (): ()) -> Arc<OutputFilenames> {
698696
if !only_dep_info {
699697
if let Some(ref dir) = sess.io.output_dir {
700698
if fs::create_dir_all(dir).is_err() {
701-
sess.emit_fatal(OutDirError);
699+
sess.emit_fatal(errors::OutDirError);
702700
}
703701
}
704702
}
@@ -977,7 +975,7 @@ pub fn start_codegen<'tcx>(
977975

978976
if tcx.sess.opts.output_types.contains_key(&OutputType::Mir) {
979977
if let Err(error) = rustc_mir_transform::dump_mir::emit_mir(tcx) {
980-
tcx.sess.emit_err(CantEmitMIR { error });
978+
tcx.sess.emit_err(errors::CantEmitMIR { error });
981979
tcx.sess.abort_if_errors();
982980
}
983981
}

0 commit comments

Comments
 (0)