Skip to content

Commit b3c9912

Browse files
committed
Suggest x.into() when it is a better choice than x.try_into() when
converting ints in librustc_typeck Fixes #70851
1 parent 39b6253 commit b3c9912

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/librustc_typeck/check/demand.rs

+2
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
755755
(&ty::Int(ref exp), &ty::Int(ref found)) => {
756756
let is_fallible = match (found.bit_width(), exp.bit_width()) {
757757
(Some(found), Some(exp)) if found > exp => true,
758+
(None, Some(8 | 16)) | (Some(8 | 16), None) => false,
758759
(None, _) | (_, None) => true,
759760
_ => false,
760761
};
@@ -764,6 +765,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
764765
(&ty::Uint(ref exp), &ty::Uint(ref found)) => {
765766
let is_fallible = match (found.bit_width(), exp.bit_width()) {
766767
(Some(found), Some(exp)) if found > exp => true,
768+
(None, Some(8 | 16)) | (Some(8 | 16), None) => false,
767769
(None, _) | (_, None) => true,
768770
_ => false,
769771
};

0 commit comments

Comments
 (0)