Skip to content

Commit 1311bb5

Browse files
Simplify an ObjectData field
1 parent 9e68b6f commit 1311bb5

File tree

4 files changed

+14
-10
lines changed

4 files changed

+14
-10
lines changed

compiler/rustc_middle/src/traits/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ pub enum ImplSource<'tcx, N> {
653653
Param(Vec<N>, ty::BoundConstness),
654654

655655
/// Virtual calls through an object.
656-
Object(ImplSourceObjectData<'tcx, N>),
656+
Object(ImplSourceObjectData<N>),
657657

658658
/// Successful resolution for a builtin trait.
659659
Builtin(Vec<N>),
@@ -735,7 +735,7 @@ impl<'tcx, N> ImplSource<'tcx, N> {
735735
ImplSource::Param(n, ct) => ImplSource::Param(n.into_iter().map(f).collect(), ct),
736736
ImplSource::Builtin(n) => ImplSource::Builtin(n.into_iter().map(f).collect()),
737737
ImplSource::Object(o) => ImplSource::Object(ImplSourceObjectData {
738-
upcast_trait_ref: o.upcast_trait_ref,
738+
upcast_trait_def_id: o.upcast_trait_def_id,
739739
vtable_base: o.vtable_base,
740740
nested: o.nested.into_iter().map(f).collect(),
741741
}),
@@ -835,9 +835,9 @@ pub struct ImplSourceTraitUpcastingData<N> {
835835

836836
#[derive(PartialEq, Eq, Clone, TyEncodable, TyDecodable, HashStable, Lift)]
837837
#[derive(TypeFoldable, TypeVisitable)]
838-
pub struct ImplSourceObjectData<'tcx, N> {
838+
pub struct ImplSourceObjectData<N> {
839839
/// `Foo` upcast to the obligation trait. This will be some supertrait of `Foo`.
840-
pub upcast_trait_ref: ty::PolyTraitRef<'tcx>,
840+
pub upcast_trait_def_id: DefId,
841841

842842
/// The vtable is formed by concatenating together the method lists of
843843
/// the base object trait and all supertraits, pointers to supertrait vtable will

compiler/rustc_middle/src/traits/structural_impls.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,12 @@ impl<N: fmt::Debug> fmt::Debug for traits::ImplSourceTraitUpcastingData<N> {
8282
}
8383
}
8484

85-
impl<'tcx, N: fmt::Debug> fmt::Debug for traits::ImplSourceObjectData<'tcx, N> {
85+
impl<N: fmt::Debug> fmt::Debug for traits::ImplSourceObjectData<N> {
8686
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
8787
write!(
8888
f,
8989
"ImplSourceObjectData(upcast={:?}, vtable_base={}, nested={:?})",
90-
self.upcast_trait_ref, self.vtable_base, self.nested
90+
self.upcast_trait_def_id, self.vtable_base, self.nested
9191
)
9292
}
9393
}

compiler/rustc_trait_selection/src/traits/select/confirmation.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
486486
&mut self,
487487
obligation: &TraitObligation<'tcx>,
488488
index: usize,
489-
) -> Result<ImplSourceObjectData<'tcx, PredicateObligation<'tcx>>, SelectionError<'tcx>> {
489+
) -> Result<ImplSourceObjectData<PredicateObligation<'tcx>>, SelectionError<'tcx>> {
490490
let tcx = self.tcx();
491491
debug!(?obligation, ?index, "confirm_object_candidate");
492492

@@ -653,7 +653,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
653653
(unnormalized_upcast_trait_ref, ty::Binder::dummy(object_trait_ref)),
654654
);
655655

656-
Ok(ImplSourceObjectData { upcast_trait_ref, vtable_base, nested })
656+
Ok(ImplSourceObjectData {
657+
upcast_trait_def_id: upcast_trait_ref.def_id(),
658+
vtable_base,
659+
nested,
660+
})
657661
}
658662

659663
fn confirm_fn_pointer_candidate(

compiler/rustc_trait_selection/src/traits/util.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -243,12 +243,12 @@ pub fn upcast_choices<'tcx>(
243243
/// `object.upcast_trait_ref`) within the vtable for `object`.
244244
pub fn get_vtable_index_of_object_method<'tcx, N>(
245245
tcx: TyCtxt<'tcx>,
246-
object: &super::ImplSourceObjectData<'tcx, N>,
246+
object: &super::ImplSourceObjectData<N>,
247247
method_def_id: DefId,
248248
) -> Option<usize> {
249249
// Count number of methods preceding the one we are selecting and
250250
// add them to the total offset.
251-
tcx.own_existential_vtable_entries(object.upcast_trait_ref.def_id())
251+
tcx.own_existential_vtable_entries(object.upcast_trait_def_id)
252252
.iter()
253253
.copied()
254254
.position(|def_id| def_id == method_def_id)

0 commit comments

Comments
 (0)