diff options
| author | Caio <c410.f3r@gmail.com> | 2022-03-26 15:39:21 -0300 |
|---|---|---|
| committer | Caio <c410.f3r@gmail.com> | 2022-03-26 15:39:21 -0300 |
| commit | c687f6575f106b7cd7546b63b7692bad4dee4c5b (patch) | |
| tree | a9af9248a8715a2fc0e7da0b31a3a3ac1da04c8e /clippy_lints | |
| parent | 8ebe766695e66a97775e4992d3d08f74ce2a7270 (diff) | |
| download | rust-c687f6575f106b7cd7546b63b7692bad4dee4c5b.tar.gz rust-c687f6575f106b7cd7546b63b7692bad4dee4c5b.zip | |
Do not fire `panic` in a constant environment
Diffstat (limited to 'clippy_lints')
| -rw-r--r-- | clippy_lints/src/panic_unimplemented.rs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/clippy_lints/src/panic_unimplemented.rs b/clippy_lints/src/panic_unimplemented.rs index 6ef6b9a20aa..2f3007658ea 100644 --- a/clippy_lints/src/panic_unimplemented.rs +++ b/clippy_lints/src/panic_unimplemented.rs @@ -78,6 +78,10 @@ impl<'tcx> LateLintPass<'tcx> for PanicUnimplemented { fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) { let Some(macro_call) = root_macro_call_first_node(cx, expr) else { return }; if is_panic(cx, macro_call.def_id) { + if cx.tcx.hir().is_inside_const_context(expr.hir_id) { + return; + } + span_lint( cx, PANIC, |
