diff options
Diffstat (limited to 'src/test/ui/never_type/impl-for-never.rs')
-rw-r--r-- | src/test/ui/never_type/impl-for-never.rs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/test/ui/never_type/impl-for-never.rs b/src/test/ui/never_type/impl-for-never.rs new file mode 100644 index 000000000..9423f0885 --- /dev/null +++ b/src/test/ui/never_type/impl-for-never.rs @@ -0,0 +1,27 @@ +// run-pass + +#![feature(never_type)] + +// Test that we can call static methods on ! both directly and when it appears in a generic + +trait StringifyType { + fn stringify_type() -> &'static str; +} + +impl StringifyType for ! { + fn stringify_type() -> &'static str { + "!" + } +} + +fn maybe_stringify<T: StringifyType>(opt: Option<T>) -> &'static str { + match opt { + Some(_) => T::stringify_type(), + None => "none", + } +} + +fn main() { + println!("! is {}", <!>::stringify_type()); + println!("None is {}", maybe_stringify(None::<!>)); +} |