File tree Expand file tree Collapse file tree 3 files changed +16
-7
lines changed Expand file tree Collapse file tree 3 files changed +16
-7
lines changed Original file line number Diff line number Diff line change 55
55
*
56
56
*/
57
57
58
+ use kinds:: Sized ;
59
+
58
60
/**
59
61
*
60
62
* The `Drop` trait is used to run some code when a value goes out of scope. This
@@ -700,7 +702,7 @@ pub trait IndexMut<Index,Result> {
700
702
* ```
701
703
*/
702
704
#[ lang="deref" ]
703
- pub trait Deref < Result > {
705
+ pub trait Deref < Sized ? Result > {
704
706
/// The method called to dereference a value
705
707
fn deref < ' a > ( & ' a self ) -> & ' a Result ;
706
708
}
@@ -740,7 +742,7 @@ pub trait Deref<Result> {
740
742
* ```
741
743
*/
742
744
#[ lang="deref_mut" ]
743
- pub trait DerefMut < Result > : Deref < Result > {
745
+ pub trait DerefMut < Sized ? Result > : Deref < Result > {
744
746
/// The method called to mutably dereference a value
745
747
fn deref_mut < ' a > ( & ' a mut self ) -> & ' a mut Result ;
746
748
}
Original file line number Diff line number Diff line change @@ -199,6 +199,15 @@ fn check_item(cx: &mut Context, item: &Item) {
199
199
cx,
200
200
item. span ,
201
201
& * trait_ref) ;
202
+
203
+ let trait_def = ty:: lookup_trait_def ( cx. tcx , trait_ref. def_id ) ;
204
+ for ( ty, type_param_def) in trait_ref. substs . types
205
+ . iter ( )
206
+ . zip ( trait_def. generics
207
+ . types
208
+ . iter ( ) ) {
209
+ check_typaram_bounds ( cx, item. span , * ty, type_param_def) ;
210
+ }
202
211
}
203
212
}
204
213
}
Original file line number Diff line number Diff line change @@ -57,20 +57,18 @@ fn f9<Sized? X>(x1: Box<S<X>>, x2: Box<E<X>>) {
57
57
//~^ ERROR instantiating a type parameter with an incompatible type
58
58
}
59
59
60
- // I would like these to fail eventually.
61
- /*
62
60
// impl - bounded
63
61
trait T1 < Z : T > {
64
62
}
65
63
struct S3 < Sized ? Y > ;
66
- impl<Sized? X: T> T1<X> for S3<X> { //ERROR instantiating a type parameter with an incompatible type
64
+ impl < Sized ? X : T > T1 < X > for S3 < X > { //~ ERROR instantiating a type parameter with an incompatible
67
65
}
68
66
69
67
// impl - unbounded
70
68
trait T2 < Z > {
71
69
}
72
- impl<Sized? X> T2<X> for S3<X> { //ERROR instantiating a type parameter with an incompatible type `X
73
- */
70
+ impl < Sized ? X > T2 < X > for S3 < X > { //~ ERROR instantiating a type parameter with an incompatible type
71
+ }
74
72
75
73
// impl - struct
76
74
trait T3 < Sized ? Z > {
You can’t perform that action at this time.
0 commit comments