Skip to content

Commit dfe713a

Browse files
committed
addressed nits
1 parent 6d8d542 commit dfe713a

File tree

3 files changed

+18
-39
lines changed

3 files changed

+18
-39
lines changed

chalk-ir/src/lib.rs

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,13 +1158,10 @@ impl<T> Binders<T> {
11581158

11591159
/// Skips the binder and returns the "bound" value. This is a
11601160
/// risky thing to do because it's easy to get confused about
1161-
/// De Bruijn indices and the like. It is usually better to
1162-
/// discharge the binder using `no_bound_vars` or something
1163-
/// like that. `skip_binder` is only valid when you are either
1164-
/// extracting data that has nothing to do with bound vars, you
1165-
/// are doing some sort of test that does not involve bound
1166-
/// regions, or you are being very careful about your depth
1167-
/// accounting.
1161+
/// De Bruijn indices and the like. `skip_binder` is only valid
1162+
/// when you are either extracting data that has nothing to
1163+
/// do with bound vars, or you are being very careful about
1164+
/// your depth accounting.
11681165
///
11691166
/// Some examples where `skip_binder` is reasonable:
11701167
///
@@ -1174,6 +1171,9 @@ impl<T> Binders<T> {
11741171
&self.value
11751172
}
11761173

1174+
/// Converts `&Binders<T>` to `Binders<&T>`. Produces new `Binders`
1175+
/// with cloned quantifiers containing a reference to the original
1176+
/// value, leaving the original in place.
11771177
pub fn as_ref(&self) -> Binders<&T> {
11781178
Binders {
11791179
binders: self.binders.clone(),
@@ -1219,27 +1219,6 @@ impl<T> Binders<T> {
12191219
}
12201220
}
12211221

1222-
/// Unwraps and returns the value within, but only if it contains
1223-
/// no vars bound by this binder. (In other words, if this binder --
1224-
/// and indeed any enclosing binder -- doesn't bind anything at
1225-
/// all.) Otherwise, returns `None`.
1226-
///
1227-
/// (One could imagine having a method that just unwraps a single
1228-
/// binder, but permits late-bound vars bound by enclosing
1229-
/// binders, but that would require adjusting the debruijn
1230-
/// indices, and given the shallow binding structure we often use,
1231-
/// would not be that useful.)
1232-
pub fn no_bound_vars<I: Interner>(&self, interner: &I) -> Option<&T>
1233-
where
1234-
T: Visit<I>,
1235-
{
1236-
if self.skip_binders().has_free_vars(interner) {
1237-
None
1238-
} else {
1239-
Some(self.skip_binders())
1240-
}
1241-
}
1242-
12431222
pub fn len(&self) -> usize {
12441223
self.binders.len()
12451224
}

chalk-solve/src/coherence/solve.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,16 @@ impl<I: Interner> CoherenceSolver<'_, I> {
8989
let (rhs_binders, rhs_bound) = rhs.binders.as_ref().into();
9090

9191
// Upshift the rhs variables in params to account for the joined binders
92-
let lhs_params = params(interner, lhs_bound).iter().cloned();
93-
let rhs_params = params(interner, rhs_bound)
92+
let lhs_params = lhs_bound
93+
.trait_ref
94+
.substitution
95+
.parameters(interner)
96+
.iter()
97+
.cloned();
98+
let rhs_params = rhs_bound
99+
.trait_ref
100+
.substitution
101+
.parameters(interner)
94102
.iter()
95103
.map(|param| param.shifted_in(interner));
96104

@@ -260,11 +268,3 @@ impl<I: Interner> CoherenceSolver<'_, I> {
260268
result
261269
}
262270
}
263-
264-
fn params<'a, I: Interner>(
265-
interner: &I,
266-
impl_datum_bound: &'a ImplDatumBound<I>,
267-
) -> &'a [Parameter<I>] {
268-
// We can skip binders here because the caller is handling correct binders handling
269-
impl_datum_bound.trait_ref.substitution.parameters(interner)
270-
}

chalk-solve/src/solve/slg/resolvent.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ impl<'i, I: Interner> Zipper<'i, I> for AnswerSubstitutor<'i, I> {
485485
T: Zip<I> + Fold<I, Result = T>,
486486
{
487487
self.outer_binder.shift_in();
488-
Zip::zip_with(self, &answer.skip_binders(), &pending.skip_binders())?;
488+
Zip::zip_with(self, answer.skip_binders(), pending.skip_binders())?;
489489
self.outer_binder.shift_out();
490490
Ok(())
491491
}

0 commit comments

Comments
 (0)