about summary refs log tree commit diff
diff options
context:
space:
mode:
authorKyle Lin <minecraft.kyle.train@gmail.com>2023-07-01 01:29:40 +0800
committerKyle Lin <minecraft.kyle.train@gmail.com>2023-08-18 15:19:19 +0800
commit78c85f439f04f2aa484a9f1be3133d74bda87c7d (patch)
tree15d6b2ff17bd81918e873b364e6756530bc8d755
parentfe17ae3af6e1ff42b81a5309dc88b36dacfc8577 (diff)
downloadrust-78c85f439f04f2aa484a9f1be3133d74bda87c7d.tar.gz
rust-78c85f439f04f2aa484a9f1be3133d74bda87c7d.zip
fomar files
-rw-r--r--compiler/rustc_resolve/src/rustdoc.rs9
-rw-r--r--src/librustdoc/passes/lint/redundant_explicit_links.rs13
2 files changed, 17 insertions, 5 deletions
diff --git a/compiler/rustc_resolve/src/rustdoc.rs b/compiler/rustc_resolve/src/rustdoc.rs
index f7275bed59c..cbda0535c89 100644
--- a/compiler/rustc_resolve/src/rustdoc.rs
+++ b/compiler/rustc_resolve/src/rustdoc.rs
@@ -410,7 +410,14 @@ fn parse_links<'md>(doc: &'md str) -> Vec<Box<str>> {
     while let Some(event) = event_iter.next() {
         match event {
             Event::Start(Tag::Link(link_type, dest, _)) if may_be_doc_link(link_type) => {
-                if matches!(link_type, LinkType::Inline | LinkType::ReferenceUnknown | LinkType::Reference) {
+                if matches!(
+                    link_type,
+                    LinkType::Inline
+                        | LinkType::ReferenceUnknown
+                        | LinkType::Reference
+                        | LinkType::Shortcut
+                        | LinkType::ShortcutUnknown
+                ) {
                     if let Some(display_text) = collect_link_data(&mut event_iter) {
                         links.push(display_text);
                     }
diff --git a/src/librustdoc/passes/lint/redundant_explicit_links.rs b/src/librustdoc/passes/lint/redundant_explicit_links.rs
index da8a73be60b..a41e278fd81 100644
--- a/src/librustdoc/passes/lint/redundant_explicit_links.rs
+++ b/src/librustdoc/passes/lint/redundant_explicit_links.rs
@@ -34,7 +34,7 @@ pub(crate) fn visit_item(cx: &DocContext<'_>, item: &Item) {
 
     if item.link_names(&cx.cache).is_empty() {
         // If there's no link names in this item,
-        // then we skip resolution querying to 
+        // then we skip resolution querying to
         // avoid from panicking.
         return;
     }
@@ -80,7 +80,8 @@ fn check_redundant_explicit_link<'md>(
                 if (explicit_len >= display_len
                     && &explicit_link[(explicit_len - display_len)..] == display_link)
                     || (display_len >= explicit_len
-                        && &display_link[(display_len - explicit_len)..] == explicit_link) {
+                        && &display_link[(display_len - explicit_len)..] == explicit_link)
+                {
                     match link_type {
                         LinkType::Inline | LinkType::ReferenceUnknown => {
                             check_inline_or_reference_unknown_redundancy(
@@ -92,7 +93,11 @@ fn check_redundant_explicit_link<'md>(
                                 link_range,
                                 dest.to_string(),
                                 link_data,
-                                if link_type == LinkType::Inline { (b'(', b')') } else { (b'[', b']') },
+                                if link_type == LinkType::Inline {
+                                    (b'(', b')')
+                                } else {
+                                    (b'[', b']')
+                                },
                             );
                         }
                         LinkType::Reference => {
@@ -110,7 +115,7 @@ fn check_redundant_explicit_link<'md>(
                         _ => {}
                     }
                 }
-            },
+            }
             _ => {}
         }
     }