]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_metadata/decoder.rs
Auto merge of #50271 - sinkuu:fix_ice, r=eddyb
[rust.git] / src / librustc_metadata / decoder.rs
index 388bf1fb99a34ecd35fa11bc0d4158d6bd5ed2e5..57f92707ccfe332060a7ed943a7b9d4fa713f70b 100644 (file)
@@ -977,7 +977,13 @@ pub fn get_implementations_for_trait(&self,
     }
 
     pub fn get_trait_of_item(&self, id: DefIndex) -> Option<DefId> {
-        self.def_key(id).parent.and_then(|parent_index| {
+        let def_key = self.def_key(id);
+        match def_key.disambiguated_data.data {
+            DefPathData::TypeNs(..) | DefPathData::ValueNs(..) => (),
+            // Not an associated item
+            _ => return None,
+        }
+        def_key.parent.and_then(|parent_index| {
             match self.entry(parent_index).kind {
                 EntryKind::Trait(_) => Some(self.local_def_id(parent_index)),
                 _ => None,