Skip to content

Missing visit_const/fold_const when visit_ty/fold_ty exists and consts are relevant. #70317

Closed
@eddyb

Description

@eddyb

For visiting, I've identified these two examples:

fn visit_ty(&mut self, t: Ty<'tcx>) -> bool {
match t.kind {
ty::Bound(debruijn, bound_ty) if debruijn == self.binder_index => {
self.types.insert(
bound_ty.var.as_u32(),
match bound_ty.kind {
ty::BoundTyKind::Param(name) => name,
ty::BoundTyKind::Anon => {
Symbol::intern(&format!("^{}", bound_ty.var.as_u32()))
}
},
);
}
_ => (),
};
t.super_visit_with(self)
}

fn visit_ty(&mut self, t: Ty<'tcx>) -> bool {
// if we are only looking for "constrained" region, we have to
// ignore the inputs to a projection, as they may not appear
// in the normalized form
if self.just_constrained {
match t.kind {
ty::Projection(..) | ty::Opaque(..) => {
return false;
}
_ => {}
}
}
t.super_visit_with(self)
}

(the latter would need to handle ty::ConstKind::Unevaluated the same way ty::Projection is handled, as "unevaluated" consts are effectively projections)

For folding, I've listed one missing fold_const and two which are missing some recursion, in #70125 (comment).

cc @varkor @yodaldevoid

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-genericsArea: const generics (parameters and arguments)C-bugCategory: This is a bug.F-const_generics`#![feature(const_generics)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions