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
This commit is contained in:
commit
a334ae658b
7 changed files with 97 additions and 187 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue