diff options
| author | bors <bors@rust-lang.org> | 2021-03-17 04:34:15 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-03-17 04:34:15 +0000 |
| commit | 56161b2982a4e6513e6765d6cc951ccc0f297a89 (patch) | |
| tree | a063b8722e8c5ff9cfa331a4b3c166894e26ff8d /clippy_lints/src | |
| parent | 5b3e61d62fef8a486bf42bf80b450c116189f3ef (diff) | |
| parent | 02ceeb59d4853eecec3a52a7fbd9f6acc1c3f91c (diff) | |
Auto merge of #6917 - MysteryJump:fix-manual-unwrap-or-const-fn, r=giraffate
Fix false-positive `manual_unwrap_or` inside const fn Fixes #6898 changelog: Fix false-positive for manual_unwrap_or in const fn.
Diffstat (limited to 'clippy_lints/src')
| -rw-r--r-- | clippy_lints/src/manual_unwrap_or.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/clippy_lints/src/manual_unwrap_or.rs b/clippy_lints/src/manual_unwrap_or.rs index 0e030e0e261..615e2d5c2af 100644 --- a/clippy_lints/src/manual_unwrap_or.rs +++ b/clippy_lints/src/manual_unwrap_or.rs @@ -1,6 +1,6 @@ use crate::consts::constant_simple; use crate::utils; -use crate::utils::{path_to_local_id, sugg}; +use crate::utils::{in_constant, path_to_local_id, sugg}; use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::{indent_of, reindent_multiline, snippet_opt}; use clippy_utils::ty::is_type_diagnostic_item; @@ -45,7 +45,7 @@ declare_lint_pass!(ManualUnwrapOr => [MANUAL_UNWRAP_OR]); impl LateLintPass<'_> for ManualUnwrapOr { fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) { - if in_external_macro(cx.sess(), expr.span) { + if in_external_macro(cx.sess(), expr.span) || in_constant(cx, expr.hir_id) { return; } lint_manual_unwrap_or(cx, expr); |
