@@ -38,6 +38,8 @@ Two kind of item _declarations_ are allowed in external blocks: [functions] and
38
38
[ statics] . Calling functions or accessing statics that are declared in external
39
39
blocks is only allowed in an ` unsafe ` context.
40
40
41
+ ## Functions
42
+
41
43
Functions within external blocks are declared in the same way as other Rust
42
44
functions, with the exception that they may not have a body and are instead
43
45
terminated by a semicolon. Patterns are not allowed in parameters, only
@@ -53,10 +55,18 @@ extern "abi" for<'l1, ..., 'lm> fn(A1, ..., An) -> R`, where `'l1`, ... `'lm`
53
55
are its lifetime parameters, ` A1 ` , ..., ` An ` are the declared types of its
54
56
parameters and ` R ` is the declared return type.
55
57
56
- Statics within external blocks are declared in the same way as statics outside of external blocks,
58
+ ## Statics
59
+
60
+ Statics within external blocks are declared in the same way as [ statics] outside of external blocks,
57
61
except that they do not have an expression initializing their value.
58
62
It is ` unsafe ` to access a static item declared in an extern block, whether or
59
- not it's mutable.
63
+ not it's mutable, because there is nothing guaranteeing that the bit pattern at the static's
64
+ memory is valid for the type it is declared with, since some arbitrary (e.g. C) code is in charge
65
+ of initializing the static.
66
+
67
+ Extern statics can be either immutable or mutable just like [ statics] outside of external blocks.
68
+ An immutable static * must* be initialized before any Rust code is executed. It is not enough for
69
+ the static to be initialized before Rust code reads from it.
60
70
61
71
## ABI
62
72
0 commit comments