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