about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDylan MacKenzie <ecstaticmorse@gmail.com>2020-02-08 16:02:37 -0800
committerDylan MacKenzie <ecstaticmorse@gmail.com>2020-02-08 16:06:42 -0800
commit0755c41ae26af20c940a80b3c1f686ab5916e655 (patch)
treeba8e097f56d52a09f3e3ac27ed9b8a84c6982bb2
parent0b20ce97f7cc1360190cb9c2b102cdee4f487de2 (diff)
downloadrust-0755c41ae26af20c940a80b3c1f686ab5916e655.tar.gz
rust-0755c41ae26af20c940a80b3c1f686ab5916e655.zip
Test `NonZeroU8::new` in a const context
-rw-r--r--src/test/ui/consts/const-nonzero.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/test/ui/consts/const-nonzero.rs b/src/test/ui/consts/const-nonzero.rs
index 6db3d1b3331..2160bad4807 100644
--- a/src/test/ui/consts/const-nonzero.rs
+++ b/src/test/ui/consts/const-nonzero.rs
@@ -1,9 +1,18 @@
-// build-pass (FIXME(62277): could be check-pass?)
+// run-pass
+
+#![feature(const_nonzero_int_methods)]
 
 use std::num::NonZeroU8;
 
 const X: NonZeroU8 = unsafe { NonZeroU8::new_unchecked(5) };
 const Y: u8 = X.get();
 
+const ZERO: Option<NonZeroU8> = NonZeroU8::new(0);
+const ONE: Option<NonZeroU8> = NonZeroU8::new(1);
+
 fn main() {
+    assert_eq!(Y, 5);
+
+    assert!(ZERO.is_none());
+    assert_eq!(ONE.unwrap().get(), 1);
 }