diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2016-09-15 00:51:46 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2016-10-04 22:20:37 +0300 |
| commit | d19c16acfbfb718606a2b1519bbd9db43b451761 (patch) | |
| tree | 1055c9d1af95a0982718403debb804d4e8716cc5 /src/librustc_metadata/decoder.rs | |
| parent | da7b1c984c74db17198bd5434d5da78587a9a91e (diff) | |
| download | rust-d19c16acfbfb718606a2b1519bbd9db43b451761.tar.gz rust-d19c16acfbfb718606a2b1519bbd9db43b451761.zip | |
Fix cross-crate resolution of half-items created by export shadowing
Diffstat (limited to 'src/librustc_metadata/decoder.rs')
| -rw-r--r-- | src/librustc_metadata/decoder.rs | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/src/librustc_metadata/decoder.rs b/src/librustc_metadata/decoder.rs index 3e4a2542b27..59a33fcbbcd 100644 --- a/src/librustc_metadata/decoder.rs +++ b/src/librustc_metadata/decoder.rs @@ -670,10 +670,12 @@ impl<'a, 'tcx> CrateMetadata { // FIXME(eddyb) Don't encode these in children. EntryKind::ForeignMod => { for child_index in child.children.decode(self) { - callback(def::Export { - def_id: self.local_def_id(child_index), - name: self.item_name(&self.entry(child_index)) - }); + if let Some(def) = self.get_def(child_index) { + callback(def::Export { + def: def, + name: self.item_name(&self.entry(child_index)) + }); + } } continue; } @@ -683,11 +685,26 @@ impl<'a, 'tcx> CrateMetadata { } let def_key = child.def_key.decode(self); - if let Some(name) = def_key.disambiguated_data.data.get_opt_name() { - callback(def::Export { - def_id: self.local_def_id(child_index), - name: name - }); + if let (Some(def), Some(name)) = (self.get_def(child_index), + def_key.disambiguated_data.data.get_opt_name()) { + callback(def::Export { def: def, name: name }); + // For non-reexport structs and variants add their constructors to children. + // Reexport lists automatically contain constructors when necessary. + match def { + Def::Struct(..) => { + if let Some(ctor_def_id) = self.get_struct_ctor_def_id(child_index) { + let vkind = self.get_variant_kind(child_index).unwrap(); + let ctor_def = Def::StructCtor(ctor_def_id, vkind.ctor_kind()); + callback(def::Export { def: ctor_def, name: name }); + } + } + Def::Variant(def_id) => { + let vkind = self.get_variant_kind(child_index).unwrap(); + let ctor_def = Def::VariantCtor(def_id, vkind.ctor_kind()); + callback(def::Export { def: ctor_def, name: name }); + } + _ => {} + } } } } |
