Add (..)
syntax for RTN
This commit is contained in:
parent
538e8bdcc8
commit
fc6262fa0c
@ -3,7 +3,7 @@
|
|||||||
use clippy_utils::source::snippet;
|
use clippy_utils::source::snippet;
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
use rustc_hir::{GenericArg, Mutability, Ty, TyKind};
|
use rustc_hir::{GenericArg, GenericArgsParentheses, Mutability, Ty, TyKind};
|
||||||
use rustc_lint::{LateContext, LateLintPass};
|
use rustc_lint::{LateContext, LateLintPass};
|
||||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||||
use rustc_span::symbol::sym;
|
use rustc_span::symbol::sym;
|
||||||
@ -47,7 +47,7 @@ fn check_ty(&mut self, cx: &LateContext<'tcx>, ty: &'tcx Ty<'tcx>) {
|
|||||||
|
|
||||||
if cx.tcx.is_diagnostic_item(sym::Option, def_id);
|
if cx.tcx.is_diagnostic_item(sym::Option, def_id);
|
||||||
if let Some(params) = last_path_segment(qpath).args ;
|
if let Some(params) = last_path_segment(qpath).args ;
|
||||||
if !params.parenthesized;
|
if params.parenthesized == GenericArgsParentheses::No;
|
||||||
if let Some(inner_ty) = params.args.iter().find_map(|arg| match arg {
|
if let Some(inner_ty) = params.args.iter().find_map(|arg| match arg {
|
||||||
GenericArg::Type(inner_ty) => Some(inner_ty),
|
GenericArg::Type(inner_ty) => Some(inner_ty),
|
||||||
_ => None,
|
_ => None,
|
||||||
|
@ -20,7 +20,7 @@ pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, lt: &Lifetime, m
|
|||||||
if let QPath::Resolved(None, path) = *qpath;
|
if let QPath::Resolved(None, path) = *qpath;
|
||||||
if let [ref bx] = *path.segments;
|
if let [ref bx] = *path.segments;
|
||||||
if let Some(params) = bx.args;
|
if let Some(params) = bx.args;
|
||||||
if !params.parenthesized;
|
if params.parenthesized == hir::GenericArgsParentheses::No;
|
||||||
if let Some(inner) = params.args.iter().find_map(|arg| match arg {
|
if let Some(inner) = params.args.iter().find_map(|arg| match arg {
|
||||||
GenericArg::Type(ty) => Some(ty),
|
GenericArg::Type(ty) => Some(ty),
|
||||||
_ => None,
|
_ => None,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use clippy_utils::last_path_segment;
|
use clippy_utils::last_path_segment;
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_hir::{GenericArg, QPath, TyKind};
|
use rustc_hir::{GenericArg, GenericArgsParentheses, QPath, TyKind};
|
||||||
use rustc_lint::LateContext;
|
use rustc_lint::LateContext;
|
||||||
use rustc_span::source_map::Span;
|
use rustc_span::source_map::Span;
|
||||||
|
|
||||||
@ -8,7 +8,7 @@ pub(super) fn match_borrows_parameter(_cx: &LateContext<'_>, qpath: &QPath<'_>)
|
|||||||
let last = last_path_segment(qpath);
|
let last = last_path_segment(qpath);
|
||||||
if_chain! {
|
if_chain! {
|
||||||
if let Some(params) = last.args;
|
if let Some(params) = last.args;
|
||||||
if !params.parenthesized;
|
if params.parenthesized == GenericArgsParentheses::No;
|
||||||
if let Some(ty) = params.args.iter().find_map(|arg| match arg {
|
if let Some(ty) = params.args.iter().find_map(|arg| match arg {
|
||||||
GenericArg::Type(ty) => Some(ty),
|
GenericArg::Type(ty) => Some(ty),
|
||||||
_ => None,
|
_ => None,
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
def::{CtorOf, DefKind, Res},
|
def::{CtorOf, DefKind, Res},
|
||||||
def_id::LocalDefId,
|
def_id::LocalDefId,
|
||||||
intravisit::{walk_inf, walk_ty, Visitor},
|
intravisit::{walk_inf, walk_ty, Visitor},
|
||||||
Expr, ExprKind, FnRetTy, FnSig, GenericArg, GenericParam, GenericParamKind, HirId, Impl, ImplItemKind, Item,
|
Expr, ExprKind, FnRetTy, FnSig, GenericArg, GenericArgsParentheses, GenericParam, GenericParamKind, HirId, Impl, ImplItemKind, Item,
|
||||||
ItemKind, Pat, PatKind, Path, QPath, Ty, TyKind,
|
ItemKind, Pat, PatKind, Path, QPath, Ty, TyKind,
|
||||||
};
|
};
|
||||||
use rustc_hir_analysis::hir_ty_to_ty;
|
use rustc_hir_analysis::hir_ty_to_ty;
|
||||||
@ -100,7 +100,8 @@ fn check_item(&mut self, cx: &LateContext<'tcx>, item: &Item<'tcx>) {
|
|||||||
if let TyKind::Path(QPath::Resolved(_, item_path)) = self_ty.kind;
|
if let TyKind::Path(QPath::Resolved(_, item_path)) = self_ty.kind;
|
||||||
let parameters = &item_path.segments.last().expect(SEGMENTS_MSG).args;
|
let parameters = &item_path.segments.last().expect(SEGMENTS_MSG).args;
|
||||||
if parameters.as_ref().map_or(true, |params| {
|
if parameters.as_ref().map_or(true, |params| {
|
||||||
!params.parenthesized && !params.args.iter().any(|arg| matches!(arg, GenericArg::Lifetime(_)))
|
params.parenthesized == GenericArgsParentheses::No
|
||||||
|
&& !params.args.iter().any(|arg| matches!(arg, GenericArg::Lifetime(_)))
|
||||||
});
|
});
|
||||||
if !item.span.from_expansion();
|
if !item.span.from_expansion();
|
||||||
if !is_from_proc_macro(cx, item); // expensive, should be last check
|
if !is_from_proc_macro(cx, item); // expensive, should be last check
|
||||||
|
@ -401,14 +401,9 @@ pub fn eq_path(&mut self, left: &Path<'_>, right: &Path<'_>) -> bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn eq_path_parameters(&mut self, left: &GenericArgs<'_>, right: &GenericArgs<'_>) -> bool {
|
fn eq_path_parameters(&mut self, left: &GenericArgs<'_>, right: &GenericArgs<'_>) -> bool {
|
||||||
if !(left.parenthesized || right.parenthesized) {
|
if left.parenthesized == right.parenthesized {
|
||||||
over(left.args, right.args, |l, r| self.eq_generic_arg(l, r)) // FIXME(flip1995): may not work
|
over(left.args, right.args, |l, r| self.eq_generic_arg(l, r)) // FIXME(flip1995): may not work
|
||||||
&& over(left.bindings, right.bindings, |l, r| self.eq_type_binding(l, r))
|
&& over(left.bindings, right.bindings, |l, r| self.eq_type_binding(l, r))
|
||||||
} else if left.parenthesized && right.parenthesized {
|
|
||||||
over(left.inputs(), right.inputs(), |l, r| self.eq_ty(l, r))
|
|
||||||
&& both(&Some(&left.bindings[0].ty()), &Some(&right.bindings[0].ty()), |l, r| {
|
|
||||||
self.eq_ty(l, r)
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user