]> git.lizzy.rs Git - rust.git/commit - src/tools/miri
Rollup merge of #87166 - de-vri-es:show-discriminant-before-overflow, r=jackh726
authorGuillaume Gomez <guillaume1.gomez@gmail.com>
Sun, 22 Aug 2021 18:52:51 +0000 (20:52 +0200)
committerGitHub <noreply@github.com>
Sun, 22 Aug 2021 18:52:51 +0000 (20:52 +0200)
commit3b1e7b1fc9853497140f7f5371882234f0295893
treeac00ffb1283c9807767e2dd2ebac82f4bd6b64eb
parent2627db6a3cc4115cc3ff7a1597eb44347acb0c54
parent4c0ff4db80d2c6cb4dc204f65f34ce2246e27bfe
Rollup merge of #87166 - de-vri-es:show-discriminant-before-overflow, r=jackh726

Show discriminant before overflow in diagnostic for duplicate values.

This PR adds the value before overflow for explicit discriminant values in the error for duplicate discriminant values.
I found it rather confusing to see only the overflowed value.

It only does this for literals, since overflows in const evaluated arithmetic are already a hard error.

This is my first PR to the compiler, so please let me know if the implementation can be improved :)

Before:
![image](https://user-images.githubusercontent.com/786213/125850097-bf5fb7e0-d800-4386-a738-c30f41822964.png)

After:
![image](https://user-images.githubusercontent.com/786213/125850120-e2bb765d-ad86-4888-a6cb-dec34fba3fea.png)
compiler/rustc_typeck/src/check/check.rs