Skip to content

Commit 4b42aa4

Browse files
committed
save-analysis: emit names of items that a glob import actually imports.
There is also some work here to make resolve a bit more stable - it no longer overwrites a specific import with a glob import. [breaking-change] Import shadowing of single/list imports by globs is now forbidden. An interesting case is where a glob import imports a re-export (`pub use`) of a single import. This still counts as a single import for the purposes of shadowing .You can usually fix any bustage by re-ordering such imports. A single import may still shadow (override) a glob import or the prelude.
1 parent 22a9f25 commit 4b42aa4

File tree

10 files changed

+254
-58
lines changed

10 files changed

+254
-58
lines changed

src/librustc/metadata/csearch.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,13 @@ pub fn get_impl_or_trait_item<'tcx>(tcx: &ty::ctxt<'tcx>, def: ast::DefId)
148148
tcx)
149149
}
150150

151+
pub fn get_trait_name(cstore: &cstore::CStore, def: ast::DefId) -> ast::Name {
152+
let cdata = cstore.get_crate_data(def.krate);
153+
decoder::get_trait_name(cstore.intr.clone(),
154+
&*cdata,
155+
def.node)
156+
}
157+
151158
pub fn get_trait_item_name_and_kind(cstore: &cstore::CStore, def: ast::DefId)
152159
-> (ast::Name, resolve::TraitItemKind) {
153160
let cdata = cstore.get_crate_data(def.krate);

src/librustc/metadata/decoder.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,14 @@ pub fn get_impl_items(cdata: Cmd, impl_id: ast::NodeId)
784784
impl_items
785785
}
786786

787+
pub fn get_trait_name(intr: Rc<IdentInterner>,
788+
cdata: Cmd,
789+
id: ast::NodeId)
790+
-> ast::Name {
791+
let doc = lookup_item(id, cdata.data());
792+
item_name(&*intr, doc)
793+
}
794+
787795
pub fn get_trait_item_name_and_kind(intr: Rc<IdentInterner>,
788796
cdata: Cmd,
789797
id: ast::NodeId)

0 commit comments

Comments
 (0)