diff options
| author | rsdy <p@symmetree.dev> | 2023-02-16 11:49:19 +0000 |
|---|---|---|
| committer | Pavan Kumar Sunkara <pavan.sss1991@gmail.com> | 2023-06-12 16:19:26 +0100 |
| commit | 5bb768177ee83065191b1f47111ecf63de347cff (patch) | |
| tree | 57bd786b8ed08421260b318c8579ad91926554db | |
| parent | e707447a861739fa3e12e9c05c039c8c9c6b0544 (diff) | |
| download | rust-5bb768177ee83065191b1f47111ecf63de347cff.tar.gz rust-5bb768177ee83065191b1f47111ecf63de347cff.zip | |
Add hook
| -rw-r--r-- | clippy_lints/src/methods/mod.rs | 4 | ||||
| -rw-r--r-- | clippy_lints/src/methods/unnecessary_literal_unwrap.rs | 2 |
2 files changed, 4 insertions, 2 deletions
diff --git a/clippy_lints/src/methods/mod.rs b/clippy_lints/src/methods/mod.rs index f24f00ef6a7..9d7b607ec7b 100644 --- a/clippy_lints/src/methods/mod.rs +++ b/clippy_lints/src/methods/mod.rs @@ -3865,7 +3865,9 @@ impl Methods { Some(("or", recv, [or_arg], or_span, _)) => { or_then_unwrap::check(cx, expr, recv, or_arg, or_span); }, - // unnecessary_literal_unwrap::check(cx, expr, recv); + Some((constructor @ "Some", _, _, _, _)) => { + unnecessary_literal_unwrap::check(cx, expr, recv, constructor); + } _ => {}, } unwrap_used::check(cx, expr, recv, false, self.allow_unwrap_in_tests); diff --git a/clippy_lints/src/methods/unnecessary_literal_unwrap.rs b/clippy_lints/src/methods/unnecessary_literal_unwrap.rs index 39b30b7769d..3572f4965ef 100644 --- a/clippy_lints/src/methods/unnecessary_literal_unwrap.rs +++ b/clippy_lints/src/methods/unnecessary_literal_unwrap.rs @@ -6,7 +6,7 @@ use rustc_span::sym; use super::UNNECESSARY_LITERAL_UNWRAP; -pub(super) fn check(cx: &LateContext<'_>, expr: &hir::Expr<'_>, recv: &hir::Expr<'_>) { +pub(super) fn check(cx: &LateContext<'_>, expr: &hir::Expr<'_>, recv: &hir::Expr<'_>, constructor: &str) { let obj_ty = cx.typeck_results().expr_ty(recv).peel_refs(); let mess = if is_type_diagnostic_item(cx, obj_ty, sym::Option) { |
