summaryrefslogtreecommitdiffstats
path: root/src/test/ui/type-alias-impl-trait/fallback.rs
blob: d8cf7d71fef7405b0181e284b28b7e1077bc09a2 (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
// Tests that we correctly handle opaque types being used opaquely,
// even within their defining scope.
//
#![feature(type_alias_impl_trait)]

type Foo = impl Copy;

enum Wrapper<T> {
    First(T),
    Second
}

// This method constrains `Foo` to be `bool`
fn constrained_foo() -> Foo {
    true
}


// This method does not constrain `Foo`.
// Per RFC 2071, function bodies may either
// fully constrain an opaque type, or place no
// constraints on it.
fn unconstrained_foo() -> Wrapper<Foo> {
    Wrapper::Second
    //~^ ERROR: type annotations needed
}

fn main() {}