Allow/fix non_fmt_panic in tests.

This commit is contained in:
Mara Bos 2021-02-02 00:40:17 +01:00
parent 34d5ac25c5
commit e9ad5be0f7
13 changed files with 42 additions and 35 deletions

View File

@ -77,15 +77,15 @@ fn test_comparison_ops() {
for &(op, bs) in v.iter() { for &(op, bs) in v.iter() {
let s = format!("%{{1}}%{{2}}%{}%d", op); let s = format!("%{{1}}%{{2}}%{}%d", op);
let res = expand(s.as_bytes(), &[], &mut Variables::new()); let res = expand(s.as_bytes(), &[], &mut Variables::new());
assert!(res.is_ok(), res.unwrap_err()); assert!(res.is_ok(), "{}", res.unwrap_err());
assert_eq!(res.unwrap(), vec![b'0' + bs[0]]); assert_eq!(res.unwrap(), vec![b'0' + bs[0]]);
let s = format!("%{{1}}%{{1}}%{}%d", op); let s = format!("%{{1}}%{{1}}%{}%d", op);
let res = expand(s.as_bytes(), &[], &mut Variables::new()); let res = expand(s.as_bytes(), &[], &mut Variables::new());
assert!(res.is_ok(), res.unwrap_err()); assert!(res.is_ok(), "{}", res.unwrap_err());
assert_eq!(res.unwrap(), vec![b'0' + bs[1]]); assert_eq!(res.unwrap(), vec![b'0' + bs[1]]);
let s = format!("%{{2}}%{{1}}%{}%d", op); let s = format!("%{{2}}%{{1}}%{}%d", op);
let res = expand(s.as_bytes(), &[], &mut Variables::new()); let res = expand(s.as_bytes(), &[], &mut Variables::new());
assert!(res.is_ok(), res.unwrap_err()); assert!(res.is_ok(), "{}", res.unwrap_err());
assert_eq!(res.unwrap(), vec![b'0' + bs[2]]); assert_eq!(res.unwrap(), vec![b'0' + bs[2]]);
} }
} }
@ -95,13 +95,13 @@ fn test_conditionals() {
let mut vars = Variables::new(); let mut vars = Variables::new();
let s = b"\\E[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m"; let s = b"\\E[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m";
let res = expand(s, &[Number(1)], &mut vars); let res = expand(s, &[Number(1)], &mut vars);
assert!(res.is_ok(), res.unwrap_err()); assert!(res.is_ok(), "{}", res.unwrap_err());
assert_eq!(res.unwrap(), "\\E[31m".bytes().collect::<Vec<_>>()); assert_eq!(res.unwrap(), "\\E[31m".bytes().collect::<Vec<_>>());
let res = expand(s, &[Number(8)], &mut vars); let res = expand(s, &[Number(8)], &mut vars);
assert!(res.is_ok(), res.unwrap_err()); assert!(res.is_ok(), "{}", res.unwrap_err());
assert_eq!(res.unwrap(), "\\E[90m".bytes().collect::<Vec<_>>()); assert_eq!(res.unwrap(), "\\E[90m".bytes().collect::<Vec<_>>());
let res = expand(s, &[Number(42)], &mut vars); let res = expand(s, &[Number(42)], &mut vars);
assert!(res.is_ok(), res.unwrap_err()); assert!(res.is_ok(), "{}", res.unwrap_err());
assert_eq!(res.unwrap(), "\\E[38;5;42m".bytes().collect::<Vec<_>>()); assert_eq!(res.unwrap(), "\\E[38;5;42m".bytes().collect::<Vec<_>>());
} }

View File

