Skip to content

Commit 805ef35

Browse files
committed
Auto merge of #12540 - m-rph:12366, r=blyxyas
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 caused #12366. Note: author (`@m-rph)` and `@GuillaumeGomez` couldn't replicate #12366. changelog:none r? `@blyxyas`
2 parents ca6a647 + 94fe2fa commit 805ef35

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

clippy_utils/src/lib.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,9 +300,10 @@ pub fn is_ty_alias(qpath: &QPath<'_>) -> bool {
300300
/// Checks if the method call given in `expr` belongs to the given trait.
301301
/// This is a deprecated function, consider using [`is_trait_method`].
302302
pub fn match_trait_method(cx: &LateContext<'_>, expr: &Expr<'_>, path: &[&str]) -> bool {
303-
let def_id = cx.typeck_results().type_dependent_def_id(expr.hir_id).unwrap();
304-
let trt_id = cx.tcx.trait_of_item(def_id);
305-
trt_id.map_or(false, |trt_id| match_def_path(cx, trt_id, path))
303+
cx.typeck_results()
304+
.type_dependent_def_id(expr.hir_id)
305+
.and_then(|defid| cx.tcx.trait_of_item(defid))
306+
.map_or(false, |trt_id| match_def_path(cx, trt_id, path))
306307
}
307308

308309
/// Checks if a method is defined in an impl of a diagnostic item

0 commit comments

Comments
 (0)