about summary refs log tree commit diff
path: root/tests/ui/traits/trait-upcasting/impossible-method-modulo-binders.rs
blob: 63ad1c0a060822de7f6d84854616331c66182824 (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
35
36
37
38
39
40
//@ build-pass
//@ revisions: current next
//@ ignore-compare-mode-next-solver (explicit revisions)
//@[next] compile-flags: -Znext-solver

trait Foo {}
impl Foo for fn(&'static ()) {}

trait Bar {
    type Assoc: Default;
}
impl<T: Foo> Bar for T {
    type Assoc = usize;
}
impl Bar for fn(&()) {
    type Assoc = ();
}

fn needs_foo<T: Foo>() -> usize {
    needs_bar::<T>()
}

fn needs_bar<T: Bar>() -> <T as Bar>::Assoc {
    Default::default()
}

trait Evil<T> {
    fn bad(&self)
    where
        T: Foo,
    {
        needs_foo::<T>();
    }
}

impl Evil<fn(&())> for () {}

fn main() {
    let x: &dyn Evil<fn(&())> = &();
}