]> git.lizzy.rs Git - rust.git/commitdiff
Suggest `into` to convert into `isize` only if uint is of width 8
authorSamrat Man Singh <samratmansingh@gmail.com>
Tue, 28 Apr 2020 15:57:14 +0000 (21:27 +0530)
committerSamrat Man Singh <samratmansingh@gmail.com>
Tue, 28 Apr 2020 16:10:03 +0000 (21:40 +0530)
Since Into<isize> is not implemented for uint of width greater than 8

src/librustc_typeck/check/demand.rs

index 980aefa710ff597b986fd36963bfbcaa37027438..aa36bec6e1e8813f5d543f108f0c59d5bbfeb4ca 100644 (file)
@@ -770,12 +770,12 @@ pub fn check_for_cast(
                 (&ty::Int(exp), &ty::Uint(found)) => {
                     let is_fallible = match (exp.bit_width(), found.bit_width()) {
                         (Some(exp), Some(found)) if found < exp => false,
-                        (None, Some(found)) if found <= 16 => false,
-                        _ => true
+                        (None, Some(8)) => false,
+                        _ => true,
                     };
                     suggest_to_change_suffix_or_into(err, is_fallible);
                     true
-                },
+                }
                 (&ty::Uint(_), &ty::Int(_)) => {
                     suggest_to_change_suffix_or_into(err, true);
                     true