File tree Expand file tree Collapse file tree 4 files changed +18
-3
lines changed Expand file tree Collapse file tree 4 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ r[items.extern]
55r[ items.extern.syntax]
66> ** <sup >Syntax</sup >** \
77> _ ExternBlock_ :\
8- >   ;  ; ` unsafe ` <sup >?</sup > ` extern ` [ _ Abi_ ] <sup >?</sup > ` { ` \
8+ >   ;  ; ` unsafe ` <sup >?</sup >[ ^ unsafe-2024 ] ` extern ` [ _ Abi_ ] <sup >?</sup > ` { ` \
99>   ;  ;   ;  ; [ _ InnerAttribute_ ] <sup >\* </sup >\
1010>   ;  ;   ;  ; _ ExternalItem_ <sup >\* </sup >\
1111>   ;  ; ` } `
@@ -15,6 +15,8 @@ r[items.extern.syntax]
1515>   ;  ;   ;  ;   ;  ; [ _ MacroInvocationSemi_ ] \
1616>   ;  ;   ;  ; | ( [ _ Visibility_ ] <sup >?</sup > ( [ _ StaticItem_ ] | [ _ Function_ ] ) )\
1717>   ;  ; )
18+ >
19+ > [ ^ unsafe-2024 ] : Starting with the 2024 Edition, the ` unsafe ` keyword is required semantically.
1820
1921r[ items.extern.intro]
2022External blocks provide _ declarations_ of items that are not _ defined_ in the
@@ -31,6 +33,11 @@ Calling functions or accessing statics that are declared in external blocks is o
3133r[ items.extern.namespace]
3234The external block defines its functions and statics in the [ value namespace] of the module or block where it is located.
3335
36+ ** Edition differences** : Starting in the 2024 edition, the ` unsafe ` keyword is
37+ required to appear before the ` extern ` keyword on external blocks. In previous
38+ editions, it is accepted but not required. The ` safe ` and ` unsafe ` item qualifiers
39+ are only allowed if the external block itself is marked as ` unsafe ` .
40+
3441## Functions
3542
3643r[ items.extern.fn]
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ r[items.fn.syntax]
1111>   ;  ;   ;  ; ( [ _ BlockExpression_ ] | ` ; ` )
1212>
1313> _ FunctionQualifiers_ :\
14- >   ;  ; ` const ` <sup >?</sup > ` async ` [ ^ async-edition ] <sup >?</sup > _ ItemSafety_ <sup >?</sup > (` extern ` _ Abi_ <sup >?</sup >)<sup >?</sup >
14+ >   ;  ; ` const ` <sup >?</sup > ` async ` [ ^ async-edition ] <sup >?</sup > _ ItemSafety_ <sup >?</sup >[ ^ extern-qualifiers ] (` extern ` _ Abi_ <sup >?</sup >)<sup >?</sup >
1515>
1616> _ ItemSafety_ :\
1717>   ;  ; ` safe ` [ ^ extern-safe ] | ` unsafe `
@@ -48,6 +48,10 @@ r[items.fn.syntax]
4848> [ ^ extern-safe ] : The ` safe ` function qualifier is only allowed semantically within
4949> ` extern ` blocks.
5050>
51+ > [ ^ extern-qualifiers ] : * Relevant to editions earlier than Rust 2024* : Within
52+ > ` extern ` blocks, the ` safe ` or ` unsafe ` function qualifier is only allowed
53+ > when the ` extern ` is qualified as ` unsafe ` .
54+ >
5155> [ ^ fn-param-2015 ] : Function parameters with only a type are only allowed
5256> in an associated function of a [ trait item] in the 2015 edition.
5357
Original file line number Diff line number Diff line change @@ -81,6 +81,8 @@ r[unsafe.extern]
8181
8282The programmer who declares an [ external block] must assure that the signatures of the items contained within are correct. Failing to do so may lead to undefined behavior. That this obligation has been met is indicated by writing ` unsafe extern ` .
8383
84+ ** Edition differences** : Prior to edition 2024, ` extern ` blocks were allowed without being qualified as ` unsafe ` .
85+
8486[ external block ] : items/external-blocks.md
8587
8688## Unsafe attributes (` #[unsafe(attr)] ` )
Original file line number Diff line number Diff line change @@ -26,11 +26,13 @@ r[safety.unsafe-impl]
2626- Implementing an [ unsafe trait] .
2727
2828r[ safety.unsafe-extern]
29- - Declaring an [ ` extern ` ] block.
29+ - Declaring an [ ` extern ` ] block[ ^ extern-2024 ] .
3030
3131r[ safety.unsafe-attribute]
3232- Applying an [ unsafe attribute] to an item.
3333
34+ [ ^ extern-2024 ] : Prior to the 2024 edition, extern blocks were allowed to be declared without ` unsafe ` .
35+
3436[ `extern` ] : items/external-blocks.md
3537[ `union` ] : items/unions.md
3638[ mutable ] : items/static-items.md#mutable-statics
You can’t perform that action at this time.
0 commit comments