Skip to content

Commit 95a95bd

Browse files
committed
Replace dead code with panic
1 parent ffc5fe3 commit 95a95bd

1 file changed

Lines changed: 7 additions & 14 deletions

File tree

libcc2rs-macros/tests/control_flow.rs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,6 @@ fn switch_nested_loop_break_targets_inner() {
229229

230230
#[test]
231231
fn switch_return_from_case() {
232-
#[allow(unreachable_code)]
233232
fn classify(x: i32) -> &'static str {
234233
switch!(match x {
235234
0 => {
@@ -242,7 +241,7 @@ fn switch_return_from_case() {
242241
return "other";
243242
}
244243
});
245-
"unreachable"
244+
panic!("ub: non-void function does not return a value");
246245
}
247246
assert_eq!(classify(0), "zero");
248247
assert_eq!(classify(1), "one");
@@ -285,7 +284,6 @@ fn goto_block_linear_fallthrough() {
285284

286285
#[test]
287286
fn goto_block_return_from_arm() {
288-
#[allow(unreachable_code)]
289287
fn run(start: u32) -> &'static str {
290288
goto_block!({
291289
'a: {
@@ -302,7 +300,7 @@ fn goto_block_return_from_arm() {
302300
return "c";
303301
}
304302
});
305-
"fallthrough"
303+
panic!("ub: non-void function does not return a value");
306304
}
307305
assert_eq!(run(0), "a");
308306
assert_eq!(run(1), "b");
@@ -347,8 +345,7 @@ fn goto_block_local_visible_across_label() {
347345
return ret;
348346
}
349347
});
350-
#[allow(unreachable_code)]
351-
0
348+
panic!("ub: non-void function does not return a value");
352349
}
353350
assert_eq!(early(-1), -1);
354351
assert_eq!(early(5), 100);
@@ -370,8 +367,7 @@ fn goto_block_backward_goto_retry() {
370367
return sum;
371368
}
372369
});
373-
#[allow(unreachable_code)]
374-
0
370+
panic!("ub: non-void function does not return a value");
375371
}
376372
assert_eq!(f(), 6);
377373
}
@@ -398,8 +394,7 @@ fn goto_block_multi_label_fallthrough() {
398394
return ret;
399395
}
400396
});
401-
#[allow(unreachable_code)]
402-
0
397+
panic!("ub: non-void function does not return a value");
403398
}
404399
assert_eq!(classify(5), 5);
405400
assert_eq!(classify(0), 0);
@@ -431,8 +426,7 @@ fn goto_block_goto_out_of_switch() {
431426
return ret;
432427
}
433428
});
434-
#[allow(unreachable_code)]
435-
0
429+
panic!("ub: non-void function does not return a value");
436430
}
437431
assert_eq!(sm(0), 11);
438432
assert_eq!(sm(1), 10);
@@ -460,8 +454,7 @@ fn goto_block_goto_out_of_nested_block() {
460454
return ret;
461455
}
462456
});
463-
#[allow(unreachable_code)]
464-
0
457+
panic!("ub: non-void function does not return a value");
465458
}
466459
assert_eq!(f(1), 1);
467460
assert_eq!(f(-1), 12);

0 commit comments

Comments
 (0)