File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed
tests/rustdoc-ui/intra-doc Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -997,6 +997,7 @@ fn preprocess_link(
997
997
}
998
998
} ;
999
999
1000
+ let is_shortcut_style = ori_link. kind == LinkType :: ShortcutUnknown ;
1000
1001
// If there's no backticks, be lenient and revert to the old behavior.
1001
1002
// This is to prevent churn by linting on stuff that isn't meant to be a link.
1002
1003
// only shortcut links have simple enough syntax that they
@@ -1013,11 +1014,22 @@ fn preprocess_link(
1013
1014
// | has backtick | never ignore | never ignore |
1014
1015
// | no backtick | ignore if url-like | never ignore |
1015
1016
// |-------------------------------------------------------|
1016
- let ignore_urllike =
1017
- can_be_url || ( ori_link. kind == LinkType :: ShortcutUnknown && !ori_link. link . contains ( '`' ) ) ;
1017
+ let ignore_urllike = can_be_url || ( is_shortcut_style && !ori_link. link . contains ( '`' ) ) ;
1018
1018
if ignore_urllike && should_ignore_link ( path_str) {
1019
1019
return None ;
1020
1020
}
1021
+ // If we have an intra-doc link starting with `!` (which isn't `[!]` because this is the never type), we ignore it
1022
+ // as it is never valid.
1023
+ //
1024
+ // The case is common enough because of cases like `#[doc = include_str!("../README.md")]` which often
1025
+ // uses GitHub-flavored Markdown (GFM) admonitions, such as `[!NOTE]`.
1026
+ if is_shortcut_style
1027
+ && let Some ( suffix) = ori_link. link . strip_prefix ( '!' )
1028
+ && !suffix. is_empty ( )
1029
+ && suffix. chars ( ) . all ( |c| c. is_ascii_alphabetic ( ) )
1030
+ {
1031
+ return None ;
1032
+ }
1021
1033
1022
1034
// Strip generics from the path.
1023
1035
let path_str = match strip_generics_from_path ( path_str) {
Original file line number Diff line number Diff line change
1
+ // regression test for https://github.com/rust-lang/rust/issues/141866
2
+ //@ check-pass
3
+ #![ deny( rustdoc:: broken_intra_doc_links) ]
4
+
5
+ //! > [!NOTE]
6
+ //! > This should not cause any warnings
You can’t perform that action at this time.
0 commit comments