diff options
Diffstat (limited to 'compiler/rustc_ty_utils/src')
| -rw-r--r-- | compiler/rustc_ty_utils/src/abi.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_ty_utils/src/layout.rs | 6 | ||||
| -rw-r--r-- | compiler/rustc_ty_utils/src/needs_drop.rs | 11 | ||||
| -rw-r--r-- | compiler/rustc_ty_utils/src/opaque_types.rs | 14 | ||||
| -rw-r--r-- | compiler/rustc_ty_utils/src/representability.rs | 8 |
5 files changed, 23 insertions, 20 deletions
diff --git a/compiler/rustc_ty_utils/src/abi.rs b/compiler/rustc_ty_utils/src/abi.rs index 0542ef4ecf9..638c9a53d22 100644 --- a/compiler/rustc_ty_utils/src/abi.rs +++ b/compiler/rustc_ty_utils/src/abi.rs @@ -50,7 +50,7 @@ fn fn_sig_for_fn_abi<'tcx>( // `tests/ui/polymorphization/normalized_sig_types.rs`), and codegen not keeping // track of a polymorphization `ParamEnv` to allow normalizing later. // - // We normalize the `fn_sig` again after substituting at a later point. + // We normalize the `fn_sig` again after instantiating at a later point. let mut sig = match *ty.kind() { ty::FnDef(def_id, args) => tcx .fn_sig(def_id) @@ -163,7 +163,7 @@ fn fn_sig_for_fn_abi<'tcx>( // a separate def-id for these bodies. if let InstanceDef::CoroutineKindShim { target_kind, .. } = instance.def { // Grab the parent coroutine-closure. It has the same args for the purposes - // of substitution, so this will be okay to do. + // of instantiation, so this will be okay to do. let ty::CoroutineClosure(_, coroutine_closure_args) = *tcx .instantiate_and_normalize_erasing_regions( args, diff --git a/compiler/rustc_ty_utils/src/layout.rs b/compiler/rustc_ty_utils/src/layout.rs index f20ded355b1..96f8148bf72 100644 --- a/compiler/rustc_ty_utils/src/layout.rs +++ b/compiler/rustc_ty_utils/src/layout.rs @@ -741,7 +741,7 @@ fn coroutine_layout<'tcx>( ) -> Result<Layout<'tcx>, &'tcx LayoutError<'tcx>> { use SavedLocalEligibility::*; let tcx = cx.tcx; - let subst_field = |ty: Ty<'tcx>| EarlyBinder::bind(ty).instantiate(tcx, args); + let instantiate_field = |ty: Ty<'tcx>| EarlyBinder::bind(ty).instantiate(tcx, args); let Some(info) = tcx.coroutine_layout(def_id) else { return Err(error(cx, LayoutError::Unknown(ty))); @@ -763,7 +763,7 @@ fn coroutine_layout<'tcx>( let tag_layout = cx.tcx.mk_layout(LayoutS::scalar(cx, tag)); let promoted_layouts = ineligible_locals.iter().map(|local| { - let field_ty = subst_field(info.field_tys[local].ty); + let field_ty = instantiate_field(info.field_tys[local].ty); let uninit_ty = Ty::new_maybe_uninit(tcx, field_ty); Ok(cx.spanned_layout_of(uninit_ty, info.field_tys[local].source_info.span)?.layout) }); @@ -838,7 +838,7 @@ fn coroutine_layout<'tcx>( Ineligible(_) => false, }) .map(|local| { - let field_ty = subst_field(info.field_tys[*local].ty); + let field_ty = instantiate_field(info.field_tys[*local].ty); Ty::new_maybe_uninit(tcx, field_ty) }); diff --git a/compiler/rustc_ty_utils/src/needs_drop.rs b/compiler/rustc_ty_utils/src/needs_drop.rs index 7b3d2ab22cf..48339e6120a 100644 --- a/compiler/rustc_ty_utils/src/needs_drop.rs +++ b/compiler/rustc_ty_utils/src/needs_drop.rs @@ -264,9 +264,9 @@ fn drop_tys_helper<'tcx>( ) -> NeedsDropResult<Vec<Ty<'tcx>>> { iter.into_iter().try_fold(Vec::new(), |mut vec, subty| { match subty.kind() { - ty::Adt(adt_id, subst) => { + ty::Adt(adt_id, args) => { for subty in tcx.adt_drop_tys(adt_id.did())? { - vec.push(EarlyBinder::bind(subty).instantiate(tcx, subst)); + vec.push(EarlyBinder::bind(subty).instantiate(tcx, args)); } } _ => vec.push(subty), @@ -300,7 +300,10 @@ fn drop_tys_helper<'tcx>( } else { let field_tys = adt_def.all_fields().map(|field| { let r = tcx.type_of(field.did).instantiate(tcx, args); - debug!("drop_tys_helper: Subst into {:?} with {:?} getting {:?}", field, args, r); + debug!( + "drop_tys_helper: Instantiate into {:?} with {:?} getting {:?}", + field, args, r + ); r }); if only_significant { @@ -363,7 +366,7 @@ fn adt_drop_tys<'tcx>( .map(|components| tcx.mk_type_list(&components)) } // If `def_id` refers to a generic ADT, the queries above and below act as if they had been handed -// a `tcx.make_ty(def, identity_args)` and as such it is legal to substitute the generic parameters +// a `tcx.make_ty(def, identity_args)` and as such it is legal to instantiate the generic parameters // of the ADT into the outputted `ty`s. fn adt_significant_drop_tys( tcx: TyCtxt<'_>, diff --git a/compiler/rustc_ty_utils/src/opaque_types.rs b/compiler/rustc_ty_utils/src/opaque_types.rs index ef67317a601..329cf32cad5 100644 --- a/compiler/rustc_ty_utils/src/opaque_types.rs +++ b/compiler/rustc_ty_utils/src/opaque_types.rs @@ -155,7 +155,7 @@ impl<'tcx> OpaqueTypeCollector<'tcx> { // Collect opaque types nested within the associated type bounds of this opaque type. // We use identity args here, because we already know that the opaque type uses - // only generic parameters, and thus substituting would not give us more information. + // only generic parameters, and thus instantiating would not give us more information. for (pred, span) in self .tcx .explicit_item_bounds(alias_ty.def_id) @@ -211,7 +211,7 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for OpaqueTypeCollector<'tcx> { // in the same impl block. if let Some(parent_trait_ref) = self.parent_trait_ref() { // If the trait ref of the associated item and the impl differs, - // then we can't use the impl's identity substitutions below, so + // then we can't use the impl's identity args below, so // just skip. if alias_ty.trait_ref(self.tcx) == parent_trait_ref { let parent = self.parent().expect("we should have a parent here"); @@ -258,11 +258,11 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for OpaqueTypeCollector<'tcx> { for field in variant.fields.iter() { // Don't use the `ty::Adt` args, we either // * found the opaque in the args - // * will find the opaque in the unsubstituted fields - // The only other situation that can occur is that after substituting, + // * will find the opaque in the uninstantiated fields + // The only other situation that can occur is that after instantiating, // some projection resolves to an opaque that we would have otherwise - // not found. While we could substitute and walk those, that would mean we - // would have to walk all substitutions of an Adt, which can quickly + // not found. While we could instantiate and walk those, that would mean we + // would have to walk all generic parameters of an Adt, which can quickly // degenerate into looking at an exponential number of types. let ty = self.tcx.type_of(field.did).instantiate_identity(); self.visit_spanned(self.tcx.def_span(field.did), ty); @@ -306,7 +306,7 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for ImplTraitInAssocTypeCollector<'tcx> { .parent_trait_ref() .expect("impl trait in assoc type collector used on non-assoc item"); // If the trait ref of the associated item and the impl differs, - // then we can't use the impl's identity substitutions below, so + // then we can't use the impl's identity args below, so // just skip. if alias_ty.trait_ref(self.0.tcx) == parent_trait_ref { let parent = self.0.parent().expect("we should have a parent here"); diff --git a/compiler/rustc_ty_utils/src/representability.rs b/compiler/rustc_ty_utils/src/representability.rs index ade509123ac..bb546cee2dd 100644 --- a/compiler/rustc_ty_utils/src/representability.rs +++ b/compiler/rustc_ty_utils/src/representability.rs @@ -72,8 +72,8 @@ fn representability_adt_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Representab // At this point, we know that the item of the ADT type is representable; // but the type parameters may cause a cycle with an upstream type let params_in_repr = tcx.params_in_repr(adt.did()); - for (i, subst) in args.iter().enumerate() { - if let ty::GenericArgKind::Type(ty) = subst.unpack() { + for (i, arg) in args.iter().enumerate() { + if let ty::GenericArgKind::Type(ty) = arg.unpack() { if params_in_repr.contains(i as u32) { rtry!(representability_ty(tcx, ty)); } @@ -102,8 +102,8 @@ fn params_in_repr_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, params_in_repr: &mut match *ty.kind() { ty::Adt(adt, args) => { let inner_params_in_repr = tcx.params_in_repr(adt.did()); - for (i, subst) in args.iter().enumerate() { - if let ty::GenericArgKind::Type(ty) = subst.unpack() { + for (i, arg) in args.iter().enumerate() { + if let ty::GenericArgKind::Type(ty) = arg.unpack() { if inner_params_in_repr.contains(i as u32) { params_in_repr_ty(tcx, ty, params_in_repr); } |
