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::new(*location, alloc::fmt::format(args)))
12 }
13}
14
15/// Free-fn spelling some earlier translations import.
16pub fn compile_error_raise(location: Location, args: core::fmt::Arguments<'_>) -> ! {
17 CompileError::raise(&location, args)
18}