emit a better error message for using the macro incorrectly

This commit is contained in:
Manuel Drehwald 2025-04-08 21:54:34 -04:00
parent e643f59f6d
commit f151ceadfe
3 changed files with 5 additions and 5 deletions

View file

@ -234,7 +234,7 @@ mod llvm_enzyme {
let meta_item_vec: ThinVec<MetaItemInner> = match meta_item.kind { let meta_item_vec: ThinVec<MetaItemInner> = match meta_item.kind {
ast::MetaItemKind::List(ref vec) => vec.clone(), ast::MetaItemKind::List(ref vec) => vec.clone(),
_ => { _ => {
dcx.emit_err(errors::AutoDiffInvalidApplication { span: item.span() }); dcx.emit_err(errors::AutoDiffMissingConfig { span: item.span() });
return vec![item]; return vec![item];
} }
}; };

View file

@ -63,7 +63,7 @@ fn dummy() {
// Malformed, where args? // Malformed, where args?
#[autodiff] #[autodiff]
pub fn f7(x: f64) { pub fn f7(x: f64) {
//~^ ERROR autodiff must be applied to function //~^ ERROR autodiff requires at least a name and mode
unimplemented!() unimplemented!()
} }
@ -77,7 +77,7 @@ pub fn f8(x: f64) {
// Invalid attribute syntax // Invalid attribute syntax
#[autodiff = ""] #[autodiff = ""]
pub fn f9(x: f64) { pub fn f9(x: f64) {
//~^ ERROR autodiff must be applied to function //~^ ERROR autodiff requires at least a name and mode
unimplemented!() unimplemented!()
} }

View file

@ -62,7 +62,7 @@ error: autodiff must be applied to function
LL | let add_one_v2 = |x: u32| -> u32 { x + 1 }; LL | let add_one_v2 = |x: u32| -> u32 { x + 1 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: autodiff must be applied to function error: autodiff requires at least a name and mode
--> $DIR/autodiff_illegal.rs:65:1 --> $DIR/autodiff_illegal.rs:65:1
| |
LL | / pub fn f7(x: f64) { LL | / pub fn f7(x: f64) {
@ -80,7 +80,7 @@ LL | | unimplemented!()
LL | | } LL | | }
| |_^ | |_^
error: autodiff must be applied to function error: autodiff requires at least a name and mode
--> $DIR/autodiff_illegal.rs:79:1 --> $DIR/autodiff_illegal.rs:79:1
| |
LL | / pub fn f9(x: f64) { LL | / pub fn f9(x: f64) {