@@ -2099,7 +2099,7 @@ impl Ty {
2099
2099
2100
2100
#[ derive( Clone , Encodable , Decodable , Debug ) ]
2101
2101
pub struct BareFnTy {
2102
- pub unsafety : Unsafe ,
2102
+ pub safety : Safety ,
2103
2103
pub ext : Extern ,
2104
2104
pub generic_params : ThinVec < GenericParam > ,
2105
2105
pub decl : P < FnDecl > ,
@@ -2485,6 +2485,17 @@ pub enum Unsafe {
2485
2485
No ,
2486
2486
}
2487
2487
2488
+ /// Safety of items (for now only used on inner extern block items).
2489
+ #[ derive( Copy , Clone , PartialEq , Eq , Hash , Encodable , Decodable , Debug ) ]
2490
+ #[ derive( HashStable_Generic ) ]
2491
+ pub enum Safety {
2492
+ /// `unsafe` an item is explicitly marked as `unsafe`.
2493
+ Unsafe ( Span ) ,
2494
+ /// Default means no value was provided, it will take a default value given the context in
2495
+ /// which is used.
2496
+ Default ,
2497
+ }
2498
+
2488
2499
/// Describes what kind of coroutine markers, if any, a function has.
2489
2500
///
2490
2501
/// Coroutine markers are things that cause the function to generate a coroutine, such as `async`,
@@ -3001,8 +3012,8 @@ impl Extern {
3001
3012
/// included in this struct (e.g., `async unsafe fn` or `const extern "C" fn`).
3002
3013
#[ derive( Clone , Copy , Encodable , Decodable , Debug ) ]
3003
3014
pub struct FnHeader {
3004
- /// The `unsafe` keyword, if any
3005
- pub unsafety : Unsafe ,
3015
+ /// The safety keyword, if any
3016
+ pub safety : Safety ,
3006
3017
/// Whether this is `async`, `gen`, or nothing.
3007
3018
pub coroutine_kind : Option < CoroutineKind > ,
3008
3019
/// The `const` keyword, if any
@@ -3014,8 +3025,8 @@ pub struct FnHeader {
3014
3025
impl FnHeader {
3015
3026
/// Does this function header have any qualifiers or is it empty?
3016
3027
pub fn has_qualifiers ( & self ) -> bool {
3017
- let Self { unsafety , coroutine_kind, constness, ext } = self ;
3018
- matches ! ( unsafety , Unsafe :: Yes ( _) )
3028
+ let Self { safety , coroutine_kind, constness, ext } = self ;
3029
+ matches ! ( safety , Safety :: Unsafe ( _) )
3019
3030
|| coroutine_kind. is_some ( )
3020
3031
|| matches ! ( constness, Const :: Yes ( _) )
3021
3032
|| !matches ! ( ext, Extern :: None )
@@ -3025,7 +3036,7 @@ impl FnHeader {
3025
3036
impl Default for FnHeader {
3026
3037
fn default ( ) -> FnHeader {
3027
3038
FnHeader {
3028
- unsafety : Unsafe :: No ,
3039
+ safety : Safety :: Default ,
3029
3040
coroutine_kind : None ,
3030
3041
constness : Const :: No ,
3031
3042
ext : Extern :: None ,
0 commit comments