@@ -31,7 +31,6 @@ use rustc_span::{self, Span};
31
31
use rustc_target:: spec:: abi:: Abi ;
32
32
use rustc_trait_selection:: traits:: error_reporting:: TypeErrCtxtExt as _;
33
33
use rustc_trait_selection:: traits:: { self , ObligationCtxt } ;
34
- use rustc_ty_utils:: representability:: { self , Representability } ;
35
34
36
35
use std:: ops:: ControlFlow ;
37
36
@@ -381,7 +380,7 @@ fn check_struct(tcx: TyCtxt<'_>, def_id: LocalDefId) {
381
380
let def = tcx. adt_def ( def_id) ;
382
381
let span = tcx. def_span ( def_id) ;
383
382
def. destructor ( tcx) ; // force the destructor to be evaluated
384
- check_representable ( tcx , span , def_id) ;
383
+ let _ = tcx . representability ( def_id) ;
385
384
386
385
if def. repr ( ) . simd ( ) {
387
386
check_simd ( tcx, span, def_id) ;
@@ -395,7 +394,7 @@ fn check_union(tcx: TyCtxt<'_>, def_id: LocalDefId) {
395
394
let def = tcx. adt_def ( def_id) ;
396
395
let span = tcx. def_span ( def_id) ;
397
396
def. destructor ( tcx) ; // force the destructor to be evaluated
398
- check_representable ( tcx , span , def_id) ;
397
+ let _ = tcx . representability ( def_id) ;
399
398
check_transparent ( tcx, span, def) ;
400
399
check_union_fields ( tcx, span, def_id) ;
401
400
check_packed ( tcx, span, def) ;
@@ -1151,27 +1150,6 @@ fn check_impl_items_against_trait<'tcx>(
1151
1150
}
1152
1151
}
1153
1152
1154
- /// Checks whether a type can be represented in memory. In particular, it
1155
- /// identifies types that contain themselves without indirection through a
1156
- /// pointer, which would mean their size is unbounded.
1157
- pub ( super ) fn check_representable ( tcx : TyCtxt < ' _ > , sp : Span , item_def_id : LocalDefId ) -> bool {
1158
- let rty = tcx. type_of ( item_def_id) ;
1159
-
1160
- // Check that it is possible to represent this type. This call identifies
1161
- // (1) types that contain themselves and (2) types that contain a different
1162
- // recursive type. It is only necessary to throw an error on those that
1163
- // contain themselves. For case 2, there must be an inner type that will be
1164
- // caught by case 1.
1165
- match representability:: ty_is_representable ( tcx, rty, sp, None ) {
1166
- Representability :: SelfRecursive ( spans) => {
1167
- recursive_type_with_infinite_size_error ( tcx, item_def_id. to_def_id ( ) , spans) ;
1168
- return false ;
1169
- }
1170
- Representability :: Representable | Representability :: ContainsRecursive => ( ) ,
1171
- }
1172
- true
1173
- }
1174
-
1175
1153
pub fn check_simd ( tcx : TyCtxt < ' _ > , sp : Span , def_id : LocalDefId ) {
1176
1154
let t = tcx. type_of ( def_id) ;
1177
1155
if let ty:: Adt ( def, substs) = t. kind ( )
@@ -1509,7 +1487,7 @@ fn check_enum<'tcx>(tcx: TyCtxt<'tcx>, vs: &'tcx [hir::Variant<'tcx>], def_id: L
1509
1487
1510
1488
detect_discriminant_duplicate ( tcx, def. discriminants ( tcx) . collect ( ) , vs, sp) ;
1511
1489
1512
- check_representable ( tcx , sp , def_id) ;
1490
+ let _ = tcx . representability ( def_id) ;
1513
1491
check_transparent ( tcx, sp, def) ;
1514
1492
}
1515
1493
0 commit comments