]> git.lizzy.rs Git - rust.git/blobdiff - src/test/ui/wrong-ret-type.stderr
Auto merge of #75936 - sdroege:chunks-exact-construction-bounds-check, r=nagisa
[rust.git] / src / test / ui / wrong-ret-type.stderr
index 440620f40b1e26525fc244ccef430b4aef5fdc83..c1274bd0ea6bc3226bdb8a7ca79e3780ad46ebac 100644 (file)
@@ -5,6 +5,11 @@ LL | fn mk_int() -> usize { let i: isize = 3; return i; }
    |                -----                            ^ expected `usize`, found `isize`
    |                |
    |                expected `usize` because of return type
+   |
+help: you can convert an `isize` to `usize` and panic if the converted value wouldn't fit
+   |
+LL | fn mk_int() -> usize { let i: isize = 3; return i.try_into().unwrap(); }
+   |                                                 ^^^^^^^^^^^^^^^^^^^^^
 
 error: aborting due to previous error