Skip to content

Commit

Permalink
Auto merge of rust-lang#92601 - camelid:more-intra-doc-cleanup, r=Man…
Browse files Browse the repository at this point in the history
…ishearth

rustdoc: Remove the intra-doc links side channel

The side channel made the code much more complex and harder to
understand. It was added as a temporary workaround in
0c99d80, but it's no longer necessary.

The addition of `UrlFragment` in rust-lang#92088 was the key to getting rid of
the side channel. The semantic information (rather than the strings that
used to be used for fragments) that is now captured by `UrlFragment` is
enough to obviate the side channel. An additional change had to be made
to `UrlFragment` in this PR to make this possible: it now records
`DefId`s rather than item names.

This PR also consolidates the checks for anchor conflicts into one place.

r? `@Manishearth`
  • Loading branch information
bors committed Jan 11, 2022
2 parents 89b9f7b + a626da4 commit 1f213d9
Show file tree
Hide file tree
Showing 2 changed files with 148 additions and 142 deletions.
3 changes: 1 addition & 2 deletions src/librustdoc/clean/types.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
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 @@ -496,7 +495,7 @@ impl Item {
if let Ok((mut href, ..)) = href(*did, cx) {
debug!(?href);
if let Some(ref fragment) = *fragment {
write!(href, "{}", fragment).unwrap()
fragment.render(&mut href, cx.tcx()).unwrap()
}
Some(RenderedLink {
original_text: s.clone(),
Expand Down
Loading

0 comments on commit 1f213d9

Please sign in to comment.