When a target feature is found that doesn't exist on the current target but does exist on another target, it should be explicitly pointed out in the error message. Copying the example from this comment:
#[target_feature(enable = "sse2", enable = "avx", enable = "sse")]
pub unsafe fn foo() {}
When you compile it on M1/M2 you get:
error: the feature named `sse2` is not valid for this target
--> $DIR/issue-108680.rs:3:18
|
LL | #[target_feature(enable = "sse2", enable = "avx", enable = "sse")]
| ^^^^^^^^^^^^^^^ `sse2` is not valid for this target
error: the feature named `avx` is not valid for this target
--> $DIR/issue-108680.rs:3:35
|
LL | #[target_feature(enable = "sse2", enable = "avx", enable = "sse")]
| ^^^^^^^^^^^^^^ `avx` is not valid for this target
error: the feature named `sse` is not valid for this target
--> $DIR/issue-108680.rs:3:51
|
LL | #[target_feature(enable = "sse2", enable = "avx", enable = "sse")]
| ^^^^^^^^^^^^^^ `sse` is not valid for this target
Ideally this would mention that these target features are valid for the arm64 target architecture/family:
error: the feature named `sse2` is not valid for this target
--> $DIR/issue-108680.rs:3:18
|
LL | #[target_feature(enable = "sse2", enable = "avx", enable = "sse")]
| ^^^^^^^^^^^^^^^ `sse2` is not valid for this target
= note: `sse2` is present on the `x86_64` target architecture. Did you mean to compile for that target, or use conditional compilation?
The printing also ideally would support features present on multiple target architectures, for example the aes feature is present on both arm and x86:
// only-wasm32
#[target_feature(enable = "aes")]
pub unsafe fn foo() {}
For aarch64 vs arm it might make sense to always mention them both if the feature is present on both, as the two languages are way different from each other (while x86 is very backwards compatible).
As a second thing, it would be nice if it could provide typo suggestions:
#[target_feature(enable = "avc")]
pub unsafe fn foo() {}
error: the feature named `avc` is not valid for this target
--> src/main.rs:1:18
|
1 | #[target_feature(enable = "avc")]
| ^^^^^^^^^^^^^^ `avc` is not valid for this target
= help: a similar feature `avx` exists for this target
But I'm less sure if this is a good idea as target features are often very short and similar to each other. Suggesting the wrong target feature might not be detected as easily.
@rustbot label A-diagnostics A-target-feature
When a target feature is found that doesn't exist on the current target but does exist on another target, it should be explicitly pointed out in the error message. Copying the example from this comment:
When you compile it on M1/M2 you get:
Ideally this would mention that these target features are valid for the
arm64target architecture/family:The printing also ideally would support features present on multiple target architectures, for example the
aesfeature is present on both arm and x86:For
aarch64vsarmit might make sense to always mention them both if the feature is present on both, as the two languages are way different from each other (while x86 is very backwards compatible).As a second thing, it would be nice if it could provide typo suggestions:
But I'm less sure if this is a good idea as target features are often very short and similar to each other. Suggesting the wrong target feature might not be detected as easily.
@rustbot label A-diagnostics A-target-feature