@@ -2099,7 +2099,7 @@ impl Ty {
20992099
21002100#[ derive( Clone , Encodable , Decodable , Debug ) ]
21012101pub struct BareFnTy {
2102- pub unsafety : Unsafe ,
2102+ pub safety : Safety ,
21032103 pub ext : Extern ,
21042104 pub generic_params : ThinVec < GenericParam > ,
21052105 pub decl : P < FnDecl > ,
@@ -2485,6 +2485,17 @@ pub enum Unsafe {
24852485 No ,
24862486}
24872487
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+
24882499/// Describes what kind of coroutine markers, if any, a function has.
24892500///
24902501/// Coroutine markers are things that cause the function to generate a coroutine, such as `async`,
@@ -3001,8 +3012,8 @@ impl Extern {
30013012/// included in this struct (e.g., `async unsafe fn` or `const extern "C" fn`).
30023013#[ derive( Clone , Copy , Encodable , Decodable , Debug ) ]
30033014pub struct FnHeader {
3004- /// The `unsafe` keyword, if any
3005- pub unsafety : Unsafe ,
3015+ /// The safety keyword, if any
3016+ pub safety : Safety ,
30063017 /// Whether this is `async`, `gen`, or nothing.
30073018 pub coroutine_kind : Option < CoroutineKind > ,
30083019 /// The `const` keyword, if any
@@ -3014,8 +3025,8 @@ pub struct FnHeader {
30143025impl FnHeader {
30153026 /// Does this function header have any qualifiers or is it empty?
30163027 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 ( _) )
30193030 || coroutine_kind. is_some ( )
30203031 || matches ! ( constness, Const :: Yes ( _) )
30213032 || !matches ! ( ext, Extern :: None )
@@ -3025,7 +3036,7 @@ impl FnHeader {
30253036impl Default for FnHeader {
30263037 fn default ( ) -> FnHeader {
30273038 FnHeader {
3028- unsafety : Unsafe :: No ,
3039+ safety : Safety :: Default ,
30293040 coroutine_kind : None ,
30303041 constness : Const :: No ,
30313042 ext : Extern :: None ,
0 commit comments