Skip to content

Commit 0a496ad

Browse files
committed
Auto merge of #151237 - Zalathar:revert-rustdoc, r=<try>
Revert `ice-deprecated-note-on-reexport` due to rustdoc ICE in diesel benchmark (PR 151120)
2 parents defdb83 + 3a8412e commit 0a496ad

2 files changed

Lines changed: 7 additions & 36 deletions

File tree

src/librustdoc/passes/collect_intra_doc_links.rs

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use std::fmt::Display;
77
use std::mem;
88
use std::ops::Range;
99

10+
use rustc_ast::attr::AttributeExt;
1011
use rustc_ast::util::comments::may_have_doc_links;
1112
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap, FxIndexSet};
1213
use rustc_data_structures::intern::Interned;
@@ -1061,21 +1062,20 @@ fn preprocessed_markdown_links(s: &str) -> Vec<PreprocessedMarkdownLink> {
10611062
impl LinkCollector<'_, '_> {
10621063
#[instrument(level = "debug", skip_all)]
10631064
fn resolve_links(&mut self, item: &Item) {
1064-
let tcx = self.cx.tcx;
10651065
if !self.cx.document_private()
10661066
&& let Some(def_id) = item.item_id.as_def_id()
10671067
&& let Some(def_id) = def_id.as_local()
1068-
&& !tcx.effective_visibilities(()).is_exported(def_id)
1068+
&& !self.cx.tcx.effective_visibilities(()).is_exported(def_id)
10691069
&& !has_primitive_or_keyword_or_attribute_docs(&item.attrs.other_attrs)
10701070
{
10711071
// Skip link resolution for non-exported items.
10721072
return;
10731073
}
10741074

10751075
let mut insert_links = |item_id, doc: &str| {
1076-
let module_id = match tcx.def_kind(item_id) {
1077-
DefKind::Mod if item.inner_docs(tcx) => item_id,
1078-
_ => find_nearest_parent_module(tcx, item_id).unwrap(),
1076+
let module_id = match self.cx.tcx.def_kind(item_id) {
1077+
DefKind::Mod if item.inner_docs(self.cx.tcx) => item_id,
1078+
_ => find_nearest_parent_module(self.cx.tcx, item_id).unwrap(),
10791079
};
10801080
for md_link in preprocessed_markdown_links(&doc) {
10811081
let link = self.resolve_link(&doc, item, item_id, module_id, &md_link);
@@ -1108,33 +1108,15 @@ impl LinkCollector<'_, '_> {
11081108

11091109
// Also resolve links in the note text of `#[deprecated]`.
11101110
for attr in &item.attrs.other_attrs {
1111-
let rustc_hir::Attribute::Parsed(rustc_hir::attrs::AttributeKind::Deprecation {
1112-
span,
1113-
deprecation,
1114-
}) = attr
1115-
else {
1116-
continue;
1117-
};
1118-
let Some(note_sym) = deprecation.note else { continue };
1111+
let Some(note_sym) = attr.deprecation_note() else { continue };
11191112
let note = note_sym.as_str();
11201113

11211114
if !may_have_doc_links(note) {
11221115
continue;
11231116
}
11241117

11251118
debug!("deprecated_note={note}");
1126-
// When resolving an intra-doc link inside a deprecation note that is on an inlined
1127-
// `use` statement, we need to use the `def_id` of the `use` statement, not the
1128-
// inlined item.
1129-
// <https://github.com/rust-lang/rust/pull/151120>
1130-
let item_id = if let Some(inline_stmt_id) = item.inline_stmt_id
1131-
&& item.span(tcx).is_none_or(|item_span| !item_span.inner().contains(*span))
1132-
{
1133-
inline_stmt_id.to_def_id()
1134-
} else {
1135-
item.item_id.expect_def_id()
1136-
};
1137-
insert_links(item_id, note)
1119+
insert_links(item.item_id.expect_def_id(), note)
11381120
}
11391121
}
11401122

tests/rustdoc-html/intra-doc/ice-deprecated-note-on-reexport.rs

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)