const SEGMENTS_MSG: &str = "segments should be composed of at least 1 element";
-fn span_use_self_lint(cx: &LateContext<'_, '_>, path: &Path<'_>, last_segment: Option<&PathSegment<'_>>) {
+fn span_use_self_lint(cx: &LateContext<'_>, path: &Path<'_>, last_segment: Option<&PathSegment<'_>>) {
let last_segment = last_segment.unwrap_or_else(|| path.segments.last().expect(SEGMENTS_MSG));
// Path segments only include actual path, no methods or fields.
// FIXME: always use this (more correct) visitor, not just in method signatures.
struct SemanticUseSelfVisitor<'a, 'tcx> {
- cx: &'a LateContext<'a, 'tcx>,
+ cx: &'a LateContext<'tcx>,
self_ty: Ty<'tcx>,
}
}
}
-fn check_trait_method_impl_decl<'a, 'tcx>(
- cx: &'a LateContext<'a, 'tcx>,
+fn check_trait_method_impl_decl<'tcx>(
+ cx: &LateContext<'tcx>,
impl_item: &ImplItem<'_>,
impl_decl: &'tcx FnDecl<'_>,
impl_trait_ref: ty::TraitRef<'tcx>,
}
}
-impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UseSelf {
- fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item<'_>) {
+impl<'tcx> LateLintPass<'tcx> for UseSelf {
+ fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'_>) {
if in_external_macro(cx.sess(), item.span) {
return;
}
if let TyKind::Path(QPath::Resolved(_, ref item_path)) = item_type.kind;
then {
let parameters = &item_path.segments.last().expect(SEGMENTS_MSG).args;
- let should_check = if let Some(ref params) = *parameters {
- !params.parenthesized && !params.args.iter().any(|arg| match arg {
- GenericArg::Lifetime(_) => true,
- _ => false,
- })
- } else {
- true
- };
+ let should_check = parameters.as_ref().map_or(
+ true,
+ |params| !params.parenthesized
+ &&!params.args.iter().any(|arg| matches!(arg, GenericArg::Lifetime(_)))
+ );
if should_check {
let visitor = &mut UseSelfVisitor {
struct UseSelfVisitor<'a, 'tcx> {
item_path: &'a Path<'a>,
- cx: &'a LateContext<'a, 'tcx>,
+ cx: &'a LateContext<'tcx>,
}
impl<'a, 'tcx> Visitor<'tcx> for UseSelfVisitor<'a, 'tcx> {