rust/compiler/rustc_lint
Matthias Krüger 8f9ccc5d1b
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.
2025-01-16 17:00:46 +01:00
..
src Rollup merge of #135249 - s-cerevisiae:fix-overflowing-literals-help, r=chenyukang 2025-01-16 17:00:46 +01:00
Cargo.toml rename rustc_attr to rustc_attr_parsing and create rustc_attr_data_structures 2024-12-16 19:08:19 +01:00
messages.ftl Rollup merge of #134202 - nnethercote:rm-existing_doc_keyword, r=GuillaumeGomez 2024-12-17 05:36:52 -05:00