From 837dd14de31bd4adc92d962559047e7b449c20a6 Mon Sep 17 00:00:00 2001 From: Michael Sproul Date: Mon, 10 Nov 2014 19:33:20 -0800 Subject: Add optional messages to the unreachable macro. Closes #18842. --- src/test/run-fail/unreachable-fmt-msg.rs | 14 ++++++++++++++ src/test/run-fail/unreachable-macro-fail.rs | 12 ------------ src/test/run-fail/unreachable-static-msg.rs | 12 ++++++++++++ src/test/run-fail/unreachable.rs | 12 ++++++++++++ 4 files changed, 38 insertions(+), 12 deletions(-) create mode 100644 src/test/run-fail/unreachable-fmt-msg.rs delete mode 100644 src/test/run-fail/unreachable-macro-fail.rs create mode 100644 src/test/run-fail/unreachable-static-msg.rs create mode 100644 src/test/run-fail/unreachable.rs (limited to 'src/test') diff --git a/src/test/run-fail/unreachable-fmt-msg.rs b/src/test/run-fail/unreachable-fmt-msg.rs new file mode 100644 index 00000000000..f005fa4476c --- /dev/null +++ b/src/test/run-fail/unreachable-fmt-msg.rs @@ -0,0 +1,14 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern:internal error: entered unreachable code: 6 is not prime +fn main() { + unreachable!("{} is not {}", 6u32, "prime"); +} diff --git a/src/test/run-fail/unreachable-macro-fail.rs b/src/test/run-fail/unreachable-macro-fail.rs deleted file mode 100644 index 07e05c6fed9..00000000000 --- a/src/test/run-fail/unreachable-macro-fail.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern:internal error: entered unreachable code -fn main() { unreachable!() } diff --git a/src/test/run-fail/unreachable-static-msg.rs b/src/test/run-fail/unreachable-static-msg.rs new file mode 100644 index 00000000000..25894a88541 --- /dev/null +++ b/src/test/run-fail/unreachable-static-msg.rs @@ -0,0 +1,12 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern:internal error: entered unreachable code: uhoh +fn main() { unreachable!("uhoh") } diff --git a/src/test/run-fail/unreachable.rs b/src/test/run-fail/unreachable.rs new file mode 100644 index 00000000000..07e05c6fed9 --- /dev/null +++ b/src/test/run-fail/unreachable.rs @@ -0,0 +1,12 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern:internal error: entered unreachable code +fn main() { unreachable!() } -- cgit 1.4.1-3-g733a5