]> git.lizzy.rs Git - rust.git/commitdiff
Suggest x.into() when it is a better choice than x.try_into() when
authorYashhwanth Ram <ryr397@gmail.com>
Fri, 10 Apr 2020 13:07:44 +0000 (18:37 +0530)
committerYashhwanth Ram <ryr397@gmail.com>
Fri, 10 Apr 2020 13:29:06 +0000 (18:59 +0530)
converting ints in librustc_typeck
Fixes #70851

src/librustc_typeck/check/demand.rs

index 369bb183bcd739f942b97e6bc5184256c4d0a4c2..7ef4bfb01418aa3c0165f5c917c4ba3f2c02f62d 100644 (file)
@@ -755,6 +755,7 @@ pub fn check_for_cast(
                 (&ty::Int(ref exp), &ty::Int(ref found)) => {
                     let is_fallible = match (found.bit_width(), exp.bit_width()) {
                         (Some(found), Some(exp)) if found > exp => true,
+                        (None, Some(8 | 16)) | (Some(8 | 16), None) => false,
                         (None, _) | (_, None) => true,
                         _ => false,
                     };
@@ -764,6 +765,7 @@ pub fn check_for_cast(
                 (&ty::Uint(ref exp), &ty::Uint(ref found)) => {
                     let is_fallible = match (found.bit_width(), exp.bit_width()) {
                         (Some(found), Some(exp)) if found > exp => true,
+                        (None, Some(8 | 16)) | (Some(8 | 16), None) => false,
                         (None, _) | (_, None) => true,
                         _ => false,
                     };