Skip to content

Commit 5e7f138

Browse files
committed
move ExprKind::Repeat arm to expr_is_poly
1 parent 9cd8bb0 commit 5e7f138

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

compiler/rustc_trait_selection/src/traits/const_evaluatable.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -318,22 +318,28 @@ impl<'a, 'tcx> AbstractConstBuilder<'a, 'tcx> {
318318
thir: &'a thir::Thir<'tcx>,
319319
}
320320

321+
use crate::rustc_middle::thir::visit::Visitor;
322+
use thir::visit;
323+
321324
impl<'a, 'tcx> IsThirPolymorphic<'a, 'tcx> {
322-
fn expr_is_poly(&self, expr: &thir::Expr<'tcx>) -> bool {
325+
fn expr_is_poly(&mut self, expr: &thir::Expr<'tcx>) -> bool {
323326
if expr.ty.has_param_types_or_consts() {
324327
return true;
325328
}
326329

327330
match expr.kind {
328331
thir::ExprKind::NamedConst { substs, .. } => substs.has_param_types_or_consts(),
329332
thir::ExprKind::ConstParam { .. } => true,
333+
thir::ExprKind::Repeat { value, count } => {
334+
self.visit_expr(&self.thir()[value]);
335+
count.has_param_types_or_consts()
336+
}
330337
_ => false,
331338
}
332339
}
333340
}
334341

335-
use thir::visit;
336-
impl<'a, 'tcx: 'a> visit::Visitor<'a, 'tcx> for IsThirPolymorphic<'a, 'tcx> {
342+
impl<'a, 'tcx> visit::Visitor<'a, 'tcx> for IsThirPolymorphic<'a, 'tcx> {
337343
fn thir(&self) -> &'a thir::Thir<'tcx> {
338344
&self.thir
339345
}
@@ -342,13 +348,7 @@ impl<'a, 'tcx> AbstractConstBuilder<'a, 'tcx> {
342348
fn visit_expr(&mut self, expr: &thir::Expr<'tcx>) {
343349
self.is_poly |= self.expr_is_poly(expr);
344350
if !self.is_poly {
345-
match expr.kind {
346-
thir::ExprKind::Repeat { value, count } => {
347-
self.visit_expr(&self.thir()[value]);
348-
self.is_poly |= count.has_param_types_or_consts();
349-
}
350-
_ => visit::walk_expr(self, expr),
351-
}
351+
visit::walk_expr(self, expr)
352352
}
353353
}
354354

0 commit comments

Comments
 (0)