diff options
| author | Martin Nordholts <enselic@gmail.com> | 2022-07-19 21:23:17 +0200 |
|---|---|---|
| committer | Martin Nordholts <enselic@gmail.com> | 2022-07-19 22:43:39 +0200 |
| commit | 4e73d90ce0f32d685f97080a784a30502b073711 (patch) | |
| tree | 513844ce05bc50da1b458b1255a62b503604a995 | |
| parent | 96c2df810b0b681fee63cae11ca63844792b6190 (diff) | |
| download | rust-4e73d90ce0f32d685f97080a784a30502b073711.tar.gz rust-4e73d90ce0f32d685f97080a784a30502b073711.zip | |
rustdoc-json: De-duplicate `FromWithTcx<clean::Import>`
| -rw-r--r-- | src/librustdoc/json/conversions.rs | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/src/librustdoc/json/conversions.rs b/src/librustdoc/json/conversions.rs index 2598b9b0b28..791553631ae 100644 --- a/src/librustdoc/json/conversions.rs +++ b/src/librustdoc/json/conversions.rs @@ -679,24 +679,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, } } } |
