@@ -2105,7 +2105,7 @@ impl Ty {
2105
2105
2106
2106
#[ derive( Clone , Encodable , Decodable , Debug ) ]
2107
2107
pub struct BareFnTy {
2108
- pub unsafety : Unsafe ,
2108
+ pub safety : Safety ,
2109
2109
pub ext : Extern ,
2110
2110
pub generic_params : ThinVec < GenericParam > ,
2111
2111
pub decl : P < FnDecl > ,
@@ -2491,6 +2491,17 @@ pub enum Unsafe {
2491
2491
No ,
2492
2492
}
2493
2493
2494
+ /// Safety of items (for now only used on inner extern block items).
2495
+ #[ derive( Copy , Clone , PartialEq , Eq , Hash , Encodable , Decodable , Debug ) ]
2496
+ #[ derive( HashStable_Generic ) ]
2497
+ pub enum Safety {
2498
+ /// `unsafe` an item is explicitly marked as `unsafe`.
2499
+ Unsafe ( Span ) ,
2500
+ /// Default means no value was provided, it will take a default value given the context in
2501
+ /// which is used.
2502
+ Default ,
2503
+ }
2504
+
2494
2505
/// Describes what kind of coroutine markers, if any, a function has.
2495
2506
///
2496
2507
/// Coroutine markers are things that cause the function to generate a coroutine, such as `async`,
@@ -3011,8 +3022,8 @@ impl Extern {
3011
3022
/// included in this struct (e.g., `async unsafe fn` or `const extern "C" fn`).
3012
3023
#[ derive( Clone , Copy , Encodable , Decodable , Debug ) ]
3013
3024
pub struct FnHeader {
3014
- /// The `unsafe` keyword, if any
3015
- pub unsafety : Unsafe ,
3025
+ /// The safety keyword, if any
3026
+ pub safety : Safety ,
3016
3027
/// Whether this is `async`, `gen`, or nothing.
3017
3028
pub coroutine_kind : Option < CoroutineKind > ,
3018
3029
/// The `const` keyword, if any
@@ -3024,8 +3035,8 @@ pub struct FnHeader {
3024
3035
impl FnHeader {
3025
3036
/// Does this function header have any qualifiers or is it empty?
3026
3037
pub fn has_qualifiers ( & self ) -> bool {
3027
- let Self { unsafety , coroutine_kind, constness, ext } = self ;
3028
- matches ! ( unsafety , Unsafe :: Yes ( _) )
3038
+ let Self { safety , coroutine_kind, constness, ext } = self ;
3039
+ matches ! ( safety , Safety :: Unsafe ( _) )
3029
3040
|| coroutine_kind. is_some ( )
3030
3041
|| matches ! ( constness, Const :: Yes ( _) )
3031
3042
|| !matches ! ( ext, Extern :: None )
@@ -3035,7 +3046,7 @@ impl FnHeader {
3035
3046
impl Default for FnHeader {
3036
3047
fn default ( ) -> FnHeader {
3037
3048
FnHeader {
3038
- unsafety : Unsafe :: No ,
3049
+ safety : Safety :: Default ,
3039
3050
coroutine_kind : None ,
3040
3051
constness : Const :: No ,
3041
3052
ext : Extern :: None ,
0 commit comments