summaryrefslogtreecommitdiffstats
path: root/src/test/ui/chalkify/type_implied_bound.rs
blob: 8673f5319bdf05c55bf580eb1fb33967590b1ed6 (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
// run-pass
// compile-flags: -Z chalk

trait Eq { }
trait Hash: Eq { }

impl Eq for i32 { }
impl Hash for i32 { }

struct Set<T: Hash> {
    _x: T,
}

fn only_eq<T: Eq>() { }

fn take_a_set<T>(_: &Set<T>) {
    // `Set<T>` is an input type of `take_a_set`, hence we know that
    // `T` must implement `Hash`, and we know in turn that `T` must
    // implement `Eq`.
    only_eq::<T>()
}

fn main() {
    let set = Set {
        _x: 5,
    };

    take_a_set(&set);
}