mirror of
https://github.com/rust-lang/rust-clippy
synced 2025-02-17 14:38:46 +00:00
Fix 'help' message
This commit is contained in:
parent
b69520f5fd
commit
e6811b9c26
2 changed files with 3 additions and 11 deletions
|
@ -1003,7 +1003,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CastPass {
|
||||||
FN_TO_NUMERIC_CAST,
|
FN_TO_NUMERIC_CAST,
|
||||||
expr.span,
|
expr.span,
|
||||||
&format!("casting a `{}` to `{}` may truncate the function address value.", cast_from, cast_to),
|
&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"))
|
format!("{} as usize", &snippet(cx, ex.span, "x"))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
--> $DIR/types_fn_to_int.rs:12:13
|
||||||
|
|
|
|
||||||
12 | let y = x as i32;
|
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
|
= 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.
|
error: casting a `fn() -> i32 {bar}` to `u32` may truncate the function address value.
|
||||||
--> $DIR/types_fn_to_int.rs:14:13
|
--> $DIR/types_fn_to_int.rs:14:13
|
||||||
|
|
|
|
||||||
14 | let z = bar as u32;
|
14 | let z = bar as u32;
|
||||||
| ^^^^^^^^^^
|
| ^^^^^^^^^^ help: if you need the address of the function, consider: `bar as usize`
|
||||||
help: if you need the address of the function, consider :
|
|
||||||
|
|
|
||||||
14 | let z = bar as usize;
|
|
||||||
| ^^^^^^^^^^^^
|
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue