File tree Expand file tree Collapse file tree 7 files changed +152
-0
lines changed
src/test/ui/lazy-type-alias-impl-trait Expand file tree Collapse file tree 7 files changed +152
-0
lines changed Original file line number Diff line number Diff line change
1
+ #![ feature( type_alias_impl_trait) ]
2
+
3
+ // check-pass
4
+
5
+ type Foo = impl std:: fmt:: Debug ;
6
+
7
+ fn foo ( b : bool ) -> Foo {
8
+ if b {
9
+ return 42
10
+ }
11
+ let x: u32 = foo ( false ) ;
12
+ 99
13
+ }
14
+
15
+ fn bar ( b : bool ) -> impl std:: fmt:: Debug {
16
+ if b {
17
+ return 42
18
+ }
19
+ let x: u32 = bar ( false ) ;
20
+ 99
21
+ }
22
+
23
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ #![ feature( type_alias_impl_trait) ]
2
+
3
+ type Foo = impl std:: fmt:: Debug ;
4
+
5
+ fn foo ( b : bool ) -> Foo {
6
+ if b {
7
+ return vec ! [ ] ;
8
+ }
9
+ let x: Vec < i32 > = foo ( false ) ;
10
+ std:: iter:: empty ( ) . collect ( ) //~ ERROR `Foo` cannot be built from an iterator
11
+ }
12
+
13
+ fn bar ( b : bool ) -> impl std:: fmt:: Debug {
14
+ if b {
15
+ return vec ! [ ]
16
+ }
17
+ let x: Vec < i32 > = bar ( false ) ;
18
+ std:: iter:: empty ( ) . collect ( )
19
+ }
20
+
21
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ error[E0277]: a value of type `Foo` cannot be built from an iterator over elements of type `_`
2
+ --> $DIR/recursion2.rs:10:24
3
+ |
4
+ LL | std::iter::empty().collect()
5
+ | ^^^^^^^ value of type `Foo` cannot be built from `std::iter::Iterator<Item=_>`
6
+ |
7
+ = help: the trait `FromIterator<_>` is not implemented for `Foo`
8
+ note: required by a bound in `collect`
9
+ --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
10
+ |
11
+ LL | fn collect<B: FromIterator<Self::Item>>(self) -> B
12
+ | ^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `collect`
13
+
14
+ error: aborting due to previous error
15
+
16
+ For more information about this error, try `rustc --explain E0277`.
Original file line number Diff line number Diff line change
1
+ #![ feature( type_alias_impl_trait) ]
2
+
3
+ type Foo = impl std:: fmt:: Debug ;
4
+
5
+ fn foo ( b : bool ) -> Foo {
6
+ if b {
7
+ return 42
8
+ }
9
+ let x: u32 = foo ( false ) + 42 ; //~ ERROR cannot add
10
+ 99
11
+ }
12
+
13
+ fn bar ( b : bool ) -> impl std:: fmt:: Debug {
14
+ if b {
15
+ return 42
16
+ }
17
+ let x: u32 = bar ( false ) + 42 ; //~ ERROR cannot add
18
+ 99
19
+ }
20
+
21
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ error[E0369]: cannot add `{integer}` to `Foo`
2
+ --> $DIR/recursion3.rs:9:29
3
+ |
4
+ LL | let x: u32 = foo(false) + 42;
5
+ | ---------- ^ -- {integer}
6
+ | |
7
+ | Foo
8
+
9
+ error[E0369]: cannot add `{integer}` to `impl Debug`
10
+ --> $DIR/recursion3.rs:17:29
11
+ |
12
+ LL | let x: u32 = bar(false) + 42;
13
+ | ---------- ^ -- {integer}
14
+ | |
15
+ | impl Debug
16
+
17
+ error: aborting due to 2 previous errors
18
+
19
+ For more information about this error, try `rustc --explain E0369`.
Original file line number Diff line number Diff line change
1
+ #![ feature( type_alias_impl_trait) ]
2
+
3
+ type Foo = impl std:: fmt:: Debug ;
4
+
5
+ fn foo ( b : bool ) -> Foo {
6
+ if b {
7
+ return vec ! [ ] ;
8
+ }
9
+ let mut x = foo ( false ) ;
10
+ x = std:: iter:: empty ( ) . collect ( ) ; //~ ERROR `Foo` cannot be built from an iterator
11
+ vec ! [ ]
12
+ }
13
+
14
+ fn bar ( b : bool ) -> impl std:: fmt:: Debug {
15
+ if b {
16
+ return vec ! [ ] ;
17
+ }
18
+ let mut x = bar ( false ) ;
19
+ x = std:: iter:: empty ( ) . collect ( ) ; //~ ERROR `impl Debug` cannot be built from an iterator
20
+ vec ! [ ]
21
+ }
22
+
23
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ error[E0277]: a value of type `Foo` cannot be built from an iterator over elements of type `_`
2
+ --> $DIR/recursion4.rs:10:28
3
+ |
4
+ LL | x = std::iter::empty().collect();
5
+ | ^^^^^^^ value of type `Foo` cannot be built from `std::iter::Iterator<Item=_>`
6
+ |
7
+ = help: the trait `FromIterator<_>` is not implemented for `Foo`
8
+ note: required by a bound in `collect`
9
+ --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
10
+ |
11
+ LL | fn collect<B: FromIterator<Self::Item>>(self) -> B
12
+ | ^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `collect`
13
+
14
+ error[E0277]: a value of type `impl Debug` cannot be built from an iterator over elements of type `_`
15
+ --> $DIR/recursion4.rs:19:28
16
+ |
17
+ LL | x = std::iter::empty().collect();
18
+ | ^^^^^^^ value of type `impl Debug` cannot be built from `std::iter::Iterator<Item=_>`
19
+ |
20
+ = help: the trait `FromIterator<_>` is not implemented for `impl Debug`
21
+ note: required by a bound in `collect`
22
+ --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
23
+ |
24
+ LL | fn collect<B: FromIterator<Self::Item>>(self) -> B
25
+ | ^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `collect`
26
+
27
+ error: aborting due to 2 previous errors
28
+
29
+ For more information about this error, try `rustc --explain E0277`.
You can’t perform that action at this time.
0 commit comments