Skip to content

Commit b5169ae

Browse files
committed
don't visit any nested bodies in is_const_evaluatable
1 parent a859e5c commit b5169ae

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

clippy_utils/src/visitors.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -316,10 +316,7 @@ pub fn is_const_evaluatable<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) ->
316316
is_const: bool,
317317
}
318318
impl<'tcx> Visitor<'tcx> for V<'_, 'tcx> {
319-
type NestedFilter = nested_filter::OnlyBodies;
320-
fn nested_visit_map(&mut self) -> Self::Map {
321-
self.cx.tcx.hir()
322-
}
319+
type NestedFilter = rustc_hir::intravisit::nested_filter::None;
323320

324321
fn visit_expr(&mut self, e: &'tcx Expr<'_>) {
325322
if !self.is_const {

tests/ui/crashes/ice-11939.rs

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#![allow(clippy::unit_arg, clippy::no_effect)]
2+
3+
const fn v(_: ()) {}
4+
5+
fn main() {
6+
if true {
7+
v({
8+
[0; 1 + 1];
9+
});
10+
Some(())
11+
} else {
12+
None
13+
};
14+
}

0 commit comments

Comments
 (0)