]> git.lizzy.rs Git - rust.git/blob - tests/ui/type-alias-impl-trait/fallback.rs
Rollup merge of #106716 - c410-f3r:rfc-2397-1, r=davidtwco
[rust.git] / tests / ui / type-alias-impl-trait / fallback.rs
1 // Tests that we correctly handle opaque types being used opaquely,
2 // even within their defining scope.
3 //
4 #![feature(type_alias_impl_trait)]
5
6 type Foo = impl Copy;
7
8 enum Wrapper<T> {
9     First(T),
10     Second
11 }
12
13 // This method constrains `Foo` to be `bool`
14 fn constrained_foo() -> Foo {
15     true
16 }
17
18
19 // This method does not constrain `Foo`.
20 // Per RFC 2071, function bodies may either
21 // fully constrain an opaque type, or place no
22 // constraints on it.
23 fn unconstrained_foo() -> Wrapper<Foo> {
24     Wrapper::Second
25     //~^ ERROR: type annotations needed
26 }
27
28 fn main() {}