|
5 | 5 | use rustc_hir::def_id::DefId;
|
6 | 6 | use rustc_hir::{lang_items, LangItem};
|
7 | 7 | use rustc_middle::ty::subst::SubstsRef;
|
8 |
| -use rustc_middle::ty::{self, AssocItemContainer, DefIdTree, Instance, ParamEnv, Ty, TyCtxt}; |
| 8 | +use rustc_middle::ty::{AssocItemContainer, Instance, ParamEnv, Ty, TyCtxt}; |
9 | 9 | use rustc_span::symbol::Ident;
|
10 | 10 | use rustc_span::{sym, DesugaringKind, Span};
|
11 | 11 |
|
@@ -39,9 +39,7 @@ pub enum CallKind<'tcx> {
|
39 | 39 | Normal {
|
40 | 40 | self_arg: Option<Ident>,
|
41 | 41 | desugaring: Option<(CallDesugaringKind, Ty<'tcx>)>,
|
42 |
| - /// Whether the self type of the method call has an `.as_ref()` method. |
43 |
| - /// Used for better diagnostics. |
44 |
| - is_option_or_result: bool, |
| 42 | + method_did: DefId, |
45 | 43 | },
|
46 | 44 | /// A call to `Fn(..)::call(..)`, desugared from `my_closure(a, b, c)`
|
47 | 45 | FnCall { fn_trait_id: DefId, self_ty: Ty<'tcx> },
|
@@ -133,16 +131,6 @@ pub fn call_kind<'tcx>(
|
133 | 131 | } else {
|
134 | 132 | None
|
135 | 133 | };
|
136 |
| - let parent_did = tcx.parent(method_did); |
137 |
| - let parent_self_ty = (tcx.def_kind(parent_did) == rustc_hir::def::DefKind::Impl) |
138 |
| - .then_some(parent_did) |
139 |
| - .and_then(|did| match tcx.type_of(did).kind() { |
140 |
| - ty::Adt(def, ..) => Some(def.did()), |
141 |
| - _ => None, |
142 |
| - }); |
143 |
| - let is_option_or_result = parent_self_ty.map_or(false, |def_id| { |
144 |
| - matches!(tcx.get_diagnostic_name(def_id), Some(sym::Option | sym::Result)) |
145 |
| - }); |
146 |
| - CallKind::Normal { self_arg, desugaring, is_option_or_result } |
| 134 | + CallKind::Normal { self_arg, desugaring, method_did } |
147 | 135 | })
|
148 | 136 | }
|
0 commit comments