Only store a LocalDefId in hir::ImplItem.
This commit is contained in:
parent
fc9bc33bba
commit
dbe7609414
16 changed files with 36 additions and 47 deletions
|
@ -258,14 +258,13 @@ impl<'tcx> LateLintPass<'tcx> for DocMarkdown {
|
||||||
}
|
}
|
||||||
if let hir::ImplItemKind::Fn(ref sig, body_id) = item.kind {
|
if let hir::ImplItemKind::Fn(ref sig, body_id) = item.kind {
|
||||||
let body = cx.tcx.hir().body(body_id);
|
let body = cx.tcx.hir().body(body_id);
|
||||||
let impl_item_def_id = cx.tcx.hir().local_def_id(item.hir_id);
|
|
||||||
let mut fpu = FindPanicUnwrap {
|
let mut fpu = FindPanicUnwrap {
|
||||||
cx,
|
cx,
|
||||||
typeck_results: cx.tcx.typeck(impl_item_def_id),
|
typeck_results: cx.tcx.typeck(item.def_id),
|
||||||
panic_span: None,
|
panic_span: None,
|
||||||
};
|
};
|
||||||
fpu.visit_expr(&body.value);
|
fpu.visit_expr(&body.value);
|
||||||
lint_for_missing_headers(cx, item.hir_id, item.span, sig, headers, Some(body_id), fpu.panic_span);
|
lint_for_missing_headers(cx, item.hir_id(), item.span, sig, headers, Some(body_id), fpu.panic_span);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,10 +116,9 @@ fn lint_impl_body<'tcx>(cx: &LateContext<'tcx>, impl_span: Span, impl_items: &[h
|
||||||
then {
|
then {
|
||||||
// check the body for `begin_panic` or `unwrap`
|
// check the body for `begin_panic` or `unwrap`
|
||||||
let body = cx.tcx.hir().body(body_id);
|
let body = cx.tcx.hir().body(body_id);
|
||||||
let impl_item_def_id = cx.tcx.hir().local_def_id(impl_item.id.hir_id);
|
|
||||||
let mut fpu = FindPanicUnwrap {
|
let mut fpu = FindPanicUnwrap {
|
||||||
lcx: cx,
|
lcx: cx,
|
||||||
typeck_results: cx.tcx.typeck(impl_item_def_id),
|
typeck_results: cx.tcx.typeck(impl_item.id.def_id),
|
||||||
result: Vec::new(),
|
result: Vec::new(),
|
||||||
};
|
};
|
||||||
fpu.visit_expr(&body.value);
|
fpu.visit_expr(&body.value);
|
||||||
|
|
|
@ -308,24 +308,24 @@ impl<'tcx> LateLintPass<'tcx> for Functions {
|
||||||
|
|
||||||
fn check_impl_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::ImplItem<'_>) {
|
fn check_impl_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::ImplItem<'_>) {
|
||||||
if let hir::ImplItemKind::Fn(ref sig, ref body_id) = item.kind {
|
if let hir::ImplItemKind::Fn(ref sig, ref body_id) = item.kind {
|
||||||
let is_public = cx.access_levels.is_exported(item.hir_id);
|
let is_public = cx.access_levels.is_exported(item.hir_id());
|
||||||
let fn_header_span = item.span.with_hi(sig.decl.output.span().hi());
|
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() {
|
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);
|
check_result_unit_err(cx, &sig.decl, item.span, fn_header_span);
|
||||||
}
|
}
|
||||||
let attr = must_use_attr(&item.attrs);
|
let attr = must_use_attr(&item.attrs);
|
||||||
if let Some(attr) = attr {
|
if let Some(attr) = attr {
|
||||||
check_needless_must_use(cx, &sig.decl, item.hir_id, item.span, fn_header_span, attr);
|
check_needless_must_use(cx, &sig.decl, item.hir_id(), item.span, fn_header_span, attr);
|
||||||
} else if is_public
|
} else if is_public
|
||||||
&& !is_proc_macro(cx.sess(), &item.attrs)
|
&& !is_proc_macro(cx.sess(), &item.attrs)
|
||||||
&& trait_ref_of_method(cx, item.hir_id).is_none()
|
&& trait_ref_of_method(cx, item.hir_id()).is_none()
|
||||||
{
|
{
|
||||||
check_must_use_candidate(
|
check_must_use_candidate(
|
||||||
cx,
|
cx,
|
||||||
&sig.decl,
|
&sig.decl,
|
||||||
cx.tcx.hir().body(*body_id),
|
cx.tcx.hir().body(*body_id),
|
||||||
item.span,
|
item.span,
|
||||||
item.hir_id,
|
item.hir_id(),
|
||||||
item.span.with_hi(sig.decl.output.span().hi()),
|
item.span.with_hi(sig.decl.output.span().hi()),
|
||||||
"this method could have a `#[must_use]` attribute",
|
"this method could have a `#[must_use]` attribute",
|
||||||
);
|
);
|
||||||
|
|
|
@ -108,10 +108,10 @@ impl<'tcx> LateLintPass<'tcx> for InherentToString {
|
||||||
if decl.inputs.len() == 1;
|
if decl.inputs.len() == 1;
|
||||||
|
|
||||||
// Check if return type is String
|
// Check if return type is String
|
||||||
if is_type_diagnostic_item(cx, return_ty(cx, impl_item.hir_id), sym::string_type);
|
if is_type_diagnostic_item(cx, return_ty(cx, impl_item.hir_id()), sym::string_type);
|
||||||
|
|
||||||
// Filters instances of to_string which are required by a trait
|
// Filters instances of to_string which are required by a trait
|
||||||
if trait_ref_of_method(cx, impl_item.hir_id).is_none();
|
if trait_ref_of_method(cx, impl_item.hir_id()).is_none();
|
||||||
|
|
||||||
then {
|
then {
|
||||||
show_lint(cx, impl_item);
|
show_lint(cx, impl_item);
|
||||||
|
@ -124,8 +124,7 @@ fn show_lint(cx: &LateContext<'_>, item: &ImplItem<'_>) {
|
||||||
let display_trait_id = get_trait_def_id(cx, &paths::DISPLAY_TRAIT).expect("Failed to get trait ID of `Display`!");
|
let display_trait_id = get_trait_def_id(cx, &paths::DISPLAY_TRAIT).expect("Failed to get trait ID of `Display`!");
|
||||||
|
|
||||||
// Get the real type of 'self'
|
// Get the real type of 'self'
|
||||||
let fn_def_id = cx.tcx.hir().local_def_id(item.hir_id);
|
let self_type = cx.tcx.fn_sig(item.def_id).input(0);
|
||||||
let self_type = cx.tcx.fn_sig(fn_def_id).input(0);
|
|
||||||
let self_type = self_type.skip_binder().peel_refs();
|
let self_type = self_type.skip_binder().peel_refs();
|
||||||
|
|
||||||
// Emit either a warning or an error
|
// Emit either a warning or an error
|
||||||
|
|
|
@ -206,17 +206,14 @@ fn check_impl_items(cx: &LateContext<'_>, item: &Item<'_>, impl_items: &[ImplIte
|
||||||
fn is_named_self(cx: &LateContext<'_>, item: &ImplItemRef<'_>, name: &str) -> bool {
|
fn is_named_self(cx: &LateContext<'_>, item: &ImplItemRef<'_>, name: &str) -> bool {
|
||||||
item.ident.name.as_str() == name
|
item.ident.name.as_str() == name
|
||||||
&& if let AssocItemKind::Fn { has_self } = item.kind {
|
&& if let AssocItemKind::Fn { has_self } = item.kind {
|
||||||
has_self && {
|
has_self && cx.tcx.fn_sig(item.id.def_id).inputs().skip_binder().len() == 1
|
||||||
let did = cx.tcx.hir().local_def_id(item.id.hir_id);
|
|
||||||
cx.tcx.fn_sig(did).inputs().skip_binder().len() == 1
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let is_empty = if let Some(is_empty) = impl_items.iter().find(|i| is_named_self(cx, i, "is_empty")) {
|
let is_empty = if let Some(is_empty) = impl_items.iter().find(|i| is_named_self(cx, i, "is_empty")) {
|
||||||
if cx.access_levels.is_exported(is_empty.id.hir_id) {
|
if cx.access_levels.is_exported(is_empty.id.hir_id()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
"a private"
|
"a private"
|
||||||
|
@ -225,7 +222,7 @@ fn check_impl_items(cx: &LateContext<'_>, item: &Item<'_>, impl_items: &[ImplIte
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(i) = impl_items.iter().find(|i| is_named_self(cx, i, "len")) {
|
if let Some(i) = impl_items.iter().find(|i| is_named_self(cx, i, "len")) {
|
||||||
if cx.access_levels.is_exported(i.id.hir_id) {
|
if cx.access_levels.is_exported(i.id.hir_id()) {
|
||||||
let ty = cx.tcx.type_of(item.def_id);
|
let ty = cx.tcx.type_of(item.def_id);
|
||||||
|
|
||||||
span_lint(
|
span_lint(
|
||||||
|
|
|
@ -87,7 +87,7 @@ impl<'tcx> LateLintPass<'tcx> for Lifetimes {
|
||||||
|
|
||||||
fn check_impl_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx ImplItem<'_>) {
|
fn check_impl_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx ImplItem<'_>) {
|
||||||
if let ImplItemKind::Fn(ref sig, id) = item.kind {
|
if let ImplItemKind::Fn(ref sig, id) = item.kind {
|
||||||
let report_extra_lifetimes = trait_ref_of_method(cx, item.hir_id).is_none();
|
let report_extra_lifetimes = trait_ref_of_method(cx, item.hir_id()).is_none();
|
||||||
check_fn_inner(
|
check_fn_inner(
|
||||||
cx,
|
cx,
|
||||||
&sig.decl,
|
&sig.decl,
|
||||||
|
|
|
@ -1685,7 +1685,7 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let name = impl_item.ident.name.as_str();
|
let name = impl_item.ident.name.as_str();
|
||||||
let parent = cx.tcx.hir().get_parent_item(impl_item.hir_id);
|
let parent = cx.tcx.hir().get_parent_item(impl_item.hir_id());
|
||||||
let item = cx.tcx.hir().expect_item(parent);
|
let item = cx.tcx.hir().expect_item(parent);
|
||||||
let self_ty = cx.tcx.type_of(item.def_id);
|
let self_ty = cx.tcx.type_of(item.def_id);
|
||||||
|
|
||||||
|
@ -1698,8 +1698,7 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
|
||||||
if let hir::ImplItemKind::Fn(ref sig, id) = impl_item.kind;
|
if let hir::ImplItemKind::Fn(ref sig, id) = impl_item.kind;
|
||||||
if let Some(first_arg) = iter_input_pats(&sig.decl, cx.tcx.hir().body(id)).next();
|
if let Some(first_arg) = iter_input_pats(&sig.decl, cx.tcx.hir().body(id)).next();
|
||||||
|
|
||||||
let method_def_id = cx.tcx.hir().local_def_id(impl_item.hir_id);
|
let method_sig = cx.tcx.fn_sig(impl_item.def_id);
|
||||||
let method_sig = cx.tcx.fn_sig(method_def_id);
|
|
||||||
let method_sig = cx.tcx.erase_late_bound_regions(method_sig);
|
let method_sig = cx.tcx.erase_late_bound_regions(method_sig);
|
||||||
|
|
||||||
let first_arg_ty = &method_sig.inputs().iter().next();
|
let first_arg_ty = &method_sig.inputs().iter().next();
|
||||||
|
@ -1708,7 +1707,7 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
|
||||||
if let Some(first_arg_ty) = first_arg_ty;
|
if let Some(first_arg_ty) = first_arg_ty;
|
||||||
|
|
||||||
then {
|
then {
|
||||||
if cx.access_levels.is_exported(impl_item.hir_id) {
|
if cx.access_levels.is_exported(impl_item.hir_id()) {
|
||||||
// check missing trait implementations
|
// check missing trait implementations
|
||||||
for method_config in &TRAIT_METHODS {
|
for method_config in &TRAIT_METHODS {
|
||||||
if name == method_config.method_name &&
|
if name == method_config.method_name &&
|
||||||
|
@ -1750,7 +1749,7 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
|
||||||
}
|
}
|
||||||
|
|
||||||
if let hir::ImplItemKind::Fn(_, _) = impl_item.kind {
|
if let hir::ImplItemKind::Fn(_, _) = impl_item.kind {
|
||||||
let ret_ty = return_ty(cx, impl_item.hir_id);
|
let ret_ty = return_ty(cx, impl_item.hir_id());
|
||||||
|
|
||||||
// walk the return type and check for Self (this does not check associated types)
|
// walk the return type and check for Self (this does not check associated types)
|
||||||
if contains_ty(ret_ty, self_ty) {
|
if contains_ty(ret_ty, self_ty) {
|
||||||
|
|
|
@ -171,8 +171,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
|
||||||
|
|
||||||
fn check_impl_item(&mut self, cx: &LateContext<'tcx>, impl_item: &'tcx hir::ImplItem<'_>) {
|
fn check_impl_item(&mut self, cx: &LateContext<'tcx>, impl_item: &'tcx hir::ImplItem<'_>) {
|
||||||
// If the method is an impl for a trait, don't doc.
|
// If the method is an impl for a trait, don't doc.
|
||||||
let def_id = cx.tcx.hir().local_def_id(impl_item.hir_id);
|
match cx.tcx.associated_item(impl_item.def_id).container {
|
||||||
match cx.tcx.associated_item(def_id).container {
|
|
||||||
ty::TraitContainer(_) => return,
|
ty::TraitContainer(_) => return,
|
||||||
ty::ImplContainer(cid) => {
|
ty::ImplContainer(cid) => {
|
||||||
if cx.tcx.impl_trait_ref(cid).is_some() {
|
if cx.tcx.impl_trait_ref(cid).is_some() {
|
||||||
|
@ -181,7 +180,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
let (article, desc) = cx.tcx.article_and_description(def_id.to_def_id());
|
let (article, desc) = cx.tcx.article_and_description(impl_item.def_id.to_def_id());
|
||||||
self.check_missing_docs_attrs(cx, &impl_item.attrs, impl_item.span, article, desc);
|
self.check_missing_docs_attrs(cx, &impl_item.attrs, impl_item.span, article, desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -138,7 +138,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingInline {
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the item being implemented is not exported, then we don't need #[inline]
|
// If the item being implemented is not exported, then we don't need #[inline]
|
||||||
if !cx.access_levels.is_exported(impl_item.hir_id) {
|
if !cx.access_levels.is_exported(impl_item.hir_id()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,14 +147,13 @@ impl<'tcx> LateLintPass<'tcx> for MissingInline {
|
||||||
hir::ImplItemKind::Const(..) | hir::ImplItemKind::TyAlias(_) => return,
|
hir::ImplItemKind::Const(..) | hir::ImplItemKind::TyAlias(_) => return,
|
||||||
};
|
};
|
||||||
|
|
||||||
let def_id = cx.tcx.hir().local_def_id(impl_item.hir_id);
|
let trait_def_id = match cx.tcx.associated_item(impl_item.def_id).container {
|
||||||
let trait_def_id = match cx.tcx.associated_item(def_id).container {
|
|
||||||
TraitContainer(cid) => Some(cid),
|
TraitContainer(cid) => Some(cid),
|
||||||
ImplContainer(cid) => cx.tcx.impl_trait_ref(cid).map(|t| t.def_id),
|
ImplContainer(cid) => cx.tcx.impl_trait_ref(cid).map(|t| t.def_id),
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(trait_def_id) = trait_def_id {
|
if let Some(trait_def_id) = trait_def_id {
|
||||||
if trait_def_id.is_local() && !cx.access_levels.is_exported(impl_item.hir_id) {
|
if trait_def_id.is_local() && !cx.access_levels.is_exported(impl_item.hir_id()) {
|
||||||
// If a trait is being implemented for an item, and the
|
// If a trait is being implemented for an item, and the
|
||||||
// trait is not exported, we don't need #[inline]
|
// trait is not exported, we don't need #[inline]
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -63,8 +63,8 @@ impl<'tcx> LateLintPass<'tcx> for MutableKeyType {
|
||||||
|
|
||||||
fn check_impl_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::ImplItem<'tcx>) {
|
fn check_impl_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::ImplItem<'tcx>) {
|
||||||
if let hir::ImplItemKind::Fn(ref sig, ..) = item.kind {
|
if let hir::ImplItemKind::Fn(ref sig, ..) = item.kind {
|
||||||
if trait_ref_of_method(cx, item.hir_id).is_none() {
|
if trait_ref_of_method(cx, item.hir_id()).is_none() {
|
||||||
check_sig(cx, item.hir_id, &sig.decl);
|
check_sig(cx, item.hir_id(), &sig.decl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@ impl<'tcx> LateLintPass<'tcx> for NewWithoutDefault {
|
||||||
}
|
}
|
||||||
if let hir::ImplItemKind::Fn(ref sig, _) = impl_item.kind {
|
if let hir::ImplItemKind::Fn(ref sig, _) = impl_item.kind {
|
||||||
let name = impl_item.ident.name;
|
let name = impl_item.ident.name;
|
||||||
let id = impl_item.hir_id;
|
let id = impl_item.hir_id();
|
||||||
if sig.header.constness == hir::Constness::Const {
|
if sig.header.constness == hir::Constness::Const {
|
||||||
// can't be implemented by default
|
// can't be implemented by default
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -271,7 +271,7 @@ impl<'tcx> LateLintPass<'tcx> for NonCopyConst {
|
||||||
|
|
||||||
fn check_impl_item(&mut self, cx: &LateContext<'tcx>, impl_item: &'tcx ImplItem<'_>) {
|
fn check_impl_item(&mut self, cx: &LateContext<'tcx>, impl_item: &'tcx ImplItem<'_>) {
|
||||||
if let ImplItemKind::Const(hir_ty, body_id) = &impl_item.kind {
|
if let ImplItemKind::Const(hir_ty, body_id) = &impl_item.kind {
|
||||||
let item_hir_id = cx.tcx.hir().get_parent_node(impl_item.hir_id);
|
let item_hir_id = cx.tcx.hir().get_parent_node(impl_item.hir_id());
|
||||||
let item = cx.tcx.hir().expect_item(item_hir_id);
|
let item = cx.tcx.hir().expect_item(item_hir_id);
|
||||||
|
|
||||||
match &item.kind {
|
match &item.kind {
|
||||||
|
|
|
@ -44,7 +44,7 @@ impl<'tcx> LateLintPass<'tcx> for PartialEqNeImpl {
|
||||||
span_lint_hir(
|
span_lint_hir(
|
||||||
cx,
|
cx,
|
||||||
PARTIALEQ_NE_IMPL,
|
PARTIALEQ_NE_IMPL,
|
||||||
impl_item.id.hir_id,
|
impl_item.id.hir_id(),
|
||||||
impl_item.span,
|
impl_item.span,
|
||||||
"re-implementing `PartialEq::ne` is unnecessary",
|
"re-implementing `PartialEq::ne` is unnecessary",
|
||||||
);
|
);
|
||||||
|
|
|
@ -130,13 +130,13 @@ impl<'tcx> LateLintPass<'tcx> for Ptr {
|
||||||
|
|
||||||
fn check_impl_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx ImplItem<'_>) {
|
fn check_impl_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx ImplItem<'_>) {
|
||||||
if let ImplItemKind::Fn(ref sig, body_id) = item.kind {
|
if let ImplItemKind::Fn(ref sig, body_id) = item.kind {
|
||||||
let parent_item = cx.tcx.hir().get_parent_item(item.hir_id);
|
let parent_item = cx.tcx.hir().get_parent_item(item.hir_id());
|
||||||
if let Some(Node::Item(it)) = cx.tcx.hir().find(parent_item) {
|
if let Some(Node::Item(it)) = cx.tcx.hir().find(parent_item) {
|
||||||
if let ItemKind::Impl(Impl { of_trait: Some(_), .. }) = it.kind {
|
if let ItemKind::Impl(Impl { of_trait: Some(_), .. }) = it.kind {
|
||||||
return; // ignore trait impls
|
return; // ignore trait impls
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
check_fn(cx, &sig.decl, item.hir_id, Some(body_id));
|
check_fn(cx, &sig.decl, item.hir_id(), Some(body_id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,10 +44,9 @@ impl<'tcx> LateLintPass<'tcx> for UnusedSelf {
|
||||||
if impl_item.span.from_expansion() {
|
if impl_item.span.from_expansion() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let parent = cx.tcx.hir().get_parent_item(impl_item.hir_id);
|
let parent = cx.tcx.hir().get_parent_item(impl_item.hir_id());
|
||||||
let parent_item = cx.tcx.hir().expect_item(parent);
|
let parent_item = cx.tcx.hir().expect_item(parent);
|
||||||
let def_id = cx.tcx.hir().local_def_id(impl_item.hir_id);
|
let assoc_item = cx.tcx.associated_item(impl_item.def_id);
|
||||||
let assoc_item = cx.tcx.associated_item(def_id);
|
|
||||||
if_chain! {
|
if_chain! {
|
||||||
if let ItemKind::Impl(Impl { of_trait: None, .. }) = parent_item.kind;
|
if let ItemKind::Impl(Impl { of_trait: None, .. }) = parent_item.kind;
|
||||||
if assoc_item.fn_has_self_parameter;
|
if assoc_item.fn_has_self_parameter;
|
||||||
|
|
|
@ -57,8 +57,8 @@ impl<'tcx> LateLintPass<'tcx> for UnwrapInResult {
|
||||||
// first check if it's a method or function
|
// first check if it's a method or function
|
||||||
if let hir::ImplItemKind::Fn(ref _signature, _) = impl_item.kind;
|
if let hir::ImplItemKind::Fn(ref _signature, _) = impl_item.kind;
|
||||||
// checking if its return type is `result` or `option`
|
// checking if its return type is `result` or `option`
|
||||||
if is_type_diagnostic_item(cx, return_ty(cx, impl_item.hir_id), sym::result_type)
|
if is_type_diagnostic_item(cx, return_ty(cx, impl_item.hir_id()), sym::result_type)
|
||||||
|| is_type_diagnostic_item(cx, return_ty(cx, impl_item.hir_id), sym::option_type);
|
|| is_type_diagnostic_item(cx, return_ty(cx, impl_item.hir_id()), sym::option_type);
|
||||||
then {
|
then {
|
||||||
lint_impl_body(cx, impl_item.span, impl_item);
|
lint_impl_body(cx, impl_item.span, impl_item);
|
||||||
}
|
}
|
||||||
|
@ -114,10 +114,9 @@ fn lint_impl_body<'tcx>(cx: &LateContext<'tcx>, impl_span: Span, impl_item: &'tc
|
||||||
if let ImplItemKind::Fn(_, body_id) = impl_item.kind;
|
if let ImplItemKind::Fn(_, body_id) = impl_item.kind;
|
||||||
then {
|
then {
|
||||||
let body = cx.tcx.hir().body(body_id);
|
let body = cx.tcx.hir().body(body_id);
|
||||||
let impl_item_def_id = cx.tcx.hir().local_def_id(impl_item.hir_id);
|
|
||||||
let mut fpu = FindExpectUnwrap {
|
let mut fpu = FindExpectUnwrap {
|
||||||
lcx: cx,
|
lcx: cx,
|
||||||
typeck_results: cx.tcx.typeck(impl_item_def_id),
|
typeck_results: cx.tcx.typeck(impl_item.def_id),
|
||||||
result: Vec::new(),
|
result: Vec::new(),
|
||||||
};
|
};
|
||||||
fpu.visit_expr(&body.value);
|
fpu.visit_expr(&body.value);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue