File tree Expand file tree Collapse file tree 2 files changed +77
-0
lines changed
src/test/ui/type-alias-impl-trait Expand file tree Collapse file tree 2 files changed +77
-0
lines changed Original file line number Diff line number Diff line change 1+ #![ feature( type_alias_impl_trait) ]
2+
3+ use std:: fmt:: Debug ;
4+
5+ type Foo = impl Debug ;
6+ //~^ ERROR cycle detected
7+ //~| ERROR cycle detected
8+
9+ fn is_send < T : Send > ( ) { }
10+
11+ fn not_good ( ) {
12+ // Error: this function does not constrain `Foo` to any particular
13+ // hidden type, so it cannot rely on `Send` being true.
14+ is_send :: < Foo > ( ) ;
15+ }
16+
17+ fn not_gooder ( ) {
18+ // Constrain `Foo = u32`
19+ let x: Foo = 22_u32 ;
20+
21+ // while we could know this from the hidden type, it would
22+ // need extra roundabout logic to support it.
23+ is_send :: < Foo > ( ) ;
24+ }
25+
26+ fn main ( ) { }
Original file line number Diff line number Diff line change 1+ error[E0391]: cycle detected when computing type of `Foo::{opaque#0}`
2+ --> $DIR/reveal_local.rs:5:12
3+ |
4+ LL | type Foo = impl Debug;
5+ | ^^^^^^^^^^
6+ |
7+ note: ...which requires type-checking `not_good`...
8+ --> $DIR/reveal_local.rs:11:1
9+ |
10+ LL | fn not_good() {
11+ | ^^^^^^^^^^^^^
12+ = note: ...which again requires computing type of `Foo::{opaque#0}`, completing the cycle
13+ note: cycle used when checking item types in top-level module
14+ --> $DIR/reveal_local.rs:1:1
15+ |
16+ LL | / #![feature(type_alias_impl_trait)]
17+ LL | |
18+ LL | | use std::fmt::Debug;
19+ LL | |
20+ ... |
21+ LL | |
22+ LL | | fn main() {}
23+ | |____________^
24+
25+ error[E0391]: cycle detected when computing type of `Foo::{opaque#0}`
26+ --> $DIR/reveal_local.rs:5:12
27+ |
28+ LL | type Foo = impl Debug;
29+ | ^^^^^^^^^^
30+ |
31+ note: ...which requires type-checking `not_gooder`...
32+ --> $DIR/reveal_local.rs:17:1
33+ |
34+ LL | fn not_gooder() {
35+ | ^^^^^^^^^^^^^^^
36+ = note: ...which again requires computing type of `Foo::{opaque#0}`, completing the cycle
37+ note: cycle used when checking item types in top-level module
38+ --> $DIR/reveal_local.rs:1:1
39+ |
40+ LL | / #![feature(type_alias_impl_trait)]
41+ LL | |
42+ LL | | use std::fmt::Debug;
43+ LL | |
44+ ... |
45+ LL | |
46+ LL | | fn main() {}
47+ | |____________^
48+
49+ error: aborting due to 2 previous errors
50+
51+ For more information about this error, try `rustc --explain E0391`.
You can’t perform that action at this time.
0 commit comments