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