File tree 3 files changed +27
-3
lines changed
tests/rustdoc-ui/intra-doc
3 files changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -988,7 +988,23 @@ fn preprocess_link(
988
988
989
989
// If there's no backticks, be lenient revert to old behavior.
990
990
// 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) {
992
1008
return None ;
993
1009
}
994
1010
Original file line number Diff line number Diff line change @@ -65,7 +65,7 @@ pub struct XLinkToCloneWithStartSpace;
65
65
/// [x][struct@Clone ] //~ERROR link
66
66
pub struct XLinkToCloneWithEndSpace ;
67
67
68
- /// [x][Clone\(\)]
68
+ /// [x][Clone\(\)] //~ERROR link
69
69
pub struct XLinkToCloneWithEscapedParens ;
70
70
71
71
/// [x][`Clone`] not URL-shaped enough
Original file line number Diff line number Diff line change @@ -123,6 +123,14 @@ LL - /// [x][struct@Clone ]
123
123
LL + /// [x][trait@Clone ]
124
124
|
125
125
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
+
126
134
error: unresolved link to `Clone`
127
135
--> $DIR/weird-syntax.rs:74:9
128
136
|
@@ -299,5 +307,5 @@ LL | /// - [`SDL_PROP_WINDOW_CREATE_COCOA_WINDOW_POINTER`]: the
299
307
|
300
308
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
301
309
302
- error: aborting due to 27 previous errors
310
+ error: aborting due to 28 previous errors
303
311
You can’t perform that action at this time.
0 commit comments