@@ -416,62 +416,6 @@ fn asyncness(tcx: TyCtxt<'_>, def_id: DefId) -> hir::IsAsync {
416
416
node. fn_sig ( ) . map_or ( hir:: IsAsync :: NotAsync , |sig| sig. header . asyncness )
417
417
}
418
418
419
- /// Don't call this directly: use ``tcx.conservative_is_privately_uninhabited`` instead.
420
- pub fn conservative_is_privately_uninhabited_raw < ' tcx > (
421
- tcx : TyCtxt < ' tcx > ,
422
- param_env_and : ty:: ParamEnvAnd < ' tcx , Ty < ' tcx > > ,
423
- ) -> bool {
424
- let ( param_env, ty) = param_env_and. into_parts ( ) ;
425
- match ty. kind ( ) {
426
- ty:: Never => {
427
- debug ! ( "ty::Never =>" ) ;
428
- true
429
- }
430
- ty:: Adt ( def, _) if def. is_union ( ) => {
431
- debug ! ( "ty::Adt(def, _) if def.is_union() =>" ) ;
432
- // For now, `union`s are never considered uninhabited.
433
- false
434
- }
435
- ty:: Adt ( def, substs) => {
436
- debug ! ( "ty::Adt(def, _) if def.is_not_union() =>" ) ;
437
- // Any ADT is uninhabited if either:
438
- // (a) It has no variants (i.e. an empty `enum`);
439
- // (b) Each of its variants (a single one in the case of a `struct`) has at least
440
- // one uninhabited field.
441
- def. variants ( ) . iter ( ) . all ( |var| {
442
- var. fields . iter ( ) . any ( |field| {
443
- let ty = tcx. bound_type_of ( field. did ) . subst ( tcx, substs) ;
444
- tcx. conservative_is_privately_uninhabited ( param_env. and ( ty) )
445
- } )
446
- } )
447
- }
448
- ty:: Tuple ( fields) => {
449
- debug ! ( "ty::Tuple(..) =>" ) ;
450
- fields. iter ( ) . any ( |ty| tcx. conservative_is_privately_uninhabited ( param_env. and ( ty) ) )
451
- }
452
- ty:: Array ( ty, len) => {
453
- debug ! ( "ty::Array(ty, len) =>" ) ;
454
- match len. try_eval_usize ( tcx, param_env) {
455
- Some ( 0 ) | None => false ,
456
- // If the array is definitely non-empty, it's uninhabited if
457
- // the type of its elements is uninhabited.
458
- Some ( 1 ..) => tcx. conservative_is_privately_uninhabited ( param_env. and ( * ty) ) ,
459
- }
460
- }
461
- ty:: Ref ( ..) => {
462
- debug ! ( "ty::Ref(..) =>" ) ;
463
- // References to uninitialised memory is valid for any type, including
464
- // uninhabited types, in unsafe code, so we treat all references as
465
- // inhabited.
466
- false
467
- }
468
- _ => {
469
- debug ! ( "_ =>" ) ;
470
- false
471
- }
472
- }
473
- }
474
-
475
419
pub fn provide ( providers : & mut ty:: query:: Providers ) {
476
420
* providers = ty:: query:: Providers {
477
421
asyncness,
@@ -481,7 +425,6 @@ pub fn provide(providers: &mut ty::query::Providers) {
481
425
instance_def_size_estimate,
482
426
issue33140_self_ty,
483
427
impl_defaultness,
484
- conservative_is_privately_uninhabited : conservative_is_privately_uninhabited_raw,
485
428
..* providers
486
429
} ;
487
430
}
0 commit comments