Skip to content

Commit 0967962

Browse files
authored
Unrolled build for rust-lang#139563
Rollup merge of rust-lang#139563 - EnzymeAD:better-autodiff-err, r=jieyouxu emit a better error message for using the macro incorrectly fixing: EnzymeAD#185 I feel like it's not a perfect message either, so I'm open to suggestions. But at the end of the day users will need to read the docs anyway, and emitting multi-line errors each time this gets triggered can probably become annoying? r? ``@jieyouxu`` since you've reviewed my frontend work back in the days. Tracking: - rust-lang#124509
2 parents 7d7de5b + f151cea commit 0967962

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

Diff for: compiler/rustc_builtin_macros/src/autodiff.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ mod llvm_enzyme {
234234
let meta_item_vec: ThinVec<MetaItemInner> = match meta_item.kind {
235235
ast::MetaItemKind::List(ref vec) => vec.clone(),
236236
_ => {
237-
dcx.emit_err(errors::AutoDiffInvalidApplication { span: item.span() });
237+
dcx.emit_err(errors::AutoDiffMissingConfig { span: item.span() });
238238
return vec![item];
239239
}
240240
};

Diff for: tests/ui/autodiff/autodiff_illegal.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ fn dummy() {
6363
// Malformed, where args?
6464
#[autodiff]
6565
pub fn f7(x: f64) {
66-
//~^ ERROR autodiff must be applied to function
66+
//~^ ERROR autodiff requires at least a name and mode
6767
unimplemented!()
6868
}
6969

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

Diff for: tests/ui/autodiff/autodiff_illegal.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ error: autodiff must be applied to function
6262
LL | let add_one_v2 = |x: u32| -> u32 { x + 1 };
6363
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6464

65-
error: autodiff must be applied to function
65+
error: autodiff requires at least a name and mode
6666
--> $DIR/autodiff_illegal.rs:65:1
6767
|
6868
LL | / pub fn f7(x: f64) {
@@ -80,7 +80,7 @@ LL | | unimplemented!()
8080
LL | | }
8181
| |_^
8282

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

0 commit comments

Comments
 (0)