File tree Expand file tree Collapse file tree 2 files changed +63
-0
lines changed
src/test/ui/type-alias-impl-trait Expand file tree Collapse file tree 2 files changed +63
-0
lines changed Original file line number Diff line number Diff line change 1+ #![ feature( type_alias_impl_trait) ]
2+ #![ allow( dead_code) ]
3+
4+ mod m {
5+ type Foo = impl std:: fmt:: Debug ;
6+ //~^ ERROR: cycle detected when computing type of `m::Foo::{opaque#0}` [E0391]
7+
8+ // Cycle: error today, but it'd be nice if it eventually worked
9+
10+ pub fn foo ( ) -> Foo {
11+ is_send ( bar ( ) )
12+ }
13+
14+ pub fn bar ( ) {
15+ is_send ( foo ( ) ) ; // Today: error
16+ }
17+
18+ fn baz ( ) {
19+ let f: Foo = 22_u32 ;
20+ //~^ ERROR: mismatched types [E0308]
21+ }
22+
23+ fn is_send < T : Send > ( _: T ) { }
24+ }
25+
26+ fn main ( ) { }
Original file line number Diff line number Diff line change 1+ error[E0391]: cycle detected when computing type of `m::Foo::{opaque#0}`
2+ --> $DIR/inference-cycle.rs:5:16
3+ |
4+ LL | type Foo = impl std::fmt::Debug;
5+ | ^^^^^^^^^^^^^^^^^^^^
6+ |
7+ note: ...which requires type-checking `m::bar`...
8+ --> $DIR/inference-cycle.rs:14:5
9+ |
10+ LL | pub fn bar() {
11+ | ^^^^^^^^^^^^
12+ = note: ...which requires evaluating trait selection obligation `impl std::fmt::Debug: std::marker::Send`...
13+ = note: ...which again requires computing type of `m::Foo::{opaque#0}`, completing the cycle
14+ note: cycle used when checking item types in module `m`
15+ --> $DIR/inference-cycle.rs:4:1
16+ |
17+ LL | mod m {
18+ | ^^^^^
19+
20+ error[E0308]: mismatched types
21+ --> $DIR/inference-cycle.rs:19:22
22+ |
23+ LL | type Foo = impl std::fmt::Debug;
24+ | -------------------- the expected opaque type
25+ ...
26+ LL | let f: Foo = 22_u32;
27+ | --- ^^^^^^ expected opaque type, found `u32`
28+ | |
29+ | expected due to this
30+ |
31+ = note: expected opaque type `impl Debug`
32+ found type `u32`
33+
34+ error: aborting due to 2 previous errors
35+
36+ Some errors have detailed explanations: E0308, E0391.
37+ For more information about an error, try `rustc --explain E0308`.
You can’t perform that action at this time.
0 commit comments