-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
rustdoc panics on broken intra-doc links if there are both inner and outer attributes #78591
Comments
This commit works around the ICE issue [1] by fixing an unresolved intra-doc link. The regression was introduced when the commit a975483 added a broken intra-doc link. [1]: <rust-lang/rust#78591>
I bet the source span is wrong somehow. |
The issue is that the documentation on the re-export is being combined with the original documentation. Not sure why it needs a separate file. |
The markdown range it comes up with is 3..13. Hmm, this is weird - I think this is actually the correct span because they both come from |
Aha, here we go:
diff --git a/src/librustdoc/passes/mod.rs b/src/librustdoc/passes/mod.rs
index 2591650e3f9..ec1e2ae36e6 100644
--- a/src/librustdoc/passes/mod.rs
+++ b/src/librustdoc/passes/mod.rs
@@ -179,7 +179,9 @@ crate fn source_span_for_markdown_range(
return None;
}
+ trace!("markdown is {}", markdown);
let snippet = cx.sess().source_map().span_to_snippet(span_of_attrs(attrs)?).ok()?;
+ trace!("snippet is {}", snippet); Maybe it could just work with |
Hmm, there are some other bugs here too: normally rustdoc will resolve |
To add another test-case for what I believe is another instance of the same problem: #[warn(rustdoc::broken_intra_doc_links)]
/// We have some module docs here.
pub mod foo {
//! [`Foo`]
//!
//! And some more module docs here.
pub struct Foo;
} This doesn't panic, but produces:
For an even more confused case, split the module into its own file: #[warn(rustdoc::broken_intra_doc_links)]
/// We have some module docs here.
pub mod foo; //! And some more module docs here.
//! [`Foo`]
pub struct Foo; Which yields this nonsensical warning:
Essentially, the span of the unresolved link is misattributed to the wrong file. The line and column values are correct, it's just the wrong file that's used. |
That's #78591 (comment).
|
…a-doc-link, r=notriddle Fix panic when handling intra doc links generated from macro Fixes rust-lang#78591. Fixes rust-lang#92789. r? `@notriddle`
src/lib.rs
:src/mymodule.rs
://! [`long_cat`] is really long
Full source code
I expected to see this happen:
cargo doc
completes successfully with a "unresolved link tolong_cat
" warningInstead, this happened:
thread 'rustc' panicked at 'could not find markdown in source', src/librustdoc/passes/mod.rs:199:48
Meta
rustc --version --verbose
:Backtrace
The text was updated successfully, but these errors were encountered: