Make expr_fallback FnMut

This commit is contained in:
Cameron Steffen 2021-02-17 09:35:55 -06:00
parent 4ac14f9e63
commit 742922a41a

View File

@ -26,7 +26,7 @@ pub struct SpanlessEq<'a, 'tcx> {
cx: &'a LateContext<'tcx>, cx: &'a LateContext<'tcx>,
maybe_typeck_results: Option<&'tcx TypeckResults<'tcx>>, maybe_typeck_results: Option<&'tcx TypeckResults<'tcx>>,
allow_side_effects: bool, allow_side_effects: bool,
expr_fallback: Option<Box<dyn Fn(&Expr<'_>, &Expr<'_>) -> bool + 'a>>, expr_fallback: Option<Box<dyn FnMut(&Expr<'_>, &Expr<'_>) -> bool + 'a>>,
} }
impl<'a, 'tcx> SpanlessEq<'a, 'tcx> { impl<'a, 'tcx> SpanlessEq<'a, 'tcx> {
@ -47,7 +47,7 @@ impl<'a, 'tcx> SpanlessEq<'a, 'tcx> {
} }
} }
pub fn expr_fallback(self, expr_fallback: impl Fn(&Expr<'_>, &Expr<'_>) -> bool + 'a) -> Self { pub fn expr_fallback(self, expr_fallback: impl FnMut(&Expr<'_>, &Expr<'_>) -> bool + 'a) -> Self {
Self { Self {
expr_fallback: Some(Box::new(expr_fallback)), expr_fallback: Some(Box::new(expr_fallback)),
..self ..self
@ -209,7 +209,7 @@ impl HirEqInterExpr<'_, '_, '_> {
(&ExprKind::DropTemps(ref le), &ExprKind::DropTemps(ref re)) => self.eq_expr(le, re), (&ExprKind::DropTemps(ref le), &ExprKind::DropTemps(ref re)) => self.eq_expr(le, re),
_ => false, _ => false,
}; };
is_eq || self.inner.expr_fallback.as_ref().map_or(false, |f| f(left, right)) is_eq || self.inner.expr_fallback.as_mut().map_or(false, |f| f(left, right))
} }
fn eq_exprs(&mut self, left: &[Expr<'_>], right: &[Expr<'_>]) -> bool { fn eq_exprs(&mut self, left: &[Expr<'_>], right: &[Expr<'_>]) -> bool {