Commit d347514
authored
Rollup merge of #128666 - pitaj:intrinsic-overflow_checks, r=BoxyUwU
Add `overflow_checks` intrinsic
This adds an intrinsic which allows code in a pre-built library to inherit the overflow checks option from a crate depending on it. This enables code in the standard library to explicitly change behavior based on whether `overflow_checks` are enabled, regardless of the setting used when standard library was compiled.
This is very similar to the `ub_checks` intrinsic, and refactors the two to use a common mechanism.
The primary use case for this is to allow the new `RangeFrom` iterator to yield the maximum element before overflowing, as requested [here](#125687 (comment)). This PR includes a working `IterRangeFrom` implementation based on this new intrinsic that exhibits the desired behavior.
[Prior discussion on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Ability.20to.20select.20code.20based.20on.20.60overflow_checks.60.3F)File tree
28 files changed
+153
-74
lines changed- compiler
- rustc_borrowck/src/type_check
- rustc_codegen_cranelift/src
- rustc_codegen_ssa/src/mir
- rustc_const_eval/src
- check_consts
- interpret
- rustc_hir_analysis/src/check
- rustc_middle/src/mir
- rustc_mir_dataflow/src/move_paths
- rustc_mir_transform/src
- rustc_public/src
- mir
- unstable/convert/stable
- library/core/src/intrinsics
- src/tools
- clippy/clippy_utils/src
- miri/src
- tests
- codegen-llvm
- auxiliary
- ui/consts/const-eval
28 files changed
+153
-74
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1046 | 1046 | | |
1047 | 1047 | | |
1048 | 1048 | | |
1049 | | - | |
1050 | | - | |
| 1049 | + | |
1051 | 1050 | | |
1052 | 1051 | | |
1053 | 1052 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
865 | 865 | | |
866 | 866 | | |
867 | 867 | | |
868 | | - | |
869 | | - | |
870 | | - | |
871 | | - | |
872 | | - | |
873 | | - | |
874 | | - | |
875 | | - | |
876 | | - | |
877 | | - | |
878 | | - | |
| 868 | + | |
| 869 | + | |
879 | 870 | | |
880 | 871 | | |
881 | 872 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
624 | 624 | | |
625 | 625 | | |
626 | 626 | | |
627 | | - | |
628 | | - | |
629 | | - | |
630 | | - | |
631 | | - | |
632 | | - | |
| 627 | + | |
| 628 | + | |
633 | 629 | | |
634 | 630 | | |
635 | 631 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
645 | 645 | | |
646 | 646 | | |
647 | 647 | | |
648 | | - | |
649 | | - | |
650 | | - | |
651 | | - | |
| 648 | + | |
652 | 649 | | |
653 | 650 | | |
654 | 651 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
298 | 298 | | |
299 | 299 | | |
300 | 300 | | |
301 | | - | |
302 | | - | |
303 | | - | |
304 | | - | |
305 | | - | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
306 | 306 | | |
307 | 307 | | |
308 | 308 | | |
| |||
681 | 681 | | |
682 | 682 | | |
683 | 683 | | |
684 | | - | |
685 | | - | |
686 | | - | |
687 | | - | |
688 | | - | |
689 | | - | |
690 | | - | |
691 | | - | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
692 | 688 | | |
693 | 689 | | |
694 | 690 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
522 | 522 | | |
523 | 523 | | |
524 | 524 | | |
525 | | - | |
526 | | - | |
| 525 | + | |
527 | 526 | | |
528 | 527 | | |
529 | 528 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
163 | 163 | | |
164 | 164 | | |
165 | 165 | | |
| 166 | + | |
166 | 167 | | |
167 | 168 | | |
168 | 169 | | |
| |||
643 | 644 | | |
644 | 645 | | |
645 | 646 | | |
646 | | - | |
| 647 | + | |
647 | 648 | | |
648 | 649 | | |
649 | 650 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
649 | 649 | | |
650 | 650 | | |
651 | 651 | | |
652 | | - | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
653 | 655 | | |
654 | 656 | | |
655 | 657 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1101 | 1101 | | |
1102 | 1102 | | |
1103 | 1103 | | |
1104 | | - | |
1105 | | - | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
1106 | 1111 | | |
1107 | 1112 | | |
1108 | 1113 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
795 | 795 | | |
796 | 796 | | |
797 | 797 | | |
798 | | - | |
799 | | - | |
| 798 | + | |
800 | 799 | | |
801 | 800 | | |
802 | 801 | | |
| |||
864 | 863 | | |
865 | 864 | | |
866 | 865 | | |
867 | | - | |
| 866 | + | |
868 | 867 | | |
869 | 868 | | |
870 | 869 | | |
| |||
0 commit comments