diff --git a/src/attributes/codegen.md b/src/attributes/codegen.md index c34b5155e..8260409a4 100644 --- a/src/attributes/codegen.md +++ b/src/attributes/codegen.md @@ -63,7 +63,8 @@ error to specify a feature for a target architecture that the crate is not being compiled for. It is [undefined behavior] to call a function that is compiled with a feature -that is not supported on the current platform the code is running on. +that is not supported on the current platform the code is running on, *except* +if the platform explicitly documents this to be safe. Functions marked with `target_feature` are not inlined into a context that does not support the given features. The `#[inline(always)]` attribute may not @@ -75,7 +76,8 @@ The following is a list of the available feature names. #### `x86` or `x86_64` -This platform requires that `#[target_feature]` is only applied to [`unsafe` +Executing code with unsupported features is undefined behavior on this platform. +Hence this platform requires that `#[target_feature]` is only applied to [`unsafe` functions][unsafe function]. Feature | Implicitly Enables | Description @@ -133,8 +135,12 @@ Feature | Implicitly Enables | Description #### `wasm32` or `wasm64` -This platform allows `#[target_feature]` to be applied to both safe and -[`unsafe` functions][unsafe function]. +`#[target_feature]` may be used with both safe and +[`unsafe` functions][unsafe function] on Wasm platforms. It is impossible to +cause undefined behavior via the `#[target_feature]` attribute because +attempting to use instructions unsupported by the Wasm engine will fail at load +time without the risk of being interpreted in a way different from what the +compiler expected. Feature | Description ------------|------------------- diff --git a/src/behavior-considered-undefined.md b/src/behavior-considered-undefined.md index c2e6fc0cb..c4a998097 100644 --- a/src/behavior-considered-undefined.md +++ b/src/behavior-considered-undefined.md @@ -33,7 +33,7 @@ code. is immutable, unless that data is contained within an [`UnsafeCell`]. * Invoking undefined behavior via compiler intrinsics. * Executing code compiled with platform features that the current platform - does not support (see [`target_feature`]). + does not support (see [`target_feature`]), *except* if the platform explicitly documents this to be safe. * Calling a function with the wrong call ABI or unwinding from a function with the wrong unwind ABI. * Producing an invalid value, even in private fields and locals. "Producing" a value happens any time a value is assigned to or read from a place, passed to