-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
Make saturating_add and saturating_sub const functions #58030
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-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.
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-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.
Type
Fields
Give feedbackNo fields configured for issues without a type.
These used to require
ifto work, but are forwarded to llvm intrinsics nowadays (#58003). We can now implement them as const eval intrinsics, too.Impl instructions:
rust/src/librustc_mir/transform/qualify_min_const_fn.rs
Line 371 in 0c0c585
unsafefor calls to the intrinsicrust/src/librustc_mir/transform/qualify_consts.rs
Line 820 in 51cc3cd
const fnrust/src/librustc_mir/interpret/intrinsics.rs
Line 102 in 79d8a0f
read_immediatecalls, a call tobinary_op_immwith arguments similar to the other add/sub intrinsics, in case the overflow bool in the return value is false, write the actual value to the destination like inrust/src/librustc_mir/interpret/operator.rs
Line 36 in 79d8a0f
rust/src/librustc_mir/interpret/operator.rs
Line 217 in 79d8a0f
dest.