File tree Expand file tree Collapse file tree 2 files changed +55
-0
lines changed Expand file tree Collapse file tree 2 files changed +55
-0
lines changed Original file line number Diff line number Diff line change 1+ #![ feature( never_type, specialization) ]
2+ #![ allow( incomplete_features) ]
3+
4+ use std:: iter:: { self , Empty } ;
5+
6+ trait Trait {
7+ type Out : Iterator < Item = u32 > ;
8+
9+ fn f ( & self ) -> Option < Self :: Out > ;
10+ }
11+
12+ impl < T > Trait for T {
13+ default type Out = !; //~ ERROR: `!` is not an iterator
14+
15+ default fn f ( & self ) -> Option < Self :: Out > {
16+ None
17+ }
18+ }
19+
20+ struct X ;
21+
22+ impl Trait for X {
23+ type Out = Empty < u32 > ;
24+
25+ fn f ( & self ) -> Option < Self :: Out > {
26+ Some ( iter:: empty ( ) )
27+ }
28+ }
29+
30+ fn f < T : Trait > ( a : T ) {
31+ if let Some ( iter) = a. f ( ) {
32+ println ! ( "Some" ) ;
33+ for x in iter {
34+ println ! ( "x = {}" , x) ;
35+ }
36+ }
37+ }
38+
39+ pub fn main ( ) {
40+ f ( 10 ) ;
41+ }
Original file line number Diff line number Diff line change 1+ error[E0277]: `!` is not an iterator
2+ --> $DIR/issue-51506.rs:13:5
3+ |
4+ LL | type Out: Iterator<Item = u32>;
5+ | ------------------------------- required by `Trait::Out`
6+ ...
7+ LL | default type Out = !;
8+ | ^^^^^^^^^^^^^^^^^^^^^ `!` is not an iterator
9+ |
10+ = help: the trait `std::iter::Iterator` is not implemented for `!`
11+
12+ error: aborting due to previous error
13+
14+ For more information about this error, try `rustc --explain E0277`.
You can’t perform that action at this time.
0 commit comments