Convert unsafety using the stable method and reuse mir::Safety

This commit is contained in:
Santiago Pastorino 2023-08-04 17:01:05 -03:00
parent 139b49b995
commit 4199a3c13a
No known key found for this signature in database
GPG Key ID: 8131A24E0C79EFAF
2 changed files with 4 additions and 13 deletions

View File

@ -826,7 +826,7 @@ impl<'tcx> Stable<'tcx> for ty::FnSig<'tcx> {
type T = stable_mir::ty::FnSig;
fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T {
use rustc_target::spec::abi;
use stable_mir::ty::{Abi, FnSig, Unsafety};
use stable_mir::ty::{Abi, FnSig};
FnSig {
inputs_and_output: self
@ -835,10 +835,7 @@ impl<'tcx> Stable<'tcx> for ty::FnSig<'tcx> {
.map(|ty| tables.intern_ty(ty))
.collect(),
c_variadic: self.c_variadic,
unsafety: match self.unsafety {
hir::Unsafety::Normal => Unsafety::Normal,
hir::Unsafety::Unsafe => Unsafety::Unsafe,
},
unsafety: self.unsafety.stable(tables),
abi: match self.abi {
abi::Abi::Rust => Abi::Rust,
abi::Abi::C { unwind } => Abi::C { unwind },

View File

@ -1,4 +1,4 @@
use super::{mir::Mutability, with, DefId};
use super::{mir::Mutability, mir::Safety, with, DefId};
use crate::rustc_internal::Opaque;
#[derive(Copy, Clone, Debug)]
@ -140,16 +140,10 @@ pub type PolyFnSig = Binder<FnSig>;
pub struct FnSig {
pub inputs_and_output: Vec<Ty>,
pub c_variadic: bool,
pub unsafety: Unsafety,
pub unsafety: Safety,
pub abi: Abi,
}
#[derive(Clone, PartialEq, Eq, Debug)]
pub enum Unsafety {
Unsafe,
Normal,
}
#[derive(Clone, PartialEq, Eq, Debug)]
pub enum Abi {
Rust,