Skip to content

Commit ccabeca

Browse files
committed
purge Kind slice with SubstsRef
1 parent 7f1eb7f commit ccabeca

29 files changed

+158
-107
lines changed

src/librustc/ich/impls_ty.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,19 @@ impl<'a, 'gcx, T> ToStableHashKey<StableHashingContext<'a>> for &'gcx ty::List<T
5454
}
5555
}
5656

57+
impl<'a, 'tcx> ToStableHashKey<StableHashingContext<'a>> for ty::subst::SubstsRef<'tcx>
58+
{
59+
type KeyType = <&'tcx ty::List<ty::subst::Kind<'tcx>> as ToStableHashKey<StableHashingContext<'a>>>::KeyType;
60+
61+
#[inline]
62+
fn to_stable_hash_key(&self, hcx: &StableHashingContext<'a>) -> Self::KeyType {
63+
let mut hasher = StableHasher::new();
64+
let mut hcx: StableHashingContext<'a> = hcx.clone();
65+
self.hash_stable(&mut hcx, &mut hasher);
66+
hasher.finish()
67+
}
68+
}
69+
5770
impl<'a, 'gcx> HashStable<StableHashingContext<'a>> for ty::subst::Kind<'gcx> {
5871
fn hash_stable<W: StableHasherResult>(&self,
5972
hcx: &mut StableHashingContext<'a>,

src/librustc/infer/error_reporting/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
535535
if !(did1.is_local() || did2.is_local()) && did1.krate != did2.krate {
536536
let abs_path = |def_id| {
537537
AbsolutePathPrinter { tcx: self.tcx }
538-
.print_def_path(def_id, &[])
538+
.print_def_path(def_id, SubstsRef::empty())
539539
};
540540

541541
// We compare strings because DefPath can be different
@@ -824,7 +824,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
824824
if !has_default {
825825
break;
826826
}
827-
if self.tcx.type_of(def_id).subst(self.tcx, &substs) != actual {
827+
if self.tcx.type_of(def_id).subst(self.tcx, substs) != actual {
828828
break;
829829
}
830830
num_supplied_defaults += 1;

src/librustc/infer/outlives/verify.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ impl<'cx, 'gcx, 'tcx> VerifyBoundCx<'cx, 'gcx, 'tcx> {
248248
debug!("projection_bounds(projection_ty={:?})", projection_ty);
249249
let tcx = self.tcx;
250250
self.region_bounds_declared_on_associated_item(projection_ty.item_def_id)
251-
.map(move |r| r.subst(tcx, &projection_ty.substs))
251+
.map(move |r| r.subst(tcx, projection_ty.substs))
252252
}
253253

254254
/// Given the `DefId` of an associated item, returns any region

src/librustc/lint/context.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use crate::lint::levels::{LintLevelSets, LintLevelsBuilder};
2525
use crate::middle::privacy::AccessLevels;
2626
use crate::rustc_serialize::{Decoder, Decodable, Encoder, Encodable};
2727
use crate::session::{config, early_error, Session};
28-
use crate::ty::{self, print::Printer, subst::Kind, TyCtxt, Ty};
28+
use crate::ty::{self, print::Printer, subst::{Kind, SubstsRef}, TyCtxt, Ty};
2929
use crate::ty::layout::{LayoutError, LayoutOf, TyLayout};
3030
use crate::util::nodemap::FxHashMap;
3131
use crate::util::common::time;
@@ -822,7 +822,7 @@ impl<'a, 'tcx> LateContext<'a, 'tcx> {
822822
) -> Result<Self::Path, Self::Error> {
823823
if trait_ref.is_none() {
824824
if let ty::Adt(def, substs) = self_ty.sty {
825-
return self.print_def_path(def.did, &substs);
825+
return self.print_def_path(def.did, substs);
826826
}
827827
}
828828

@@ -880,7 +880,7 @@ impl<'a, 'tcx> LateContext<'a, 'tcx> {
880880
}
881881

882882
AbsolutePathPrinter { tcx: self.tcx }
883-
.print_def_path(def_id, &[])
883+
.print_def_path(def_id, SubstsRef::empty())
884884
.unwrap()
885885
}
886886
}

src/librustc/mir/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2320,7 +2320,7 @@ impl<'tcx> Operand<'tcx> {
23202320
substs: SubstsRef<'tcx>,
23212321
span: Span,
23222322
) -> Self {
2323-
let ty = tcx.type_of(def_id).subst(tcx, &substs);
2323+
let ty = tcx.type_of(def_id).subst(tcx, substs);
23242324
Operand::Constant(box Constant {
23252325
span,
23262326
ty,
@@ -2539,7 +2539,7 @@ impl<'tcx> Debug for Rvalue<'tcx> {
25392539
ty::tls::with(|tcx| {
25402540
let substs = tcx.lift(&substs).expect("could not lift for printing");
25412541
FmtPrinter::new(tcx, f, Namespace::ValueNS)
2542-
.print_def_path(variant_def.def_id, &substs)?;
2542+
.print_def_path(variant_def.def_id, substs)?;
25432543
Ok(())
25442544
})?;
25452545

src/librustc/mir/tcx.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ impl<'tcx> Rvalue<'tcx> {
195195
tcx.mk_tup(ops.iter().map(|op| op.ty(local_decls, tcx)))
196196
}
197197
AggregateKind::Adt(def, _, substs, _, _) => {
198-
tcx.type_of(def.did).subst(tcx, &substs)
198+
tcx.type_of(def.did).subst(tcx, substs)
199199
}
200200
AggregateKind::Closure(did, substs) => {
201201
tcx.mk_closure(did, substs)

src/librustc/traits/auto_trait.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
8989

9090
let trait_ref = ty::TraitRef {
9191
def_id: trait_did,
92-
substs: tcx.mk_substs_trait(ty, &[]),
92+
substs: tcx.mk_substs_trait(ty, SubstsRef::empty()),
9393
};
9494

9595
let trait_pred = ty::Binder::bind(trait_ref);
@@ -306,7 +306,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
306306
predicates.push_back(ty::Binder::bind(ty::TraitPredicate {
307307
trait_ref: ty::TraitRef {
308308
def_id: trait_did,
309-
substs: infcx.tcx.mk_substs_trait(ty, &[]),
309+
substs: infcx.tcx.mk_substs_trait(ty, SubstsRef::empty()),
310310
},
311311
}));
312312

src/librustc/traits/codegen/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
9696
value,
9797
param_env,
9898
);
99-
let substituted = value.subst(self, &param_substs);
99+
let substituted = value.subst(self, param_substs);
100100
self.normalize_erasing_regions(param_env, substituted)
101101
}
102102
}

src/librustc/traits/coherence.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ fn with_fresh_ty_vars<'cx, 'gcx, 'tcx>(selcx: &mut SelectionContext<'cx, 'gcx, '
9898

9999
let header = ty::ImplHeader {
100100
impl_def_id,
101-
self_ty: tcx.type_of(impl_def_id).subst(tcx, &impl_substs),
102-
trait_ref: tcx.impl_trait_ref(impl_def_id).subst(tcx, &impl_substs),
101+
self_ty: tcx.type_of(impl_def_id).subst(tcx, impl_substs),
102+
trait_ref: tcx.impl_trait_ref(impl_def_id).subst(tcx, impl_substs),
103103
predicates: tcx.predicates_of(impl_def_id).instantiate(tcx, impl_substs.into()).predicates,
104104
};
105105

src/librustc/traits/engine.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::infer::InferCtxt;
22
use crate::ty::{self, Ty, TyCtxt, ToPredicate};
3+
use crate::ty::subst::SubstsRef;
34
use crate::traits::Obligation;
45
use crate::hir::def_id::DefId;
56

@@ -28,7 +29,7 @@ pub trait TraitEngine<'tcx>: 'tcx {
2829
) {
2930
let trait_ref = ty::TraitRef {
3031
def_id,
31-
substs: infcx.tcx.mk_substs_trait(ty, &[]),
32+
substs: infcx.tcx.mk_substs_trait(ty, SubstsRef::empty()),
3233
};
3334
self.register_predicate_obligation(infcx, Obligation {
3435
cause,

0 commit comments

Comments
 (0)