Fixes fmt & SessionDiagnostic structs
This commit is contained in:
parent
dbe39d835e
commit
e7ded9246c
2 changed files with 9 additions and 31 deletions
|
@ -550,11 +550,7 @@ fn handle_explain(registry: Registry, code: &str, output: ErrorOutputType) {
|
||||||
|
|
||||||
fn show_content_with_pager(content: &str) {
|
fn show_content_with_pager(content: &str) {
|
||||||
let pager_name = env::var_os("PAGER").unwrap_or_else(|| {
|
let pager_name = env::var_os("PAGER").unwrap_or_else(|| {
|
||||||
if cfg!(windows) {
|
if cfg!(windows) { OsString::from("more.com") } else { OsString::from("less") }
|
||||||
OsString::from("more.com")
|
|
||||||
} else {
|
|
||||||
OsString::from("less")
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
let mut fallback_to_println = false;
|
let mut fallback_to_println = false;
|
||||||
|
@ -590,24 +586,18 @@ pub fn try_process_rlink(sess: &Session, compiler: &interface::Compiler) -> Comp
|
||||||
sess.init_crate_types(collect_crate_types(sess, &[]));
|
sess.init_crate_types(collect_crate_types(sess, &[]));
|
||||||
let outputs = compiler.build_output_filenames(sess, &[]);
|
let outputs = compiler.build_output_filenames(sess, &[]);
|
||||||
let rlink_data = fs::read(file).unwrap_or_else(|err| {
|
let rlink_data = fs::read(file).unwrap_or_else(|err| {
|
||||||
sess.fatal(RlinkUnableToRead {
|
sess.emit_fatal(RlinkUnableToRead { error_message: err.to_string() });
|
||||||
span: Default::default(),
|
|
||||||
error_message: err.to_string(),
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
let codegen_results = match CodegenResults::deserialize_rlink(rlink_data) {
|
let codegen_results = match CodegenResults::deserialize_rlink(rlink_data) {
|
||||||
Ok(codegen) => codegen,
|
Ok(codegen) => codegen,
|
||||||
Err(error) => {
|
Err(error) => {
|
||||||
sess.fatal(RlinkUnableToDeserialize {
|
sess.emit_fatal(RlinkUnableToDeserialize { error_message: error.to_string() });
|
||||||
span: Default::default(),
|
|
||||||
error_message: error.to_string(),
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let result = compiler.codegen_backend().link(sess, codegen_results, &outputs);
|
let result = compiler.codegen_backend().link(sess, codegen_results, &outputs);
|
||||||
abort_on_err(result, sess);
|
abort_on_err(result, sess);
|
||||||
} else {
|
} else {
|
||||||
sess.fatal(RlinkNotAFile { span: Default::default() })
|
sess.emit_fatal(RlinkNotAFile {})
|
||||||
}
|
}
|
||||||
Compilation::Stop
|
Compilation::Stop
|
||||||
} else {
|
} else {
|
||||||
|
@ -1131,11 +1121,7 @@ fn extra_compiler_flags() -> Option<(Vec<String>, bool)> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !result.is_empty() {
|
if !result.is_empty() { Some((result, excluded_cargo_defaults)) } else { None }
|
||||||
Some((result, excluded_cargo_defaults))
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Runs a closure and catches unwinds triggered by fatal errors.
|
/// Runs a closure and catches unwinds triggered by fatal errors.
|
||||||
|
|
|
@ -1,25 +1,17 @@
|
||||||
use rustc_macros::SessionDiagnostic;
|
use rustc_macros::SessionDiagnostic;
|
||||||
use rustc_span::Span;
|
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(SessionDiagnostic)]
|
||||||
#[error(driver::rlink_unable_to_read)]
|
#[diag(driver::rlink_unable_to_read)]
|
||||||
pub(crate) struct RlinkUnableToRead {
|
pub(crate) struct RlinkUnableToRead {
|
||||||
#[primary_span]
|
|
||||||
pub span: Span,
|
|
||||||
pub error_message: String,
|
pub error_message: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(SessionDiagnostic)]
|
||||||
#[error(driver::rlink_unable_to_deserialize)]
|
#[diag(driver::rlink_unable_to_deserialize)]
|
||||||
pub(crate) struct RlinkUnableToDeserialize {
|
pub(crate) struct RlinkUnableToDeserialize {
|
||||||
#[primary_span]
|
|
||||||
pub span: Span,
|
|
||||||
pub error_message: String,
|
pub error_message: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(SessionDiagnostic)]
|
#[derive(SessionDiagnostic)]
|
||||||
#[error(driver::rlink_no_a_file)]
|
#[diag(driver::rlink_no_a_file)]
|
||||||
pub(crate) struct RlinkNotAFile {
|
pub(crate) struct RlinkNotAFile {}
|
||||||
#[primary_span]
|
|
||||||
pub span: Span,
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue