use super::RESULT_UNIT_ERR;
-pub(super) fn check_item(cx: &LateContext<'tcx>, item: &'tcx hir::Item<'_>) {
- if let hir::ItemKind::Fn(ref sig, ref _generics, _) = item.kind {
- let is_public = cx.access_levels.is_exported(item.hir_id());
+pub(super) fn check_item(cx: &LateContext<'_>, item: &hir::Item<'_>) {
+ if let hir::ItemKind::Fn(ref sig, _generics, _) = item.kind {
+ let is_public = cx.access_levels.is_exported(item.def_id);
let fn_header_span = item.span.with_hi(sig.decl.output.span().hi());
if is_public {
- check_result_unit_err(cx, &sig.decl, item.span, fn_header_span);
+ check_result_unit_err(cx, sig.decl, item.span, fn_header_span);
}
}
}
-pub(super) fn check_impl_item(cx: &LateContext<'tcx>, item: &'tcx hir::ImplItem<'_>) {
+pub(super) fn check_impl_item(cx: &LateContext<'_>, item: &hir::ImplItem<'_>) {
if let hir::ImplItemKind::Fn(ref sig, _) = item.kind {
- let is_public = cx.access_levels.is_exported(item.hir_id());
+ let is_public = cx.access_levels.is_exported(item.def_id);
let fn_header_span = item.span.with_hi(sig.decl.output.span().hi());
- if is_public && trait_ref_of_method(cx, item.hir_id()).is_none() {
- check_result_unit_err(cx, &sig.decl, item.span, fn_header_span);
+ if is_public && trait_ref_of_method(cx, item.def_id).is_none() {
+ check_result_unit_err(cx, sig.decl, item.span, fn_header_span);
}
}
}
-pub(super) fn check_trait_item(cx: &LateContext<'tcx>, item: &'tcx hir::TraitItem<'_>) {
+pub(super) fn check_trait_item(cx: &LateContext<'_>, item: &hir::TraitItem<'_>) {
if let hir::TraitItemKind::Fn(ref sig, _) = item.kind {
- let is_public = cx.access_levels.is_exported(item.hir_id());
+ let is_public = cx.access_levels.is_exported(item.def_id);
let fn_header_span = item.span.with_hi(sig.decl.output.span().hi());
if is_public {
- check_result_unit_err(cx, &sig.decl, item.span, fn_header_span);
+ check_result_unit_err(cx, sig.decl, item.span, fn_header_span);
}
}
}
fn check_result_unit_err(cx: &LateContext<'_>, decl: &hir::FnDecl<'_>, item_span: Span, fn_header_span: Span) {
if_chain! {
if !in_external_macro(cx.sess(), item_span);
- if let hir::FnRetTy::Return(ref ty) = decl.output;
+ if let hir::FnRetTy::Return(ty) = decl.output;
let ty = hir_ty_to_ty(cx.tcx, ty);
- if is_type_diagnostic_item(cx, ty, sym::result_type);
+ if is_type_diagnostic_item(cx, ty, sym::Result);
if let ty::Adt(_, substs) = ty.kind();
let err_ty = substs.type_at(1);
if err_ty.is_unit();
cx,
RESULT_UNIT_ERR,
fn_header_span,
- "this returns a `Result<_, ()>",
+ "this returns a `Result<_, ()>`",
None,
- "use a custom Error type instead",
+ "use a custom `Error` type instead",
);
}
}