Skip to content

Commit 626d93b

Browse files
committed
Update the "[run-make] run-make/intrinsic-unreachable" test.
With rustc now emitting "ud2" on unreachable code, a "return nothing" sequence may take the same number of lines as an "unreachable" sequence in assembly code. This test is testing that intrinsics::unreachable() works by testing that it reduces the number of lines in the assembly code. Fix it by adding a return value, which requires an extra instruction in the reachable case, which provides the test what it's looking for.
1 parent 89652d6 commit 626d93b

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/test/run-make/intrinsic-unreachable/exit-ret.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@
1111
#![feature(asm)]
1212
#![crate_type="lib"]
1313

14-
pub fn exit(n: usize) {
14+
#[deny(unreachable_code)]
15+
pub fn exit(n: usize) -> i32 {
1516
unsafe {
1617
// Pretend this asm is an exit() syscall.
1718
asm!("" :: "r"(n) :: "volatile");
1819
// Can't actually reach this point, but rustc doesn't know that.
1920
}
21+
42
2022
}

src/test/run-make/intrinsic-unreachable/exit-unreachable.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@
1313

1414
use std::intrinsics;
1515

16-
pub fn exit(n: usize) -> ! {
16+
#[allow(unreachable_code)]
17+
pub fn exit(n: usize) -> i32 {
1718
unsafe {
1819
// Pretend this asm is an exit() syscall.
1920
asm!("" :: "r"(n) :: "volatile");
2021
intrinsics::unreachable()
2122
}
23+
42
2224
}

0 commit comments

Comments
 (0)