# \[Pre-RFC\] Implicit number type widening

**URL:** <https://internals.rust-lang.org/t/pre-rfc-implicit-number-type-widening/10432>\
**Category:** Uncategorized\
**Created:** [June 19, 2019, 8:12pm UTC](https://internals.rust-lang.org/t/pre-rfc-implicit-number-type-widening/10432 "2019-06-19T20:12:01Z")\
**Posts on this page:** 1\
**Showing post:** 56

<div class="post-metadata">

**Author:** ![Dushistov](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/dushistov/32/4046_2.png) [@Dushistov](https://internals.rust-lang.org/u/Dushistov)\
**Post date:** [June 29, 2019, 8:13pm UTC](https://internals.rust-lang.org/t/pre-rfc-implicit-number-type-widening/10432/56 "2019-06-29T20:13:46Z")

</div>

> [@scottmcm](#):
>
> Can you show an example where it’s a bug and it’s _only_ used in the comparison?

Comparing/assign with two variables with different types are always may be bug. Because of at first you have: `a = b;` or `a == b` and "a" and "b" have the same types. After that you do some refactoring and you get different types, but in fact you want the same types, but you forget change how "b" calculated.

At now Rust works perfectly, like in tech spec for C for safe systems (which require reduce integer promotion, compare and assign different types and so on things).

But if you allow widening _even_ for obvious case:

```rust
let mut a: u16 = x;
let mut b: u8 = y;
a = b;

```

that may prevent compiler to catch bugs that developer missed after refactoring.

> [@scottmcm](#):
>
> I feel like the usual will usually fix such an error today

But you can find such things like usage of "as" in some cases, "unsafe" in some other cases. While with automatic widening there is no even clue what is wrong here during code reading.

---

_[View the full topic](https://internals.rust-lang.org/t/pre-rfc-implicit-number-type-widening/10432)._
