Skip to content

Commit

Permalink
comments
Browse files Browse the repository at this point in the history
  • Loading branch information
BoxyUwU committed Jan 27, 2021
1 parent b0625eb commit f426177
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,9 @@ pub(super) fn try_unify<'tcx>(
mut a: AbstractConst<'tcx>,
mut b: AbstractConst<'tcx>,
) -> bool {
// We substitute generics repeatedly to allow AbstractConsts to unify where a
// ConstKind::Unevalated could be turned into an AbstractConst that would unify e.g.
// Param(N) should unify with Param(T), substs: [Unevaluated("T2", [Unevaluated("T3", [Param(N)])])]
while let Node::Leaf(a_ct) = a.root() {
let a_ct = a_ct.subst(tcx, a.substs);
match AbstractConst::from_const(tcx, a_ct) {
Expand All @@ -620,7 +623,6 @@ pub(super) fn try_unify<'tcx>(
Err(_) => return true,
}
}

while let Node::Leaf(b_ct) = b.root() {
let b_ct = b_ct.subst(tcx, b.substs);
match AbstractConst::from_const(tcx, b_ct) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ where
fn main() {
assert_eq!(caller::<4>(), 5);
}

// Test that the ``(N1 + 1) + 1`` bound on ``caller`` satisfies the ``M2 + 1`` bound on ``callee``
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ where
fn main() {
assert_eq!((Generic::<10>).bar(), 11);
}

// Test that the ``ConstU64<{ K + 1 - 1}>`` bound on ``bar``'s impl block satisfies the ``ConstU64<{K - 1}>`` bound on ``foo``'s impl block
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ where
fn main() {
assert_eq!(substs3::<2>().0, [0; 3]);
}

// Test that the ``{ (L - 1) * 2 + 1 }`` bound on ``substs3`` satisfies the ``{ N + 1 }`` bound on ``Substs1``
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ fn substs3<const L: usize>() -> Substs1<{ (L) }> {
fn main() {
assert_eq!(substs3::<2>().0, [0; 2]);
}

// Test that the implicit ``{ (L) }`` bound on ``substs3`` satisfies the ``{ (N) }`` bound on ``Substs1``

0 comments on commit f426177

Please sign in to comment.