]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #50271 - sinkuu:fix_ice, r=eddyb
authorbors <bors@rust-lang.org>
Sun, 29 Apr 2018 03:01:09 +0000 (03:01 +0000)
committerbors <bors@rust-lang.org>
Sun, 29 Apr 2018 03:01:09 +0000 (03:01 +0000)
Fix ICE #48984

* ~~fbf6423  The tail type was not normalized.~~
* https://github.com/rust-lang/rust/commit/d0839d5680d2a51785eeb0811cf3e2beba90eacb  The method had a wrong assumption that something whose parent is a trait is an associated item. Fixes #48984.

1  2 
src/librustc_metadata/decoder.rs

index 388bf1fb99a34ecd35fa11bc0d4158d6bd5ed2e5,07a1da429431cadd846a88b9753247f9224cf38f..57f92707ccfe332060a7ed943a7b9d4fa713f70b
@@@ -40,7 -40,7 +40,7 @@@ use rustc_serialize::{Decodable, Decode
  use syntax::attr;
  use syntax::ast::{self, Ident};
  use syntax::codemap;
 -use syntax::symbol::{InternedString, Symbol};
 +use syntax::symbol::InternedString;
  use syntax::ext::base::MacroKind;
  use syntax_pos::{self, Span, BytePos, Pos, DUMMY_SP, NO_EXPANSION};
  
@@@ -537,12 -537,12 +537,12 @@@ impl<'a, 'tcx> CrateMetadata 
  
          ty::VariantDef {
              did: self.local_def_id(data.struct_ctor.unwrap_or(index)),
 -            name: Symbol::intern(&self.item_name(index)),
 +            name: self.item_name(index).as_symbol(),
              fields: item.children.decode(self).map(|index| {
                  let f = self.entry(index);
                  ty::FieldDef {
                      did: self.local_def_id(index),
 -                    name: Symbol::intern(&self.item_name(index)),
 +                    name: self.item_name(index).as_symbol(),
                      vis: f.visibility.decode(self)
                  }
              }).collect(),
                              if let Some(def) = self.get_def(child_index) {
                                  callback(def::Export {
                                      def,
 -                                    ident: Ident::from_str(&self.item_name(child_index)),
 +                                    ident: Ident::from_interned_str(self.item_name(child_index)),
                                      vis: self.get_visibility(child_index),
                                      span: self.entry(child_index).span.decode((self, sess)),
                                      is_import: false,
                  let span = child.span.decode((self, sess));
                  if let (Some(def), Some(name)) =
                      (self.get_def(child_index), def_key.disambiguated_data.data.get_opt_name()) {
 -                    let ident = Ident::from_str(&name);
 +                    let ident = Ident::from_interned_str(name);
                      let vis = self.get_visibility(child_index);
                      let is_import = false;
                      callback(def::Export { def, ident, vis, span, is_import });
          };
  
          ty::AssociatedItem {
 -            name: Symbol::intern(&name),
 +            name: name.as_symbol(),
              kind,
              vis: item.visibility.decode(self),
              defaultness: container.defaultness(),
          self.entry(id)
              .children
              .decode(self)
 -            .map(|index| Symbol::intern(&self.item_name(index)))
 +            .map(|index| self.item_name(index).as_symbol())
              .collect()
      }
  
      }
  
      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,
              DefKey {
                  parent: Some(CRATE_DEF_INDEX),
                  disambiguated_data: DisambiguatedDefPathData {
 -                    data: DefPathData::MacroDef(name.as_str()),
 +                    data: DefPathData::MacroDef(name.as_interned_str()),
                      disambiguator: 0,
                  }
              }