Skip to content

Commit d0be335

Browse files
committed
Remove is_inherent_method_call
1 parent e78f86d commit d0be335

File tree

3 files changed

+7
-15
lines changed

3 files changed

+7
-15
lines changed

clippy_lints/src/floating_point_arithmetic.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
use clippy_utils::consts::Constant::{F32, F64, Int};
22
use clippy_utils::consts::{ConstEvalCtxt, Constant};
33
use clippy_utils::diagnostics::span_lint_and_sugg;
4+
use clippy_utils::res::{MaybeDef, MaybeTypeckRes};
45
use clippy_utils::{
5-
eq_expr_value, get_parent_expr, has_ambiguous_literal_in_expr, higher, is_in_const_context,
6-
is_inherent_method_call, is_no_std_crate, numeric_literal, peel_blocks, sugg, sym,
6+
eq_expr_value, get_parent_expr, has_ambiguous_literal_in_expr, higher, is_in_const_context, is_no_std_crate,
7+
numeric_literal, peel_blocks, sugg, sym,
78
};
89
use rustc_ast::ast;
910
use rustc_errors::Applicability;
@@ -737,7 +738,7 @@ impl<'tcx> LateLintPass<'tcx> for FloatingPointArithmetic {
737738
if let ExprKind::MethodCall(path, receiver, args, _) = &expr.kind {
738739
let recv_ty = cx.typeck_results().expr_ty(receiver);
739740

740-
if recv_ty.is_floating_point() && !is_no_std_crate(cx) && is_inherent_method_call(cx, expr) {
741+
if recv_ty.is_floating_point() && !is_no_std_crate(cx) && cx.ty_based_def(expr).opt_parent(cx).is_impl(cx) {
741742
match path.ident.name {
742743
sym::ln => check_ln1p(cx, expr, receiver),
743744
sym::log => check_log_base(cx, expr, receiver, args),

clippy_lints/src/useless_conversion.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use clippy_utils::diagnostics::{span_lint_and_help, span_lint_and_sugg, span_lint_and_then};
2-
use clippy_utils::res::{MaybeDef, MaybeResPath};
2+
use clippy_utils::res::{MaybeDef, MaybeResPath, MaybeTypeckRes};
33
use clippy_utils::source::{snippet, snippet_with_context};
44
use clippy_utils::sugg::{DiagExt as _, Sugg};
55
use clippy_utils::ty::{is_copy, same_type_modulo_regions};
6-
use clippy_utils::{get_parent_expr, is_inherent_method_call, is_trait_item, is_trait_method, is_ty_alias, sym};
6+
use clippy_utils::{get_parent_expr, is_trait_item, is_trait_method, is_ty_alias, sym};
77
use rustc_errors::Applicability;
88
use rustc_hir::def_id::DefId;
99
use rustc_hir::{BindingMode, Expr, ExprKind, HirId, MatchSource, Mutability, Node, PatKind};
@@ -438,7 +438,7 @@ impl<'tcx> LateLintPass<'tcx> for UselessConversion {
438438
}
439439

440440
fn has_eligible_receiver(cx: &LateContext<'_>, recv: &Expr<'_>, expr: &Expr<'_>) -> bool {
441-
if is_inherent_method_call(cx, expr) {
441+
if cx.ty_based_def(expr).opt_parent(cx).is_impl(cx) {
442442
matches!(
443443
cx.typeck_results().expr_ty(recv).opt_diag_name(cx),
444444
Some(sym::Option | sym::Result | sym::ControlFlow)

clippy_utils/src/lib.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -347,15 +347,6 @@ pub fn is_ty_alias(qpath: &QPath<'_>) -> bool {
347347
}
348348
}
349349

350-
/// Checks if the given method call expression calls an inherent method.
351-
pub fn is_inherent_method_call(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
352-
if let Some(method_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id) {
353-
cx.tcx.trait_of_assoc(method_id).is_none()
354-
} else {
355-
false
356-
}
357-
}
358-
359350
/// Checks if the method call given in `expr` belongs to the given trait.
360351
pub fn is_trait_method(cx: &LateContext<'_>, expr: &Expr<'_>, diag_item: Symbol) -> bool {
361352
cx.typeck_results()

0 commit comments

Comments
 (0)