]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/clippy_lints/src/types/utils.rs
Rollup merge of #102951 - SparrowLii:type_annotation, r=estebank
[rust.git] / src / tools / clippy / clippy_lints / src / types / utils.rs
1 use clippy_utils::last_path_segment;
2 use if_chain::if_chain;
3 use rustc_hir::{GenericArg, QPath, TyKind};
4 use rustc_lint::LateContext;
5 use rustc_span::source_map::Span;
6
7 pub(super) fn match_borrows_parameter(_cx: &LateContext<'_>, qpath: &QPath<'_>) -> Option<Span> {
8     let last = last_path_segment(qpath);
9     if_chain! {
10         if let Some(params) = last.args;
11         if !params.parenthesized;
12         if let Some(ty) = params.args.iter().find_map(|arg| match arg {
13             GenericArg::Type(ty) => Some(ty),
14             _ => None,
15         });
16         if let TyKind::Rptr(..) = ty.kind;
17         then {
18             return Some(ty.span);
19         }
20     }
21     None
22 }