Put FnAbiError
behind reference to shrink result
The `FnAbi` is just a pointer, so the error type should not be bigger.
This commit is contained in:
parent
3019c1cb2a
commit
4be84771a7
4 changed files with 20 additions and 25 deletions
|
@ -71,8 +71,8 @@ impl<T> EraseType for Result<&'_ T, traits::CodegenObligationError> {
|
|||
type Result = [u8; size_of::<Result<&'static (), traits::CodegenObligationError>>()];
|
||||
}
|
||||
|
||||
impl<T> EraseType for Result<&'_ T, ty::layout::FnAbiError<'_>> {
|
||||
type Result = [u8; size_of::<Result<&'static (), ty::layout::FnAbiError<'static>>>()];
|
||||
impl<T> EraseType for Result<&'_ T, &'_ ty::layout::FnAbiError<'_>> {
|
||||
type Result = [u8; size_of::<Result<&'static (), &'static ty::layout::FnAbiError<'static>>>()];
|
||||
}
|
||||
|
||||
impl<T> EraseType for Result<(&'_ T, rustc_middle::thir::ExprId), rustc_errors::ErrorGuaranteed> {
|
||||
|
|
|
@ -1394,7 +1394,7 @@ rustc_queries! {
|
|||
/// instead, where the instance is an `InstanceDef::Virtual`.
|
||||
query fn_abi_of_fn_ptr(
|
||||
key: ty::ParamEnvAnd<'tcx, (ty::PolyFnSig<'tcx>, &'tcx ty::List<Ty<'tcx>>)>
|
||||
) -> Result<&'tcx abi::call::FnAbi<'tcx, Ty<'tcx>>, ty::layout::FnAbiError<'tcx>> {
|
||||
) -> Result<&'tcx abi::call::FnAbi<'tcx, Ty<'tcx>>, &'tcx ty::layout::FnAbiError<'tcx>> {
|
||||
desc { "computing call ABI of `{}` function pointers", key.value.0 }
|
||||
}
|
||||
|
||||
|
@ -1405,7 +1405,7 @@ rustc_queries! {
|
|||
/// to an `InstanceDef::Virtual` instance (of `<dyn Trait as Trait>::fn`).
|
||||
query fn_abi_of_instance(
|
||||
key: ty::ParamEnvAnd<'tcx, (ty::Instance<'tcx>, &'tcx ty::List<Ty<'tcx>>)>
|
||||
) -> Result<&'tcx abi::call::FnAbi<'tcx, Ty<'tcx>>, ty::layout::FnAbiError<'tcx>> {
|
||||
) -> Result<&'tcx abi::call::FnAbi<'tcx, Ty<'tcx>>, &'tcx ty::layout::FnAbiError<'tcx>> {
|
||||
desc { "computing call ABI of `{}`", key.value.0 }
|
||||
}
|
||||
|
||||
|
|
|
@ -1260,18 +1260,6 @@ pub enum FnAbiError<'tcx> {
|
|||
AdjustForForeignAbi(call::AdjustForForeignAbiError),
|
||||
}
|
||||
|
||||
impl<'tcx> From<LayoutError<'tcx>> for FnAbiError<'tcx> {
|
||||
fn from(err: LayoutError<'tcx>) -> Self {
|
||||
Self::Layout(err)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<call::AdjustForForeignAbiError> for FnAbiError<'_> {
|
||||
fn from(err: call::AdjustForForeignAbiError) -> Self {
|
||||
Self::AdjustForForeignAbi(err)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'b> IntoDiagnostic<'a, !> for FnAbiError<'b> {
|
||||
fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, !> {
|
||||
match self {
|
||||
|
@ -1331,7 +1319,7 @@ pub trait FnAbiOf<'tcx>: FnAbiOfHelpers<'tcx> {
|
|||
let tcx = self.tcx().at(span);
|
||||
|
||||
MaybeResult::from(tcx.fn_abi_of_fn_ptr(self.param_env().and((sig, extra_args))).map_err(
|
||||
|err| self.handle_fn_abi_err(err, span, FnAbiRequest::OfFnPtr { sig, extra_args }),
|
||||
|err| self.handle_fn_abi_err(*err, span, FnAbiRequest::OfFnPtr { sig, extra_args }),
|
||||
))
|
||||
}
|
||||
|
||||
|
@ -1358,7 +1346,11 @@ pub trait FnAbiOf<'tcx>: FnAbiOfHelpers<'tcx> {
|
|||
// However, we don't do this early in order to avoid calling
|
||||
// `def_span` unconditionally (which may have a perf penalty).
|
||||
let span = if !span.is_dummy() { span } else { tcx.def_span(instance.def_id()) };
|
||||
self.handle_fn_abi_err(err, span, FnAbiRequest::OfInstance { instance, extra_args })
|
||||
self.handle_fn_abi_err(
|
||||
*err,
|
||||
span,
|
||||
FnAbiRequest::OfInstance { instance, extra_args },
|
||||
)
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue