]>
Commit | Line | Data |
---|---|---|
f20569fa XL |
1 | use rustc_hir::{GenericArg, QPath, TyKind}; |
2 | use rustc_lint::LateContext; | |
3 | use rustc_span::source_map::Span; | |
4 | ||
5 | use crate::utils::last_path_segment; | |
6 | ||
7 | use if_chain::if_chain; | |
8 | ||
9 | pub(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 | } |