Merge #4106
4106: Fix wrong substitution code r=matklad a=flodiebold We need to shift in when we're substituting inside a binder. This should fix #4053 (it doesn't fix the occasional overflow that also occurs on the Diesel codebase though). Co-authored-by: Florian Diebold <flodiebold@gmail.com>
This commit is contained in:
commit
5eb51c1e60
@ -863,7 +863,7 @@ fn subst_bound_vars_at_depth(mut self, substs: &Substs, depth: DebruijnIndex) ->
|
||||
&mut |ty, binders| {
|
||||
if let &mut Ty::Bound(bound) = ty {
|
||||
if bound.debruijn >= binders {
|
||||
*ty = substs.0[bound.index].clone();
|
||||
*ty = substs.0[bound.index].clone().shift_bound_vars(binders);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -533,3 +533,44 @@ fn foo(b: Bar) {
|
||||
"###
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn issue_4053_diesel_where_clauses() {
|
||||
assert_snapshot!(
|
||||
infer(r#"
|
||||
trait BoxedDsl<DB> {
|
||||
type Output;
|
||||
fn internal_into_boxed(self) -> Self::Output;
|
||||
}
|
||||
|
||||
struct SelectStatement<From, Select, Distinct, Where, Order, LimitOffset, GroupBy, Locking> {
|
||||
order: Order,
|
||||
}
|
||||
|
||||
trait QueryFragment<DB: Backend> {}
|
||||
|
||||
trait Into<T> { fn into(self) -> T; }
|
||||
|
||||
impl<F, S, D, W, O, LOf, DB> BoxedDsl<DB>
|
||||
for SelectStatement<F, S, D, W, O, LOf, G>
|
||||
where
|
||||
O: Into<dyn QueryFragment<DB>>,
|
||||
{
|
||||
type Output = XXX;
|
||||
|
||||
fn internal_into_boxed(self) -> Self::Output {
|
||||
self.order.into();
|
||||
}
|
||||
}
|
||||
"#),
|
||||
@r###"
|
||||
[66; 70) 'self': Self
|
||||
[268; 272) 'self': Self
|
||||
[467; 471) 'self': SelectStatement<F, S, D, W, O, LOf, {unknown}, {unknown}>
|
||||
[489; 523) '{ ... }': ()
|
||||
[499; 503) 'self': SelectStatement<F, S, D, W, O, LOf, {unknown}, {unknown}>
|
||||
[499; 509) 'self.order': O
|
||||
[499; 516) 'self.o...into()': dyn QueryFragment<DB>
|
||||
"###
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user