@@ -95,15 +95,11 @@ fn fixes(ctx: &DiagnosticsContext<'_>, d: &RemoveUnnecessaryElse) -> Option<Vec<
9595
9696#[ cfg( test) ]
9797mod tests {
98- use crate :: tests:: { check_diagnostics, check_diagnostics_with_disabled, check_fix} ;
99-
100- fn check_diagnostics_with_needless_return_disabled ( ra_fixture : & str ) {
101- check_diagnostics_with_disabled ( ra_fixture, std:: iter:: once ( "needless_return" . to_owned ( ) ) ) ;
102- }
98+ use crate :: tests:: { check_diagnostics_with_disabled, check_fix} ;
10399
104100 #[ test]
105101 fn remove_unnecessary_else_for_return ( ) {
106- check_diagnostics_with_needless_return_disabled (
102+ check_diagnostics_with_disabled (
107103 r#"
108104fn test() {
109105 if foo {
@@ -114,6 +110,7 @@ fn test() {
114110 }
115111}
116112"# ,
113+ & [ "needless_return" , "E0425" ] ,
117114 ) ;
118115 check_fix (
119116 r#"
@@ -138,7 +135,7 @@ fn test() {
138135
139136 #[ test]
140137 fn remove_unnecessary_else_for_return2 ( ) {
141- check_diagnostics_with_needless_return_disabled (
138+ check_diagnostics_with_disabled (
142139 r#"
143140fn test() {
144141 if foo {
@@ -151,6 +148,7 @@ fn test() {
151148 }
152149}
153150"# ,
151+ & [ "needless_return" , "E0425" ] ,
154152 ) ;
155153 check_fix (
156154 r#"
@@ -181,7 +179,7 @@ fn test() {
181179
182180 #[ test]
183181 fn remove_unnecessary_else_for_return3 ( ) {
184- check_diagnostics_with_needless_return_disabled (
182+ check_diagnostics_with_disabled (
185183 r#"
186184fn test(a: bool) -> i32 {
187185 if a {
@@ -192,6 +190,7 @@ fn test(a: bool) -> i32 {
192190 }
193191}
194192"# ,
193+ & [ "needless_return" , "E0425" ] ,
195194 ) ;
196195 check_fix (
197196 r#"
@@ -216,7 +215,7 @@ fn test(a: bool) -> i32 {
216215
217216 #[ test]
218217 fn remove_unnecessary_else_for_return_in_child_if_expr ( ) {
219- check_diagnostics_with_needless_return_disabled (
218+ check_diagnostics_with_disabled (
220219 r#"
221220fn test() {
222221 if foo {
@@ -229,6 +228,7 @@ fn test() {
229228 }
230229}
231230"# ,
231+ & [ "needless_return" , "E0425" ] ,
232232 ) ;
233233 check_fix (
234234 r#"
@@ -294,7 +294,7 @@ fn test() {
294294
295295 #[ test]
296296 fn remove_unnecessary_else_for_break ( ) {
297- check_diagnostics (
297+ check_diagnostics_with_disabled (
298298 r#"
299299fn test() {
300300 loop {
@@ -307,6 +307,7 @@ fn test() {
307307 }
308308}
309309"# ,
310+ & [ "E0425" ] ,
310311 ) ;
311312 check_fix (
312313 r#"
@@ -335,7 +336,7 @@ fn test() {
335336
336337 #[ test]
337338 fn remove_unnecessary_else_for_continue ( ) {
338- check_diagnostics (
339+ check_diagnostics_with_disabled (
339340 r#"
340341fn test() {
341342 loop {
@@ -348,6 +349,7 @@ fn test() {
348349 }
349350}
350351"# ,
352+ & [ "E0425" ] ,
351353 ) ;
352354 check_fix (
353355 r#"
@@ -376,7 +378,7 @@ fn test() {
376378
377379 #[ test]
378380 fn remove_unnecessary_else_for_never ( ) {
379- check_diagnostics (
381+ check_diagnostics_with_disabled (
380382 r#"
381383fn test() {
382384 if foo {
@@ -391,6 +393,7 @@ fn never() -> ! {
391393 loop {}
392394}
393395"# ,
396+ & [ "E0425" ] ,
394397 ) ;
395398 check_fix (
396399 r#"
@@ -423,7 +426,7 @@ fn never() -> ! {
423426
424427 #[ test]
425428 fn no_diagnostic_if_no_else_branch ( ) {
426- check_diagnostics (
429+ check_diagnostics_with_disabled (
427430 r#"
428431fn test() {
429432 if foo {
@@ -433,12 +436,13 @@ fn test() {
433436 do_something_else();
434437}
435438"# ,
439+ & [ "E0425" ] ,
436440 ) ;
437441 }
438442
439443 #[ test]
440444 fn no_diagnostic_if_no_divergence ( ) {
441- check_diagnostics (
445+ check_diagnostics_with_disabled (
442446 r#"
443447fn test() {
444448 if foo {
@@ -448,12 +452,13 @@ fn test() {
448452 }
449453}
450454"# ,
455+ & [ "E0425" ] ,
451456 ) ;
452457 }
453458
454459 #[ test]
455460 fn no_diagnostic_if_no_divergence_in_else_branch ( ) {
456- check_diagnostics_with_needless_return_disabled (
461+ check_diagnostics_with_disabled (
457462 r#"
458463fn test() {
459464 if foo {
@@ -463,12 +468,13 @@ fn test() {
463468 }
464469}
465470"# ,
471+ & [ "needless_return" , "E0425" ] ,
466472 ) ;
467473 }
468474
469475 #[ test]
470476 fn no_diagnostic_if_not_expr_stmt ( ) {
471- check_diagnostics_with_needless_return_disabled (
477+ check_diagnostics_with_disabled (
472478 r#"
473479fn test1() {
474480 let _x = if a {
@@ -490,13 +496,15 @@ fn test2() {
490496 };
491497}
492498"# ,
499+ & [ "needless_return" , "E0425" ] ,
493500 ) ;
494- check_diagnostics (
501+ check_diagnostics_with_disabled (
495502 r#"
496503fn test3() -> u8 {
497504 foo(if a { return 1 } else { 0 })
498505}
499506"# ,
507+ & [ "E0425" ] ,
500508 ) ;
501509 }
502510}
0 commit comments