Skip to content

Commit b3b3d54

Browse files
authored
Rollup merge of #157386 - TaKO8Ki:rustdoc-deprecated-note-links-separately, r=notriddle
Parse deprecated note links separately in rustc_resolve Fixes #157326 `rustc_resolve` pre-caches intra-doc link resolutions for rustdoc. It previously parsed doc comments and `#[deprecated(note = "...")]` text as one Markdown document.
2 parents b4f59aa + db13562 commit b3b3d54

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

compiler/rustc_resolve/src/rustdoc.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -412,17 +412,16 @@ pub fn may_be_doc_link(link_type: LinkType) -> bool {
412412
pub(crate) fn attrs_to_preprocessed_links(attrs: &[ast::Attribute]) -> Vec<Box<str>> {
413413
let (doc_fragments, other_attrs) =
414414
attrs_to_doc_fragments(attrs.iter().map(|attr| (attr, None)), false);
415-
let mut doc =
416-
prepare_to_doc_link_resolution(&doc_fragments).into_values().next().unwrap_or_default();
415+
let doc = prepare_to_doc_link_resolution(&doc_fragments).into_values().next();
416+
let mut links = doc.as_deref().map(parse_links).unwrap_or_default();
417417

418418
for attr in other_attrs {
419419
if let Some(note) = attr.deprecation_note() {
420-
doc += note.as_str();
421-
doc += "\n";
420+
links.extend(parse_links(note.as_str()));
422421
}
423422
}
424423

425-
parse_links(&doc)
424+
links
426425
}
427426

428427
/// Similar version of `markdown_links` from rustdoc.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//@ check-pass
2+
3+
// Regression test for https://github.com/rust-lang/rust/issues/157326.
4+
#![allow(rustdoc::invalid_rust_codeblocks)]
5+
#![deprecated(note = "use [Env::try_invoke] instead")]
6+
//! ```
7+
8+
pub struct Env;
9+
10+
impl Env {
11+
pub fn try_invoke(&self) {}
12+
}

0 commit comments

Comments
 (0)