Commit 7750c3d
committed
Auto merge of rust-lang#73513 - oli-obk:const_binop_overflow, r=estebank
Show the values and computation that would overflow a const evaluation or propagation
Fixes rust-lang#71134
In contrast to the example in the issue it doesn't use individual spans for each operand. The effort required to implement that is quite high compared to the little (if at all) benefit it would bring to diagnostics.
cc @shepmaster
The way this is implemented it is also fairly easy to do the same for overflow panics at runtime, but that should be done in a separate PR since it may have runtime performance implications.File tree
202 files changed
+1273
-986
lines changed- src
- librustc_codegen_ssa/mir
- librustc_middle
- mir
- ty
- print
- librustc_mir_build/build/expr
- librustc_mir
- const_eval
- interpret
- transform
- librustdoc/clean
- test
- mir-opt
- address-of
- array-index-is-temporary
- 32bit
- 64bit
- byte_slice
- combine_array_len
- 32bit
- 64bit
- const_prop_miscompile
- const_prop
- aggregate
- array_index
- 32bit
- 64bit
- bad_op_div_by_zero
- bad_op_mod_by_zero
- bad_op_unsafe_oob_for_slices
- 32bit
- 64bit
- boxes
- cast
- checked_add
- discriminant
- 32bit
- 64bit
- indirect
- issue-66971
- issue-67019
- mutable_variable_aggregate_mut_ref
- mutable_variable_aggregate_partial_read
- mutable_variable_aggregate
- mutable_variable_no_prop
- mutable_variable_unprop_assign
- mutable_variable
- optimizes_into_variable
- 32bit
- 64bit
- read_immutable_static
- ref_deref_project
- ref_deref
- repeat
- 32bit
- 64bit
- return_place
- scalar_literal_propagation
- slice_len
- 32bit
- 64bit
- switch_int
- tuple_literal_propagation
- copy_propagation_arg
- exponential-or
- generator-drop-cleanup
- generator-storage-dead-unwind
- generator-tiny
- inline
- inline-any-operand
- inline-into-box-place
- 32bit
- 64bit
- inline-specialization
- instrument_coverage
- issue-41697
- 32bit
- 64bit
- issue-41888
- issue-49232
- issue-62289
- issue-72181
- 32bit
- 64bit
- loop_test
- match-arm-scopes
- match_false_edges
- match_test
- no-drop-for-inactive-variant
- nrvo-simple
- packed-struct-drop-aligned
- 32bit
- 64bit
- remove_fake_borrows
- retag
- simple-match
- 32bit
- 64bit
- simplify-arm-identity
- 32bit
- 64bit
- simplify-arm
- simplify-locals-fixedpoint
- simplify-locals-removes-unused-consts
- simplify-locals-removes-unused-discriminant-reads
- 32bit
- 64bit
- simplify_try_if_let
- simplify_try
- slice-drop-shim
- 32bit
- 64bit
- storage_live_dead_in_statics
- storage_ranges
- tls-access
- uniform_array_move_out
- uninhabited_enum_branching
- unreachable_asm_2
- unreachable_asm
- unreachable_diverging
- unreachable
- unusual-item-types
- 32bit
- 64bit
- rustdoc/const-generics
- ui
- array-slice-vec
- associated-const
- const-generics
- array-impls
- consts
- const-eval
- error-codes
- for
- half-open-range-patterns
- issues
- lint
- mir
- numbers-arithmetic
- or-patterns
- pattern/usefulness
- suggestions
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
202 files changed
+1273
-986
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
380 | 380 | | |
381 | 381 | | |
382 | 382 | | |
383 | | - | |
| 383 | + | |
384 | 384 | | |
385 | 385 | | |
386 | 386 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
5 | 7 | | |
6 | 8 | | |
7 | 9 | | |
| |||
1246 | 1248 | | |
1247 | 1249 | | |
1248 | 1250 | | |
1249 | | - | |
1250 | | - | |
1251 | | - | |
1252 | | - | |
| 1251 | + | |
| 1252 | + | |
| 1253 | + | |
| 1254 | + | |
1253 | 1255 | | |
1254 | 1256 | | |
1255 | 1257 | | |
| |||
1522 | 1524 | | |
1523 | 1525 | | |
1524 | 1526 | | |
1525 | | - | |
1526 | | - | |
1527 | | - | |
1528 | | - | |
1529 | | - | |
1530 | | - | |
1531 | | - | |
1532 | | - | |
1533 | | - | |
1534 | | - | |
1535 | | - | |
| 1527 | + | |
| 1528 | + | |
| 1529 | + | |
| 1530 | + | |
| 1531 | + | |
| 1532 | + | |
| 1533 | + | |
| 1534 | + | |
| 1535 | + | |
| 1536 | + | |
| 1537 | + | |
1536 | 1538 | | |
1537 | 1539 | | |
1538 | 1540 | | |
| |||
1546 | 1548 | | |
1547 | 1549 | | |
1548 | 1550 | | |
| 1551 | + | |
1549 | 1552 | | |
1550 | | - | |
| 1553 | + | |
1551 | 1554 | | |
1552 | 1555 | | |
1553 | 1556 | | |
1554 | 1557 | | |
| 1558 | + | |
| 1559 | + | |
| 1560 | + | |
| 1561 | + | |
| 1562 | + | |
| 1563 | + | |
| 1564 | + | |
| 1565 | + | |
| 1566 | + | |
| 1567 | + | |
| 1568 | + | |
| 1569 | + | |
| 1570 | + | |
| 1571 | + | |
| 1572 | + | |
| 1573 | + | |
| 1574 | + | |
| 1575 | + | |
| 1576 | + | |
| 1577 | + | |
| 1578 | + | |
| 1579 | + | |
| 1580 | + | |
| 1581 | + | |
| 1582 | + | |
| 1583 | + | |
| 1584 | + | |
| 1585 | + | |
| 1586 | + | |
| 1587 | + | |
| 1588 | + | |
| 1589 | + | |
| 1590 | + | |
| 1591 | + | |
| 1592 | + | |
| 1593 | + | |
| 1594 | + | |
| 1595 | + | |
| 1596 | + | |
| 1597 | + | |
| 1598 | + | |
1555 | 1599 | | |
1556 | 1600 | | |
1557 | 1601 | | |
| |||
1564 | 1608 | | |
1565 | 1609 | | |
1566 | 1610 | | |
| 1611 | + | |
| 1612 | + | |
| 1613 | + | |
| 1614 | + | |
| 1615 | + | |
| 1616 | + | |
| 1617 | + | |
| 1618 | + | |
| 1619 | + | |
| 1620 | + | |
| 1621 | + | |
| 1622 | + | |
| 1623 | + | |
| 1624 | + | |
| 1625 | + | |
| 1626 | + | |
| 1627 | + | |
| 1628 | + | |
| 1629 | + | |
| 1630 | + | |
| 1631 | + | |
| 1632 | + | |
| 1633 | + | |
| 1634 | + | |
| 1635 | + | |
| 1636 | + | |
| 1637 | + | |
| 1638 | + | |
1567 | 1639 | | |
1568 | 1640 | | |
1569 | 1641 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
| 61 | + | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
70 | 69 | | |
71 | 70 | | |
72 | 71 | | |
| |||
117 | 116 | | |
118 | 117 | | |
119 | 118 | | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
126 | 124 | | |
127 | 125 | | |
128 | 126 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
571 | 571 | | |
572 | 572 | | |
573 | 573 | | |
574 | | - | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
575 | 581 | | |
576 | 582 | | |
577 | 583 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
| 87 | + | |
| 88 | + | |
87 | 89 | | |
88 | 90 | | |
89 | 91 | | |
| |||
108 | 110 | | |
109 | 111 | | |
110 | 112 | | |
| 113 | + | |
111 | 114 | | |
112 | 115 | | |
113 | 116 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | | - | |
4 | | - | |
| 2 | + | |
5 | 3 | | |
6 | 4 | | |
7 | | - | |
| 5 | + | |
8 | 6 | | |
9 | 7 | | |
10 | 8 | | |
| |||
981 | 979 | | |
982 | 980 | | |
983 | 981 | | |
984 | | - | |
985 | | - | |
986 | | - | |
987 | | - | |
988 | | - | |
989 | | - | |
990 | | - | |
991 | | - | |
992 | | - | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
993 | 985 | | |
994 | 986 | | |
995 | 987 | | |
996 | | - | |
997 | | - | |
998 | | - | |
999 | | - | |
1000 | | - | |
1001 | | - | |
1002 | | - | |
1003 | | - | |
1004 | | - | |
1005 | | - | |
1006 | | - | |
1007 | | - | |
1008 | | - | |
1009 | | - | |
1010 | | - | |
1011 | | - | |
1012 | | - | |
| 988 | + | |
| 989 | + | |
1013 | 990 | | |
1014 | 991 | | |
1015 | 992 | | |
| |||
0 commit comments