luau-syntax 0.732.0

Luau lexer, parser, AST, CST, and source utilities
Documentation
use luau_syntax::allocator::AstArena;

#[derive(Debug)]
struct Counter {
    id: usize,
}

// Parser.test.cpp: allocator_can_be_moved
#[test]
fn arena_can_be_moved() {
    let (arena, counter) = {
        let arena = AstArena::new();
        let counter = arena.alloc(Counter { id: 1 }) as *const Counter;
        (arena, counter)
    };

    let _moved = arena;

    assert_eq!(unsafe { (*counter).id }, 1);
}

// Parser.test.cpp: aligns_things
#[test]
fn aligns_things() {
    let arena = AstArena::new();

    let _one = arena.alloc(b'a');
    let two = arena.alloc(1.0_f64);

    assert_eq!((two as *const f64).addr() & (align_of::<f64>() - 1), 0);
}

// Parser.test.cpp: initial_double_is_aligned
#[test]
fn initial_double_is_aligned() {
    let arena = AstArena::new();

    let one = arena.alloc(1.0_f64);

    assert_eq!((one as *const f64).addr() & (align_of::<f64>() - 1), 0);
}