From 4199a3c13a05d05fcc863d506ee2aed74228b8e7 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Fri, 4 Aug 2023 17:01:05 -0300 Subject: [PATCH] Convert unsafety using the stable method and reuse mir::Safety --- compiler/rustc_smir/src/rustc_smir/mod.rs | 7 ++----- compiler/rustc_smir/src/stable_mir/ty.rs | 10 ++-------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/compiler/rustc_smir/src/rustc_smir/mod.rs b/compiler/rustc_smir/src/rustc_smir/mod.rs index e377843cdb4..6eb7e930425 100644 --- a/compiler/rustc_smir/src/rustc_smir/mod.rs +++ b/compiler/rustc_smir/src/rustc_smir/mod.rs @@ -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 @@ fn stable(&self, tables: &mut Tables<'tcx>) -> Self::T { .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 }, diff --git a/compiler/rustc_smir/src/stable_mir/ty.rs b/compiler/rustc_smir/src/stable_mir/ty.rs index df28fc4eed9..be917b2e140 100644 --- a/compiler/rustc_smir/src/stable_mir/ty.rs +++ b/compiler/rustc_smir/src/stable_mir/ty.rs @@ -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 struct AliasTy { pub struct FnSig { pub inputs_and_output: Vec, 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,