don't visit any nested bodies in is_const_evaluatable

This commit is contained in:
y21 2023-12-16 22:07:31 +01:00
parent a859e5cc1c
commit b5169aea52
2 changed files with 15 additions and 4 deletions

View file

@ -316,10 +316,7 @@ pub fn is_const_evaluatable<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) ->
is_const: bool, is_const: bool,
} }
impl<'tcx> Visitor<'tcx> for V<'_, 'tcx> { impl<'tcx> Visitor<'tcx> for V<'_, 'tcx> {
type NestedFilter = nested_filter::OnlyBodies; type NestedFilter = rustc_hir::intravisit::nested_filter::None;
fn nested_visit_map(&mut self) -> Self::Map {
self.cx.tcx.hir()
}
fn visit_expr(&mut self, e: &'tcx Expr<'_>) { fn visit_expr(&mut self, e: &'tcx Expr<'_>) {
if !self.is_const { if !self.is_const {

View file

@ -0,0 +1,14 @@
#![allow(clippy::unit_arg, clippy::no_effect)]
const fn v(_: ()) {}
fn main() {
if true {
v({
[0; 1 + 1];
});
Some(())
} else {
None
};
}