11use clippy_utils:: diagnostics:: span_lint_and_sugg;
2- use clippy_utils:: res:: MaybeQPath ;
2+ use clippy_utils:: res:: { MaybeDef , MaybeQPath } ;
33use clippy_utils:: source:: { indent_of, reindent_multiline} ;
44use clippy_utils:: sugg:: Sugg ;
55use clippy_utils:: ty:: { option_arg_ty, peel_and_count_ty_refs} ;
6- use clippy_utils:: { get_parent_expr, is_res_lang_ctor , peel_blocks, span_contains_comment} ;
6+ use clippy_utils:: { get_parent_expr, peel_blocks, span_contains_comment} ;
77use rustc_ast:: { BindingMode , Mutability } ;
88use rustc_errors:: Applicability ;
99use rustc_hir:: LangItem :: { OptionNone , OptionSome , ResultErr } ;
@@ -73,7 +73,10 @@ fn is_variant_or_wildcard(cx: &LateContext<'_>, pat: &Pat<'_>, can_be_wild: bool
7373 true
7474 } ,
7575 PatKind :: TupleStruct ( qpath, ..) => {
76- is_res_lang_ctor ( cx, cx. qpath_res ( & qpath, pat. hir_id ) , ResultErr ) == must_match_err
76+ cx. qpath_res ( & qpath, pat. hir_id )
77+ . ctor_parent ( cx)
78+ . is_lang_item ( cx, ResultErr )
79+ == must_match_err
7780 } ,
7881 PatKind :: Binding ( _, _, _, Some ( pat) ) | PatKind :: Ref ( pat, _) => {
7982 is_variant_or_wildcard ( cx, pat, can_be_wild, must_match_err)
@@ -104,7 +107,7 @@ fn is_ok_or_err<'hir>(cx: &LateContext<'_>, pat: &Pat<'hir>) -> Option<(bool, &'
104107/// Check if `expr` contains `Some(ident)`, possibly as a block
105108fn is_some_ident < ' tcx > ( cx : & LateContext < ' tcx > , expr : & Expr < ' _ > , ident : & Ident , ty : Ty < ' tcx > ) -> bool {
106109 if let ExprKind :: Call ( body_callee, [ body_arg] ) = peel_blocks ( expr) . kind
107- && is_res_lang_ctor ( cx , body_callee. res ( cx) , OptionSome )
110+ && body_callee. res ( cx) . ctor_parent ( cx ) . is_lang_item ( cx , OptionSome )
108111 && cx. typeck_results ( ) . expr_ty ( body_arg) == ty
109112 && let ExprKind :: Path ( QPath :: Resolved (
110113 _,
@@ -121,7 +124,7 @@ fn is_some_ident<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'_>, ident: &Ident, t
121124
122125/// Check if `expr` is `None`, possibly as a block
123126fn is_none ( cx : & LateContext < ' _ > , expr : & Expr < ' _ > ) -> bool {
124- is_res_lang_ctor ( cx , peel_blocks ( expr) . res ( cx) , OptionNone )
127+ peel_blocks ( expr) . res ( cx) . ctor_parent ( cx ) . is_lang_item ( cx , OptionNone )
125128}
126129
127130/// Suggest replacing `expr` by `scrutinee.METHOD()`, where `METHOD` is either `ok` or
0 commit comments