Skip to content

Commit a9ece00

Browse files
committed
change skip_binder to use T by value
1 parent c321c06 commit a9ece00

File tree

36 files changed

+78
-83
lines changed

36 files changed

+78
-83
lines changed

src/librustc_infer/infer/canonical/query_response.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
302302
// Screen out `'a: 'a` cases -- we skip the binder here but
303303
// only compare the inner values to one another, so they are still at
304304
// consistent binding levels.
305-
let &ty::OutlivesPredicate(k1, r2) = r_c.skip_binder();
305+
let ty::OutlivesPredicate(k1, r2) = r_c.skip_binder();
306306
if k1 != r2.into() { Some(r_c) } else { None }
307307
}),
308308
);
@@ -526,7 +526,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
526526
) -> impl Iterator<Item = PredicateObligation<'tcx>> + 'a + Captures<'tcx> {
527527
unsubstituted_region_constraints.iter().map(move |constraint| {
528528
let constraint = substitute_value(self.tcx, result_subst, constraint);
529-
let &ty::OutlivesPredicate(k1, r2) = constraint.skip_binder(); // restored below
529+
let ty::OutlivesPredicate(k1, r2) = constraint.skip_binder(); // restored below
530530

531531
Obligation::new(
532532
cause.clone(),

src/librustc_infer/infer/combine.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ impl TypeRelation<'tcx> for Generalizer<'_, 'tcx> {
496496
where
497497
T: Relate<'tcx>,
498498
{
499-
Ok(ty::Binder::bind(self.relate(*a.skip_binder(), *b.skip_binder())?))
499+
Ok(ty::Binder::bind(self.relate(a.skip_binder(), b.skip_binder())?))
500500
}
501501

502502
fn relate_item_substs(

src/librustc_infer/infer/equate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ impl TypeRelation<'tcx> for Equate<'combine, 'infcx, 'tcx> {
135135
self.fields.higher_ranked_sub(b, a, self.a_is_expected)
136136
} else {
137137
// Fast path for the common case.
138-
self.relate(*a.skip_binder(), *b.skip_binder())?;
138+
self.relate(a.skip_binder(), b.skip_binder())?;
139139
Ok(a)
140140
}
141141
}

src/librustc_infer/infer/nll_relate/mod.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,9 @@ where
159159
}
160160
}
161161

162-
// FIXME: consider taking `ty::Binder` directly, without the reference.
163162
fn create_scope(
164163
&mut self,
165-
value: &ty::Binder<impl TypeFoldable<'tcx>>,
164+
value: ty::Binder<impl Relate<'tcx>>,
166165
universally_quantified: UniversallyQuantified,
167166
) -> BoundRegionScope<'tcx> {
168167
let mut scope = BoundRegionScope::default();
@@ -654,8 +653,8 @@ where
654653
// instantiation of B (i.e., B instantiated with
655654
// universals).
656655

657-
let b_scope = self.create_scope(&b, UniversallyQuantified(true));
658-
let a_scope = self.create_scope(&a, UniversallyQuantified(false));
656+
let b_scope = self.create_scope(b, UniversallyQuantified(true));
657+
let a_scope = self.create_scope(a, UniversallyQuantified(false));
659658

660659
debug!("binders: a_scope = {:?} (existential)", a_scope);
661660
debug!("binders: b_scope = {:?} (universal)", b_scope);
@@ -683,7 +682,7 @@ where
683682
// subtyping (i.e., `&'b u32 <: &{P} u32`).
684683
let variance = ::std::mem::replace(&mut self.ambient_variance, ty::Variance::Covariant);
685684

686-
self.relate(*a.skip_binder(), *b.skip_binder())?;
685+
self.relate(a.skip_binder(), b.skip_binder())?;
687686

688687
self.ambient_variance = variance;
689688

@@ -698,8 +697,8 @@ where
698697
// instantiation of B (i.e., B instantiated with
699698
// existentials). Opposite of above.
700699

701-
let a_scope = self.create_scope(&a, UniversallyQuantified(true));
702-
let b_scope = self.create_scope(&b, UniversallyQuantified(false));
700+
let a_scope = self.create_scope(a, UniversallyQuantified(true));
701+
let b_scope = self.create_scope(b, UniversallyQuantified(false));
703702

704703
debug!("binders: a_scope = {:?} (universal)", a_scope);
705704
debug!("binders: b_scope = {:?} (existential)", b_scope);
@@ -712,7 +711,7 @@ where
712711
let variance =
713712
::std::mem::replace(&mut self.ambient_variance, ty::Variance::Contravariant);
714713

715-
self.relate(*a.skip_binder(), *b.skip_binder())?;
714+
self.relate(a.skip_binder(), b.skip_binder())?;
716715

717716
self.ambient_variance = variance;
718717

@@ -1010,7 +1009,7 @@ where
10101009
debug!("TypeGeneralizer::binders(a={:?})", a);
10111010

10121011
self.first_free_index.shift_in(1);
1013-
let result = self.relate(*a.skip_binder(), *a.skip_binder())?;
1012+
let result = self.relate(a.skip_binder(), a.skip_binder())?;
10141013
self.first_free_index.shift_out(1);
10151014
Ok(ty::Binder::bind(result))
10161015
}

src/librustc_lint/builtin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -911,7 +911,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MutableTransmutes {
911911
}
912912
let sig = cx.tables().node_type(expr.hir_id).fn_sig(cx.tcx);
913913
let from = sig.inputs().skip_binder()[0];
914-
let to = *sig.output().skip_binder();
914+
let to = sig.output().skip_binder();
915915
return Some((from, to));
916916
}
917917
None

