about summary refs log tree commit diff
path: root/clippy_lints/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-09-20 13:07:11 +0000
committerbors <bors@rust-lang.org>2020-09-20 13:07:11 +0000
commita334ae658ba7ab1a82230afe2248557f4ef74ea6 (patch)
tree92123da01b7fc361e38bbe565a8cf97c8e7b15b8 /clippy_lints/src
parent78f9ea543154b6a0d6b5b5a86e92d8cc1938b436 (diff)
parentac0d0696169d0e69504dface45544132525244b6 (diff)
Auto merge of #76136 - CDirkx:const-result, r=dtolnay
Stabilize some Result methods as const

Stabilize the following methods of Result as const:
 - `is_ok`
 - `is_err`
 - `as_ref`

A test is also included, analogous to the test for `const_option`.

These methods are currently const under the unstable feature `const_result` (tracking issue: #67520).
I believe these methods to be eligible for stabilization because of the stabilization of #49146 (Allow if and match in constants) and the trivial implementations, see also: [PR#75463](https://github.com/rust-lang/rust/pull/75463) and [PR#76135](https://github.com/rust-lang/rust/pull/76135).

Note: these methods are the only methods currently under the `const_result` feature, thus this PR results in the removal of the feature.

Related: #76225
Diffstat (limited to 'clippy_lints/src')
-rw-r--r--clippy_lints/src/matches.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/clippy_lints/src/matches.rs b/clippy_lints/src/matches.rs
index 7ba7397c29c..db52c97475f 100644
--- a/clippy_lints/src/matches.rs
+++ b/clippy_lints/src/matches.rs
@@ -1469,10 +1469,10 @@ mod redundant_pattern_match {
         keyword: &'static str,
     ) {
         fn find_suggestion(cx: &LateContext<'_>, hir_id: HirId, path: &QPath<'_>) -> Option<&'static str> {
-            if match_qpath(path, &paths::RESULT_OK) && can_suggest(cx, hir_id, sym!(result_type), "is_ok") {
+            if match_qpath(path, &paths::RESULT_OK) {
                 return Some("is_ok()");
             }
-            if match_qpath(path, &paths::RESULT_ERR) && can_suggest(cx, hir_id, sym!(result_type), "is_err") {
+            if match_qpath(path, &paths::RESULT_ERR) {
                 return Some("is_err()");
             }
             if match_qpath(path, &paths::OPTION_SOME) && can_suggest(cx, hir_id, sym!(option_type), "is_some") {
@@ -1562,8 +1562,8 @@ mod redundant_pattern_match {
                             &paths::RESULT_ERR,
                             "is_ok()",
                             "is_err()",
-                            || can_suggest(cx, hir_id, sym!(result_type), "is_ok"),
-                            || can_suggest(cx, hir_id, sym!(result_type), "is_err"),
+                            || true,
+                            || true,
                         )
                     } else {
                         None