File tree 7 files changed +152
-0
lines changed
7 files changed +152
-0
lines changed Original file line number Diff line number Diff line change
1
+ // check-pass
2
+
3
+ #![ feature( impl_trait_in_bindings) ]
4
+ #![ allow( incomplete_features) ]
5
+
6
+ struct A < ' a > ( & ' a ( ) ) ;
7
+
8
+ trait Trait < T > { }
9
+
10
+ impl < T > Trait < T > for ( ) { }
11
+
12
+ pub fn foo < ' a > ( ) {
13
+ let _x: impl Trait < A < ' a > > = ( ) ;
14
+ }
15
+
16
+ fn main ( ) { }
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`.
Original file line number Diff line number Diff line change
1
+ #![ crate_type = "lib" ]
2
+ #![ feature( specialization) ]
3
+ #![ feature( unsize, coerce_unsized) ]
4
+ #![ allow( incomplete_features) ]
5
+
6
+ use std:: ops:: CoerceUnsized ;
7
+
8
+ pub struct SmartassPtr < A : Smartass +?Sized > ( A :: Data ) ;
9
+
10
+ pub trait Smartass {
11
+ type Data ;
12
+ type Data2 : CoerceUnsized < * const [ u8 ] > ;
13
+ }
14
+
15
+ pub trait MaybeObjectSafe { }
16
+
17
+ impl MaybeObjectSafe for ( ) { }
18
+
19
+ impl < T > Smartass for T {
20
+ type Data = <Self as Smartass >:: Data2 ;
21
+ default type Data2 = ( ) ;
22
+ //~^ ERROR: the trait bound `(): std::ops::CoerceUnsized<*const [u8]>` is not satisfied
23
+ }
24
+
25
+ impl Smartass for ( ) {
26
+ type Data2 = * const [ u8 ; 1 ] ;
27
+ }
28
+
29
+ impl Smartass for dyn MaybeObjectSafe {
30
+ type Data = * const [ u8 ] ;
31
+ type Data2 = * const [ u8 ; 0 ] ;
32
+ }
33
+
34
+ impl < U : Smartass +?Sized , T : Smartass +?Sized > CoerceUnsized < SmartassPtr < T > > for SmartassPtr < U >
35
+ where <U as Smartass >:: Data : std:: ops:: CoerceUnsized < <T as Smartass >:: Data >
36
+ { }
37
+
38
+ pub fn conv ( s : SmartassPtr < ( ) > ) -> SmartassPtr < dyn MaybeObjectSafe > {
39
+ s
40
+ }
Original file line number Diff line number Diff line change
1
+ error[E0277]: the trait bound `(): std::ops::CoerceUnsized<*const [u8]>` is not satisfied
2
+ --> $DIR/issue-44861.rs:21:5
3
+ |
4
+ LL | type Data2: CoerceUnsized<*const [u8]>;
5
+ | --------------------------------------- required by `Smartass::Data2`
6
+ ...
7
+ LL | default type Data2 = ();
8
+ | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::ops::CoerceUnsized<*const [u8]>` is not implemented for `()`
9
+
10
+ error: aborting due to previous error
11
+
12
+ For more information about this error, try `rustc --explain E0277`.
Original file line number Diff line number Diff line change
1
+ #![ feature( specialization) ]
2
+ #![ allow( incomplete_features) ]
3
+
4
+ struct MyStruct { }
5
+
6
+ trait MyTrait {
7
+ type MyType : Default ;
8
+ }
9
+
10
+ impl MyTrait for i32 {
11
+ default type MyType = MyStruct ;
12
+ //~^ ERROR: the trait bound `MyStruct: std::default::Default` is not satisfied
13
+ }
14
+
15
+ fn main ( ) {
16
+ let _x: <i32 as MyTrait >:: MyType = <i32 as MyTrait >:: MyType :: default ( ) ;
17
+ }
Original file line number Diff line number Diff line change
1
+ error[E0277]: the trait bound `MyStruct: std::default::Default` is not satisfied
2
+ --> $DIR/issue-59435.rs:11:5
3
+ |
4
+ LL | type MyType: Default;
5
+ | --------------------- required by `MyTrait::MyType`
6
+ ...
7
+ LL | default type MyType = MyStruct;
8
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::default::Default` is not implemented for `MyStruct`
9
+
10
+ error: aborting due to previous error
11
+
12
+ For more information about this error, try `rustc --explain E0277`.
You can’t perform that action at this time.
0 commit comments