about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2025-01-16 17:00:46 +0100
committerGitHub <noreply@github.com>2025-01-16 17:00:46 +0100
commit8f9ccc5d1b3ebc517037d6e6edf47a242edb243d (patch)
tree38af5e1fd48e2818c5b7f3f000620e3ade8f50f3 /compiler/rustc_codegen_llvm/src
parent87b3671ce9095216a1466e2718956b06977ddba0 (diff)
parent74e2e8b59834aede7aafee57e00ede07ae13739b (diff)
downloadrust-8f9ccc5d1b3ebc517037d6e6edf47a242edb243d.tar.gz
rust-8f9ccc5d1b3ebc517037d6e6edf47a242edb243d.zip
Rollup merge of #135249 - s-cerevisiae:fix-overflowing-literals-help, r=chenyukang
Fix overflows in the implementation of `overflowing_literals` lint's help

This PR fixes two overflow problems that cause the `overflowing_literals` lint to behave incorrectly in some edge cases.

1. When an integer literal is between `i128::MAX` and `u128::MAX`, an overflowing `as` cast can cause the suggested type to be overly small. It's fixed by using checked type conversion and returning `u128` when it's the only choice. (Fixes #135248)
2. When an integer literal is `i128::MIN` but is of a smaller type, an overflowing negation cause the compiler to panic in debug build. Fixed by checking the number size beforehand and `wrapping_neg`. (Fixes #131849)

Edit: extracted the type conversion part into a standalone function to separate the concern of overflowing.
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
0 files changed, 0 insertions, 0 deletions