@@ -2105,7 +2105,7 @@ impl Ty {
21052105
21062106#[ derive( Clone , Encodable , Decodable , Debug ) ]
21072107pub struct BareFnTy {
2108- pub unsafety : Unsafe ,
2108+ pub safety : Safety ,
21092109 pub ext : Extern ,
21102110 pub generic_params : ThinVec < GenericParam > ,
21112111 pub decl : P < FnDecl > ,
@@ -2491,6 +2491,17 @@ pub enum Unsafe {
24912491 No ,
24922492}
24932493
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+
24942505/// Describes what kind of coroutine markers, if any, a function has.
24952506///
24962507/// Coroutine markers are things that cause the function to generate a coroutine, such as `async`,
@@ -3011,8 +3022,8 @@ impl Extern {
30113022/// included in this struct (e.g., `async unsafe fn` or `const extern "C" fn`).
30123023#[ derive( Clone , Copy , Encodable , Decodable , Debug ) ]
30133024pub struct FnHeader {
3014- /// The `unsafe` keyword, if any
3015- pub unsafety : Unsafe ,
3025+ /// The safety keyword, if any
3026+ pub safety : Safety ,
30163027 /// Whether this is `async`, `gen`, or nothing.
30173028 pub coroutine_kind : Option < CoroutineKind > ,
30183029 /// The `const` keyword, if any
@@ -3024,8 +3035,8 @@ pub struct FnHeader {
30243035impl FnHeader {
30253036 /// Does this function header have any qualifiers or is it empty?
30263037 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 ( _) )
30293040 || coroutine_kind. is_some ( )
30303041 || matches ! ( constness, Const :: Yes ( _) )
30313042 || !matches ! ( ext, Extern :: None )
@@ -3035,7 +3046,7 @@ impl FnHeader {
30353046impl Default for FnHeader {
30363047 fn default ( ) -> FnHeader {
30373048 FnHeader {
3038- unsafety : Unsafe :: No ,
3049+ safety : Safety :: Default ,
30393050 coroutine_kind : None ,
30403051 constness : Const :: No ,
30413052 ext : Extern :: None ,
0 commit comments