Skip to content

Commit

Permalink
Rollup merge of #94478 - GuillaumeGomez:macro-generated-intra-doc-lin…
Browse files Browse the repository at this point in the history
…k, r=notriddle

Fix panic when handling intra doc links generated from macro

Fixes #78591.
Fixes #92789.

r? ``@notriddle``
  • Loading branch information
matthiaskrgr authored Mar 2, 2022
2 parents 42596a7 + 885e808 commit 64e16d3
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/librustdoc/passes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ crate fn source_span_for_markdown_range(

'outer: for (line_no, md_line) in md_lines.enumerate() {
loop {
let source_line = src_lines.next().expect("could not find markdown in source");
let source_line = src_lines.next()?;
match source_line.find(md_line) {
Some(offset) => {
if line_no == starting_line {
Expand Down
1 change: 1 addition & 0 deletions src/test/rustdoc-ui/auxiliary/module_macro_doc.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//! [`long_cat`] is really long
12 changes: 12 additions & 0 deletions src/test/rustdoc-ui/macro-docs.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// check-pass

macro_rules! m {
() => {
/// A
//~^ WARNING
#[path = "auxiliary/module_macro_doc.rs"]
pub mod mymodule;
}
}

m!();
20 changes: 20 additions & 0 deletions src/test/rustdoc-ui/macro-docs.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
warning: unresolved link to `long_cat`
--> $DIR/macro-docs.rs:5:9
|
LL | /// A
| ^^^^^
...
LL | m!();
| ---- in this macro invocation
|
= note: `#[warn(rustdoc::broken_intra_doc_links)]` on by default
= note: the link appears in this line:

[`long_cat`] is really long
^^^^^^^^^^
= note: no item named `long_cat` in scope
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
= note: this warning originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: 1 warning emitted

Empty file.

0 comments on commit 64e16d3

Please sign in to comment.