archmage 0.9.15

Safely invoke your intrinsic power, using the tokens granted to you by the CPU. Cast primitive magics faster than any mage alive.
Documentation
//! 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");
}