summaryrefslogtreecommitdiffstats
path: root/tests/ui/rfc-2027-object-safe-for-dispatch/downcast-unsafe-trait-objects.rs
blob: fa04f4b12d5fe603f1b455c7467f3ba1a4518b31 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Check that we if we get ahold of an object unsafe trait
// object with auto traits and lifetimes, we can downcast it
//
// check-pass

#![feature(object_safe_for_dispatch)]

trait Trait: Sized {}

fn downcast_auto(t: &(dyn Trait + Send)) -> &dyn Trait {
    t
}

fn downcast_lifetime<'a, 'b, 't>(t: &'a (dyn Trait + 't))
                                 -> &'b (dyn Trait + 't)
where
    'a: 'b,
    't: 'a + 'b,
{
    t
}

fn main() {}