Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-ty/src/layout/adt.rs')
-rw-r--r--crates/hir-ty/src/layout/adt.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/crates/hir-ty/src/layout/adt.rs b/crates/hir-ty/src/layout/adt.rs
index 1f321af794..777d0803fc 100644
--- a/crates/hir-ty/src/layout/adt.rs
+++ b/crates/hir-ty/src/layout/adt.rs
@@ -142,8 +142,8 @@ fn repr_discr(
Integer::I8
};
- // If there are no negative values, we can use the unsigned fit.
- Ok(if min >= 0 {
+ // `min` and `max` are the ends of a wrapping range, so their sign is not a usable test.
+ Ok(if unsigned_fit <= signed_fit {
(cmp::max(unsigned_fit, at_least), false)
} else {
(cmp::max(signed_fit, at_least), true)