Rollup merge of #99479 - Enselic:import-can-be-without-id, r=camelid
rustdoc-json: Remove doc FIXME for Import::id and explain Also add some test and refactor related code a bit. ``@rustbot`` labels +A-rustdoc-json +T-rustdoc
This commit is contained in:
commit
0dc39c7bd9
3 changed files with 23 additions and 20 deletions
|
@ -685,24 +685,18 @@ impl FromWithTcx<clean::Variant> for Variant {
|
|||
impl FromWithTcx<clean::Import> for Import {
|
||||
fn from_tcx(import: clean::Import, tcx: TyCtxt<'_>) -> Self {
|
||||
use clean::ImportKind::*;
|
||||
match import.kind {
|
||||
Simple(s) => Import {
|
||||
source: import.source.path.whole_name(),
|
||||
name: s.to_string(),
|
||||
id: import.source.did.map(ItemId::from).map(|i| from_item_id(i, tcx)),
|
||||
glob: false,
|
||||
},
|
||||
Glob => Import {
|
||||
source: import.source.path.whole_name(),
|
||||
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,
|
||||
},
|
||||
let (name, glob) = match import.kind {
|
||||
Simple(s) => (s.to_string(), false),
|
||||
Glob => (
|
||||
import.source.path.last_opt().unwrap_or_else(|| Symbol::intern("*")).to_string(),
|
||||
true,
|
||||
),
|
||||
};
|
||||
Import {
|
||||
source: import.source.path.whole_name(),
|
||||
name,
|
||||
id: import.source.did.map(ItemId::from).map(|i| from_item_id(i, tcx)),
|
||||
glob,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue