-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stabilize some Option methods as const #76135
Conversation
r? @KodrAus (rust_highfive has picked a reviewer for you, use r? to override) |
r? @KodrAus (Needs FCP) |
Created an issue for similar stabilizations: #76225 |
@rfcbot fcp merge |
Team member @KodrAus has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
It seems like |
I believe (someone should verify this) that the other two would depend on the unstable |
I checked, even though nothing actually gets dropped inside |
This makes sense (example playground), and also resolves my comment here: #76136 (comment). |
Stabilize some Option methods as const Stabilize the following methods of `Option` as const: - `is_some` - `is_none` - `as_ref` These methods are currently const under the unstable feature `const_option` (tracking issue: rust-lang#67441). I believe these methods to be eligible for stabilization because of the stabilization of rust-lang#49146 (Allow if and match in constants) and the trivial implementations, see also: [PR#75463](rust-lang#75463). Related: rust-lang#76225
@bors rollup |
I think this caused the clippy test failure in #76907 (comment). The affected test, @bors r- |
Edit: see #76136 (comment), after #76136 gets merged the Clippy check |
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: rust-lang#67520). I believe these methods to be eligible for stabilization because of the stabilization of rust-lang#49146 (Allow if and match in constants) and the trivial implementations, see also: [PR#75463](rust-lang#75463) and [PR#76135](rust-lang#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: rust-lang#76225
Stabilize the following methods of `Option` as const: - `is_some` - `is_none` - `as_ref` Possible because of stabilization of rust-lang#49146 (Allow if and match in constants).
04e4a39
to
4f859fb
Compare
Update the test `redundant_pattern_matching`: check if `is_some` and `is_none` are suggested within const contexts.
Removes `can_suggest` from as it is no longer used. Reverts rust-clippy#5724.
fa5a5d7
to
43cba34
Compare
With #76136 merged I updated the testcases and now completely removed |
LGTM. @rust-lang/clippy could someone take a look at the clippy changes here? |
@bors r=dtolnay,oli-obk |
📌 Commit 43cba34 has been approved by |
Rollup of 13 pull requests Successful merges: - rust-lang#76135 (Stabilize some Option methods as const) - rust-lang#76628 (Add sample defaults for config.toml ) - rust-lang#76846 (Avoiding unnecesary allocations at rustc_errors) - rust-lang#76867 (Use intra-doc links in core/src/iter when possible) - rust-lang#76868 (Finish moving to intra doc links for std::sync) - rust-lang#76872 (Remove DeclareMethods) - rust-lang#76936 (Add non-`unsafe` `.get_mut()` for `Unsafecell`) - rust-lang#76958 (Replace manual as_nanos and as_secs_f64 reimplementations) - rust-lang#76959 (Replace write_fmt with write!) - rust-lang#76961 (Add test for issue rust-lang#34634) - rust-lang#76962 (Use const_cstr macro in consts.rs) - rust-lang#76963 (Remove unused static_assert macro) - rust-lang#77000 (update Miri) Failed merges: r? `@ghost`
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](rust-lang/rust#75463) and [PR#76135](rust-lang/rust#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
Stabilize the following methods of
Option
as const:is_some
is_none
as_ref
These methods are currently const under the unstable feature
const_option
(tracking issue: #67441).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.
Related: #76225