}
}
- fn check_body(&mut self, cx: &LateContext<'_, '_>, body: &hir::Body) {
+ fn check_body(&mut self, cx: &LateContext<'_, '_>, body: &hir::Body<'_>) {
let body_owner = cx.tcx.hir().body_owner(body.id());
match cx.tcx.hir().body_owner_kind(body_owner) {
}
}
- fn check_body_post(&mut self, cx: &LateContext<'_, '_>, body: &hir::Body) {
+ fn check_body_post(&mut self, cx: &LateContext<'_, '_>, body: &hir::Body<'_>) {
let body_owner = cx.tcx.hir().body_owner(body.id());
let body_span = cx.tcx.hir().span(body_owner);
}
}
- fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
+ fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item<'_>) {
if is_relevant_item(cx, item) {
check_attrs(cx, item.span, item.ident.name, &item.attrs)
}
}
}
- fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx ImplItem) {
+ fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx ImplItem<'_>) {
if is_relevant_impl(cx, item) {
check_attrs(cx, item.span, item.ident.name, &item.attrs)
}
}
- fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem) {
+ fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem<'_>) {
if is_relevant_trait(cx, item) {
check_attrs(cx, item.span, item.ident.name, &item.attrs)
}
}
}
-fn is_relevant_item(cx: &LateContext<'_, '_>, item: &Item) -> bool {
+fn is_relevant_item(cx: &LateContext<'_, '_>, item: &Item<'_>) -> bool {
if let ItemKind::Fn(_, _, eid) = item.kind {
is_relevant_expr(cx, cx.tcx.body_tables(eid), &cx.tcx.hir().body(eid).value)
} else {
}
}
-fn is_relevant_impl(cx: &LateContext<'_, '_>, item: &ImplItem) -> bool {
+fn is_relevant_impl(cx: &LateContext<'_, '_>, item: &ImplItem<'_>) -> bool {
match item.kind {
ImplItemKind::Method(_, eid) => is_relevant_expr(cx, cx.tcx.body_tables(eid), &cx.tcx.hir().body(eid).value),
_ => false,
}
}
-fn is_relevant_trait(cx: &LateContext<'_, '_>, item: &TraitItem) -> bool {
+fn is_relevant_trait(cx: &LateContext<'_, '_>, item: &TraitItem<'_>) -> bool {
match item.kind {
TraitItemKind::Method(_, TraitMethod::Required(_)) => true,
TraitItemKind::Method(_, TraitMethod::Provided(eid)) => {
cx: &LateContext<'a, 'tcx>,
_: intravisit::FnKind<'tcx>,
_: &'tcx FnDecl,
- body: &'tcx Body,
+ body: &'tcx Body<'_>,
_: Span,
_: HirId,
) {
cx: &'a LateContext<'a, 'tcx>,
kind: FnKind<'tcx>,
decl: &'tcx FnDecl,
- body: &'tcx Body,
+ body: &'tcx Body<'_>,
body_span: Span,
) {
if body_span.from_expansion() {
cx: &LateContext<'a, 'tcx>,
kind: FnKind<'tcx>,
decl: &'tcx FnDecl,
- body: &'tcx Body,
+ body: &'tcx Body<'_>,
span: Span,
hir_id: HirId,
) {
declare_lint_pass!(CopyIterator => [COPY_ITERATOR]);
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CopyIterator {
- fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
+ fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item<'_>) {
if let ItemKind::Impl(_, _, _, _, Some(ref trait_ref), _, _) = item.kind {
let ty = cx.tcx.type_of(cx.tcx.hir().local_def_id(item.hir_id));
declare_lint_pass!(Derive => [EXPL_IMPL_CLONE_ON_COPY, DERIVE_HASH_XOR_EQ]);
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Derive {
- fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
+ fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item<'_>) {
if let ItemKind::Impl(_, _, _, _, Some(ref trait_ref), _, _) = item.kind {
let ty = cx.tcx.type_of(cx.tcx.hir().local_def_id(item.hir_id));
let is_automatically_derived = is_automatically_derived(&*item.attrs);
}
/// Implementation of the `EXPL_IMPL_CLONE_ON_COPY` lint.
-fn check_copy_clone<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, item: &Item, trait_ref: &TraitRef, ty: Ty<'tcx>) {
+fn check_copy_clone<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, item: &Item<'_>, trait_ref: &TraitRef, ty: Ty<'tcx>) {
if match_path(&trait_ref.path, &paths::CLONE_TRAIT) {
if !is_copy(cx, ty) {
return;
impl_lint_pass!(DocMarkdown => [DOC_MARKDOWN, MISSING_SAFETY_DOC, MISSING_ERRORS_DOC, NEEDLESS_DOCTEST_MAIN]);
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for DocMarkdown {
- fn check_crate(&mut self, cx: &LateContext<'a, 'tcx>, krate: &'tcx hir::Crate) {
+ fn check_crate(&mut self, cx: &LateContext<'a, 'tcx>, krate: &'tcx hir::Crate<'_>) {
check_attrs(cx, &self.valid_idents, &krate.attrs);
}
- fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::Item) {
+ fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::Item<'_>) {
let headers = check_attrs(cx, &self.valid_idents, &item.attrs);
match item.kind {
hir::ItemKind::Fn(ref sig, ..) => {
}
}
- fn check_item_post(&mut self, _cx: &LateContext<'a, 'tcx>, item: &'tcx hir::Item) {
+ fn check_item_post(&mut self, _cx: &LateContext<'a, 'tcx>, item: &'tcx hir::Item<'_>) {
if let hir::ItemKind::Impl(..) = item.kind {
self.in_trait_impl = false;
}
}
- fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::TraitItem) {
+ fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::TraitItem<'_>) {
let headers = check_attrs(cx, &self.valid_idents, &item.attrs);
if let hir::TraitItemKind::Method(ref sig, ..) = item.kind {
lint_for_missing_headers(cx, item.hir_id, item.span, sig, headers);
}
}
- fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::ImplItem) {
+ fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::ImplItem<'_>) {
let headers = check_attrs(cx, &self.valid_idents, &item.attrs);
if self.in_trait_impl {
return;
declare_lint_pass!(EmptyEnum => [EMPTY_ENUM]);
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EmptyEnum {
- fn check_item(&mut self, cx: &LateContext<'_, '_>, item: &Item) {
+ fn check_item(&mut self, cx: &LateContext<'_, '_>, item: &Item<'_>) {
let did = cx.tcx.hir().local_def_id(item.hir_id);
if let ItemKind::Enum(..) = item.kind {
let ty = cx.tcx.type_of(did);
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnportableVariant {
#[allow(clippy::cast_possible_truncation, clippy::cast_possible_wrap, clippy::cast_sign_loss)]
- fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
+ fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item<'_>) {
if cx.tcx.data_layout.pointer_size.bits() != 64 {
return;
}
declare_lint_pass!(EnumGlobUse => [ENUM_GLOB_USE]);
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EnumGlobUse {
- fn check_mod(&mut self, cx: &LateContext<'a, 'tcx>, m: &'tcx Mod, _: Span, _: HirId) {
+ fn check_mod(&mut self, cx: &LateContext<'a, 'tcx>, m: &'tcx Mod<'_>, _: Span, _: HirId) {
let map = cx.tcx.hir();
// only check top level `use` statements
for item in &m.item_ids {
}
}
-fn lint_item(cx: &LateContext<'_, '_>, item: &Item) {
+fn lint_item(cx: &LateContext<'_, '_>, item: &Item<'_>) {
if item.vis.node.is_pub() {
return; // re-exports are fine
}
cx: &LateContext<'a, 'tcx>,
_: visit::FnKind<'tcx>,
_: &'tcx FnDecl,
- body: &'tcx Body,
+ body: &'tcx Body<'_>,
_: Span,
hir_id: HirId,
) {
declare_lint_pass!(FallibleImplFrom => [FALLIBLE_IMPL_FROM]);
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for FallibleImplFrom {
- fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::Item) {
+ fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::Item<'_>) {
// check for `impl From<???> for ..`
let impl_def_id = cx.tcx.hir().local_def_id(item.hir_id);
if_chain! {
cx: &LateContext<'a, 'tcx>,
kind: intravisit::FnKind<'tcx>,
decl: &'tcx hir::FnDecl,
- body: &'tcx hir::Body,
+ body: &'tcx hir::Body<'_>,
span: Span,
hir_id: hir::HirId,
) {
self.check_line_number(cx, span, body);
}
- fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::Item) {
+ fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::Item<'_>) {
let attr = must_use_attr(&item.attrs);
if let hir::ItemKind::Fn(ref sig, ref _generics, ref body_id) = item.kind {
if let Some(attr) = attr {
}
}
- fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::ImplItem) {
+ fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::ImplItem<'_>) {
if let hir::ImplItemKind::Method(ref sig, ref body_id) = item.kind {
let attr = must_use_attr(&item.attrs);
if let Some(attr) = attr {
}
}
- fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::TraitItem) {
+ fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::TraitItem<'_>) {
if let hir::TraitItemKind::Method(ref sig, ref eid) = item.kind {
// don't lint extern functions decls, it's not their fault
if sig.header.abi == Abi::Rust {
}
}
- fn check_line_number(self, cx: &LateContext<'_, '_>, span: Span, body: &'tcx hir::Body) {
+ fn check_line_number(self, cx: &LateContext<'_, '_>, span: Span, body: &'tcx hir::Body<'_>) {
if in_external_macro(cx.sess(), span) {
return;
}
cx: &LateContext<'a, 'tcx>,
unsafety: hir::Unsafety,
decl: &'tcx hir::FnDecl,
- body: &'tcx hir::Body,
+ body: &'tcx hir::Body<'_>,
hir_id: hir::HirId,
) {
let expr = &body.value;
fn check_must_use_candidate<'a, 'tcx>(
cx: &LateContext<'a, 'tcx>,
decl: &'tcx hir::FnDecl,
- body: &'tcx hir::Body,
+ body: &'tcx hir::Body<'_>,
item_span: Span,
item_id: hir::HirId,
fn_span: Span,
}
}
-fn has_mutable_arg(cx: &LateContext<'_, '_>, body: &hir::Body) -> bool {
+fn has_mutable_arg(cx: &LateContext<'_, '_>, body: &hir::Body<'_>) -> bool {
let mut tys = FxHashSet::default();
body.params.iter().any(|param| is_mutable_pat(cx, ¶m.pat, &mut tys))
}
}
}
-fn mutates_static<'a, 'tcx>(cx: &'a LateContext<'a, 'tcx>, body: &'tcx hir::Body) -> bool {
+fn mutates_static<'a, 'tcx>(cx: &'a LateContext<'a, 'tcx>, body: &'tcx hir::Body<'_>) -> bool {
let mut v = StaticMutVisitor {
cx,
mutates_static: false,
cx: &LateContext<'a, 'tcx>,
_: FnKind<'tcx>,
_: &'tcx FnDecl,
- body: &'tcx Body,
+ body: &'tcx Body<'_>,
span: Span,
_: HirId,
) {
impl_lint_pass!(MultipleInherentImpl => [MULTIPLE_INHERENT_IMPL]);
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MultipleInherentImpl {
- fn check_item(&mut self, _: &LateContext<'a, 'tcx>, item: &'tcx Item) {
+ fn check_item(&mut self, _: &LateContext<'a, 'tcx>, item: &'tcx Item<'_>) {
if let ItemKind::Impl(_, _, _, ref generics, None, _, _) = item.kind {
// Remember for each inherent implementation encoutered its span and generics
// but filter out implementations that have generic params (type or lifetime)
}
}
- fn check_crate_post(&mut self, cx: &LateContext<'a, 'tcx>, krate: &'tcx Crate) {
+ fn check_crate_post(&mut self, cx: &LateContext<'a, 'tcx>, krate: &'tcx Crate<'_>) {
if let Some(item) = krate.items.values().nth(0) {
// Retrieve all inherent implementations from the crate, grouped by type
for impls in cx
declare_lint_pass!(InherentToString => [INHERENT_TO_STRING, INHERENT_TO_STRING_SHADOW_DISPLAY]);
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InherentToString {
- fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, impl_item: &'tcx ImplItem) {
+ fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, impl_item: &'tcx ImplItem<'_>) {
if impl_item.span.from_expansion() {
return;
}
}
}
-fn show_lint(cx: &LateContext<'_, '_>, item: &ImplItem) {
+fn show_lint(cx: &LateContext<'_, '_>, item: &ImplItem<'_>) {
let display_trait_id =
get_trait_def_id(cx, &["core", "fmt", "Display"]).expect("Failed to get trait ID of `Display`!");
declare_lint_pass!(InlineFnWithoutBody => [INLINE_FN_WITHOUT_BODY]);
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InlineFnWithoutBody {
- fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem) {
+ fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem<'_>) {
if let TraitItemKind::Method(_, TraitMethod::Required(_)) = item.kind {
check_attrs(cx, item.ident.name, &item.attrs);
}
impl_lint_pass!(LargeEnumVariant => [LARGE_ENUM_VARIANT]);
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LargeEnumVariant {
- fn check_item(&mut self, cx: &LateContext<'_, '_>, item: &Item) {
+ fn check_item(&mut self, cx: &LateContext<'_, '_>, item: &Item<'_>) {
let did = cx.tcx.hir().local_def_id(item.hir_id);
if let ItemKind::Enum(ref def, _) = item.kind {
let ty = cx.tcx.type_of(did);
declare_lint_pass!(LenZero => [LEN_ZERO, LEN_WITHOUT_IS_EMPTY]);
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LenZero {
- fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
+ fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item<'_>) {
if item.span.from_expansion() {
return;
}
}
}
-fn check_trait_items(cx: &LateContext<'_, '_>, visited_trait: &Item, trait_items: &[TraitItemRef]) {
+fn check_trait_items(cx: &LateContext<'_, '_>, visited_trait: &Item<'_>, trait_items: &[TraitItemRef]) {
fn is_named_self(cx: &LateContext<'_, '_>, item: &TraitItemRef, name: &str) -> bool {
item.ident.name.as_str() == name
&& if let AssocItemKind::Method { has_self } = item.kind {
}
}
-fn check_impl_items(cx: &LateContext<'_, '_>, item: &Item, impl_items: &[ImplItemRef]) {
+fn check_impl_items(cx: &LateContext<'_, '_>, item: &Item<'_>, impl_items: &[ImplItemRef]) {
fn is_named_self(cx: &LateContext<'_, '_>, item: &ImplItemRef, name: &str) -> bool {
item.ident.name.as_str() == name
&& if let AssocItemKind::Method { has_self } = item.kind {
declare_lint_pass!(Lifetimes => [NEEDLESS_LIFETIMES, EXTRA_UNUSED_LIFETIMES]);
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Lifetimes {
- fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
+ fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item<'_>) {
if let ItemKind::Fn(ref sig, ref generics, id) = item.kind {
check_fn_inner(cx, &sig.decl, Some(id), generics, item.span, true);
}
}
- fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx ImplItem) {
+ fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx ImplItem<'_>) {
if let ImplItemKind::Method(ref sig, id) = item.kind {
let report_extra_lifetimes = trait_ref_of_method(cx, item.hir_id).is_none();
check_fn_inner(
}
}
- fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem) {
+ fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem<'_>) {
if let TraitItemKind::Method(ref sig, ref body) = item.kind {
let body = match *body {
TraitMethod::Required(_) => None,
impl_lint_pass!(MainRecursion => [MAIN_RECURSION]);
impl LateLintPass<'_, '_> for MainRecursion {
- fn check_crate(&mut self, _: &LateContext<'_, '_>, krate: &Crate) {
+ fn check_crate(&mut self, _: &LateContext<'_, '_>, krate: &Crate<'_>) {
self.has_no_std_attr = krate.attrs.iter().any(|attr| {
if let AttrKind::Normal(ref attr) = attr.kind {
attr.path == sym::no_std
}
}
- fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, impl_item: &'tcx hir::ImplItem) {
+ fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, impl_item: &'tcx hir::ImplItem<'_>) {
if in_external_macro(cx.sess(), impl_item.span) {
return;
}
cx: &LateContext<'a, 'tcx>,
k: FnKind<'tcx>,
decl: &'tcx FnDecl,
- body: &'tcx Body,
+ body: &'tcx Body<'_>,
_: Span,
_: HirId,
) {
cx: &LateContext<'_, '_>,
kind: FnKind<'_>,
_: &FnDecl,
- _: &Body,
+ _: &Body<'_>,
span: Span,
hir_id: HirId,
) {
self.doc_hidden_stack.pop().expect("empty doc_hidden_stack");
}
- fn check_crate(&mut self, cx: &LateContext<'a, 'tcx>, krate: &'tcx hir::Crate) {
+ fn check_crate(&mut self, cx: &LateContext<'a, 'tcx>, krate: &'tcx hir::Crate<'_>) {
self.check_missing_docs_attrs(cx, &krate.attrs, krate.span, "crate");
}
- fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, it: &'tcx hir::Item) {
+ fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, it: &'tcx hir::Item<'_>) {
let desc = match it.kind {
hir::ItemKind::Const(..) => "a constant",
hir::ItemKind::Enum(..) => "an enum",
self.check_missing_docs_attrs(cx, &it.attrs, it.span, desc);
}
- fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, trait_item: &'tcx hir::TraitItem) {
+ fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, trait_item: &'tcx hir::TraitItem<'_>) {
let desc = match trait_item.kind {
hir::TraitItemKind::Const(..) => "an associated constant",
hir::TraitItemKind::Method(..) => "a trait method",
self.check_missing_docs_attrs(cx, &trait_item.attrs, trait_item.span, desc);
}
- fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, impl_item: &'tcx hir::ImplItem) {
+ fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, impl_item: &'tcx hir::ImplItem<'_>) {
// 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(def_id).container {
self.check_missing_docs_attrs(cx, &impl_item.attrs, impl_item.span, desc);
}
- fn check_struct_field(&mut self, cx: &LateContext<'a, 'tcx>, sf: &'tcx hir::StructField) {
+ fn check_struct_field(&mut self, cx: &LateContext<'a, 'tcx>, sf: &'tcx hir::StructField<'_>) {
if !sf.is_positional() {
self.check_missing_docs_attrs(cx, &sf.attrs, sf.span, "a struct field");
}
}
- fn check_variant(&mut self, cx: &LateContext<'a, 'tcx>, v: &'tcx hir::Variant) {
+ fn check_variant(&mut self, cx: &LateContext<'a, 'tcx>, v: &'tcx hir::Variant<'_>) {
self.check_missing_docs_attrs(cx, &v.attrs, v.span, "a variant");
}
}
declare_lint_pass!(MissingInline => [MISSING_INLINE_IN_PUBLIC_ITEMS]);
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingInline {
- fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, it: &'tcx hir::Item) {
+ fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, it: &'tcx hir::Item<'_>) {
if lint::in_external_macro(cx.sess(), it.span) || is_executable(cx) {
return;
}
};
}
- fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, impl_item: &'tcx hir::ImplItem) {
+ fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, impl_item: &'tcx hir::ImplItem<'_>) {
use rustc::ty::{ImplContainer, TraitContainer};
if lint::in_external_macro(cx.sess(), impl_item.span) || is_executable(cx) {
return;
}
}
- fn check_item(&mut self, _: &LateContext<'a, 'tcx>, item: &'tcx Item) {
+ fn check_item(&mut self, _: &LateContext<'a, 'tcx>, item: &'tcx Item<'_>) {
if item.attrs.iter().any(|a| a.check_name(sym!(automatically_derived))) {
debug_assert!(self.derived_item.is_none());
self.derived_item = Some(item.hir_id);
}
}
- fn check_item_post(&mut self, _: &LateContext<'a, 'tcx>, item: &'tcx Item) {
+ fn check_item_post(&mut self, _: &LateContext<'a, 'tcx>, item: &'tcx Item<'_>) {
if let Some(id) = self.derived_item {
if item.hir_id == id {
self.derived_item = None;
cx: &LateContext<'a, 'tcx>,
kind: FnKind<'tcx>,
decl: &'tcx FnDecl,
- body: &'tcx Body,
+ body: &'tcx Body<'_>,
span: Span,
hir_id: HirId,
) {
impl_lint_pass!(NewWithoutDefault => [NEW_WITHOUT_DEFAULT]);
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NewWithoutDefault {
- fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::Item) {
+ fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::Item<'_>) {
if let hir::ItemKind::Impl(_, _, _, _, None, _, ref items) = item.kind {
for assoc_item in items {
if let hir::AssocItemKind::Method { has_self: false } = assoc_item.kind {
declare_lint_pass!(NonCopyConst => [DECLARE_INTERIOR_MUTABLE_CONST, BORROW_INTERIOR_MUTABLE_CONST]);
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonCopyConst {
- fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, it: &'tcx Item) {
+ fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, it: &'tcx Item<'_>) {
if let ItemKind::Const(hir_ty, ..) = &it.kind {
let ty = hir_ty_to_ty(cx.tcx, hir_ty);
verify_ty_bound(cx, ty, Source::Item { item: it.span });
}
}
- fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, trait_item: &'tcx TraitItem) {
+ fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, trait_item: &'tcx TraitItem<'_>) {
if let TraitItemKind::Const(hir_ty, ..) = &trait_item.kind {
let ty = hir_ty_to_ty(cx.tcx, hir_ty);
verify_ty_bound(
}
}
- fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, impl_item: &'tcx ImplItem) {
+ fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, impl_item: &'tcx ImplItem<'_>) {
if let ImplItemKind::Const(hir_ty, ..) = &impl_item.kind {
let item_hir_id = cx.tcx.hir().get_parent_node(impl_item.hir_id);
let item = cx.tcx.hir().expect_item(item_hir_id);
declare_lint_pass!(PartialEqNeImpl => [PARTIALEQ_NE_IMPL]);
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PartialEqNeImpl {
- fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
+ fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item<'_>) {
if_chain! {
if let ItemKind::Impl(_, _, _, _, Some(ref trait_ref), _, ref impl_items) = item.kind;
if !is_automatically_derived(&*item.attrs);
declare_lint_pass!(Ptr => [PTR_ARG, CMP_NULL, MUT_FROM_REF]);
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Ptr {
- fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
+ fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item<'_>) {
if let ItemKind::Fn(ref sig, _, body_id) = item.kind {
check_fn(cx, &sig.decl, item.hir_id, Some(body_id));
}
}
- fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx ImplItem) {
+ fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx ImplItem<'_>) {
if let ImplItemKind::Method(ref sig, body_id) = item.kind {
let parent_item = cx.tcx.hir().get_parent_item(item.hir_id);
if let Some(Node::Item(it)) = cx.tcx.hir().find(parent_item) {
}
}
- fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem) {
+ fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem<'_>) {
if let TraitItemKind::Method(ref sig, ref trait_method) = item.kind {
let body_id = if let TraitMethod::Provided(b) = *trait_method {
Some(b)
cx: &LateContext<'a, 'tcx>,
_: FnKind<'tcx>,
_: &'tcx FnDecl,
- body: &'tcx Body,
+ body: &'tcx Body<'_>,
_: Span,
_: HirId,
) {
impl_lint_pass!(Regex => [INVALID_REGEX, REGEX_MACRO, TRIVIAL_REGEX]);
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Regex {
- fn check_crate(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx Crate) {
+ fn check_crate(&mut self, _: &LateContext<'a, 'tcx>, _: &'tcx Crate<'_>) {
self.spans.clear();
}
declare_lint_pass!(SerdeAPI => [SERDE_API_MISUSE]);
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for SerdeAPI {
- fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
+ fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item<'_>) {
if let ItemKind::Impl(_, _, _, _, Some(ref trait_ref), _, ref items) = item.kind {
let did = trait_ref.path.res.def_id();
if let Some(visit_did) = get_trait_def_id(cx, &paths::SERDE_DE_VISITOR) {
cx: &LateContext<'a, 'tcx>,
_: FnKind<'tcx>,
decl: &'tcx FnDecl,
- body: &'tcx Body,
+ body: &'tcx Body<'_>,
_: Span,
_: HirId,
) {
}
}
-fn check_fn<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, decl: &'tcx FnDecl, body: &'tcx Body) {
+fn check_fn<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, decl: &'tcx FnDecl, body: &'tcx Body<'_>) {
let mut bindings = Vec::new();
for arg in iter_input_pats(decl, body) {
if let PatKind::Binding(.., ident, _) = arg.pat.kind {
impl_lint_pass!(TriviallyCopyPassByRef => [TRIVIALLY_COPY_PASS_BY_REF]);
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TriviallyCopyPassByRef {
- fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::TraitItem) {
+ fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::TraitItem<'_>) {
if item.span.from_expansion() {
return;
}
cx: &LateContext<'a, 'tcx>,
kind: FnKind<'tcx>,
decl: &'tcx FnDecl,
- _body: &'tcx Body,
+ _body: &'tcx Body<'_>,
span: Span,
hir_id: HirId,
) {
declare_lint_pass!(Types => [BOX_VEC, VEC_BOX, OPTION_OPTION, LINKEDLIST, BORROWED_BOX]);
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Types {
- fn check_fn(&mut self, cx: &LateContext<'_, '_>, _: FnKind<'_>, decl: &FnDecl, _: &Body, _: Span, id: HirId) {
+ fn check_fn(&mut self, cx: &LateContext<'_, '_>, _: FnKind<'_>, decl: &FnDecl, _: &Body<'_>, _: Span, id: HirId) {
// Skip trait implementations; see issue #605.
if let Some(hir::Node::Item(item)) = cx.tcx.hir().find(cx.tcx.hir().get_parent_item(id)) {
if let ItemKind::Impl(_, _, _, _, Some(..), _, _) = item.kind {
check_fn_decl(cx, decl);
}
- fn check_struct_field(&mut self, cx: &LateContext<'_, '_>, field: &hir::StructField) {
+ fn check_struct_field(&mut self, cx: &LateContext<'_, '_>, field: &hir::StructField<'_>) {
check_ty(cx, &field.ty, false);
}
- fn check_trait_item(&mut self, cx: &LateContext<'_, '_>, item: &TraitItem) {
+ fn check_trait_item(&mut self, cx: &LateContext<'_, '_>, item: &TraitItem<'_>) {
match item.kind {
TraitItemKind::Const(ref ty, _) | TraitItemKind::Type(_, Some(ref ty)) => check_ty(cx, ty, false),
TraitItemKind::Method(ref sig, _) => check_fn_decl(cx, &sig.decl),
cx: &LateContext<'a, 'tcx>,
_: FnKind<'tcx>,
decl: &'tcx FnDecl,
- _: &'tcx Body,
+ _: &'tcx Body<'_>,
_: Span,
_: HirId,
) {
self.check_fndecl(cx, decl);
}
- fn check_struct_field(&mut self, cx: &LateContext<'a, 'tcx>, field: &'tcx hir::StructField) {
+ fn check_struct_field(&mut self, cx: &LateContext<'a, 'tcx>, field: &'tcx hir::StructField<'_>) {
// enum variants are also struct fields now
self.check_type(cx, &field.ty);
}
- fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
+ fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item<'_>) {
match item.kind {
ItemKind::Static(ref ty, _, _) | ItemKind::Const(ref ty, _) => self.check_type(cx, ty),
// functions, enums, structs, impls and traits are covered
}
}
- fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem) {
+ fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx TraitItem<'_>) {
match item.kind {
TraitItemKind::Const(ref ty, _) | TraitItemKind::Type(_, Some(ref ty)) => self.check_type(cx, ty),
TraitItemKind::Method(FnSig { ref decl, .. }, TraitMethod::Required(_)) => self.check_fndecl(cx, decl),
}
}
- fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx ImplItem) {
+ fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx ImplItem<'_>) {
match item.kind {
ImplItemKind::Const(ref ty, _) | ImplItemKind::TyAlias(ref ty) => self.check_type(cx, ty),
// methods are covered by check_fn
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ImplicitHasher {
#[allow(clippy::cast_possible_truncation, clippy::too_many_lines)]
- fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
+ fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item<'_>) {
use syntax_pos::BytePos;
fn suggestion<'a, 'tcx>(
}
impl<'a, 'b, 'tcx> Visitor<'tcx> for ImplicitHasherConstructorVisitor<'a, 'b, 'tcx> {
- fn visit_body(&mut self, body: &'tcx Body) {
+ fn visit_body(&mut self, body: &'tcx Body<'_>) {
let prev_body = self.body;
self.body = self.cx.tcx.body_tables(body.id());
walk_body(self, body);
declare_lint_pass!(UnusedSelf => [UNUSED_SELF]);
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedSelf {
- fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &Item) {
+ fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &Item<'_>) {
if item.span.from_expansion() {
return;
}
cx: &LateContext<'a, 'tcx>,
kind: FnKind<'tcx>,
decl: &'tcx FnDecl,
- body: &'tcx Body,
+ body: &'tcx Body<'_>,
span: Span,
fn_id: HirId,
) {
fn check_trait_method_impl_decl<'a, 'tcx>(
cx: &'a LateContext<'a, 'tcx>,
item_type: Ty<'tcx>,
- impl_item: &ImplItem,
+ impl_item: &ImplItem<'_>,
impl_decl: &'tcx FnDecl,
impl_trait_ref: &ty::TraitRef<'_>,
) {
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UseSelf {
- fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
+ fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item<'_>) {
if in_external_macro(cx.sess(), item.span) {
return;
}
walk_path(self, path);
}
- fn visit_item(&mut self, item: &'tcx Item) {
+ fn visit_item(&mut self, item: &'tcx Item<'_>) {
match item.kind {
ItemKind::Use(..)
| ItemKind::Static(..)
}
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Author {
- fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::Item) {
+ fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::Item<'_>) {
if !has_attr(cx.sess(), &item.attrs) {
return;
}
done();
}
- fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::ImplItem) {
+ fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::ImplItem<'_>) {
if !has_attr(cx.sess(), &item.attrs) {
return;
}
done();
}
- fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::TraitItem) {
+ fn check_trait_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::TraitItem<'_>) {
if !has_attr(cx.sess(), &item.attrs) {
return;
}
done();
}
- fn check_variant(&mut self, cx: &LateContext<'a, 'tcx>, var: &'tcx hir::Variant) {
+ fn check_variant(&mut self, cx: &LateContext<'a, 'tcx>, var: &'tcx hir::Variant<'_>) {
if !has_attr(cx.sess(), &var.attrs) {
return;
}
done();
}
- fn check_struct_field(&mut self, cx: &LateContext<'a, 'tcx>, field: &'tcx hir::StructField) {
+ fn check_struct_field(&mut self, cx: &LateContext<'a, 'tcx>, field: &'tcx hir::StructField<'_>) {
if !has_attr(cx.sess(), &field.attrs) {
return;
}
done();
}
- fn check_foreign_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::ForeignItem) {
+ fn check_foreign_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::ForeignItem<'_>) {
if !has_attr(cx.sess(), &item.attrs) {
return;
}
declare_lint_pass!(DeepCodeInspector => [DEEP_CODE_INSPECTION]);
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for DeepCodeInspector {
- fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::Item) {
+ fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::Item<'_>) {
if !has_attr(cx.sess(), &item.attrs) {
return;
}
print_item(cx, item);
}
- fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::ImplItem) {
+ fn check_impl_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx hir::ImplItem<'_>) {
if !has_attr(cx.sess(), &item.attrs) {
return;
}
}
}
-fn print_item(cx: &LateContext<'_, '_>, item: &hir::Item) {
+fn print_item(cx: &LateContext<'_, '_>, item: &hir::Item<'_>) {
let did = cx.tcx.hir().local_def_id(item.hir_id);
println!("item `{}`", item.ident.name);
match item.vis.node {
impl_lint_pass!(LintWithoutLintPass => [LINT_WITHOUT_LINT_PASS]);
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LintWithoutLintPass {
- fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
+ fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item<'_>) {
if let hir::ItemKind::Static(ref ty, Mutability::Not, _) = item.kind {
if is_lint_ref_type(cx, ty) {
self.declared_lints.insert(item.ident.name, item.span);
}
}
- fn check_crate_post(&mut self, cx: &LateContext<'a, 'tcx>, _: &'tcx Crate) {
+ fn check_crate_post(&mut self, cx: &LateContext<'a, 'tcx>, _: &'tcx Crate<'_>) {
for (lint_name, &lint_span) in &self.declared_lints {
// When using the `declare_tool_lint!` macro, the original `lint_span`'s
// file points to "<rustc macros>".
false
}
-pub fn iter_input_pats<'tcx>(decl: &FnDecl, body: &'tcx Body) -> impl Iterator<Item = &'tcx Param> {
+pub fn iter_input_pats<'tcx>(decl: &FnDecl, body: &'tcx Body<'_>) -> impl Iterator<Item = &'tcx Param> {
(0..decl.inputs.len()).map(move |i| &body.params[i])
}
cx: &LateContext<'a, 'tcx>,
name: Name,
replace: &[(&'static str, &'static str)],
- body: &'tcx Body,
+ body: &'tcx Body<'_>,
) -> Option<Vec<(Span, Cow<'static, str>)>> {
let mut visitor = PtrCloneVisitor {
cx,