File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -232,7 +232,14 @@ where
232
232
233
233
pub fn verify_trait_impl ( & self , impl_id : ImplId < I > ) -> Result < ( ) , WfError < I > > {
234
234
let interner = self . db . interner ( ) ;
235
+
235
236
let impl_datum = self . db . impl_datum ( impl_id) ;
237
+ let trait_id = impl_datum. trait_id ( ) ;
238
+
239
+ // You can't manually implement Sized
240
+ if let Some ( WellKnownTrait :: SizedTrait ) = self . db . trait_datum ( trait_id) . well_known {
241
+ return Err ( WfError :: IllFormedTraitImpl ( trait_id) ) ;
242
+ }
236
243
237
244
let impl_goal = Goal :: all (
238
245
interner,
@@ -258,8 +265,7 @@ where
258
265
if is_legal {
259
266
Ok ( ( ) )
260
267
} else {
261
- let trait_ref = & impl_datum. binders . value . trait_ref ;
262
- Err ( WfError :: IllFormedTraitImpl ( trait_ref. trait_id ) )
268
+ Err ( WfError :: IllFormedTraitImpl ( trait_id) )
263
269
}
264
270
}
265
271
}
Original file line number Diff line number Diff line change @@ -711,4 +711,17 @@ fn struct_sized_constraints() {
711
711
}
712
712
}
713
713
}
714
+
715
+ lowering_error ! {
716
+ program {
717
+ #[ lang( sized) ]
718
+ trait Sized { }
719
+
720
+ struct Foo { }
721
+
722
+ impl Sized for Foo { }
723
+ } error_msg {
724
+ "trait impl for `Sized` does not meet well-formedness requirements"
725
+ }
726
+ }
714
727
}
You can’t perform that action at this time.
0 commit comments