mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-24 13:43:17 +00:00
Remove unwrap
from match_trait_method
Unused_IO_amount relies on `match_trait_method` in order to match trait methods that exist in Tokio traits as the corresponding symbols don't exist. With this commit we remove the unwrap that may have caused 12366. Note: author (@m-rph) and @GuillaumeGomez couldn't replicate 12366.
This commit is contained in:
parent
660b058ba2
commit
94fe2fac63
1 changed files with 4 additions and 3 deletions
|
@ -298,9 +298,10 @@ pub fn is_ty_alias(qpath: &QPath<'_>) -> bool {
|
||||||
/// Checks if the method call given in `expr` belongs to the given trait.
|
/// Checks if the method call given in `expr` belongs to the given trait.
|
||||||
/// This is a deprecated function, consider using [`is_trait_method`].
|
/// This is a deprecated function, consider using [`is_trait_method`].
|
||||||
pub fn match_trait_method(cx: &LateContext<'_>, expr: &Expr<'_>, path: &[&str]) -> bool {
|
pub fn match_trait_method(cx: &LateContext<'_>, expr: &Expr<'_>, path: &[&str]) -> bool {
|
||||||
let def_id = cx.typeck_results().type_dependent_def_id(expr.hir_id).unwrap();
|
cx.typeck_results()
|
||||||
let trt_id = cx.tcx.trait_of_item(def_id);
|
.type_dependent_def_id(expr.hir_id)
|
||||||
trt_id.map_or(false, |trt_id| match_def_path(cx, trt_id, path))
|
.and_then(|defid| cx.tcx.trait_of_item(defid))
|
||||||
|
.map_or(false, |trt_id| match_def_path(cx, trt_id, path))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks if a method is defined in an impl of a diagnostic item
|
/// Checks if a method is defined in an impl of a diagnostic item
|
||||||
|
|
Loading…
Reference in a new issue