Avoid slice indexing in Clippy (down with the ICEs)

This commit is contained in:
xFrednet 2021-09-04 18:21:49 +02:00
parent a8c2c7b712
commit 62b46125cb
18 changed files with 58 additions and 58 deletions

View File

@ -61,8 +61,8 @@ impl<'a, 'tcx> Visitor<'tcx> for ExVisitor<'a, 'tcx> {
// do not lint if the closure is called using an iterator (see #1141) // do not lint if the closure is called using an iterator (see #1141)
if_chain! { if_chain! {
if let Some(parent) = get_parent_expr(self.cx, expr); if let Some(parent) = get_parent_expr(self.cx, expr);
if let ExprKind::MethodCall(_, _, args, _) = parent.kind; if let ExprKind::MethodCall(_, _, [self_arg, ..], _) = &parent.kind;
let caller = self.cx.typeck_results().expr_ty(&args[0]); let caller = self.cx.typeck_results().expr_ty(self_arg);
if let Some(iter_id) = self.cx.tcx.get_diagnostic_item(sym::Iterator); if let Some(iter_id) = self.cx.tcx.get_diagnostic_item(sym::Iterator);
if implements_trait(self.cx, caller, iter_id, &[]); if implements_trait(self.cx, caller, iter_id, &[]);
then { then {

View File

@ -19,7 +19,7 @@ pub(super) fn check(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
cx.typeck_results().expr_ty(expr), cx.typeck_results().expr_ty(expr),
); );
lint_cast_ptr_alignment(cx, expr, cast_from, cast_to); lint_cast_ptr_alignment(cx, expr, cast_from, cast_to);
} else if let ExprKind::MethodCall(method_path, _, args, _) = expr.kind { } else if let ExprKind::MethodCall(method_path, _, [self_arg, ..], _) = &expr.kind {
if_chain! { if_chain! {
if method_path.ident.name == sym!(cast); if method_path.ident.name == sym!(cast);
if let Some(generic_args) = method_path.args; if let Some(generic_args) = method_path.args;
@ -28,7 +28,7 @@ pub(super) fn check(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
if !is_hir_ty_cfg_dependant(cx, cast_to); if !is_hir_ty_cfg_dependant(cx, cast_to);
then { then {
let (cast_from, cast_to) = let (cast_from, cast_to) =
(cx.typeck_results().expr_ty(&args[0]), cx.typeck_results().expr_ty(expr)); (cx.typeck_results().expr_ty(self_arg), cx.typeck_results().expr_ty(expr));
lint_cast_ptr_alignment(cx, expr, cast_from, cast_to); lint_cast_ptr_alignment(cx, expr, cast_from, cast_to);
} }
} }

View File

@ -362,22 +362,22 @@ fn detect_hypot(cx: &LateContext<'_>, args: &[Expr<'_>]) -> Option<String> {
if_chain! { if_chain! {
if let ExprKind::MethodCall( if let ExprKind::MethodCall(
PathSegment { ident: lmethod_name, .. }, PathSegment { ident: lmethod_name, .. },
ref _lspan, _lspan,
largs, [largs_0, largs_1, ..],
_ _
) = add_lhs.kind; ) = &add_lhs.kind;
if let ExprKind::MethodCall( if let ExprKind::MethodCall(
PathSegment { ident: rmethod_name, .. }, PathSegment { ident: rmethod_name, .. },
ref _rspan, _rspan,
rargs, [rargs_0, rargs_1, ..],
_ _
) = add_rhs.kind; ) = &add_rhs.kind;
if lmethod_name.as_str() == "powi" && rmethod_name.as_str() == "powi"; if lmethod_name.as_str() == "powi" && rmethod_name.as_str() == "powi";
if let Some((lvalue, _)) = constant(cx, cx.typeck_results(), &largs[1]); if let Some((lvalue, _)) = constant(cx, cx.typeck_results(), largs_1);
if let Some((rvalue, _)) = constant(cx, cx.typeck_results(), &rargs[1]); if let Some((rvalue, _)) = constant(cx, cx.typeck_results(), rargs_1);
if Int(2) == lvalue && Int(2) == rvalue; if Int(2) == lvalue && Int(2) == rvalue;
then { then {
return Some(format!("{}.hypot({})", Sugg::hir(cx, &largs[0], ".."), Sugg::hir(cx, &rargs[0], ".."))); return Some(format!("{}.hypot({})", Sugg::hir(cx, largs_0, ".."), Sugg::hir(cx, rargs_0, "..")));
} }
} }
} }
@ -407,8 +407,8 @@ fn check_expm1(cx: &LateContext<'_>, expr: &Expr<'_>) {
if cx.typeck_results().expr_ty(lhs).is_floating_point(); if cx.typeck_results().expr_ty(lhs).is_floating_point();
if let Some((value, _)) = constant(cx, cx.typeck_results(), rhs); if let Some((value, _)) = constant(cx, cx.typeck_results(), rhs);
if F32(1.0) == value || F64(1.0) == value; if F32(1.0) == value || F64(1.0) == value;
if let ExprKind::MethodCall(path, _, method_args, _) = lhs.kind; if let ExprKind::MethodCall(path, _, [self_arg, ..], _) = &lhs.kind;
if cx.typeck_results().expr_ty(&method_args[0]).is_floating_point(); if cx.typeck_results().expr_ty(self_arg).is_floating_point();
if path.ident.name.as_str() == "exp"; if path.ident.name.as_str() == "exp";
then { then {
span_lint_and_sugg( span_lint_and_sugg(
@ -419,7 +419,7 @@ fn check_expm1(cx: &LateContext<'_>, expr: &Expr<'_>) {
"consider using", "consider using",
format!( format!(
"{}.exp_m1()", "{}.exp_m1()",
Sugg::hir(cx, &method_args[0], "..") Sugg::hir(cx, self_arg, "..")
), ),
Applicability::MachineApplicable, Applicability::MachineApplicable,
); );
@ -617,8 +617,8 @@ fn check_log_division(cx: &LateContext<'_>, expr: &Expr<'_>) {
rhs, rhs,
) = &expr.kind; ) = &expr.kind;
if are_same_base_logs(cx, lhs, rhs); if are_same_base_logs(cx, lhs, rhs);
if let ExprKind::MethodCall(_, _, largs, _) = lhs.kind; if let ExprKind::MethodCall(_, _, [largs_self, ..], _) = &lhs.kind;
if let ExprKind::MethodCall(_, _, rargs, _) = rhs.kind; if let ExprKind::MethodCall(_, _, [rargs_self, ..], _) = &rhs.kind;
then { then {
span_lint_and_sugg( span_lint_and_sugg(
cx, cx,
@ -626,7 +626,7 @@ fn check_log_division(cx: &LateContext<'_>, expr: &Expr<'_>) {
expr.span, expr.span,
"log base can be expressed more clearly", "log base can be expressed more clearly",
"consider using", "consider using",
format!("{}.log({})", Sugg::hir(cx, &largs[0], ".."), Sugg::hir(cx, &rargs[0], ".."),), format!("{}.log({})", Sugg::hir(cx, largs_self, ".."), Sugg::hir(cx, rargs_self, ".."),),
Applicability::MachineApplicable, Applicability::MachineApplicable,
); );
} }

View File

@ -138,12 +138,12 @@ impl<'tcx, 'l> ArmVisitor<'tcx, 'l> {
fn is_mutex_lock_call<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) -> Option<&'tcx Expr<'tcx>> { fn is_mutex_lock_call<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) -> Option<&'tcx Expr<'tcx>> {
if_chain! { if_chain! {
if let ExprKind::MethodCall(path, _span, args, _) = &expr.kind; if let ExprKind::MethodCall(path, _span, [self_arg, ..], _) = &expr.kind;
if path.ident.as_str() == "lock"; if path.ident.as_str() == "lock";
let ty = cx.typeck_results().expr_ty(&args[0]); let ty = cx.typeck_results().expr_ty(self_arg);
if is_type_diagnostic_item(cx, ty, sym!(mutex_type)); if is_type_diagnostic_item(cx, ty, sym!(mutex_type));
then { then {
Some(&args[0]) Some(self_arg)
} else { } else {
None None
} }

View File

@ -46,10 +46,10 @@ impl<'tcx> LateLintPass<'tcx> for OkIfLet {
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) { fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
if_chain! { //begin checking variables if_chain! { //begin checking variables
if let Some(higher::IfLet { let_pat, let_expr, .. }) = higher::IfLet::hir(cx, expr); if let Some(higher::IfLet { let_pat, let_expr, .. }) = higher::IfLet::hir(cx, expr);
if let ExprKind::MethodCall(_, ok_span, result_types, _) = let_expr.kind; //check is expr.ok() has type Result<T,E>.ok(, _) if let ExprKind::MethodCall(_, ok_span, [ref result_types_0, ..], _) = let_expr.kind; //check is expr.ok() has type Result<T,E>.ok(, _)
if let PatKind::TupleStruct(QPath::Resolved(_, x), y, _) = let_pat.kind; //get operation if let PatKind::TupleStruct(QPath::Resolved(_, x), y, _) = let_pat.kind; //get operation
if method_chain_args(let_expr, &["ok"]).is_some(); //test to see if using ok() methoduse std::marker::Sized; if method_chain_args(let_expr, &["ok"]).is_some(); //test to see if using ok() methoduse std::marker::Sized;
if is_type_diagnostic_item(cx, cx.typeck_results().expr_ty(&result_types[0]), sym::result_type); if is_type_diagnostic_item(cx, cx.typeck_results().expr_ty(result_types_0), sym::result_type);
if rustc_hir_pretty::to_string(rustc_hir_pretty::NO_ANN, |s| s.print_path(x, false)) == "Some"; if rustc_hir_pretty::to_string(rustc_hir_pretty::NO_ANN, |s| s.print_path(x, false)) == "Some";
then { then {

View File

@ -301,10 +301,10 @@ impl<'a, 'tcx> Visitor<'tcx> for VarVisitor<'a, 'tcx> {
fn visit_expr(&mut self, expr: &'tcx Expr<'_>) { fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
if_chain! { if_chain! {
// a range index op // a range index op
if let ExprKind::MethodCall(meth, _, args, _) = expr.kind; if let ExprKind::MethodCall(meth, _, [args_0, args_1, ..], _) = &expr.kind;
if (meth.ident.name == sym::index && match_trait_method(self.cx, expr, &paths::INDEX)) if (meth.ident.name == sym::index && match_trait_method(self.cx, expr, &paths::INDEX))
|| (meth.ident.name == sym::index_mut && match_trait_method(self.cx, expr, &paths::INDEX_MUT)); || (meth.ident.name == sym::index_mut && match_trait_method(self.cx, expr, &paths::INDEX_MUT));
if !self.check(&args[1], &args[0], expr); if !self.check(args_1, args_0, expr);
then { return } then { return }
} }

View File

@ -28,11 +28,11 @@ declare_lint_pass!(MemForget => [MEM_FORGET]);
impl<'tcx> LateLintPass<'tcx> for MemForget { impl<'tcx> LateLintPass<'tcx> for MemForget {
fn check_expr(&mut self, cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) { fn check_expr(&mut self, cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) {
if let ExprKind::Call(path_expr, args) = e.kind { if let ExprKind::Call(path_expr, [ref first_arg, ..]) = e.kind {
if let ExprKind::Path(ref qpath) = path_expr.kind { if let ExprKind::Path(ref qpath) = path_expr.kind {
if let Some(def_id) = cx.qpath_res(qpath, path_expr.hir_id).opt_def_id() { if let Some(def_id) = cx.qpath_res(qpath, path_expr.hir_id).opt_def_id() {
if match_def_path(cx, def_id, &paths::MEM_FORGET) { if match_def_path(cx, def_id, &paths::MEM_FORGET) {
let forgot_ty = cx.typeck_results().expr_ty(&args[0]); let forgot_ty = cx.typeck_results().expr_ty(first_arg);
if forgot_ty.ty_adt_def().map_or(false, |def| def.has_dtor(cx.tcx)) { if forgot_ty.ty_adt_def().map_or(false, |def| def.has_dtor(cx.tcx)) {
span_lint(cx, MEM_FORGET, e.span, "usage of `mem::forget` on `Drop` type"); span_lint(cx, MEM_FORGET, e.span, "usage of `mem::forget` on `Drop` type");

View File

@ -96,9 +96,9 @@ pub(super) fn check<'tcx>(
(&paths::RESULT, true, &["or", "unwrap_or"], "else"), (&paths::RESULT, true, &["or", "unwrap_or"], "else"),
]; ];
if let hir::ExprKind::MethodCall(path, _, args, _) = &arg.kind { if let hir::ExprKind::MethodCall(path, _, [self_arg, ..], _) = &arg.kind {
if path.ident.name == sym::len { if path.ident.name == sym::len {
let ty = cx.typeck_results().expr_ty(&args[0]).peel_refs(); let ty = cx.typeck_results().expr_ty(self_arg).peel_refs();
match ty.kind() { match ty.kind() {
ty::Slice(_) | ty::Array(_, _) | ty::Str => return, ty::Slice(_) | ty::Array(_, _) | ty::Str => return,

View File

@ -24,9 +24,9 @@ pub(super) fn derefs_to_slice<'tcx>(
} }
} }
if let hir::ExprKind::MethodCall(path, _, args, _) = expr.kind { if let hir::ExprKind::MethodCall(path, _, [self_arg, ..], _) = &expr.kind {
if path.ident.name == sym::iter && may_slice(cx, cx.typeck_results().expr_ty(&args[0])) { if path.ident.name == sym::iter && may_slice(cx, cx.typeck_results().expr_ty(self_arg)) {
Some(&args[0]) Some(self_arg)
} else { } else {
None None
} }

View File

@ -513,12 +513,12 @@ fn is_signum(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
} }
if_chain! { if_chain! {
if let ExprKind::MethodCall(method_name, _, expressions, _) = expr.kind; if let ExprKind::MethodCall(method_name, _, [ref self_arg, ..], _) = expr.kind;
if sym!(signum) == method_name.ident.name; if sym!(signum) == method_name.ident.name;
// Check that the receiver of the signum() is a float (expressions[0] is the receiver of // Check that the receiver of the signum() is a float (expressions[0] is the receiver of
// the method call) // the method call)
then { then {
return is_float(cx, &expressions[0]); return is_float(cx, self_arg);
} }
} }
false false

View File

@ -47,9 +47,9 @@ declare_lint_pass!(MutMutexLock => [MUT_MUTEX_LOCK]);
impl<'tcx> LateLintPass<'tcx> for MutMutexLock { impl<'tcx> LateLintPass<'tcx> for MutMutexLock {
fn check_expr(&mut self, cx: &LateContext<'tcx>, ex: &'tcx Expr<'tcx>) { fn check_expr(&mut self, cx: &LateContext<'tcx>, ex: &'tcx Expr<'tcx>) {
if_chain! { if_chain! {
if let ExprKind::MethodCall(path, method_span, args, _) = &ex.kind; if let ExprKind::MethodCall(path, method_span, [self_arg, ..], _) = &ex.kind;
if path.ident.name == sym!(lock); if path.ident.name == sym!(lock);
let ty = cx.typeck_results().expr_ty(&args[0]); let ty = cx.typeck_results().expr_ty(self_arg);
if let ty::Ref(_, inner_ty, Mutability::Mut) = ty.kind(); if let ty::Ref(_, inner_ty, Mutability::Mut) = ty.kind();
if is_type_diagnostic_item(cx, inner_ty, sym!(mutex_type)); if is_type_diagnostic_item(cx, inner_ty, sym!(mutex_type));
then { then {

View File

@ -31,11 +31,11 @@ declare_lint_pass!(OpenOptions => [NONSENSICAL_OPEN_OPTIONS]);
impl<'tcx> LateLintPass<'tcx> for OpenOptions { impl<'tcx> LateLintPass<'tcx> for OpenOptions {
fn check_expr(&mut self, cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) { fn check_expr(&mut self, cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) {
if let ExprKind::MethodCall(path, _, arguments, _) = e.kind { if let ExprKind::MethodCall(path, _, [self_arg, ..], _) = &e.kind {
let obj_ty = cx.typeck_results().expr_ty(&arguments[0]).peel_refs(); let obj_ty = cx.typeck_results().expr_ty(self_arg).peel_refs();
if path.ident.name == sym!(open) && match_type(cx, obj_ty, &paths::OPEN_OPTIONS) { if path.ident.name == sym!(open) && match_type(cx, obj_ty, &paths::OPEN_OPTIONS) {
let mut options = Vec::new(); let mut options = Vec::new();
get_open_options(cx, &arguments[0], &mut options); get_open_options(cx, self_arg, &mut options);
check_open_options(cx, &options, e.span); check_open_options(cx, &options, e.span);
} }
} }

View File

@ -92,13 +92,13 @@ fn expr_as_ptr_offset_call<'tcx>(
cx: &LateContext<'tcx>, cx: &LateContext<'tcx>,
expr: &'tcx Expr<'_>, expr: &'tcx Expr<'_>,
) -> Option<(&'tcx Expr<'tcx>, &'tcx Expr<'tcx>, Method)> { ) -> Option<(&'tcx Expr<'tcx>, &'tcx Expr<'tcx>, Method)> {
if let ExprKind::MethodCall(path_segment, _, args, _) = expr.kind { if let ExprKind::MethodCall(path_segment, _, [arg_0, arg_1, ..], _) = &expr.kind {
if is_expr_ty_raw_ptr(cx, &args[0]) { if is_expr_ty_raw_ptr(cx, arg_0) {
if path_segment.ident.name == sym::offset { if path_segment.ident.name == sym::offset {
return Some((&args[0], &args[1], Method::Offset)); return Some((arg_0, arg_1, Method::Offset));
} }
if path_segment.ident.name == sym!(wrapping_offset) { if path_segment.ident.name == sym!(wrapping_offset) {
return Some((&args[0], &args[1], Method::WrappingOffset)); return Some((arg_0, arg_1, Method::WrappingOffset));
} }
} }
} }

View File

@ -345,9 +345,9 @@ declare_lint_pass!(StrToString => [STR_TO_STRING]);
impl LateLintPass<'_> for StrToString { impl LateLintPass<'_> for StrToString {
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &Expr<'_>) { fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &Expr<'_>) {
if_chain! { if_chain! {
if let ExprKind::MethodCall(path, _, args, _) = &expr.kind; if let ExprKind::MethodCall(path, _, [self_arg, ..], _) = &expr.kind;
if path.ident.name == sym!(to_string); if path.ident.name == sym!(to_string);
let ty = cx.typeck_results().expr_ty(&args[0]); let ty = cx.typeck_results().expr_ty(self_arg);
if let ty::Ref(_, ty, ..) = ty.kind(); if let ty::Ref(_, ty, ..) = ty.kind();
if *ty.kind() == ty::Str; if *ty.kind() == ty::Str;
then { then {
@ -394,9 +394,9 @@ declare_lint_pass!(StringToString => [STRING_TO_STRING]);
impl LateLintPass<'_> for StringToString { impl LateLintPass<'_> for StringToString {
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &Expr<'_>) { fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &Expr<'_>) {
if_chain! { if_chain! {
if let ExprKind::MethodCall(path, _, args, _) = &expr.kind; if let ExprKind::MethodCall(path, _, [self_arg, ..], _) = &expr.kind;
if path.ident.name == sym!(to_string); if path.ident.name == sym!(to_string);
let ty = cx.typeck_results().expr_ty(&args[0]); let ty = cx.typeck_results().expr_ty(self_arg);
if is_type_diagnostic_item(cx, ty, sym::string_type); if is_type_diagnostic_item(cx, ty, sym::string_type);
then { then {
span_lint_and_help( span_lint_and_help(

View File

@ -92,11 +92,11 @@ impl LateLintPass<'_> for ToStringInDisplay {
if_chain! { if_chain! {
if self.in_display_impl; if self.in_display_impl;
if let Some(self_hir_id) = self.self_hir_id; if let Some(self_hir_id) = self.self_hir_id;
if let ExprKind::MethodCall(path, _, args, _) = expr.kind; if let ExprKind::MethodCall(path, _, [ref self_arg, ..], _) = expr.kind;
if path.ident.name == sym!(to_string); if path.ident.name == sym!(to_string);
if let Some(expr_def_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id); if let Some(expr_def_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id);
if is_diag_trait_item(cx, expr_def_id, sym::ToString); if is_diag_trait_item(cx, expr_def_id, sym::ToString);
if path_to_local_id(&args[0], self_hir_id); if path_to_local_id(self_arg, self_hir_id);
then { then {
span_lint( span_lint(
cx, cx,

View File

@ -37,8 +37,8 @@ declare_lint_pass!(UndroppedManuallyDrops => [UNDROPPED_MANUALLY_DROPS]);
impl LateLintPass<'tcx> for UndroppedManuallyDrops { impl LateLintPass<'tcx> for UndroppedManuallyDrops {
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) { fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
if let Some(args) = match_function_call(cx, expr, &paths::DROP) { if let Some([arg_0, ..]) = match_function_call(cx, expr, &paths::DROP) {
let ty = cx.typeck_results().expr_ty(&args[0]); let ty = cx.typeck_results().expr_ty(arg_0);
if is_type_lang_item(cx, ty, lang_items::LangItem::ManuallyDrop) { if is_type_lang_item(cx, ty, lang_items::LangItem::ManuallyDrop) {
span_lint_and_help( span_lint_and_help(
cx, cx,

View File

@ -45,20 +45,20 @@ impl<'tcx> LateLintPass<'tcx> for UnusedIoAmount {
match expr.kind { match expr.kind {
hir::ExprKind::Match(res, _, _) if is_try(cx, expr).is_some() => { hir::ExprKind::Match(res, _, _) if is_try(cx, expr).is_some() => {
if let hir::ExprKind::Call(func, args) = res.kind { if let hir::ExprKind::Call(func, [ref arg_0, ..]) = res.kind {
if matches!( if matches!(
func.kind, func.kind,
hir::ExprKind::Path(hir::QPath::LangItem(hir::LangItem::TryTraitBranch, _)) hir::ExprKind::Path(hir::QPath::LangItem(hir::LangItem::TryTraitBranch, _))
) { ) {
check_map_error(cx, &args[0], expr); check_map_error(cx, arg_0, expr);
} }
} else { } else {
check_map_error(cx, res, expr); check_map_error(cx, res, expr);
} }
}, },
hir::ExprKind::MethodCall(path, _, args, _) => match &*path.ident.as_str() { hir::ExprKind::MethodCall(path, _, [ref arg_0, ..], _) => match &*path.ident.as_str() {
"expect" | "unwrap" | "unwrap_or" | "unwrap_or_else" => { "expect" | "unwrap" | "unwrap_or" | "unwrap_or_else" => {
check_map_error(cx, &args[0], expr); check_map_error(cx, arg_0, expr);
}, },
_ => (), _ => (),
}, },

View File

@ -504,10 +504,10 @@ impl<'tcx> LateLintPass<'tcx> for CompilerLintFunctions {
} }
if_chain! { if_chain! {
if let ExprKind::MethodCall(path, _, args, _) = expr.kind; if let ExprKind::MethodCall(path, _, [self_arg, ..], _) = &expr.kind;
let fn_name = path.ident; let fn_name = path.ident;
if let Some(sugg) = self.map.get(&*fn_name.as_str()); if let Some(sugg) = self.map.get(&*fn_name.as_str());
let ty = cx.typeck_results().expr_ty(&args[0]).peel_refs(); let ty = cx.typeck_results().expr_ty(self_arg).peel_refs();
if match_type(cx, ty, &paths::EARLY_CONTEXT) if match_type(cx, ty, &paths::EARLY_CONTEXT)
|| match_type(cx, ty, &paths::LATE_CONTEXT); || match_type(cx, ty, &paths::LATE_CONTEXT);
then { then {