You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tests/ui/autodiff/autodiff_illegal.rs
+23-37
Original file line number
Diff line number
Diff line change
@@ -7,75 +7,75 @@
7
7
8
8
// Test that invalid ad macros give nice errors and don't ICE.
9
9
10
-
use std::autodiff::autodiff;
10
+
use std::autodiff::{autodiff_forward, autodiff_reverse};
11
11
12
12
// We can't use Duplicated on scalars
13
-
#[autodiff(df1,Reverse,Duplicated)]
13
+
#[autodiff_reverse(df1,Duplicated)]
14
14
pubfnf1(x:f64){
15
15
//~^ ERROR Duplicated can not be used for this type
16
16
unimplemented!()
17
17
}
18
18
19
19
// Too many activities
20
-
#[autodiff(df3,Reverse,Duplicated,Const)]
20
+
#[autodiff_reverse(df3,Duplicated,Const)]
21
21
pubfnf3(x:f64){
22
22
//~^^ ERROR expected 1 activities, but found 2
23
23
unimplemented!()
24
24
}
25
25
26
26
// To few activities
27
-
#[autodiff(df4,Reverse)]
27
+
#[autodiff_reverse(df4)]
28
28
pubfnf4(x:f64){
29
29
//~^^ ERROR expected 1 activities, but found 0
30
30
unimplemented!()
31
31
}
32
32
33
33
// We can't use Dual in Reverse mode
34
-
#[autodiff(df5,Reverse,Dual)]
34
+
#[autodiff_reverse(df5,Dual)]
35
35
pubfnf5(x:f64){
36
36
//~^^ ERROR Dual can not be used in Reverse Mode
37
37
unimplemented!()
38
38
}
39
39
40
40
// We can't use Duplicated in Forward mode
41
-
#[autodiff(df6,Forward,Duplicated)]
41
+
#[autodiff_forward(df6,Duplicated)]
42
42
pubfnf6(x:f64){
43
43
//~^^ ERROR Duplicated can not be used in Forward Mode
44
44
//~^^ ERROR Duplicated can not be used for this type
45
45
unimplemented!()
46
46
}
47
47
48
48
fndummy(){
49
-
#[autodiff(df7,Forward,Dual)]
49
+
#[autodiff_forward(df7,Dual)]
50
50
letmut x = 5;
51
51
//~^ ERROR autodiff must be applied to function
52
52
53
-
#[autodiff(df7,Forward,Dual)]
53
+
#[autodiff_forward(df7,Dual)]
54
54
x = x + 3;
55
55
//~^^ ERROR attributes on expressions are experimental [E0658]
56
56
//~^^ ERROR autodiff must be applied to function
57
57
58
-
#[autodiff(df7,Forward,Dual)]
58
+
#[autodiff_forward(df7,Dual)]
59
59
let add_one_v2 = |x:u32| -> u32{ x + 1};
60
60
//~^ ERROR autodiff must be applied to function
61
61
}
62
62
63
63
// Malformed, where args?
64
-
#[autodiff]
64
+
#[autodiff_forward]
65
65
pubfnf7(x:f64){
66
66
//~^ ERROR autodiff requires at least a name and mode
67
67
unimplemented!()
68
68
}
69
69
70
70
// Malformed, where args?
71
-
#[autodiff()]
71
+
#[autodiff_forward()]
72
72
pubfnf8(x:f64){
73
73
//~^ ERROR autodiff requires at least a name and mode
74
74
unimplemented!()
75
75
}
76
76
77
77
// Invalid attribute syntax
78
-
#[autodiff = ""]
78
+
#[autodiff_forward = ""]
79
79
pubfnf9(x:f64){
80
80
//~^ ERROR autodiff requires at least a name and mode
81
81
unimplemented!()
@@ -84,29 +84,15 @@ pub fn f9(x: f64) {
84
84
fnfn_exists(){}
85
85
86
86
// We colide with an already existing function
87
-
#[autodiff(fn_exists,Reverse,Active)]
87
+
#[autodiff_reverse(fn_exists,Active)]
88
88
pubfnf10(x:f64){
89
89
//~^^ ERROR the name `fn_exists` is defined multiple times [E0428]
90
90
unimplemented!()
91
91
}
92
92
93
-
// Malformed, missing a mode
94
-
#[autodiff(df11)]
95
-
pubfnf11(){
96
-
//~^ ERROR autodiff requires at least a name and mode
97
-
unimplemented!()
98
-
}
99
-
100
-
// Invalid Mode
101
-
#[autodiff(df12,Debug)]
102
-
pubfnf12(){
103
-
//~^^ ERROR unknown Mode: `Debug`. Use `Forward` or `Reverse`
104
-
unimplemented!()
105
-
}
106
-
107
93
// Invalid, please pick one Mode
108
94
// or use two autodiff macros.
109
-
#[autodiff(df13,Forward,Reverse)]
95
+
#[autodiff_reverse(df13,Reverse)]
110
96
pubfnf13(){
111
97
//~^^ ERROR did not recognize Activity: `Reverse`
112
98
unimplemented!()
@@ -117,7 +103,7 @@ struct Foo {}
117
103
// We can't handle Active structs, because that would mean (in the general case), that we would
118
104
// need to allocate and initialize arbitrary user types. We have Duplicated/Dual input args for
119
105
// that. FIXME: Give a nicer error and suggest to the user to have a `&mut Foo` input instead.
120
-
#[autodiff(df14,Reverse,Active,Active)]
106
+
#[autodiff_reverse(df14,Active,Active)]
121
107
fnf14(x:f32) -> Foo{
122
108
unimplemented!()
123
109
}
@@ -127,14 +113,14 @@ type MyFloat = f32;
127
113
// We would like to support type alias to f32/f64 in argument type in the future,
128
114
// but that requires us to implement our checks at a later stage
129
115
// like THIR which has type information available.
130
-
#[autodiff(df15,Reverse,Active,Active)]
116
+
#[autodiff_reverse(df15,Active,Active)]
131
117
fnf15(x:MyFloat) -> f32{
132
118
//~^^ ERROR failed to resolve: use of undeclared type `MyFloat` [E0433]
133
119
unimplemented!()
134
120
}
135
121
136
122
// We would like to support type alias to f32/f64 in return type in the future
137
-
#[autodiff(df16,Reverse,Active,Active)]
123
+
#[autodiff_reverse(df16,Active,Active)]
138
124
fnf16(x:f32) -> MyFloat{
139
125
unimplemented!()
140
126
}
@@ -145,40 +131,40 @@ struct F64Trans {
145
131
}
146
132
147
133
// We would like to support `#[repr(transparent)]` f32/f64 wrapper in return type in the future
148
-
#[autodiff(df17,Reverse,Active,Active)]
134
+
#[autodiff_reverse(df17,Active,Active)]
149
135
fnf17(x:f64) -> F64Trans{
150
136
unimplemented!()
151
137
}
152
138
153
139
// We would like to support `#[repr(transparent)]` f32/f64 wrapper in argument type in the future
154
-
#[autodiff(df18,Reverse,Active,Active)]
140
+
#[autodiff_reverse(df18,Active,Active)]
155
141
fnf18(x:F64Trans) -> f64{
156
142
//~^^ ERROR failed to resolve: use of undeclared type `F64Trans` [E0433]
157
143
unimplemented!()
158
144
}
159
145
160
146
// Invalid return activity
161
-
#[autodiff(df19,Forward,Dual,Active)]
147
+
#[autodiff_forward(df19,Dual,Active)]
162
148
fnf19(x:f32) -> f32{
163
149
//~^^ ERROR invalid return activity Active in Forward Mode
164
150
unimplemented!()
165
151
}
166
152
167
-
#[autodiff(df20,Reverse,Active,Dual)]
153
+
#[autodiff_reverse(df20,Active,Dual)]
168
154
fnf20(x:f32) -> f32{
169
155
//~^^ ERROR invalid return activity Dual in Reverse Mode
170
156
unimplemented!()
171
157
}
172
158
173
159
// Duplicated cannot be used as return activity
174
-
#[autodiff(df21,Reverse,Active,Duplicated)]
160
+
#[autodiff_reverse(df21,Active,Duplicated)]
175
161
fnf21(x:f32) -> f32{
176
162
//~^^ ERROR invalid return activity Duplicated in Reverse Mode
177
163
unimplemented!()
178
164
}
179
165
180
166
structDoesNotImplDefault;
181
-
#[autodiff(df22,Forward,Dual)]
167
+
#[autodiff_forward(df22,Dual)]
182
168
pubfnf22() -> DoesNotImplDefault{
183
169
//~^^ ERROR the function or associated item `default` exists for tuple `(DoesNotImplDefault, DoesNotImplDefault)`, but its trait bounds were not satisfied
error[E0433]: failed to resolve: use of undeclared type `MyFloat`
143
-
--> $DIR/autodiff_illegal.rs:130:1
128
+
--> $DIR/autodiff_illegal.rs:116:1
144
129
|
145
-
LL | #[autodiff(df15, Reverse, Active, Active)]
146
-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ use of undeclared type `MyFloat`
130
+
LL | #[autodiff_reverse(df15, Active, Active)]
131
+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ use of undeclared type `MyFloat`
147
132
148
133
error[E0433]: failed to resolve: use of undeclared type `F64Trans`
149
-
--> $DIR/autodiff_illegal.rs:154:1
134
+
--> $DIR/autodiff_illegal.rs:140:1
150
135
|
151
-
LL | #[autodiff(df18, Reverse, Active, Active)]
152
-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ use of undeclared type `F64Trans`
136
+
LL | #[autodiff_reverse(df18, Active, Active)]
137
+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ use of undeclared type `F64Trans`
153
138
154
139
error[E0599]: the function or associated item `default` exists for tuple `(DoesNotImplDefault, DoesNotImplDefault)`, but its trait bounds were not satisfied
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function or associated item cannot be called on `(DoesNotImplDefault, DoesNotImplDefault)` due to unsatisfied trait bounds
144
+
LL | #[autodiff_forward(df22, Dual)]
145
+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function or associated item cannot be called on `(DoesNotImplDefault, DoesNotImplDefault)` due to unsatisfied trait bounds
161
146
|
162
147
= note: the following trait bounds were not satisfied:
163
148
`DoesNotImplDefault: Default`
@@ -168,7 +153,7 @@ LL + #[derive(Default)]
168
153
LL | struct DoesNotImplDefault;
169
154
|
170
155
171
-
error: aborting due to 23 previous errors
156
+
error: aborting due to 21 previous errors
172
157
173
158
Some errors have detailed explanations: E0428, E0433, E0599, E0658.
174
159
For more information about an error, try `rustc --explain E0428`.
0 commit comments