Auto merge of #73513 - oli-obk:const_binop_overflow, r=estebank
Show the values and computation that would overflow a const evaluation or propagation Fixes #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.
This commit is contained in:
commit
7750c3d46b
202 changed files with 1286 additions and 999 deletions
|
@ -481,8 +481,8 @@ pub fn print_const(cx: &DocContext<'_>, n: &'tcx ty::Const<'_>) -> String {
|
|||
_ => {
|
||||
let mut s = n.to_string();
|
||||
// array lengths are obviously usize
|
||||
if s.ends_with("usize") {
|
||||
let n = s.len() - "usize".len();
|
||||
if s.ends_with("_usize") {
|
||||
let n = s.len() - "_usize".len();
|
||||
s.truncate(n);
|
||||
if s.ends_with(": ") {
|
||||
let n = s.len() - ": ".len();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue