@@ -2,6 +2,7 @@ use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet};
22use rustc_errors:: codes:: * ;
33use rustc_errors:: struct_span_code_err;
44use rustc_hir as hir;
5+ use rustc_hir:: LangItem ;
56use rustc_hir:: def:: { DefKind , Res } ;
67use rustc_lint_defs:: builtin:: UNUSED_ASSOCIATED_TYPE_BOUNDS ;
78use rustc_middle:: ty:: elaborate:: ClauseWithSupertraitSpan ;
@@ -69,7 +70,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
6970 . into_iter ( )
7071 . partition ( |( trait_ref, _) | !tcx. trait_is_auto ( trait_ref. def_id ( ) ) ) ;
7172
72- // We don't support empty trait objects.
73+ // We don't support empty trait objects.
7374 if regular_traits. is_empty ( ) && auto_traits. is_empty ( ) {
7475 let guar =
7576 self . report_trait_object_with_no_traits ( span, user_written_bounds. iter ( ) . copied ( ) ) ;
@@ -80,6 +81,13 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
8081 let guar = self . report_trait_object_addition_traits ( & regular_traits) ;
8182 return Ty :: new_error ( tcx, guar) ;
8283 }
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+
8391 // Don't create a dyn trait if we have errors in the principal.
8492 if let Err ( guar) = regular_traits. error_reported ( ) {
8593 return Ty :: new_error ( tcx, guar) ;
0 commit comments