about summary refs log tree commit diff
diff options
context:
space:
mode:
authorYashhwanth Ram <ryr397@gmail.com>2020-04-10 18:37:44 +0530
committerYashhwanth Ram <ryr397@gmail.com>2020-04-10 18:59:06 +0530
commitb3c9912dbad13d7a3c369df4913e36d7fd7315ad (patch)
treed2a295b5dc0a81be728461fff115bfb7293ddeb7
parent39b62533c7f9d0581a6ea9b9fc2cc51f21c3b5b0 (diff)
downloadrust-b3c9912dbad13d7a3c369df4913e36d7fd7315ad.tar.gz
rust-b3c9912dbad13d7a3c369df4913e36d7fd7315ad.zip
Suggest x.into() when it is a better choice than x.try_into() when
converting ints in librustc_typeck
Fixes #70851
-rw-r--r--src/librustc_typeck/check/demand.rs2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/librustc_typeck/check/demand.rs b/src/librustc_typeck/check/demand.rs
index 369bb183bcd..7ef4bfb0141 100644
--- a/src/librustc_typeck/check/demand.rs
+++ b/src/librustc_typeck/check/demand.rs
@@ -755,6 +755,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
                 (&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 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
                 (&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,
                     };