File tree Expand file tree Collapse file tree 3 files changed +18
-1
lines changed
compiler/rustc_builtin_macros Expand file tree Collapse file tree 3 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ builtin_macros_autodiff_unknown_activity = did not recognize activity {$act}
5
5
builtin_macros_autodiff = autodiff must be applied to function
6
6
builtin_macros_autodiff_not_build = this rustc version does not support autodiff
7
7
builtin_macros_autodiff_mode_activity = { $act } can not be used in { $mode } Mode
8
+ builtin_macros_autodiff_number_activities = expected { $expected } activities, but found { $found }
8
9
builtin_macros_autodiff_mode = unknown Mode: `{ $mode } `. Use `Forward` or `Reverse`
9
10
builtin_macros_autodiff_ty_activity = { $act } can not be used for this type
10
11
Original file line number Diff line number Diff line change @@ -493,6 +493,15 @@ fn gen_enzyme_decl(
493
493
x : & AutoDiffAttrs ,
494
494
span : Span ,
495
495
) -> ( ast:: FnSig , Vec < String > , Vec < Ident > ) {
496
+ let sig_args = sig. decl . inputs . len ( ) + if sig. decl . output . has_ret ( ) { 1 } else { 0 } ;
497
+ let num_activities = x. input_activity . len ( ) + if x. has_ret_activity ( ) { 1 } else { 0 } ;
498
+ if sig_args != num_activities {
499
+ ecx. sess . dcx ( ) . emit_fatal ( errors:: AutoDiffInvalidNumberActivities {
500
+ span,
501
+ expected : sig_args,
502
+ found : num_activities,
503
+ } ) ;
504
+ }
496
505
assert ! ( sig. decl. inputs. len( ) == x. input_activity. len( ) ) ;
497
506
assert ! ( sig. decl. output. has_ret( ) == x. has_ret_activity( ) ) ;
498
507
let mut d_decl = sig. decl . clone ( ) ;
Original file line number Diff line number Diff line change @@ -177,7 +177,14 @@ pub(crate) struct AutoDiffInvalidTypeForActivity {
177
177
pub ( crate ) span : Span ,
178
178
pub ( crate ) act : String ,
179
179
}
180
-
180
+ #[ derive( Diagnostic ) ]
181
+ #[ diag( builtin_macros_autodiff_number_activities) ]
182
+ pub ( crate ) struct AutoDiffInvalidNumberActivities {
183
+ #[ primary_span]
184
+ pub ( crate ) span : Span ,
185
+ pub ( crate ) expected : usize ,
186
+ pub ( crate ) found : usize ,
187
+ }
181
188
#[ derive( Diagnostic ) ]
182
189
#[ diag( builtin_macros_autodiff_mode_activity) ]
183
190
pub ( crate ) struct AutoDiffInvalidApplicationModeAct {
You can’t perform that action at this time.
0 commit comments