Skip to content

Commit 91aa996

Browse files
committed
Do not store ty
1 parent 91e99a3 commit 91aa996

File tree

5 files changed

+16
-28
lines changed

5 files changed

+16
-28
lines changed

src/librustc/traits/mod.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ pub enum Vtable<'tcx, N> {
301301
VtableObject(VtableObjectData<'tcx, N>),
302302

303303
/// Successful resolution for a builtin trait.
304-
VtableBuiltin(VtableBuiltinData<'tcx, N>),
304+
VtableBuiltin(VtableBuiltinData<N>),
305305

306306
/// Vtable automatically generated for a closure. The def ID is the ID
307307
/// of the closure expression. This is a `VtableImpl` in spirit, but the
@@ -345,9 +345,7 @@ pub struct VtableDefaultImplData<N> {
345345
}
346346

347347
#[derive(Clone)]
348-
pub struct VtableBuiltinData<'tcx, N> {
349-
/// `ty` can be used for generating shim for builtin implementations like `Clone::clone`.
350-
pub ty: ty::Ty<'tcx>,
348+
pub struct VtableBuiltinData<N> {
351349
pub nested: Vec<N>
352350
}
353351

@@ -771,7 +769,6 @@ impl<'tcx, N> Vtable<'tcx, N> {
771769
}),
772770
VtableParam(n) => VtableParam(n.into_iter().map(f).collect()),
773771
VtableBuiltin(i) => VtableBuiltin(VtableBuiltinData {
774-
ty: i.ty,
775772
nested: i.nested.into_iter().map(f).collect(),
776773
}),
777774
VtableObject(o) => VtableObject(VtableObjectData {

src/librustc/traits/select.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2265,7 +2265,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
22652265
fn confirm_builtin_candidate(&mut self,
22662266
obligation: &TraitObligation<'tcx>,
22672267
has_nested: bool)
2268-
-> VtableBuiltinData<'tcx, PredicateObligation<'tcx>>
2268+
-> VtableBuiltinData<PredicateObligation<'tcx>>
22692269
{
22702270
debug!("confirm_builtin_candidate({:?}, {:?})",
22712271
obligation, has_nested);
@@ -2303,8 +2303,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
23032303
debug!("confirm_builtin_candidate: obligations={:?}",
23042304
obligations);
23052305

2306-
let self_ty = self.infcx.shallow_resolve(obligation.predicate.skip_binder().self_ty());
2307-
VtableBuiltinData { ty: self_ty, nested: obligations }
2306+
VtableBuiltinData { nested: obligations }
23082307
}
23092308

23102309
/// This handles the case where a `impl Foo for ..` impl is being used.
@@ -2611,7 +2610,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
26112610

26122611
fn confirm_builtin_unsize_candidate(&mut self,
26132612
obligation: &TraitObligation<'tcx>,)
2614-
-> Result<VtableBuiltinData<'tcx, PredicateObligation<'tcx>>, SelectionError<'tcx>>
2613+
-> Result<VtableBuiltinData<PredicateObligation<'tcx>>, SelectionError<'tcx>>
26152614
{
26162615
let tcx = self.tcx();
26172616

@@ -2814,7 +2813,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
28142813
_ => bug!()
28152814
};
28162815

2817-
Ok(VtableBuiltinData { ty: source, nested: nested })
2816+
Ok(VtableBuiltinData { nested: nested })
28182817
}
28192818

28202819
///////////////////////////////////////////////////////////////////////////

src/librustc/traits/structural_impls.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ impl<'tcx, N: fmt::Debug> fmt::Debug for traits::VtableClosureData<'tcx, N> {
8686
}
8787
}
8888

89-
impl<'tcx, N: fmt::Debug> fmt::Debug for traits::VtableBuiltinData<'tcx, N> {
89+
impl<'tcx, N: fmt::Debug> fmt::Debug for traits::VtableBuiltinData<N> {
9090
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
91-
write!(f, "VtableBuiltin(ty={:?}, nested={:?})", self.ty, self.nested)
91+
write!(f, "VtableBuiltin(nested={:?})", self.nested)
9292
}
9393
}
9494

@@ -300,14 +300,7 @@ impl<'a, 'tcx> Lift<'tcx> for traits::Vtable<'a, ()> {
300300
})
301301
}
302302
traits::VtableParam(n) => Some(traits::VtableParam(n)),
303-
traits::VtableBuiltin(traits::VtableBuiltinData { ty, nested }) => {
304-
tcx.lift(&ty).map(|ty| {
305-
traits::VtableBuiltin(traits::VtableBuiltinData {
306-
ty,
307-
nested,
308-
})
309-
})
310-
}
303+
traits::VtableBuiltin(n) => Some(traits::VtableBuiltin(n)),
311304
traits::VtableObject(traits::VtableObjectData {
312305
upcast_trait_ref,
313306
vtable_base,
@@ -385,10 +378,9 @@ impl<'tcx, N: TypeFoldable<'tcx>> TypeFoldable<'tcx> for traits::VtableDefaultIm
385378
}
386379
}
387380

