X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=clippy_lints%2Fsrc%2Funnecessary_wraps.rs;h=83ef3b0fac8741fb6f46cf8f1c2724f15ddba649;hb=c153bd62377f3c563b9f6e9d6ba7742523c45209;hp=1728533f18b858caeb6b9814f37ff2dcdbbc5e78;hpb=731dfde26779dff941868c7678a2f7716f5f4223;p=rust.git diff --git a/clippy_lints/src/unnecessary_wraps.rs b/clippy_lints/src/unnecessary_wraps.rs index 1728533f18b..83ef3b0fac8 100644 --- a/clippy_lints/src/unnecessary_wraps.rs +++ b/clippy_lints/src/unnecessary_wraps.rs @@ -102,9 +102,9 @@ fn check_fn( // Get the wrapper and inner types, if can't, abort. let (return_type_label, lang_item, inner_type) = if let ty::Adt(adt_def, subst) = return_ty(cx, hir_id).kind() { - if cx.tcx.is_diagnostic_item(sym::Option, adt_def.did) { + if cx.tcx.is_diagnostic_item(sym::Option, adt_def.did()) { ("Option", OptionSome, subst.type_at(0)) - } else if cx.tcx.is_diagnostic_item(sym::Result, adt_def.did) { + } else if cx.tcx.is_diagnostic_item(sym::Result, adt_def.did()) { ("Result", ResultOk, subst.type_at(0)) } else { return; @@ -115,7 +115,7 @@ fn check_fn( // Check if all return expression respect the following condition and collect them. let mut suggs = Vec::new(); - let can_sugg = find_all_ret_expressions(cx, &body.value, |ret_expr| { + let can_sugg = find_all_ret_expressions(cx, body.value, |ret_expr| { if_chain! { if !ret_expr.span.from_expansion(); // Check if a function call. @@ -130,7 +130,7 @@ fn check_fn( ( ret_expr.span, if inner_type.is_unit() { - "".to_string() + String::new() } else { snippet(cx, arg.span.source_callsite(), "..").to_string() } @@ -153,11 +153,8 @@ fn check_fn( ) } else { ( - format!( - "this function's return value is unnecessarily wrapped by `{}`", - return_type_label - ), - format!("remove `{}` from the return type...", return_type_label), + format!("this function's return value is unnecessarily wrapped by `{return_type_label}`"), + format!("remove `{return_type_label}` from the return type..."), inner_type.to_string(), "...and then change returning expressions", )