diff options
Diffstat (limited to 'compiler/rustc_ty_utils')
| -rw-r--r-- | compiler/rustc_ty_utils/src/needs_drop.rs | 23 | ||||
| -rw-r--r-- | compiler/rustc_ty_utils/src/representability.rs | 14 | ||||
| -rw-r--r-- | compiler/rustc_ty_utils/src/ty.rs | 8 |
3 files changed, 24 insertions, 21 deletions
diff --git a/compiler/rustc_ty_utils/src/needs_drop.rs b/compiler/rustc_ty_utils/src/needs_drop.rs index 322511be817..6195c712c58 100644 --- a/compiler/rustc_ty_utils/src/needs_drop.rs +++ b/compiler/rustc_ty_utils/src/needs_drop.rs @@ -16,7 +16,7 @@ fn needs_drop_raw<'tcx>(tcx: TyCtxt<'tcx>, query: ty::ParamEnvAnd<'tcx, Ty<'tcx> // parameter without a `Copy` bound, then we conservatively return that it // needs drop. let adt_has_dtor = - |adt_def: &ty::AdtDef| adt_def.destructor(tcx).map(|_| DtorType::Significant); + |adt_def: ty::AdtDef<'tcx>| adt_def.destructor(tcx).map(|_| DtorType::Significant); let res = drop_tys_helper(tcx, query.value, query.param_env, adt_has_dtor, false).next().is_some(); @@ -78,7 +78,7 @@ impl<'tcx, F> NeedsDropTypes<'tcx, F> { impl<'tcx, F, I> Iterator for NeedsDropTypes<'tcx, F> where - F: Fn(&ty::AdtDef, SubstsRef<'tcx>) -> NeedsDropResult<I>, + F: Fn(ty::AdtDef<'tcx>, SubstsRef<'tcx>) -> NeedsDropResult<I>, I: Iterator<Item = Ty<'tcx>>, { type Item = NeedsDropResult<Ty<'tcx>>; @@ -193,7 +193,7 @@ fn drop_tys_helper<'tcx>( tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, param_env: rustc_middle::ty::ParamEnv<'tcx>, - adt_has_dtor: impl Fn(&ty::AdtDef) -> Option<DtorType>, + adt_has_dtor: impl Fn(ty::AdtDef<'tcx>) -> Option<DtorType>, only_significant: bool, ) -> impl Iterator<Item = NeedsDropResult<Ty<'tcx>>> { fn with_query_cache<'tcx>( @@ -203,7 +203,7 @@ fn drop_tys_helper<'tcx>( iter.into_iter().try_fold(Vec::new(), |mut vec, subty| { match subty.kind() { ty::Adt(adt_id, subst) => { - for subty in tcx.adt_drop_tys(adt_id.did)? { + for subty in tcx.adt_drop_tys(adt_id.did())? { vec.push(subty.subst(tcx, subst)); } } @@ -213,7 +213,7 @@ fn drop_tys_helper<'tcx>( }) } - let adt_components = move |adt_def: &ty::AdtDef, substs: SubstsRef<'tcx>| { + let adt_components = move |adt_def: ty::AdtDef<'tcx>, substs: SubstsRef<'tcx>| { if adt_def.is_manually_drop() { debug!("drop_tys_helper: `{:?}` is manually drop", adt_def); Ok(Vec::new()) @@ -260,9 +260,9 @@ fn drop_tys_helper<'tcx>( fn adt_consider_insignificant_dtor<'tcx>( tcx: TyCtxt<'tcx>, -) -> impl Fn(&ty::AdtDef) -> Option<DtorType> + 'tcx { - move |adt_def: &ty::AdtDef| { - let is_marked_insig = tcx.has_attr(adt_def.did, sym::rustc_insignificant_dtor); +) -> impl Fn(ty::AdtDef<'tcx>) -> Option<DtorType> + 'tcx { + move |adt_def: ty::AdtDef<'tcx>| { + let is_marked_insig = tcx.has_attr(adt_def.did(), sym::rustc_insignificant_dtor); if is_marked_insig { // In some cases like `std::collections::HashMap` where the struct is a wrapper around // a type that is a Drop type, and the wrapped type (eg: `hashbrown::HashMap`) lies @@ -281,11 +281,14 @@ fn adt_consider_insignificant_dtor<'tcx>( } } -fn adt_drop_tys(tcx: TyCtxt<'_>, def_id: DefId) -> Result<&ty::List<Ty<'_>>, AlwaysRequiresDrop> { +fn adt_drop_tys<'tcx>( + tcx: TyCtxt<'tcx>, + def_id: DefId, +) -> Result<&ty::List<Ty<'tcx>>, AlwaysRequiresDrop> { // This is for the "adt_drop_tys" query, that considers all `Drop` impls, therefore all dtors are // significant. let adt_has_dtor = - |adt_def: &ty::AdtDef| adt_def.destructor(tcx).map(|_| DtorType::Significant); + |adt_def: ty::AdtDef<'tcx>| adt_def.destructor(tcx).map(|_| DtorType::Significant); // `tcx.type_of(def_id)` identical to `tcx.make_adt(def, identity_substs)` drop_tys_helper(tcx, tcx.type_of(def_id), tcx.param_env(def_id), adt_has_dtor, false) .collect::<Result<Vec<_>, _>>() diff --git a/compiler/rustc_ty_utils/src/representability.rs b/compiler/rustc_ty_utils/src/representability.rs index 11a57688580..b8f3efe6462 100644 --- a/compiler/rustc_ty_utils/src/representability.rs +++ b/compiler/rustc_ty_utils/src/representability.rs @@ -33,7 +33,7 @@ pub fn ty_is_representable<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, sp: Span) -> R // cleared when recursing to check A, but `shadow_seen` won't, so that we // can catch cases of mutual recursion where A also contains B). let mut seen: Vec<Ty<'_>> = Vec::new(); - let mut shadow_seen: Vec<&'tcx ty::AdtDef> = Vec::new(); + let mut shadow_seen: Vec<ty::AdtDef<'tcx>> = Vec::new(); let mut representable_cache = FxHashMap::default(); let mut force_result = false; let r = is_type_structurally_recursive( @@ -63,7 +63,7 @@ fn are_inner_types_recursive<'tcx>( tcx: TyCtxt<'tcx>, sp: Span, seen: &mut Vec<Ty<'tcx>>, - shadow_seen: &mut Vec<&'tcx ty::AdtDef>, + shadow_seen: &mut Vec<ty::AdtDef<'tcx>>, representable_cache: &mut FxHashMap<Ty<'tcx>, Representability>, ty: Ty<'tcx>, force_result: &mut bool, @@ -150,7 +150,7 @@ fn are_inner_types_recursive<'tcx>( .take(shadow_seen.len() - 1) .any(|seen_def| seen_def == def) { - let adt_def_id = def.did; + let adt_def_id = def.did(); let raw_adt_ty = tcx.type_of(adt_def_id); debug!("are_inner_types_recursive: checking nested type: {:?}", raw_adt_ty); @@ -236,7 +236,7 @@ fn are_inner_types_recursive<'tcx>( } } -fn same_adt<'tcx>(ty: Ty<'tcx>, def: &'tcx ty::AdtDef) -> bool { +fn same_adt<'tcx>(ty: Ty<'tcx>, def: ty::AdtDef<'tcx>) -> bool { match *ty.kind() { ty::Adt(ty_def, _) => ty_def == def, _ => false, @@ -249,7 +249,7 @@ fn is_type_structurally_recursive<'tcx>( tcx: TyCtxt<'tcx>, sp: Span, seen: &mut Vec<Ty<'tcx>>, - shadow_seen: &mut Vec<&'tcx ty::AdtDef>, + shadow_seen: &mut Vec<ty::AdtDef<'tcx>>, representable_cache: &mut FxHashMap<Ty<'tcx>, Representability>, ty: Ty<'tcx>, force_result: &mut bool, @@ -281,7 +281,7 @@ fn is_type_structurally_recursive_inner<'tcx>( tcx: TyCtxt<'tcx>, sp: Span, seen: &mut Vec<Ty<'tcx>>, - shadow_seen: &mut Vec<&'tcx ty::AdtDef>, + shadow_seen: &mut Vec<ty::AdtDef<'tcx>>, representable_cache: &mut FxHashMap<Ty<'tcx>, Representability>, ty: Ty<'tcx>, force_result: &mut bool, @@ -332,7 +332,7 @@ fn is_type_structurally_recursive_inner<'tcx>( // For structs and enums, track all previously seen types by pushing them // onto the 'seen' stack. seen.push(ty); - shadow_seen.push(def); + shadow_seen.push(*def); let out = are_inner_types_recursive( tcx, sp, diff --git a/compiler/rustc_ty_utils/src/ty.rs b/compiler/rustc_ty_utils/src/ty.rs index e6ce3447548..44ef0a09a65 100644 --- a/compiler/rustc_ty_utils/src/ty.rs +++ b/compiler/rustc_ty_utils/src/ty.rs @@ -8,7 +8,7 @@ use rustc_trait_selection::traits; fn sized_constraint_for_ty<'tcx>( tcx: TyCtxt<'tcx>, - adtdef: &ty::AdtDef, + adtdef: ty::AdtDef<'tcx>, ty: Ty<'tcx>, ) -> Vec<Ty<'tcx>> { use ty::TyKind::*; @@ -56,7 +56,7 @@ fn sized_constraint_for_ty<'tcx>( }) .without_const() .to_predicate(tcx); - let predicates = tcx.predicates_of(adtdef.did).predicates; + let predicates = tcx.predicates_of(adtdef.did()).predicates; if predicates.iter().any(|(p, _)| *p == sized_predicate) { vec![] } else { vec![ty] } } @@ -99,7 +99,7 @@ fn adt_sized_constraint(tcx: TyCtxt<'_>, def_id: DefId) -> ty::AdtSizedConstrain let def = tcx.adt_def(def_id); let result = tcx.mk_type_list( - def.variants + def.variants() .iter() .flat_map(|v| v.fields.last()) .flat_map(|f| sized_constraint_for_ty(tcx, def, tcx.type_of(f.did))), @@ -454,7 +454,7 @@ pub fn conservative_is_privately_uninhabited_raw<'tcx>( // (a) It has no variants (i.e. an empty `enum`); // (b) Each of its variants (a single one in the case of a `struct`) has at least // one uninhabited field. - def.variants.iter().all(|var| { + def.variants().iter().all(|var| { var.fields.iter().any(|field| { let ty = tcx.type_of(field.did).subst(tcx, substs); tcx.conservative_is_privately_uninhabited(param_env.and(ty)) |
