[rust-dev] Warn about implicit integer conversion

Brian Anderson banderson at mozilla.com
Tue Dec 18 12:56:04 PST 2012

On 12/18/2012 10:35 AM, Michael Neumann wrote:
> Hi,
>   let a: u8 = 10_000; // this does not fit inside u8!
>   io::println(fmt!("%?", a)); // print "10"
> I would have expected that rust would warn me if I try to assign an 
> integer constant that doesn't fit into the types range.
> Maybe there exists a warning that I can enable?

This is a surprise to me too. Perhaps the compiler just doesn't do this 
check yet. There is a lint check called type_limits that is enabled by 
default but it only deals with comparison operators.

More information about the Rust-dev mailing list