summaryrefslogtreecommitdiffstats
path: root/tests/ui/traits/new-solver/try-example.rs
blob: e826f3a00599bcd62595b9e12b6878cee75a88a1 (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
// check-pass
// compile-flags: -Ztrait-solver=next

use std::error::Error;

fn main() -> Result<(), Box<dyn Error>> {
    let x: i32 = parse()?;
    Ok(())
}

trait Parse {}

impl Parse for i32 {}

#[derive(Debug)]
struct ParseError;

impl std::fmt::Display for ParseError {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "ParseError")
    }
}

impl Error for ParseError {}

fn parse<T: Parse>() -> Result<T, ParseError> {
    todo!()
}