Skip to content

emit a better error message for using the macro incorrectly #139563

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/autodiff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ mod llvm_enzyme {
let meta_item_vec: ThinVec<MetaItemInner> = match meta_item.kind {
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];
}
};
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/autodiff/autodiff_illegal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ fn dummy() {
// Malformed, where args?
#[autodiff]
pub fn f7(x: f64) {
//~^ ERROR autodiff must be applied to function
//~^ ERROR autodiff requires at least a name and mode
unimplemented!()
}

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

Expand Down
4 changes: 2 additions & 2 deletions tests/ui/autodiff/autodiff_illegal.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ error: autodiff must be applied to function
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
|
LL | / pub fn f7(x: f64) {
Expand All @@ -80,7 +80,7 @@ LL | | unimplemented!()
LL | | }
| |_^

error: autodiff must be applied to function
error: autodiff requires at least a name and mode
--> $DIR/autodiff_illegal.rs:79:1
|
LL | / pub fn f9(x: f64) {
Expand Down
Loading