@ -199,7 +199,7 @@ fn f() {
fn test_should_panic_non_string_message_type() { fn test_should_panic_non_string_message_type() {
use crate::tests::TrFailedMsg; use crate::tests::TrFailedMsg;
fn f() { fn f() {
panic!(1i32); std::panic::panic_any(1i32);
} }
let expected = "foobar"; let expected = "foobar";
let failed_msg = format!( let failed_msg = format!(

View File

@ -50,7 +50,7 @@ fn test() {
.output().unwrap(); .output().unwrap();
assert!(child_output.status.success(), assert!(child_output.status.success(),
format!("child assertion failed\n child stdout:\n {}\n child stderr:\n {}", "child assertion failed\n child stdout:\n {}\n child stderr:\n {}",
str::from_utf8(&child_output.stdout).unwrap(), str::from_utf8(&child_output.stdout).unwrap(),
str::from_utf8(&child_output.stderr).unwrap())); str::from_utf8(&child_output.stderr).unwrap());
} }

View File

@ -1,4 +1,5 @@
#![feature(const_panic)] #![feature(const_panic)]
#![allow(non_fmt_panic)]
#![crate_type = "lib"] #![crate_type = "lib"]
const MSG: &str = "hello"; const MSG: &str = "hello";

View File

@ -1,10 +1,10 @@
error: any use of this value will cause an error error: any use of this value will cause an error
--> $DIR/const_panic.rs:6:15 --> $DIR/const_panic.rs:7:15
| |
LL | const Z: () = std::panic!("cheese"); LL | const Z: () = std::panic!("cheese");
| --------------^^^^^^^^^^^^^^^^^^^^^- | --------------^^^^^^^^^^^^^^^^^^^^^-
| | | |
| the evaluated program panicked at 'cheese', $DIR/const_panic.rs:6:15 | the evaluated program panicked at 'cheese', $DIR/const_panic.rs:7:15
| |
= note: `#[deny(const_err)]` on by default = note: `#[deny(const_err)]` on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
@ -12,108 +12,108 @@ LL | const Z: () = std::panic!("cheese");
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: any use of this value will cause an error error: any use of this value will cause an error
--> $DIR/const_panic.rs:10:16 --> $DIR/const_panic.rs:11:16
| |
LL | const Z2: () = std::panic!(); LL | const Z2: () = std::panic!();
| ---------------^^^^^^^^^^^^^- | ---------------^^^^^^^^^^^^^-
| | | |
| the evaluated program panicked at 'explicit panic', $DIR/const_panic.rs:10:16 | the evaluated program panicked at 'explicit panic', $DIR/const_panic.rs:11:16
| |
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: any use of this value will cause an error error: any use of this value will cause an error
--> $DIR/const_panic.rs:14:15 --> $DIR/const_panic.rs:15:15
| |
LL | const Y: () = std::unreachable!(); LL | const Y: () = std::unreachable!();
| --------------^^^^^^^^^^^^^^^^^^^- | --------------^^^^^^^^^^^^^^^^^^^-
| | | |
| the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:14:15 | the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:15:15
| |
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: any use of this value will cause an error error: any use of this value will cause an error
--> $DIR/const_panic.rs:18:15 --> $DIR/const_panic.rs:19:15
| |
LL | const X: () = std::unimplemented!(); LL | const X: () = std::unimplemented!();
| --------------^^^^^^^^^^^^^^^^^^^^^- | --------------^^^^^^^^^^^^^^^^^^^^^-
| | | |
| the evaluated program panicked at 'not implemented', $DIR/const_panic.rs:18:15 | the evaluated program panicked at 'not implemented', $DIR/const_panic.rs:19:15
| |
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: any use of this value will cause an error error: any use of this value will cause an error
--> $DIR/const_panic.rs:22:15 --> $DIR/const_panic.rs:23:15
| |
LL | const W: () = std::panic!(MSG); LL | const W: () = std::panic!(MSG);
| --------------^^^^^^^^^^^^^^^^- | --------------^^^^^^^^^^^^^^^^-
| | | |
| the evaluated program panicked at 'hello', $DIR/const_panic.rs:22:15 | the evaluated program panicked at 'hello', $DIR/const_panic.rs:23:15
| |
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: any use of this value will cause an error error: any use of this value will cause an error
--> $DIR/const_panic.rs:26:20 --> $DIR/const_panic.rs:27:20
| |
LL | const Z_CORE: () = core::panic!("cheese"); LL | const Z_CORE: () = core::panic!("cheese");
| -------------------^^^^^^^^^^^^^^^^^^^^^^- | -------------------^^^^^^^^^^^^^^^^^^^^^^-
| | | |
| the evaluated program panicked at 'cheese', $DIR/const_panic.rs:26:20 | the evaluated program panicked at 'cheese', $DIR/const_panic.rs:27:20
| |
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: any use of this value will cause an error error: any use of this value will cause an error
--> $DIR/const_panic.rs:30:21 --> $DIR/const_panic.rs:31:21
| |
LL | const Z2_CORE: () = core::panic!(); LL | const Z2_CORE: () = core::panic!();
| --------------------^^^^^^^^^^^^^^- | --------------------^^^^^^^^^^^^^^-
| | | |
| the evaluated program panicked at 'explicit panic', $DIR/const_panic.rs:30:21 | the evaluated program panicked at 'explicit panic', $DIR/const_panic.rs:31:21
| |
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: any use of this value will cause an error error: any use of this value will cause an error
--> $DIR/const_panic.rs:34:20 --> $DIR/const_panic.rs:35:20
| |
LL | const Y_CORE: () = core::unreachable!(); LL | const Y_CORE: () = core::unreachable!();
| -------------------^^^^^^^^^^^^^^^^^^^^- | -------------------^^^^^^^^^^^^^^^^^^^^-
| | | |
| the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:34:20 | the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:35:20
| |
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: any use of this value will cause an error error: any use of this value will cause an error
--> $DIR/const_panic.rs:38:20 --> $DIR/const_panic.rs:39:20
| |
LL | const X_CORE: () = core::unimplemented!(); LL | const X_CORE: () = core::unimplemented!();
| -------------------^^^^^^^^^^^^^^^^^^^^^^- | -------------------^^^^^^^^^^^^^^^^^^^^^^-
| | | |
| the evaluated program panicked at 'not implemented', $DIR/const_panic.rs:38:20 | the evaluated program panicked at 'not implemented', $DIR/const_panic.rs:39:20
| |
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error: any use of this value will cause an error error: any use of this value will cause an error
--> $DIR/const_panic.rs:42:20 --> $DIR/const_panic.rs:43:20
| |
LL | const W_CORE: () = core::panic!(MSG); LL | const W_CORE: () = core::panic!(MSG);
| -------------------^^^^^^^^^^^^^^^^^- | -------------------^^^^^^^^^^^^^^^^^-
| | | |
| the evaluated program panicked at 'hello', $DIR/const_panic.rs:42:20 | the evaluated program panicked at 'hello', $DIR/const_panic.rs:43:20
| |
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800>

View File

@ -82,7 +82,7 @@ fn fallible_operation(&self) {
self.cur_ops.set(self.cur_ops.get() + 1); self.cur_ops.set(self.cur_ops.get() + 1);
if self.cur_ops.get() == self.failing_op { if self.cur_ops.get() == self.failing_op {
panic!(InjectedFailure); panic::panic_any(InjectedFailure);
} }
} }
} }

View File

@ -46,7 +46,7 @@ fn alloc(&self) -> Ptr<'_> {
self.cur_ops.set(self.cur_ops.get() + 1); self.cur_ops.set(self.cur_ops.get() + 1);
if self.cur_ops.get() == self.failing_op { if self.cur_ops.get() == self.failing_op {
panic!(InjectedFailure); panic::panic_any(InjectedFailure);
} }
let mut data = self.data.borrow_mut(); let mut data = self.data.borrow_mut();
@ -67,7 +67,7 @@ fn drop(&mut self) {
self.1.cur_ops.set(self.1.cur_ops.get() + 1); self.1.cur_ops.set(self.1.cur_ops.get() + 1);
if self.1.cur_ops.get() == self.1.failing_op { if self.1.cur_ops.get() == self.1.failing_op {
panic!(InjectedFailure); panic::panic_any(InjectedFailure);
} }
} }
} }

