File tree Expand file tree Collapse file tree 3 files changed +27
-3
lines changed
tests/rustdoc-ui/intra-doc Expand file tree Collapse file tree 3 files changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -988,7 +988,23 @@ fn preprocess_link(
988988
989989 // If there's no backticks, be lenient revert to old behavior.
990990 // This is to prevent churn by linting on stuff that isn't meant to be a link.
991- if ( can_be_url || !ori_link. link . contains ( '`' ) ) && should_ignore_link ( path_str) {
991+ // only shortcut links have simple enough syntax that they
992+ // are likely to be written accidentlly, collapsed and reference links
993+ // need 4 metachars, and reference links will not usually use
994+ // backticks in the reference name.
995+ // therefore, only shortcut syntax gets the lenient behavior.
996+ //
997+ // here's a truth table for how link kinds that cannot be urls are handled:
998+ //
999+ // |-------------------------------------------------------|
1000+ // | | is shortcut link | not shortcut link |
1001+ // |--------------|--------------------|-------------------|
1002+ // | has backtick | never ignore | never ignore |
1003+ // | no backtick | ignore if url-like | never ignore |
1004+ // |-------------------------------------------------------|
1005+ let ignore_urllike =
1006+ can_be_url || ( ori_link. kind == LinkType :: ShortcutUnknown && !ori_link. link . contains ( '`' ) ) ;
1007+ if ignore_urllike && should_ignore_link ( path_str) {
9921008 return None ;
9931009 }
9941010
Original file line number Diff line number Diff line change @@ -65,7 +65,7 @@ pub struct XLinkToCloneWithStartSpace;
6565/// [x][struct@Clone ] //~ERROR link
6666pub struct XLinkToCloneWithEndSpace ;
6767
68- /// [x][Clone\(\)]
68+ /// [x][Clone\(\)] //~ERROR link
6969pub struct XLinkToCloneWithEscapedParens ;
7070
7171/// [x][`Clone`] not URL-shaped enough
Original file line number Diff line number Diff line change @@ -123,6 +123,14 @@ LL - /// [x][struct@Clone ]
123123LL + /// [x][trait@Clone ]
124124 |
125125
126+ error: unresolved link to `Clone\(\)`
127+ --> $DIR/weird-syntax.rs:68:9
128+ |
129+ LL | /// [x][Clone\(\)]
130+ | ^^^^^^^^^ no item named `Clone\(\)` in scope
131+ |
132+ = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
133+
126134error: unresolved link to `Clone`
127135 --> $DIR/weird-syntax.rs:74:9
128136 |
@@ -299,5 +307,5 @@ LL | /// - [`SDL_PROP_WINDOW_CREATE_COCOA_WINDOW_POINTER`]: the
299307 |
300308 = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
301309
302- error: aborting due to 27 previous errors
310+ error: aborting due to 28 previous errors
303311
You can’t perform that action at this time.
0 commit comments