1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//! Compile-fail tests to verify that unsafe intrinsics require unsafe blocks
//!
//! These tests ensure that our safety guarantees are enforced by the compiler.
//! Pointer-based SIMD operations (load, store, gather, masked ops) must always
//! require unsafe blocks, even inside #[target_feature] functions.
//!
//! Note: These tests are skipped in CI because trybuild's exact stderr matching
//! is fragile across Rust versions and platforms. Run locally to verify.
// These tests only apply to x86_64 (the UI tests use x86_64 intrinsics)
#![cfg(target_arch = "x86_64")]
#[test]
fn ui_tests() {
let t = trybuild::TestCases::new();
// These tests verify that pointer-based intrinsics fail without unsafe
t.compile_fail("tests/ui/unsafe_load_requires_unsafe.rs");
t.compile_fail("tests/ui/unsafe_store_requires_unsafe.rs");
t.compile_fail("tests/ui/unsafe_gather_requires_unsafe.rs");
t.compile_fail("tests/ui/unsafe_maskload_requires_unsafe.rs");
// Token type safety tests
t.compile_fail("tests/compile_fail/wrong_token.rs");
// Macro rejects unknown trait bounds (e.g., removed HasAvx2, HasFma)
t.compile_fail("tests/compile_fail/unknown_trait_bound.rs");
t.compile_fail("tests/compile_fail/unknown_generic_bound.rs");
// Macro rejects featureless traits (SimdToken, IntoConcreteToken)
t.compile_fail("tests/compile_fail/featureless_simdtoken.rs");
// incant! always emits fn_scalar — missing _scalar function = compile error
t.compile_fail("tests/compile_fail/missing_scalar.rs");
// incant! with explicit tiers requires `scalar` in the list
// (gated behind REQUIRE_EXPLICIT_SCALAR, currently false — re-enable in v1.0)
// t.compile_fail("tests/compile_fail/scalar_not_in_tier_list.rs");
// scalar + default are mutually exclusive
t.compile_fail("tests/compile_fail/scalar_default_mutual_exclusion.rs");
// #[autoversion] rejects concrete tokens
t.compile_fail("tests/compile_fail/autoversion_concrete_token.rs");
}