Skip to content

Commit 69bd46a

Browse files
committed
Remove special-casing from TyCtxt::impl_of_method.
We can do this now that opt_associated_item doesn't have any panicking paths.
1 parent 97da6da commit 69bd46a

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

src/librustc/ty/mod.rs

+2-12
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
3535
use rustc_data_structures::sync::{self, par_iter, Lrc, ParallelIterator};
3636
use rustc_hir as hir;
3737
use rustc_hir::def::{CtorKind, CtorOf, DefKind, Namespace, Res};
38-
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LocalDefId, CRATE_DEF_INDEX, LOCAL_CRATE};
38+
use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LocalDefId, CRATE_DEF_INDEX};
3939
use rustc_hir::{Constness, GlobMap, Node, TraitMap};
4040
use rustc_index::vec::{Idx, IndexVec};
4141
use rustc_macros::HashStable;
@@ -3054,17 +3054,7 @@ impl<'tcx> TyCtxt<'tcx> {
30543054
/// If the given defid describes a method belonging to an impl, returns the
30553055
/// `DefId` of the impl that the method belongs to; otherwise, returns `None`.
30563056
pub fn impl_of_method(self, def_id: DefId) -> Option<DefId> {
3057-
let item = if def_id.krate != LOCAL_CRATE {
3058-
if let Some(DefKind::AssocFn) = self.def_kind(def_id) {
3059-
Some(self.associated_item(def_id))
3060-
} else {
3061-
None
3062-
}
3063-
} else {
3064-
self.opt_associated_item(def_id)
3065-
};
3066-
3067-
item.and_then(|trait_item| match trait_item.container {
3057+
self.opt_associated_item(def_id).and_then(|trait_item| match trait_item.container {
30683058
TraitContainer(_) => None,
30693059
ImplContainer(def_id) => Some(def_id),
30703060
})

0 commit comments

Comments
 (0)