File tree Expand file tree Collapse file tree 2 files changed +53
-0
lines changed
src/test/ui/impl-trait/issues Expand file tree Collapse file tree 2 files changed +53
-0
lines changed Original file line number Diff line number Diff line change
1
+ #![ feature( type_alias_impl_trait) ]
2
+ #![ feature( impl_trait_in_bindings) ]
3
+ #![ allow( incomplete_features) ]
4
+
5
+ type FooArg < ' a > = & ' a dyn ToString ;
6
+ type FooRet = impl std:: fmt:: Debug ;
7
+
8
+ type FooItem = Box < dyn Fn ( FooArg ) -> FooRet > ;
9
+ type Foo = impl Iterator < Item = FooItem > ; //~ ERROR: type mismatch
10
+
11
+ #[ repr( C ) ]
12
+ struct Bar ( u8 ) ;
13
+
14
+ impl Iterator for Bar {
15
+ type Item = FooItem ;
16
+
17
+ fn next ( & mut self ) -> Option < Self :: Item > {
18
+ Some ( Box :: new ( quux) )
19
+ }
20
+ }
21
+
22
+ fn quux ( st : FooArg ) -> FooRet {
23
+ Some ( st. to_string ( ) )
24
+ }
25
+
26
+ fn ham ( ) -> Foo {
27
+ Bar ( 1 )
28
+ }
29
+
30
+ fn oof ( ) -> impl std:: fmt:: Debug {
31
+ let mut bar = ham ( ) ;
32
+ let func = bar. next ( ) . unwrap ( ) ;
33
+ return func ( & "oof" ) ;
34
+ }
35
+
36
+ fn main ( ) {
37
+ let _ = oof ( ) ;
38
+ }
Original file line number Diff line number Diff line change
1
+ error[E0271]: type mismatch resolving `<Bar as Iterator>::Item == Box<(dyn for<'r> Fn(&'r (dyn ToString + 'r)) -> Option<String> + 'static)>`
2
+ --> $DIR/issue-70877.rs:9:12
3
+ |
4
+ LL | type FooRet = impl std::fmt::Debug;
5
+ | -------------------- the expected opaque type
6
+ ...
7
+ LL | type Foo = impl Iterator<Item = FooItem>;
8
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected opaque type, found enum `Option`
9
+ |
10
+ = note: expected struct `Box<(dyn for<'r> Fn(&'r (dyn ToString + 'r)) -> impl Debug + 'static)>`
11
+ found struct `Box<(dyn for<'r> Fn(&'r (dyn ToString + 'r)) -> Option<String> + 'static)>`
12
+
13
+ error: aborting due to previous error
14
+
15
+ For more information about this error, try `rustc --explain E0271`.
You can’t perform that action at this time.
0 commit comments