Fix glob import ICE in rustdoc JSON format
This commit is contained in:
parent
bd2e51a338
commit
b7e62000dd
2 changed files with 11 additions and 2 deletions
|
@ -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 {
|
||||
|
|
|
@ -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,
|
||||
},
|
||||
|
|
Loading…
Add table
Reference in a new issue