luaur_compiler/methods/compile_error_raise.rs
1//! Source: `Compiler/include/Luau/Compiler.h:84` + Compiler.cpp (hand-ported)
2//! C varargs printf-style raise -> core::fmt::Arguments (project-wide precedent).
3
4use crate::records::compile_error::CompileError;
5use luaur_ast::records::location::Location;
6
7impl CompileError {
8 /// C++ `static LUAU_NORETURN void raise(const Location&, const char* format, ...)`
9 /// Callers pass `format_args!(...)` (the varargs convention).
10 pub fn raise(location: &Location, args: core::fmt::Arguments<'_>) -> ! {
11 std::panic::panic_any(CompileError {
12 location: *location,
13 message: alloc::fmt::format(args),
14 })
15 }
16}
17
18/// Free-fn spelling some earlier translations import.
19pub fn compile_error_raise(location: Location, args: core::fmt::Arguments<'_>) -> ! {
20 CompileError::raise(&location, args)
21}