Add ErrorGuaranteed to ast::ExprKind::Err

This commit is contained in:
Lieselotte
2024-02-25 22:22:11 +01:00
parent a3fce72a27
commit c440a5b814
37 changed files with 660 additions and 602 deletions

View File

@@ -9,16 +9,14 @@ pub fn expand_compile_error<'cx>(
sp: Span,
tts: TokenStream,
) -> Box<dyn base::MacResult + 'cx> {
let Some(var) = get_single_str_from_tts(cx, sp, tts, "compile_error!") else {
return DummyResult::any(sp);
let var = match get_single_str_from_tts(cx, sp, tts, "compile_error!") {
Ok(var) => var,
Err(guar) => return DummyResult::any(sp, guar),
};
#[expect(
rustc::diagnostic_outside_of_impl,
reason = "diagnostic message is specified by user"
)]
#[expect(rustc::diagnostic_outside_of_impl, reason = "diagnostic message is specified by user")]
#[expect(rustc::untranslatable_diagnostic, reason = "diagnostic message is specified by user")]
cx.dcx().span_err(sp, var.to_string());
let guar = cx.dcx().span_err(sp, var.to_string());
DummyResult::any(sp)
DummyResult::any(sp, guar)
}