@@ -2,6 +2,7 @@ use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet};
2
2
use rustc_errors:: codes:: * ;
3
3
use rustc_errors:: struct_span_code_err;
4
4
use rustc_hir as hir;
5
+ use rustc_hir:: LangItem ;
5
6
use rustc_hir:: def:: { DefKind , Res } ;
6
7
use rustc_lint_defs:: builtin:: UNUSED_ASSOCIATED_TYPE_BOUNDS ;
7
8
use rustc_middle:: ty:: elaborate:: ClauseWithSupertraitSpan ;
@@ -69,7 +70,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
69
70
. into_iter ( )
70
71
. partition ( |( trait_ref, _) | !tcx. trait_is_auto ( trait_ref. def_id ( ) ) ) ;
71
72
72
- // We don't support empty trait objects.
73
+ // We don't support empty trait objects.
73
74
if regular_traits. is_empty ( ) && auto_traits. is_empty ( ) {
74
75
let guar =
75
76
self . report_trait_object_with_no_traits ( span, user_written_bounds. iter ( ) . copied ( ) ) ;
@@ -80,6 +81,13 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
80
81
let guar = self . report_trait_object_addition_traits ( & regular_traits) ;
81
82
return Ty :: new_error ( tcx, guar) ;
82
83
}
84
+ // We don't support `PointeeSized` principals
85
+ let pointee_sized_did = tcx. require_lang_item ( LangItem :: PointeeSized , span) ;
86
+ if regular_traits. iter ( ) . any ( |( pred, _) | pred. def_id ( ) == pointee_sized_did) {
87
+ let guar = self . report_pointee_sized_trait_object ( span) ;
88
+ return Ty :: new_error ( tcx, guar) ;
89
+ }
90
+
83
91
// Don't create a dyn trait if we have errors in the principal.
84
92
if let Err ( guar) = regular_traits. error_reported ( ) {
85
93
return Ty :: new_error ( tcx, guar) ;
0 commit comments