Skip to content

Commit

Permalink
Auto merge of #92088 - camelid:intra-doc-cleanup, r=Manishearth
Browse files Browse the repository at this point in the history
intra-doc: Use an enum to represent URL fragments

This is a step in the direction of computing the links more lazily,
which I think will simplify the implementation of intra-doc links.
This will also make it easier to eventually use the actual `Res` for
associated items, enum variants, and fields, rather than their HTML
page's `Res`.

r? `@jyn514`
  • Loading branch information
bors committed Dec 28, 2021
2 parents 41ce641 + ae2bc69 commit cc65bf3
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 79 deletions.
7 changes: 4 additions & 3 deletions src/librustdoc/clean/types.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::cell::RefCell;
use std::default::Default;
use std::fmt::Write;
use std::hash::Hash;
use std::lazy::SyncOnceCell as OnceCell;
use std::path::PathBuf;
Expand Down Expand Up @@ -40,6 +41,7 @@ use crate::formats::cache::Cache;
use crate::formats::item_type::ItemType;
use crate::html::render::cache::ExternalLocation;
use crate::html::render::Context;
use crate::passes::collect_intra_doc_links::UrlFragment;

crate use self::FnRetTy::*;
crate use self::ItemKind::*;
Expand Down Expand Up @@ -485,8 +487,7 @@ impl Item {
if let Ok((mut href, ..)) = href(*did, cx) {
debug!(?href);
if let Some(ref fragment) = *fragment {
href.push('#');
href.push_str(fragment);
write!(href, "{}", fragment).unwrap()
}
Some(RenderedLink {
original_text: s.clone(),
Expand Down Expand Up @@ -977,7 +978,7 @@ crate struct ItemLink {
pub(crate) link_text: String,
pub(crate) did: DefId,
/// The url fragment to append to the link
pub(crate) fragment: Option<String>,
pub(crate) fragment: Option<UrlFragment>,
}

pub struct RenderedLink {
Expand Down
Loading

0 comments on commit cc65bf3

Please sign in to comment.