Repository navigation
Make the NonZero* methods const fn #53331
Copy link
Copy link
Closed
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Description
Activity
- addedE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
on Aug 14, 2018 Doesn't this require panicking in constants?
Ah, no, it requires conditional control-flow.Ah I thought there were more trivial methods.
This issue is only acctionable for
getat the momentHi, I'd like to help out on this. I would appreciate if some one gave me pointers on what needs to be accomplished.
Steps:
- add
constto https://github.com/rust-lang/rust/blob/master/src/libcore/num/mod.rs#L80 - add the
rustc_const_unstableattribute - add a test in
src/test/ui/constthat shows a const usage of the method (needs the feature gate specified inrustc_const_unstable - See whether the linked commit above can be partially reverted
Reacted by Siva Prasad and Lucas Fantacuci- add
@MagnumOpus21 you may take a look at #53697. These are the steps you have to do in order to add
const.@cyres I will do that sir. Was busy with my internship.
@MagnumOpus21 If you need help, don't hesitate to ping me here, in Discord (Cyres#8322) or on StackOverflow in the rust chat room.
Thank you 😄 @cyres
- added a commit that references this issue
on Dec 28, 2018 - addedA-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)
on Dec 1, 2024
Metadata
Metadata
Assignees
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
and undo the const -> fn changes in https://github.com/rust-lang/rust/pull/53315/files#diff-a4a060a3c734b42317d2b9136d68918eL186
This requires changing applicable methods on
NonZero*fromfntoconst fn, adding the#[rustc_const_unstable="const_nonzero*_methods"]attribute to all of them and adding some tests ensuring that the methods are not const fn on stable rust.