Fix 'help' message

This commit is contained in:
Victor Korkin 2018-05-30 16:55:03 +07:00
parent b69520f5fd
commit e6811b9c26
2 changed files with 3 additions and 11 deletions

View file

@ -1003,7 +1003,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CastPass {
FN_TO_NUMERIC_CAST,
expr.span,
&format!("casting a `{}` to `{}` may truncate the function address value.", cast_from, cast_to),
"if you need the address of the function, consider :",
"if you need the address of the function, consider",
format!("{} as usize", &snippet(cx, ex.span, "x"))
);
}

View file

@ -2,23 +2,15 @@ error: casting a `fn(usize) -> Foo {Foo::A}` to `i32` may truncate the function
--> $DIR/types_fn_to_int.rs:12:13
|
12 | let y = x as i32;
| ^^^^^^^^
| ^^^^^^^^ help: if you need the address of the function, consider: `x as usize`
|
= note: #[deny(fn_to_numeric_cast)] on by default
help: if you need the address of the function, consider :
|
12 | let y = x as usize;
| ^^^^^^^^^^
error: casting a `fn() -> i32 {bar}` to `u32` may truncate the function address value.
--> $DIR/types_fn_to_int.rs:14:13
|
14 | let z = bar as u32;
| ^^^^^^^^^^
help: if you need the address of the function, consider :
|
14 | let z = bar as usize;
| ^^^^^^^^^^^^
| ^^^^^^^^^^ help: if you need the address of the function, consider: `bar as usize`
error: aborting due to 2 previous errors