src/librustc_middle/ich/impls_ty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ where
123123
T: HashStable<StableHashingContext<'a>>,
124124
{
125125
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
126-
self.skip_binder().hash_stable(hcx, hasher);
126+
self.as_ref().skip_binder().hash_stable(hcx, hasher);
127127
}
128128
}
129129

src/librustc_middle/ty/_match.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,6 @@ impl TypeRelation<'tcx> for Match<'tcx> {
118118
where
119119
T: Relate<'tcx>,
120120
{
121-
Ok(ty::Binder::bind(self.relate(*a.skip_binder(), *b.skip_binder())?))
121+
Ok(ty::Binder::bind(self.relate(a.skip_binder(), b.skip_binder())?))
122122
}
123123
}

src/librustc_middle/ty/flags.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,13 @@ impl FlagComputation {
8888
self.add_substs(substs);
8989
}
9090

91-
&ty::GeneratorWitness(ref ts) => {
91+
&ty::GeneratorWitness(ts) => {
9292
let mut computation = FlagComputation::new();
93-
computation.add_tys(&ts.skip_binder()[..]);
93+
computation.add_tys(ts.skip_binder());
9494
self.add_bound_computation(computation);
9595
}
9696

97-
&ty::Closure(_, ref substs) => {
97+
&ty::Closure(_, substs) => {
9898
self.add_substs(substs);
9999
}
100100

@@ -122,7 +122,7 @@ impl FlagComputation {
122122
self.add_substs(substs);
123123
}
124124

125-
&ty::Projection(ref data) => {
125+
&ty::Projection(data) => {
126126
self.add_flags(TypeFlags::HAS_TY_PROJECTION);
127127
self.add_projection_ty(data);
128128
}
@@ -211,7 +211,7 @@ impl FlagComputation {
211211

212212
self.add_bound_computation(computation);
213213
}
214-
ty::PredicateKind::Projection(projection) => {
214+
&ty::PredicateKind::Projection(projection) => {
215215
let mut computation = FlagComputation::new();
216216
let ty::ProjectionPredicate { projection_ty, ty } = projection.skip_binder();
217217
computation.add_projection_ty(projection_ty);
@@ -298,7 +298,7 @@ impl FlagComputation {
298298
self.add_ty(projection.ty);
299299
}
300300

301-
fn add_projection_ty(&mut self, projection_ty: &ty::ProjectionTy<'_>) {
301+
fn add_projection_ty(&mut self, projection_ty: ty::ProjectionTy<'_>) {
302302
self.add_substs(projection_ty.substs);
303303
}
304304

src/librustc_middle/ty/fold.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ impl<'tcx> TyCtxt<'tcx> {
336336
{
337337
fn visit_binder<T: TypeFoldable<'tcx>>(&mut self, t: &Binder<T>) -> bool {
338338
self.outer_index.shift_in(1);
339-
let result = t.skip_binder().visit_with(self);
339+
let result = t.as_ref().skip_binder().visit_with(self);
340340
self.outer_index.shift_out(1);
341341
result
342342
}
@@ -558,7 +558,7 @@ impl<'tcx> TyCtxt<'tcx> {
558558
let fld_c = |bound_ct, ty| {
559559
self.mk_const(ty::Const { val: ty::ConstKind::Bound(ty::INNERMOST, bound_ct), ty })
560560
};
561-
self.replace_escaping_bound_vars(value.skip_binder(), fld_r, fld_t, fld_c)
561+
self.replace_escaping_bound_vars(value.as_ref().skip_binder(), fld_r, fld_t, fld_c)
562562
}
563563

564564
/// Replaces all escaping bound vars. The `fld_r` closure replaces escaping
@@ -617,7 +617,7 @@ impl<'tcx> TyCtxt<'tcx> {
617617
H: FnMut(ty::BoundVar, Ty<'tcx>) -> &'tcx ty::Const<'tcx>,
618618
T: TypeFoldable<'tcx>,
619619
{
620-
self.replace_escaping_bound_vars(value.skip_binder(), fld_r, fld_t, fld_c)
620+
self.replace_escaping_bound_vars(value.as_ref().skip_binder(), fld_r, fld_t, fld_c)
621621
}
622622

623623
/// Replaces any late-bound regions bound in `value` with
@@ -673,7 +673,7 @@ impl<'tcx> TyCtxt<'tcx> {
673673
T: TypeFoldable<'tcx>,
674674
{
675675
let mut collector = LateBoundRegionsCollector::new(just_constraint);
676-
let result = value.skip_binder().visit_with(&mut collector);
676+
let result = value.as_ref().skip_binder().visit_with(&mut collector);
677677
assert!(!result); // should never have stopped early
678678
collector.regions
679679
}

src/librustc_middle/ty/layout.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2303,7 +2303,7 @@ impl<'tcx> ty::Instance<'tcx> {
23032303

23042304
let env_ty = tcx.closure_env_ty(def_id, substs).unwrap();
23052305
sig.map_bound(|sig| tcx.mk_fn_sig(
2306-
iter::once(*env_ty.skip_binder()).chain(sig.inputs().iter().cloned()),
2306+
iter::once(env_ty.skip_binder()).chain(sig.inputs().iter().cloned()),
23072307
sig.output(),
23082308
sig.c_variadic,
23092309
sig.unsafety,

0 commit comments

Comments
 (0)