Skip to content

Commit fbc905e

Browse files
authored
Rollup merge of #110501 - notriddle:notriddle/ice-110495, r=petrochenkov
rustdoc: fix ICE from rustc_resolve and librustdoc parse divergence Fixes #110495
2 parents ff4a5fb + df8a48f commit fbc905e

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed

compiler/rustc_resolve/src/rustdoc.rs

+1
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@ fn preprocess_link(link: &str) -> Box<str> {
367367
let link = link.strip_suffix("{}").unwrap_or(link);
368368
let link = link.strip_suffix("[]").unwrap_or(link);
369369
let link = if link != "!" { link.strip_suffix('!').unwrap_or(link) } else { link };
370+
let link = link.trim();
370371
strip_generics_from_path(link).unwrap_or_else(|_| link.into())
371372
}
372373

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// this test used to ICE
2+
#![deny(rustdoc::broken_intra_doc_links)]
3+
//! [Clone ()]. //~ ERROR unresolved
4+
//! [Clone !]. //~ ERROR incompatible
5+
//! [`Clone ()`]. //~ ERROR unresolved
6+
//! [`Clone !`]. //~ ERROR incompatible
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
error: unresolved link to `Clone`
2+
--> $DIR/issue-110495-suffix-with-space.rs:3:6
3+
|
4+
LL | //! [Clone ()].
5+
| ^^^^^^^^ this link resolves to the trait `Clone`, which is not in the value namespace
6+
|
7+
note: the lint level is defined here
8+
--> $DIR/issue-110495-suffix-with-space.rs:2:9
9+
|
10+
LL | #![deny(rustdoc::broken_intra_doc_links)]
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12+
help: to link to the trait, prefix with `trait@`
13+
|
14+
LL - //! [Clone ()].
15+
LL + //! [trait@Clone ].
16+
|
17+
18+
error: incompatible link kind for `Clone`
19+
--> $DIR/issue-110495-suffix-with-space.rs:4:6
20+
|
21+
LL | //! [Clone !].
22+
| ^^^^^^^ this link resolved to a derive macro, which is not a macro
23+
|
24+
help: to link to the derive macro, prefix with `derive@`
25+
|
26+
LL - //! [Clone !].
27+
LL + //! [derive@Clone ].
28+
|
29+
30+
error: unresolved link to `Clone`
31+
--> $DIR/issue-110495-suffix-with-space.rs:5:7
32+
|
33+
LL | //! [`Clone ()`].
34+
| ^^^^^^^^ this link resolves to the trait `Clone`, which is not in the value namespace
35+
|
36+
help: to link to the trait, prefix with `trait@`
37+
|
38+
LL - //! [`Clone ()`].
39+
LL + //! [`trait@Clone (`].
40+
|
41+
42+
error: incompatible link kind for `Clone`
43+
--> $DIR/issue-110495-suffix-with-space.rs:6:7
44+
|
45+
LL | //! [`Clone !`].
46+
| ^^^^^^^ this link resolved to a derive macro, which is not a macro
47+
|
48+
help: to link to the derive macro, prefix with `derive@`
49+
|
50+
LL | //! [`derive@Clone !`].
51+
| +++++++
52+
53+
error: aborting due to 4 previous errors
54+

0 commit comments

Comments
 (0)