Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix panic when handling intra doc links generated from macro #94478

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
| ^^^^^
notriddle marked this conversation as resolved.
Show resolved Hide resolved
...
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.