Skip to content

Commit 4199a3c

Browse files
committed
Convert unsafety using the stable method and reuse mir::Safety
1 parent 139b49b commit 4199a3c

File tree

2 files changed

+4
-13
lines changed

2 files changed

+4
-13
lines changed

Diff for: compiler/rustc_smir/src/rustc_smir/mod.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,7 @@ impl<'tcx> Stable<'tcx> for ty::FnSig<'tcx> {
826826
type T = stable_mir::ty::FnSig;
827827
fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T {
828828
use rustc_target::spec::abi;
829-
use stable_mir::ty::{Abi, FnSig, Unsafety};
829+
use stable_mir::ty::{Abi, FnSig};
830830

831831
FnSig {
832832
inputs_and_output: self
@@ -835,10 +835,7 @@ impl<'tcx> Stable<'tcx> for ty::FnSig<'tcx> {
835835
.map(|ty| tables.intern_ty(ty))
836836
.collect(),
837837
c_variadic: self.c_variadic,
838-
unsafety: match self.unsafety {
839-
hir::Unsafety::Normal => Unsafety::Normal,
840-
hir::Unsafety::Unsafe => Unsafety::Unsafe,
841-
},
838+
unsafety: self.unsafety.stable(tables),
842839
abi: match self.abi {
843840
abi::Abi::Rust => Abi::Rust,
844841
abi::Abi::C { unwind } => Abi::C { unwind },

Diff for: compiler/rustc_smir/src/stable_mir/ty.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::{mir::Mutability, with, DefId};
1+
use super::{mir::Mutability, mir::Safety, with, DefId};
22
use crate::rustc_internal::Opaque;
33

44
#[derive(Copy, Clone, Debug)]
@@ -140,16 +140,10 @@ pub type PolyFnSig = Binder<FnSig>;
140140
pub struct FnSig {
141141
pub inputs_and_output: Vec<Ty>,
142142
pub c_variadic: bool,
143-
pub unsafety: Unsafety,
143+
pub unsafety: Safety,
144144
pub abi: Abi,
145145
}
146146

147-
#[derive(Clone, PartialEq, Eq, Debug)]
148-
pub enum Unsafety {
149-
Unsafe,
150-
Normal,
151-
}
152-
153147
#[derive(Clone, PartialEq, Eq, Debug)]
154148
pub enum Abi {
155149
Rust,

0 commit comments

Comments
 (0)