]> git.proxmox.com Git - rustc.git/blame - src/tools/clippy/clippy_lints/src/types/utils.rs
Merge tag 'debian/1.52.1+dfsg1-1_exp2' into proxmox/buster
[rustc.git] / src / tools / clippy / clippy_lints / src / types / utils.rs
CommitLineData
f20569fa
XL
1use rustc_hir::{GenericArg, QPath, TyKind};
2use rustc_lint::LateContext;
3use rustc_span::source_map::Span;
4
5use crate::utils::last_path_segment;
6
7use if_chain::if_chain;
8
9pub(super) fn match_borrows_parameter(_cx: &LateContext<'_>, qpath: &QPath<'_>) -> Option<Span> {
10 let last = last_path_segment(qpath);
11 if_chain! {
12 if let Some(ref params) = last.args;
13 if !params.parenthesized;
14 if let Some(ty) = params.args.iter().find_map(|arg| match arg {
15 GenericArg::Type(ty) => Some(ty),
16 _ => None,
17 });
18 if let TyKind::Rptr(..) = ty.kind;
19 then {
20 return Some(ty.span);
21 }
22 }
23 None
24}