From 787b2707a77fa1a98f512a4905662a1a16daf13c Mon Sep 17 00:00:00 2001 From: Christiaan Dirkx Date: Fri, 4 Sep 2020 00:24:34 +0200 Subject: [PATCH] Move const tests for `Result` to `library\core` Part of #76268 --- library/core/tests/result.rs | 16 ++++++++++++++++ src/test/ui/consts/const-result.rs | 12 ------------ 2 files changed, 16 insertions(+), 12 deletions(-) delete mode 100644 src/test/ui/consts/const-result.rs diff --git a/library/core/tests/result.rs b/library/core/tests/result.rs index caa2d916cd7..d3c650669da 100644 --- a/library/core/tests/result.rs +++ b/library/core/tests/result.rs @@ -305,3 +305,19 @@ fn test_result_as_deref_mut() { let expected_result = Result::Err::<&mut u32, &mut Vec>(&mut expected_vec); assert_eq!(mut_err.as_deref_mut(), expected_result); } + +#[test] +fn result_const() { + // test that the methods of `Result` are usable in a const context + + const RESULT: Result = Ok(32); + + const REF: Result<&usize, &bool> = RESULT.as_ref(); + assert_eq!(REF, Ok(&32)); + + const IS_OK: bool = RESULT.is_ok(); + assert!(IS_OK); + + const IS_ERR: bool = RESULT.is_err(); + assert!(!IS_ERR) +} diff --git a/src/test/ui/consts/const-result.rs b/src/test/ui/consts/const-result.rs deleted file mode 100644 index e548d3e79ff..00000000000 --- a/src/test/ui/consts/const-result.rs +++ /dev/null @@ -1,12 +0,0 @@ -// run-pass - -fn main() { - const X: Result = Ok(32); - const Y: Result<&i32, &bool> = X.as_ref(); - - const IS_OK: bool = X.is_ok(); - assert!(IS_OK); - - const IS_ERR: bool = Y.is_err(); - assert!(!IS_ERR) -}