summaryrefslogtreecommitdiffstats
path: root/tests/ui/traits/trait-upcasting/fewer-associated.rs
blob: 58e72d9d7ef57e039b28c3d103f32fd1c9e7d811 (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
// check-pass
// issue: 114035
// revisions: current next
//[next] compile-flags: -Znext-solver

#![feature(trait_upcasting)]

trait A: B {
    type Assoc;
}

trait B {}

fn upcast(a: &dyn A<Assoc = i32>) -> &dyn B {
    a
}

// Make sure that we can drop the existential projection `A::Assoc = i32`
// when upcasting `dyn A<Assoc = i32>` to `dyn B`. Before, we used some
// complicated algorithm which required rebuilding a new object type with
// different bounds in order to test that an upcast was valid, but this
// didn't allow upcasting to t that have fewer associated types
// than the source type.

fn main() {}