File tree Expand file tree Collapse file tree 1 file changed +94
-3
lines changed
crates/ide-diagnostics/src/handlers Expand file tree Collapse file tree 1 file changed +94
-3
lines changed Original file line number Diff line number Diff line change @@ -115,7 +115,98 @@ fn quickfix_for_redundant_assoc_item(
115
115
116
116
#[ cfg( test) ]
117
117
mod tests {
118
- use crate :: tests:: check_diagnostics;
118
+ use crate :: tests:: { check_diagnostics, check_fix, check_no_fix} ;
119
+
120
+ #[ test]
121
+ fn quickfix_for_assoc_func ( ) {
122
+ check_fix (
123
+ r#"
124
+ trait Marker {
125
+ fn boo();
126
+ }
127
+ struct Foo;
128
+ impl Marker for Foo {
129
+ fn$0 bar(_a: i32, _b: String) -> String {}
130
+ fn boo() {}
131
+ }
132
+ "# ,
133
+ r#"
134
+ trait Marker {
135
+ fn bar(_a: i32, _b: String) -> String;
136
+ fn boo();
137
+ }
138
+ struct Foo;
139
+ impl Marker for Foo {
140
+ fn bar(_a: i32, _b: String) -> String {}
141
+ fn boo() {}
142
+ }
143
+ "# ,
144
+ )
145
+ }
146
+
147
+ #[ test]
148
+ fn quickfix_for_assoc_const ( ) {
149
+ check_fix (
150
+ r#"
151
+ trait Marker {
152
+ fn foo () {}
153
+ }
154
+ struct Foo;
155
+ impl Marker for Foo {
156
+ const FLAG: bool$0 = false;
157
+ }
158
+ "# ,
159
+ r#"
160
+ trait Marker {
161
+ const FLAG: bool;
162
+ fn foo () {}
163
+ }
164
+ struct Foo;
165
+ impl Marker for Foo {
166
+ const FLAG: bool = false;
167
+ }
168
+ "# ,
169
+ )
170
+ }
171
+
172
+ #[ test]
173
+ fn quickfix_for_assoc_type ( ) {
174
+ check_fix (
175
+ r#"
176
+ trait Marker {
177
+ }
178
+ struct Foo;
179
+ impl Marker for Foo {
180
+ type T = i32;$0
181
+ }
182
+ "# ,
183
+ r#"
184
+ trait Marker {
185
+ type T;
186
+ }
187
+ struct Foo;
188
+ impl Marker for Foo {
189
+ type T = i32;
190
+ }
191
+ "# ,
192
+ )
193
+ }
194
+
195
+ #[ test]
196
+ fn quickfix_dont_work ( ) {
197
+ check_no_fix (
198
+ r#"
199
+ //- /dep.rs crate:dep
200
+ trait Marker {
201
+ }
202
+ //- /main.rs crate:main deps:dep
203
+ struct Foo;
204
+ impl dep::Marker for Foo {
205
+ type T = i32;$0
206
+ }
207
+ "# ,
208
+ )
209
+ }
119
210
120
211
#[ test]
121
212
fn trait_with_default_value ( ) {
@@ -129,12 +220,12 @@ trait Marker {
129
220
struct Foo;
130
221
impl Marker for Foo {
131
222
type T = i32;
132
- //^^^^^^^^^^^^^ error: `type T` is not a member of trait `Marker`
223
+ //^^^^^^^^^^^^^ 💡 error: `type T` is not a member of trait `Marker`
133
224
134
225
const FLAG: bool = true;
135
226
136
227
fn bar() {}
137
- //^^^^^^^^^^^ error: `fn bar` is not a member of trait `Marker`
228
+ //^^^^^^^^^^^ 💡 error: `fn bar` is not a member of trait `Marker`
138
229
139
230
fn boo() {}
140
231
}
You can’t perform that action at this time.
0 commit comments