Skip to content

Commit 126cb9b

Browse files
Remove dead code
1 parent dde78bd commit 126cb9b

File tree

2 files changed

+1
-115
lines changed

2 files changed

+1
-115
lines changed

Diff for: src/librustdoc/html/markdown.rs

+1-48
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ use std::str::{self, CharIndices};
3535
use std::sync::OnceLock;
3636

3737
use pulldown_cmark::{
38-
BrokenLink, BrokenLinkCallback, CodeBlockKind, CowStr, Event, LinkType, OffsetIter, Options,
39-
Parser, Tag, TagEnd, html,
38+
BrokenLink, CodeBlockKind, CowStr, Event, LinkType, Options, Parser, Tag, TagEnd, html,
4039
};
4140
use rustc_data_structures::fx::FxHashMap;
4241
use rustc_errors::{Diag, DiagMessage};
@@ -1683,7 +1682,6 @@ pub(crate) fn html_text_from_events<'a>(
16831682
pub(crate) struct MarkdownLink {
16841683
pub kind: LinkType,
16851684
pub link: String,
1686-
pub display_text: Option<String>,
16871685
pub range: MarkdownLinkRange,
16881686
}
16891687

@@ -1845,23 +1843,9 @@ pub(crate) fn markdown_links<'md, R>(
18451843
LinkType::Autolink | LinkType::Email => unreachable!(),
18461844
};
18471845

1848-
let display_text = if matches!(
1849-
link_type,
1850-
LinkType::Inline
1851-
| LinkType::ReferenceUnknown
1852-
| LinkType::Reference
1853-
| LinkType::Shortcut
1854-
| LinkType::ShortcutUnknown
1855-
) {
1856-
collect_link_data(&mut event_iter)
1857-
} else {
1858-
None
1859-
};
1860-
18611846
if let Some(link) = preprocess_link(MarkdownLink {
18621847
kind: link_type,
18631848
link: dest_url.into_string(),
1864-
display_text,
18651849
range,
18661850
}) {
18671851
links.push(link);
@@ -1874,37 +1858,6 @@ pub(crate) fn markdown_links<'md, R>(
18741858
links
18751859
}
18761860

1877-
/// Collects additional data of link.
1878-
fn collect_link_data<'input, F: BrokenLinkCallback<'input>>(
1879-
event_iter: &mut OffsetIter<'input, F>,
1880-
) -> Option<String> {
1881-
let mut display_text: Option<String> = None;
1882-
let mut append_text = |text: CowStr<'_>| {
1883-
if let Some(display_text) = &mut display_text {
1884-
display_text.push_str(&text);
1885-
} else {
1886-
display_text = Some(text.to_string());
1887-
}
1888-
};
1889-
1890-
while let Some((event, _span)) = event_iter.next() {
1891-
match event {
1892-
Event::Text(text) => {
1893-
append_text(text);
1894-
}
1895-
Event::Code(code) => {
1896-
append_text(code);
1897-
}
1898-
Event::End(_) => {
1899-
break;
1900-
}
1901-
_ => {}
1902-
}
1903-
}
1904-
1905-
display_text
1906-
}
1907-
19081861
#[derive(Debug)]
19091862
pub(crate) struct RustCodeBlock {
19101863
/// The range in the markdown that the code block occupies. Note that this includes the fences

Diff for: src/librustdoc/passes/collect_intra_doc_links.rs

-67
Original file line numberDiff line numberDiff line change
@@ -1028,21 +1028,6 @@ impl LinkCollector<'_, '_> {
10281028
false,
10291029
)?;
10301030

1031-
if ori_link.display_text.is_some() {
1032-
self.resolve_display_text(
1033-
path_str,
1034-
ResolutionInfo {
1035-
item_id,
1036-
module_id,
1037-
dis: disambiguator,
1038-
path_str: ori_link.display_text.clone()?.into_boxed_str(),
1039-
extra_fragment: extra_fragment.clone(),
1040-
},
1041-
&ori_link,
1042-
&diag_info,
1043-
);
1044-
}
1045-
10461031
// Check for a primitive which might conflict with a module
10471032
// Report the ambiguity and require that the user specify which one they meant.
10481033
// FIXME: could there ever be a primitive not in the type namespace?
@@ -1385,58 +1370,6 @@ impl LinkCollector<'_, '_> {
13851370
}
13861371
}
13871372
}
1388-
1389-
/// Resolve display text if the provided link has separated parts of links.
1390-
///
1391-
/// For example:
1392-
/// Inline link `[display_text](dest_link)` and reference link `[display_text][reference_link]` has
1393-
/// separated parts of links.
1394-
fn resolve_display_text(
1395-
&mut self,
1396-
explicit_link: &Box<str>,
1397-
display_res_info: ResolutionInfo,
1398-
ori_link: &MarkdownLink,
1399-
diag_info: &DiagnosticInfo<'_>,
1400-
) {
1401-
// Check if explicit resolution's path is same as resolution of original link's display text path, see
1402-
// tests/rustdoc-ui/lint/redundant_explicit_links.rs for more cases.
1403-
//
1404-
// To avoid disambiguator from panicking, we check if display text path is possible to be disambiguated
1405-
// into explicit path.
1406-
if !matches!(
1407-
ori_link.kind,
1408-
LinkType::Inline | LinkType::Reference | LinkType::ReferenceUnknown
1409-
) {
1410-
return;
1411-
}
1412-
1413-
// Algorithm to check if display text could possibly be the explicit link:
1414-
//
1415-
// Consider 2 links which are display text and explicit link, pick the shorter
1416-
// one as symbol and longer one as full qualified path, and tries to match symbol
1417-
// to the full qualified path's last symbol.
1418-
//
1419-
// Otherwise, check if 2 links are same, if so, skip the resolve process.
1420-
//
1421-
// Notice that this algorithm is passive, might possibly miss actual redundant cases.
1422-
let explicit_link = explicit_link.to_string();
1423-
let display_text = ori_link.display_text.as_ref().unwrap();
1424-
1425-
if display_text.len() == explicit_link.len() {
1426-
// Whether they are same or not, skip the resolve process.
1427-
return;
1428-
}
1429-
1430-
if explicit_link.ends_with(&display_text[..]) || display_text.ends_with(&explicit_link[..])
1431-
{
1432-
self.resolve_with_disambiguator_cached(
1433-
display_res_info,
1434-
diag_info.clone(), // this struct should really be Copy, but Range is not :(
1435-
false,
1436-
true,
1437-
);
1438-
}
1439-
}
14401373
}
14411374

14421375
/// Get the section of a link between the backticks,

0 commit comments

Comments
 (0)