diff options
| author | bors <bors@rust-lang.org> | 2022-09-10 06:55:37 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-09-10 06:55:37 +0000 |
| commit | db9d86b58dff2a19d84d5e557641dfbb4cbb3a8d (patch) | |
| tree | b34922610ea83e017e6942fde1e716a4c76fb7dc /src/librustdoc | |
| parent | cedd26b1ea066fe243b82b0f78e37066c6f4d789 (diff) | |
| parent | 973059e1e7e3a66c3138e7578d7c9c9ab83b5318 (diff) | |
| download | rust-db9d86b58dff2a19d84d5e557641dfbb4cbb3a8d.tar.gz rust-db9d86b58dff2a19d84d5e557641dfbb4cbb3a8d.zip | |
Auto merge of #101639 - matthiaskrgr:rollup-sewkrgm, r=matthiaskrgr
Rollup of 6 pull requests
Successful merges:
- #101413 (Use RelocModel::Pic for UEFI targets)
- #101595 (Fix ICE report flags display.)
- #101616 (Adapt test for msan message change)
- #101624 (rustdoc: remove unused CSS `#search { position: relative }`)
- #101633 (Rustdoc-Json: Correcty handle intra-doc-links to items without HTML page)
- #101634 (Rustdoc-Json Tests: Use ``@is`` and ``@ismany`` more often.)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'src/librustdoc')
| -rw-r--r-- | src/librustdoc/clean/types.rs | 7 | ||||
| -rw-r--r-- | src/librustdoc/html/static/css/rustdoc.css | 5 | ||||
| -rw-r--r-- | src/librustdoc/json/conversions.rs | 11 | ||||
| -rw-r--r-- | src/librustdoc/passes/collect_intra_doc_links.rs | 10 |
4 files changed, 21 insertions, 12 deletions
diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 2077cf71b2e..f973fd0889e 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -510,7 +510,7 @@ impl Item { .get(&self.item_id) .map_or(&[][..], |v| v.as_slice()) .iter() - .filter_map(|ItemLink { link: s, link_text, did, ref fragment }| { + .filter_map(|ItemLink { link: s, link_text, page_id: did, ref fragment }| { debug!(?did); if let Ok((mut href, ..)) = href(*did, cx) { debug!(?href); @@ -1134,7 +1134,10 @@ pub(crate) struct ItemLink { /// This may not be the same as `link` if there was a disambiguator /// in an intra-doc link (e.g. \[`fn@f`\]) pub(crate) link_text: String, - pub(crate) did: DefId, + /// The `DefId` of the Item whose **HTML Page** contains the item being + /// linked to. This will be different to `item_id` on item's that don't + /// have their own page, such as struct fields and enum variants. + pub(crate) page_id: DefId, /// The url fragment to append to the link pub(crate) fragment: Option<UrlFragment>, } diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index ec9e3b1ecd1..dae2ff4e226 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -592,10 +592,6 @@ h2.location a { margin: 0; } -#search { - position: relative; -} - .search-loading { text-align: center; } @@ -973,7 +969,6 @@ so that we can apply CSS-filters to change the arrow color in themes */ .search-results > a { display: block; - width: 100%; /* A little margin ensures the browser's outlining of focused links has room to display. */ margin-left: 2px; margin-right: 2px; diff --git a/src/librustdoc/json/conversions.rs b/src/librustdoc/json/conversions.rs index 1177d482ac0..49a31f5f1da 100644 --- a/src/librustdoc/json/conversions.rs +++ b/src/librustdoc/json/conversions.rs @@ -19,6 +19,7 @@ use crate::clean::utils::print_const_expr; use crate::clean::{self, ItemId}; use crate::formats::item_type::ItemType; use crate::json::JsonRenderer; +use crate::passes::collect_intra_doc_links::UrlFragment; impl JsonRenderer<'_> { pub(super) fn convert_item(&self, item: clean::Item) -> Option<Item> { @@ -29,8 +30,14 @@ impl JsonRenderer<'_> { .get(&item.item_id) .into_iter() .flatten() - .map(|clean::ItemLink { link, did, .. }| { - (link.clone(), from_item_id((*did).into(), self.tcx)) + .map(|clean::ItemLink { link, page_id, fragment, .. }| { + let id = match fragment { + Some(UrlFragment::Item(frag_id)) => *frag_id, + // FIXME: Pass the `UserWritten` segment to JSON consumer. + Some(UrlFragment::UserWritten(_)) | None => *page_id, + }; + + (link.clone(), from_item_id(id.into(), self.tcx)) }) .collect(); let docs = item.attrs.collapsed_doc_value(); diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index cfd6ce402c2..677c980f63c 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -223,6 +223,9 @@ enum MalformedGenerics { #[derive(Clone, Debug, Hash, PartialEq, Eq)] pub(crate) enum UrlFragment { Item(DefId), + /// A part of a page that isn't a rust item. + /// + /// Eg: `[Vector Examples](std::vec::Vec#examples)` UserWritten(String), } @@ -1127,7 +1130,7 @@ impl LinkCollector<'_, '_> { Some(ItemLink { link: ori_link.link.clone(), link_text: link_text.clone(), - did: res.def_id(self.cx.tcx), + page_id: res.def_id(self.cx.tcx), fragment, }) } @@ -1146,11 +1149,12 @@ impl LinkCollector<'_, '_> { item, &diag_info, )?; - let id = clean::register_res(self.cx, rustc_hir::def::Res::Def(kind, id)); + + let page_id = clean::register_res(self.cx, rustc_hir::def::Res::Def(kind, id)); Some(ItemLink { link: ori_link.link.clone(), link_text: link_text.clone(), - did: id, + page_id, fragment, }) } |
