]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/impl-for-never.rs
Auto merge of #61361 - estebank:infer-type, r=varkor
[rust.git] / src / test / run-pass / impl-for-never.rs
1 // Test that we can call static methods on ! both directly and when it appears in a generic
2
3 #![feature(never_type)]
4
5 trait StringifyType {
6     fn stringify_type() -> &'static str;
7 }
8
9 impl StringifyType for ! {
10     fn stringify_type() -> &'static str {
11         "!"
12     }
13 }
14
15 fn maybe_stringify<T: StringifyType>(opt: Option<T>) -> &'static str {
16     match opt {
17         Some(_) => T::stringify_type(),
18         None => "none",
19     }
20 }
21
22 fn main() {
23     println!("! is {}", <!>::stringify_type());
24     println!("None is {}", maybe_stringify(None::<!>));
25 }