Fix glob import ICE in rustdoc JSON format

This commit is contained in:
Guillaume Gomez 2022-06-28 11:46:03 +02:00
parent bd2e51a338
commit b7e62000dd
2 changed files with 11 additions and 2 deletions

View file

@ -2161,8 +2161,12 @@ impl Path {
self.res.def_id()
}
pub(crate) fn last_opt(&self) -> Option<Symbol> {
self.segments.last().map(|s| s.name)
}
pub(crate) fn last(&self) -> Symbol {
self.segments.last().expect("segments were empty").name
self.last_opt().expect("segments were empty")
}
pub(crate) fn whole_name(&self) -> String {

View file

@ -663,7 +663,12 @@ impl FromWithTcx<clean::Import> for Import {
},
Glob => Import {
source: import.source.path.whole_name(),
name: import.source.path.last().to_string(),
name: import
.source
.path
.last_opt()
.unwrap_or_else(|| Symbol::intern("*"))
.to_string(),
id: import.source.did.map(ItemId::from).map(|i| from_item_id(i, tcx)),
glob: true,
},