]> git.lizzy.rs Git - rust.git/commitdiff
Add a basic test for specialization.
authorScott Olson <scott@solson.me>
Mon, 28 Mar 2016 23:59:48 +0000 (17:59 -0600)
committerScott Olson <scott@solson.me>
Mon, 28 Mar 2016 23:59:48 +0000 (17:59 -0600)
test/specialization.rs [new file with mode: 0755]

diff --git a/test/specialization.rs b/test/specialization.rs
new file mode 100755 (executable)
index 0000000..ac510ec
--- /dev/null
@@ -0,0 +1,19 @@
+#![feature(custom_attribute, specialization)]
+#![allow(dead_code, unused_attributes)]
+
+trait IsUnit {
+    fn is_unit() -> bool;
+}
+
+impl<T> IsUnit for T {
+    default fn is_unit() -> bool { false }
+}
+
+impl IsUnit for () {
+    fn is_unit() -> bool { true }
+}
+
+#[miri_run]
+fn specialization() -> (bool, bool) {
+    (i32::is_unit(), <()>::is_unit())
+}