From 3a8412e2d82537a520660a48cd0e68d743f19881 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Sat, 17 Jan 2026 18:32:37 +1100 Subject: [PATCH] Revert `ice-deprecated-note-on-reexport` due to ICE in diesel benchmark This reverts commit 176bf87df0cc1f916711823a2abf9d6415306cdb, reversing changes made to 3157d50d5b787d8ee0cf3fe29bf7d0b98a25695c. --- .../passes/collect_intra_doc_links.rs | 32 ++++--------------- .../ice-deprecated-note-on-reexport.rs | 11 ------- 2 files changed, 7 insertions(+), 36 deletions(-) delete mode 100644 tests/rustdoc-html/intra-doc/ice-deprecated-note-on-reexport.rs diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index 018e20b76dc83..debea4fc0cec6 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -7,6 +7,7 @@ use std::fmt::Display; use std::mem; use std::ops::Range; +use rustc_ast::attr::AttributeExt; use rustc_ast::util::comments::may_have_doc_links; use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap, FxIndexSet}; use rustc_data_structures::intern::Interned; @@ -1061,11 +1062,10 @@ fn preprocessed_markdown_links(s: &str) -> Vec { impl LinkCollector<'_, '_> { #[instrument(level = "debug", skip_all)] fn resolve_links(&mut self, item: &Item) { - let tcx = self.cx.tcx; if !self.cx.document_private() && let Some(def_id) = item.item_id.as_def_id() && let Some(def_id) = def_id.as_local() - && !tcx.effective_visibilities(()).is_exported(def_id) + && !self.cx.tcx.effective_visibilities(()).is_exported(def_id) && !has_primitive_or_keyword_or_attribute_docs(&item.attrs.other_attrs) { // Skip link resolution for non-exported items. @@ -1073,9 +1073,9 @@ impl LinkCollector<'_, '_> { } let mut insert_links = |item_id, doc: &str| { - let module_id = match tcx.def_kind(item_id) { - DefKind::Mod if item.inner_docs(tcx) => item_id, - _ => find_nearest_parent_module(tcx, item_id).unwrap(), + let module_id = match self.cx.tcx.def_kind(item_id) { + DefKind::Mod if item.inner_docs(self.cx.tcx) => item_id, + _ => find_nearest_parent_module(self.cx.tcx, item_id).unwrap(), }; for md_link in preprocessed_markdown_links(&doc) { let link = self.resolve_link(&doc, item, item_id, module_id, &md_link); @@ -1108,14 +1108,7 @@ impl LinkCollector<'_, '_> { // Also resolve links in the note text of `#[deprecated]`. for attr in &item.attrs.other_attrs { - let rustc_hir::Attribute::Parsed(rustc_hir::attrs::AttributeKind::Deprecation { - span, - deprecation, - }) = attr - else { - continue; - }; - let Some(note_sym) = deprecation.note else { continue }; + let Some(note_sym) = attr.deprecation_note() else { continue }; let note = note_sym.as_str(); if !may_have_doc_links(note) { @@ -1123,18 +1116,7 @@ impl LinkCollector<'_, '_> { } debug!("deprecated_note={note}"); - // When resolving an intra-doc link inside a deprecation note that is on an inlined - // `use` statement, we need to use the `def_id` of the `use` statement, not the - // inlined item. - // - let item_id = if let Some(inline_stmt_id) = item.inline_stmt_id - && item.span(tcx).is_none_or(|item_span| !item_span.inner().contains(*span)) - { - inline_stmt_id.to_def_id() - } else { - item.item_id.expect_def_id() - }; - insert_links(item_id, note) + insert_links(item.item_id.expect_def_id(), note) } } diff --git a/tests/rustdoc-html/intra-doc/ice-deprecated-note-on-reexport.rs b/tests/rustdoc-html/intra-doc/ice-deprecated-note-on-reexport.rs deleted file mode 100644 index 99415a9a2fd4a..0000000000000 --- a/tests/rustdoc-html/intra-doc/ice-deprecated-note-on-reexport.rs +++ /dev/null @@ -1,11 +0,0 @@ -// This test ensures that the intra-doc link in `deprecated` note is resolved at the correct -// location (ie in the current crate and not in the reexported item's location/crate) and -// therefore doesn't crash. -// -// This is a regression test for . - -#![crate_name = "foo"] - -#[deprecated(note = "use [`std::mem::forget`]")] -#[doc(inline)] -pub use std::mem::drop;