From 626d93b86d3fe0c3f12f0299d72a8f65185ec268 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Fri, 10 Nov 2017 15:32:06 -0800 Subject: [PATCH] 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. --- src/test/run-make/intrinsic-unreachable/exit-ret.rs | 4 +++- src/test/run-make/intrinsic-unreachable/exit-unreachable.rs | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/test/run-make/intrinsic-unreachable/exit-ret.rs b/src/test/run-make/intrinsic-unreachable/exit-ret.rs index f5be5a055c3e..3de079be2a54 100644 --- a/src/test/run-make/intrinsic-unreachable/exit-ret.rs +++ b/src/test/run-make/intrinsic-unreachable/exit-ret.rs @@ -11,10 +11,12 @@ #![feature(asm)] #![crate_type="lib"] -pub fn exit(n: usize) { +#[deny(unreachable_code)] +pub fn exit(n: usize) -> i32 { unsafe { // Pretend this asm is an exit() syscall. asm!("" :: "r"(n) :: "volatile"); // Can't actually reach this point, but rustc doesn't know that. } + 42 } diff --git a/src/test/run-make/intrinsic-unreachable/exit-unreachable.rs b/src/test/run-make/intrinsic-unreachable/exit-unreachable.rs index f58d2cd8f91d..2a9dea1705ae 100644 --- a/src/test/run-make/intrinsic-unreachable/exit-unreachable.rs +++ b/src/test/run-make/intrinsic-unreachable/exit-unreachable.rs @@ -13,10 +13,12 @@ use std::intrinsics; -pub fn exit(n: usize) -> ! { +#[allow(unreachable_code)] +pub fn exit(n: usize) -> i32 { unsafe { // Pretend this asm is an exit() syscall. asm!("" :: "r"(n) :: "volatile"); intrinsics::unreachable() } + 42 }