mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-10 07:04:18 +00:00
Check for get method and new test case in unfixable
This commit is contained in:
parent
d43acb803f
commit
af3346a85f
3 changed files with 5 additions and 1 deletions
|
@ -72,6 +72,7 @@ fn check_non_zero_conversion(cx: &LateContext<'_>, expr: &Expr<'_>, applicabilit
|
|||
&& let ExprKind::Path(qpath) = &func.kind
|
||||
&& let Some(def_id) = cx.qpath_res(qpath, func.hir_id).opt_def_id()
|
||||
&& let ExprKind::MethodCall(rcv_path, receiver, _, _) = &arg.kind
|
||||
&& rcv_path.ident.name.as_str() == "get"
|
||||
{
|
||||
let fn_name = cx.tcx.item_name(def_id);
|
||||
let target_ty = cx.typeck_results().expr_ty(expr);
|
||||
|
|
|
@ -10,6 +10,9 @@ fn main() {
|
|||
let y = u64::from(n.get());
|
||||
//~^ ERROR: consider using `NonZeroU64::from()` for more efficient and type-safe conversion
|
||||
some_fn_that_only_takes_u64(y);
|
||||
|
||||
let m = NonZeroU32::try_from(1).unwrap();
|
||||
let _z: NonZeroU64 = m.into();
|
||||
}
|
||||
|
||||
fn return_non_zero(x: u64, y: NonZeroU32) -> u64 {
|
||||
|
|
|
@ -14,7 +14,7 @@ LL | let y = u64::from(n.get());
|
|||
| ^^^^^^^^^^^^^^^^^^ help: replace with: `NonZeroU64::from(n)`
|
||||
|
||||
error: consider using `NonZeroU64::from()` for more efficient and type-safe conversion
|
||||
--> tests/ui/non_zero_suggestions_unfixable.rs:16:5
|
||||
--> tests/ui/non_zero_suggestions_unfixable.rs:19:5
|
||||
|
|
||||
LL | u64::from(y.get())
|
||||
| ^^^^^^^^^^^^^^^^^^ help: replace with: `NonZeroU64::from(y)`
|
||||
|
|
Loading…
Reference in a new issue