@@ -38,19 +38,20 @@ pub(super) fn check(
3838 }
3939
4040 let ( constructor, call_args, ty) = if let hir:: ExprKind :: Call ( call, call_args) = init. kind {
41- let Some ( ( qpath, hir_id) ) = call. opt_qpath ( ) else {
42- return ;
43- } ;
44-
45- let args = last_path_segment ( qpath) . args . map ( |args| args. args ) ;
46- let res = cx. qpath_res ( qpath, hir_id) ;
47-
48- if res. ctor_parent ( cx) . is_lang_item ( cx, hir:: LangItem :: OptionSome ) {
49- ( sym:: Some , call_args, get_ty_from_args ( args, 0 ) )
50- } else if res. ctor_parent ( cx) . is_lang_item ( cx, hir:: LangItem :: ResultOk ) {
51- ( sym:: Ok , call_args, get_ty_from_args ( args, 0 ) )
52- } else if res. ctor_parent ( cx) . is_lang_item ( cx, hir:: LangItem :: ResultErr ) {
53- ( sym:: Err , call_args, get_ty_from_args ( args, 1 ) )
41+ if let Some ( ( qpath, hir_id) ) = call. opt_qpath ( )
42+ && let args = last_path_segment ( qpath) . args . map ( |args| args. args )
43+ && let Some ( did) = cx. qpath_res ( qpath, hir_id) . ctor_parent ( cx) . opt_def_id ( )
44+ {
45+ let lang_items = cx. tcx . lang_items ( ) ;
46+ if Some ( did) == lang_items. option_some_variant ( ) {
47+ ( sym:: Some , call_args, get_ty_from_args ( args, 0 ) )
48+ } else if Some ( did) == lang_items. result_ok_variant ( ) {
49+ ( sym:: Ok , call_args, get_ty_from_args ( args, 0 ) )
50+ } else if Some ( did) == lang_items. result_err_variant ( ) {
51+ ( sym:: Err , call_args, get_ty_from_args ( args, 1 ) )
52+ } else {
53+ return ;
54+ }
5455 } else {
5556 return ;
5657 }
0 commit comments