]> git.lizzy.rs Git - rust.git/blob - src/test/ui/defaulted-never-note.rs
Rollup merge of #57107 - mjbshaw:thread_local_test, r=nikomatsakis
[rust.git] / src / test / ui / defaulted-never-note.rs
1 // We need to opt into the `!` feature in order to trigger the
2 // requirement that this is testing.
3 #![feature(never_type)]
4
5 #![allow(unused)]
6
7 trait Deserialize: Sized {
8     fn deserialize() -> Result<Self, String>;
9 }
10
11 impl Deserialize for () {
12     fn deserialize() -> Result<(), String> {
13         Ok(())
14     }
15 }
16
17 trait ImplementedForUnitButNotNever {}
18
19 impl ImplementedForUnitButNotNever for () {}
20
21 fn foo<T: ImplementedForUnitButNotNever>(_t: T) {}
22 //~^ NOTE required by `foo`
23
24 fn smeg() {
25     let _x = return;
26     foo(_x);
27     //~^ ERROR the trait bound
28     //~| NOTE the trait `ImplementedForUnitButNotNever` is not implemented
29     //~| NOTE the trait is implemented for `()`
30 }
31
32 fn main() {
33     smeg();
34 }
35