about summary refs log tree commit diff
path: root/src/test/ui/defaulted-never-note.rs
blob: cf1922ecc789f4c3847c3e5d834bd36c4a7a36b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// We need to opt into the `!` feature in order to trigger the
// requirement that this is testing.
#![feature(never_type)]

#![allow(unused)]

trait Deserialize: Sized {
    fn deserialize() -> Result<Self, String>;
}

impl Deserialize for () {
    fn deserialize() -> Result<(), String> {
        Ok(())
    }
}

trait ImplementedForUnitButNotNever {}

impl ImplementedForUnitButNotNever for () {}

fn foo<T: ImplementedForUnitButNotNever>(_t: T) {}
//~^ NOTE required by `foo`

fn smeg() {
    let _x = return;
    foo(_x);
    //~^ ERROR the trait bound
    //~| NOTE the trait `ImplementedForUnitButNotNever` is not implemented
    //~| NOTE the trait is implemented for `()`
}

fn main() {
    smeg();
}