388-
impl<'tcx, N: TypeFoldable<'tcx>> TypeFoldable<'tcx> for traits::VtableBuiltinData<'tcx, N> {
381+
impl<'tcx, N: TypeFoldable<'tcx>> TypeFoldable<'tcx> for traits::VtableBuiltinData<N> {
389382
fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self {
390383
traits::VtableBuiltinData {
391-
ty: self.ty.fold_with(folder),
392384
nested: self.nested.fold_with(folder),
393385
}
394386
}

src/librustc_mir/shim.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ impl<'a, 'tcx> DropElaborator<'a, 'tcx> for DropShimElaborator<'a, 'tcx> {
275275
/// Build a `Clone::clone` shim for `recvr_ty`. Here, `def_id` is `Clone::clone`.
276276
fn build_clone_shim<'a, 'tcx>(tcx: ty::TyCtxt<'a, 'tcx, 'tcx>,
277277
def_id: DefId,
278-
recvr_ty: ty::Ty<'tcx>)
278+
rcvr_ty: ty::Ty<'tcx>)
279279
-> Mir<'tcx>
280280
{
281281
let sig = tcx.fn_sig(def_id);
@@ -348,7 +348,7 @@ fn build_clone_shim<'a, 'tcx>(tcx: ty::TyCtxt<'a, 'tcx, 'tcx>,
348348
loc
349349
};
350350

351-
match recvr_ty.sty {
351+
match rcvr_ty.sty {
352352
ty::TyArray(ty, len) => {
353353
let mut returns = Vec::new();
354354
for i in 0..len {
@@ -374,7 +374,7 @@ fn build_clone_shim<'a, 'tcx>(tcx: ty::TyCtxt<'a, 'tcx, 'tcx>,
374374
Lvalue::Local(RETURN_POINTER),
375375
Rvalue::Aggregate(
376376
box AggregateKind::Array(ty),
377-
returns.into_iter().map(|loc| Operand::Consume(loc)).collect()
377+
returns.into_iter().map(Operand::Consume).collect()
378378
)
379379
)
380380
};
@@ -396,7 +396,7 @@ fn build_clone_shim<'a, 'tcx>(tcx: ty::TyCtxt<'a, 'tcx, 'tcx>,
396396
Lvalue::Local(RETURN_POINTER),
397397
Rvalue::Aggregate(
398398
box AggregateKind::Tuple,
399-
returns.into_iter().map(|loc| Operand::Consume(loc)).collect()
399+
returns.into_iter().map(Operand::Consume).collect()
400400
)
401401
)
402402
};

src/librustc_trans/monomorphize.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,9 @@ fn resolve_associated_item<'a, 'tcx>(
143143
substs: rcvr_substs
144144
}
145145
}
146-
traits::VtableBuiltin(ref data) => {
146+
traits::VtableBuiltin(..) => {
147147
Instance {
148-
def: ty::InstanceDef::BuiltinShim(def_id, data.ty),
148+
def: ty::InstanceDef::BuiltinShim(def_id, trait_ref.self_ty()),
149149
substs: rcvr_substs
150150
}
151151
}

0 commit comments

Comments
 (0)