aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/rust/execute/torture/min_specialization2.rs
blob: d3239eea4705d782973a913151a4c5f293b1eb5d (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
#![feature(min_specialization)]

#[lang = "sized"]
trait Sized {}

trait Foo {
    fn foo(&self) -> i32;
}

impl<T> Foo for T {
    default fn foo(&self) -> i32 { // { dg-warning "unused" }
        15
    }
}

impl Foo for bool {
    fn foo(&self) -> i32 {
        if *self {
            1
        } else {
            0
        }
    }
}

fn main() -> i32 {
    let a = 1.foo() - 15;
    let b = true.foo() - 1;

    a + b
}