Remove use of DiagnosticArgFromDisplay
This commit is contained in:
parent
0d80ee705f
commit
645de5b825
3 changed files with 22 additions and 30 deletions
|
@ -1,7 +1,9 @@
|
||||||
use rustc_errors::DiagnosticArgFromDisplay;
|
|
||||||
use rustc_macros::SessionDiagnostic;
|
use rustc_macros::SessionDiagnostic;
|
||||||
use rustc_span::{Span, Symbol};
|
use rustc_span::{Span, Symbol};
|
||||||
|
|
||||||
|
use std::io;
|
||||||
|
use std::path::Path;
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(SessionDiagnostic)]
|
||||||
#[diag(interface::ferris_identifier)]
|
#[diag(interface::ferris_identifier)]
|
||||||
pub struct FerrisIdentifier {
|
pub struct FerrisIdentifier {
|
||||||
|
@ -34,21 +36,21 @@ pub struct ProcMacroDocWithoutArg;
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(SessionDiagnostic)]
|
||||||
#[diag(interface::error_writing_dependencies)]
|
#[diag(interface::error_writing_dependencies)]
|
||||||
pub struct ErrorWritingDependencies<'a> {
|
pub struct ErrorWritingDependencies<'a> {
|
||||||
pub path: DiagnosticArgFromDisplay<'a>,
|
pub path: &'a Path,
|
||||||
pub error: DiagnosticArgFromDisplay<'a>,
|
pub error: io::Error,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(SessionDiagnostic)]
|
||||||
#[diag(interface::input_file_would_be_overwritten)]
|
#[diag(interface::input_file_would_be_overwritten)]
|
||||||
pub struct InputFileWouldBeOverWritten<'a> {
|
pub struct InputFileWouldBeOverWritten<'a> {
|
||||||
pub path: DiagnosticArgFromDisplay<'a>,
|
pub path: &'a Path,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(SessionDiagnostic)]
|
||||||
#[diag(interface::generated_file_conflicts_with_directory)]
|
#[diag(interface::generated_file_conflicts_with_directory)]
|
||||||
pub struct GeneratedFileConflictsWithDirectory<'a> {
|
pub struct GeneratedFileConflictsWithDirectory<'a> {
|
||||||
pub input_path: DiagnosticArgFromDisplay<'a>,
|
pub input_path: &'a Path,
|
||||||
pub dir_path: DiagnosticArgFromDisplay<'a>,
|
pub dir_path: &'a Path,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(SessionDiagnostic)]
|
||||||
|
@ -61,8 +63,8 @@ pub struct OutDirError;
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(SessionDiagnostic)]
|
||||||
#[diag(interface::cant_emit_mir)]
|
#[diag(interface::cant_emit_mir)]
|
||||||
pub struct CantEmitMIR<'a> {
|
pub struct CantEmitMIR {
|
||||||
pub error: DiagnosticArgFromDisplay<'a>,
|
pub error: io::Error,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(SessionDiagnostic)]
|
||||||
|
@ -82,6 +84,6 @@ pub struct RustcErrorUnexpectedAnnotation {
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(SessionDiagnostic)]
|
||||||
#[diag(interface::failed_writing_file)]
|
#[diag(interface::failed_writing_file)]
|
||||||
pub struct FailedWritingFile<'a> {
|
pub struct FailedWritingFile<'a> {
|
||||||
pub path: DiagnosticArgFromDisplay<'a>,
|
pub path: &'a Path,
|
||||||
pub error: DiagnosticArgFromDisplay<'a>,
|
pub error: io::Error,
|
||||||
}
|
}
|
||||||
|
|
|
@ -647,11 +647,8 @@ fn write_out_deps(
|
||||||
.emit_artifact_notification(&deps_filename, "dep-info");
|
.emit_artifact_notification(&deps_filename, "dep-info");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(error) => {
|
||||||
sess.emit_fatal(ErrorWritingDependencies {
|
sess.emit_fatal(ErrorWritingDependencies { path: &deps_filename, error });
|
||||||
path: (&deps_filename.display()).into(),
|
|
||||||
error: (&e).into(),
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -682,15 +679,12 @@ pub fn prepare_outputs(
|
||||||
if let Some(ref input_path) = compiler.input_path {
|
if let Some(ref input_path) = compiler.input_path {
|
||||||
if sess.opts.will_create_output_file() {
|
if sess.opts.will_create_output_file() {
|
||||||
if output_contains_path(&output_paths, input_path) {
|
if output_contains_path(&output_paths, input_path) {
|
||||||
let reported = sess
|
let reported = sess.emit_err(InputFileWouldBeOverWritten { path: input_path });
|
||||||
.emit_err(InputFileWouldBeOverWritten { path: (&input_path.display()).into() });
|
|
||||||
return Err(reported);
|
return Err(reported);
|
||||||
}
|
}
|
||||||
if let Some(dir_path) = output_conflicts_with_dir(&output_paths) {
|
if let Some(ref dir_path) = output_conflicts_with_dir(&output_paths) {
|
||||||
let reported = sess.emit_err(GeneratedFileConflictsWithDirectory {
|
let reported =
|
||||||
input_path: (&input_path.display()).into(),
|
sess.emit_err(GeneratedFileConflictsWithDirectory { input_path, dir_path });
|
||||||
dir_path: (&dir_path.display()).into(),
|
|
||||||
});
|
|
||||||
return Err(reported);
|
return Err(reported);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -994,8 +988,8 @@ pub fn start_codegen<'tcx>(
|
||||||
info!("Post-codegen\n{:?}", tcx.debug_stats());
|
info!("Post-codegen\n{:?}", tcx.debug_stats());
|
||||||
|
|
||||||
if tcx.sess.opts.output_types.contains_key(&OutputType::Mir) {
|
if tcx.sess.opts.output_types.contains_key(&OutputType::Mir) {
|
||||||
if let Err(e) = rustc_mir_transform::dump_mir::emit_mir(tcx, outputs) {
|
if let Err(error) = rustc_mir_transform::dump_mir::emit_mir(tcx, outputs) {
|
||||||
tcx.sess.emit_err(CantEmitMIR { error: (&e).into() });
|
tcx.sess.emit_err(CantEmitMIR { error });
|
||||||
tcx.sess.abort_if_errors();
|
tcx.sess.abort_if_errors();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -357,12 +357,8 @@ impl Linker {
|
||||||
if sess.opts.unstable_opts.no_link {
|
if sess.opts.unstable_opts.no_link {
|
||||||
let encoded = CodegenResults::serialize_rlink(&codegen_results);
|
let encoded = CodegenResults::serialize_rlink(&codegen_results);
|
||||||
let rlink_file = self.prepare_outputs.with_extension(config::RLINK_EXT);
|
let rlink_file = self.prepare_outputs.with_extension(config::RLINK_EXT);
|
||||||
std::fs::write(&rlink_file, encoded).map_err(|err| {
|
std::fs::write(&rlink_file, encoded)
|
||||||
sess.emit_fatal(FailedWritingFile {
|
.map_err(|error| sess.emit_fatal(FailedWritingFile { path: &rlink_file, error }))?;
|
||||||
path: (&rlink_file.display()).into(),
|
|
||||||
error: (&err).into(),
|
|
||||||
})
|
|
||||||
})?;
|
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue