Skip to content

Commit 64e16d3

Browse files
authored
Rollup merge of #94478 - GuillaumeGomez:macro-generated-intra-doc-link, r=notriddle
Fix panic when handling intra doc links generated from macro Fixes #78591. Fixes #92789. r? ``@notriddle``
2 parents 42596a7 + 885e808 commit 64e16d3

File tree

5 files changed

+34
-1
lines changed

5 files changed

+34
-1
lines changed

src/librustdoc/passes/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ crate fn source_span_for_markdown_range(
178178

179179
'outer: for (line_no, md_line) in md_lines.enumerate() {
180180
loop {
181-
let source_line = src_lines.next().expect("could not find markdown in source");
181+
let source_line = src_lines.next()?;
182182
match source_line.find(md_line) {
183183
Some(offset) => {
184184
if line_no == starting_line {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
//! [`long_cat`] is really long

src/test/rustdoc-ui/macro-docs.rs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// check-pass
2+
3+
macro_rules! m {
4+
() => {
5+
/// A
6+
//~^ WARNING
7+
#[path = "auxiliary/module_macro_doc.rs"]
8+
pub mod mymodule;
9+
}
10+
}
11+
12+
m!();

src/test/rustdoc-ui/macro-docs.stderr

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
warning: unresolved link to `long_cat`
2+
--> $DIR/macro-docs.rs:5:9
3+
|
4+
LL | /// A
5+
| ^^^^^
6+
...
7+
LL | m!();
8+
| ---- in this macro invocation
9+
|
10+
= note: `#[warn(rustdoc::broken_intra_doc_links)]` on by default
11+
= note: the link appears in this line:
12+
13+
[`long_cat`] is really long
14+
^^^^^^^^^^
15+
= note: no item named `long_cat` in scope
16+
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
17+
= note: this warning originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
18+
19+
warning: 1 warning emitted
20+

src/test/rustdoc-ui/macro-docs.stdout

Whitespace-only changes.

0 commit comments

Comments
 (0)