View File

@ -2,6 +2,8 @@
// error-pattern:panicked at 'test-assert-owned' // error-pattern:panicked at 'test-assert-owned'
// ignore-emscripten no processes // ignore-emscripten no processes
#![allow(non_fmt_panic)]
fn main() { fn main() {
assert!(false, "test-assert-owned".to_string()); assert!(false, "test-assert-owned".to_string());
} }

View File

@ -38,7 +38,7 @@ fn main() {
assert_eq!(get(), vec![0, 2, 3, 1]); assert_eq!(get(), vec![0, 2, 3, 1]);
let _ = std::panic::catch_unwind(|| { let _ = std::panic::catch_unwind(|| {
(d(4), &d(5), d(6), &d(7), panic!(InjectedFailure)); (d(4), &d(5), d(6), &d(7), panic::panic_any(InjectedFailure));
}); });
// here, the temporaries (5/7) live until the end of the // here, the temporaries (5/7) live until the end of the

View File

@ -1,5 +1,6 @@
#![allow(unused_assignments)] #![allow(unused_assignments)]
#![allow(unused_variables)] #![allow(unused_variables)]
#![allow(non_fmt_panic)]
// run-fail // run-fail
// error-pattern:wooooo // error-pattern:wooooo

View File

@ -2,6 +2,8 @@
// error-pattern:panicked at 'Box<Any>' // error-pattern:panicked at 'Box<Any>'
// ignore-emscripten no processes // ignore-emscripten no processes
#![allow(non_fmt_panic)]
fn main() { fn main() {
panic!(Box::new(612_i64)); panic!(Box::new(612_i64));
} }

View File

@ -3,6 +3,7 @@
// ignore-emscripten no processes // ignore-emscripten no processes
#![feature(box_syntax)] #![feature(box_syntax)]
#![allow(non_fmt_panic)]
fn main() { fn main() {
panic!(box 413 as Box<dyn std::any::Any + Send>); panic!(box 413 as Box<dyn std::any::Any + Send>);

View File

@ -5,7 +5,7 @@
// ignore-emscripten no processes // ignore-emscripten no processes
fn main() { fn main() {
panic!({ panic!("{}", {
while true { while true {
panic!("giraffe") panic!("giraffe")
} }