Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
eddyb opened this issue Mar 23, 2020 · 0 comments · Fixed by #70319
Closed

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

eddyb opened this issue Mar 23, 2020 · 0 comments · Fixed by #70319
Labels
A-const-generics Area: const generics (parameters and arguments) C-bug Category: This is a bug. F-const_generics `#![feature(const_generics)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@eddyb
Copy link
Member

eddyb commented Mar 23, 2020

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

@jonas-schievink jonas-schievink added A-const-generics Area: const generics (parameters and arguments) C-bug Category: This is a bug. F-const_generics `#![feature(const_generics)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 23, 2020
Centril added a commit to Centril/rust that referenced this issue Mar 24, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Mar 25, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Mar 25, 2020
@bors bors closed this as completed in 1154023 Mar 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-generics Area: const generics (parameters and arguments) C-bug Category: This is a bug. F-const_generics `#![feature(const_generics)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants