compiler: die immediately instead of handling unknown target codegen
We cannot produce anything useful if asked to compile unknown targets. We should handle the error immediately at the point of discovery instead of propagating it upward, and preferably in the simplest way: Die. This allows cleaning up our "error-handling" spread across 5 crates.
This commit is contained in:
parent
8c04e39595
commit
17716be86e
7 changed files with 7 additions and 63 deletions
|
@ -216,10 +216,6 @@ pub enum InvalidProgramInfo<'tcx> {
|
|||
AlreadyReported(ReportedErrorInfo),
|
||||
/// An error occurred during layout computation.
|
||||
Layout(layout::LayoutError<'tcx>),
|
||||
/// An error occurred during FnAbi computation: the passed --target lacks FFI support
|
||||
/// (which unfortunately typeck does not reject).
|
||||
/// Not using `FnAbiError` as that contains a nested `LayoutError`.
|
||||
FnAbiAdjustForForeignAbi(rustc_target::callconv::AdjustForForeignAbiError),
|
||||
}
|
||||
|
||||
/// Details of why a pointer had to be in-bounds.
|
||||
|
|
|
@ -24,7 +24,6 @@ use rustc_target::spec::{
|
|||
use tracing::debug;
|
||||
use {rustc_abi as abi, rustc_hir as hir};
|
||||
|
||||
use crate::error::UnsupportedFnAbi;
|
||||
use crate::middle::codegen_fn_attrs::CodegenFnAttrFlags;
|
||||
use crate::query::TyCtxtAt;
|
||||
use crate::ty::normalize_erasing_regions::NormalizationError;
|
||||
|
@ -1275,18 +1274,12 @@ pub fn fn_can_unwind(tcx: TyCtxt<'_>, fn_def_id: Option<DefId>, abi: ExternAbi)
|
|||
pub enum FnAbiError<'tcx> {
|
||||
/// Error produced by a `layout_of` call, while computing `FnAbi` initially.
|
||||
Layout(LayoutError<'tcx>),
|
||||
|
||||
/// Error produced by attempting to adjust a `FnAbi`, for a "foreign" ABI.
|
||||
AdjustForForeignAbi(rustc_target::callconv::AdjustForForeignAbiError),
|
||||
}
|
||||
|
||||
impl<'a, 'b, G: EmissionGuarantee> Diagnostic<'a, G> for FnAbiError<'b> {
|
||||
fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> {
|
||||
match self {
|
||||
Self::Layout(e) => e.into_diagnostic().into_diag(dcx, level),
|
||||
Self::AdjustForForeignAbi(
|
||||
rustc_target::callconv::AdjustForForeignAbiError::Unsupported { arch, abi },
|
||||
) => UnsupportedFnAbi { arch, abi: abi.name() }.into_diag(dcx, level),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue