diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2021-03-05 21:44:37 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-03-05 21:44:37 +0100 |
| commit | 92861c79276cee63e53ed4c63111cd37560c458c (patch) | |
| tree | 6ff6c7c2b59c66572b44986909a15d6ccf800784 /src/librustdoc/html | |
| parent | 8fd946c63a6c3aae9788bd459d278cb2efa77099 (diff) | |
| parent | 286a3570454b08fbf7fae890f19500190f55e0dc (diff) | |
| download | rust-92861c79276cee63e53ed4c63111cd37560c458c.tar.gz rust-92861c79276cee63e53ed4c63111cd37560c458c.zip | |
Rollup merge of #80845 - GuillaumeGomez:item-kind-transition, r=jyn514
Make ItemKind::ExternCrate looks like hir::ItemKind::ExternCrate to make transition over hir::ItemKind simpler It was surprisingly difficult to make this change, mostly because of two issues: * We now store the `ExternCrate` name in the parent struct (`clean::Item`), which forced me to modify the json conversion code a bit more than expected. * The second problem was that, since we now have a `Some(name)`, it was trying to render it, ending up in a panic because we ended up in a `unreachable` statement. The solution was simply to add `!item.is_extern_crate()` in `formats::renderer` before calling `cx.item(item, &cache)?;`. I'll continue to replace all the `clean::ItemKind` variants one by one until it looks exactly like `hir::ItemKind`. Then we'll simply discard the rustdoc type. Once this done, we'll be able to discard `clean::Item` too to use `hir::Item`. r? ``@jyn514``
Diffstat (limited to 'src/librustdoc/html')
| -rw-r--r-- | src/librustdoc/html/render/print_item.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index 6d61248f28e..6cdd3838023 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -240,7 +240,7 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl } match *myitem.kind { - clean::ExternCrateItem(ref name, ref src) => { + clean::ExternCrateItem { ref src } => { use crate::html::format::anchor; match *src { @@ -249,13 +249,13 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl "<tr><td><code>{}extern crate {} as {};", myitem.visibility.print_with_space(cx.tcx(), myitem.def_id, cx.cache()), anchor(myitem.def_id, &*src.as_str(), cx.cache()), - name + myitem.name.as_ref().unwrap(), ), None => write!( w, "<tr><td><code>{}extern crate {};", myitem.visibility.print_with_space(cx.tcx(), myitem.def_id, cx.cache()), - anchor(myitem.def_id, &*name.as_str(), cx.cache()) + anchor(myitem.def_id, &*myitem.name.as_ref().unwrap().as_str(), cx.cache()), ), } w.write_str("</code></td></tr>"); |
