diff options
| author | bors <bors@rust-lang.org> | 2023-03-22 19:04:49 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-03-22 19:04:49 +0000 |
| commit | a266f11990d9544ee408e213e1eec8cc9eb032b7 (patch) | |
| tree | 8047ee2a1679b107542e980b2ffb2f1f9daf91b5 /compiler/rustc_resolve/src | |
| parent | 439292bc7913399e406d9bb7e8da0f70c6317c6e (diff) | |
| parent | eda88a30c767d1933aaf82a83d679a245b7d26b8 (diff) | |
| download | rust-a266f11990d9544ee408e213e1eec8cc9eb032b7.tar.gz rust-a266f11990d9544ee408e213e1eec8cc9eb032b7.zip | |
Auto merge of #109496 - Dylan-DPC:rollup-u8rsi3h, r=Dylan-DPC
Rollup of 11 pull requests Successful merges: - #100311 (Fix handling of trailing bare CR in str::lines) - #108997 (Change text -> rust highlighting in sanitizer.md) - #109179 (move Option::as_slice to intrinsic) - #109187 (Render source page layout with Askama) - #109280 (Remove `VecMap`) - #109295 (refactor `fn bootstrap::builder::Builder::compiler_for` logic) - #109312 (rustdoc: Cleanup parent module tracking for doc links) - #109317 (Update links for custom discriminants.) - #109405 (RPITITs are `DefKind::Opaque` with new lowering strategy) - #109414 (Do not consider synthesized RPITITs on missing items checks) - #109435 (Detect uninhabited types early in const eval) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_resolve/src')
| -rw-r--r-- | compiler/rustc_resolve/src/rustdoc.rs | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/compiler/rustc_resolve/src/rustdoc.rs b/compiler/rustc_resolve/src/rustdoc.rs index b8853c1744c..0e40f794f18 100644 --- a/compiler/rustc_resolve/src/rustdoc.rs +++ b/compiler/rustc_resolve/src/rustdoc.rs @@ -26,11 +26,13 @@ pub enum DocFragmentKind { #[derive(Clone, PartialEq, Eq, Debug)] pub struct DocFragment { pub span: Span, - /// The module this doc-comment came from. - /// - /// This allows distinguishing between the original documentation and a pub re-export. - /// If it is `None`, the item was not re-exported. - pub parent_module: Option<DefId>, + /// The item this doc-comment came from. + /// Used to determine the scope in which doc links in this fragment are resolved. + /// Typically filled for reexport docs when they are merged into the docs of the + /// original reexported item. + /// If the id is not filled, which happens for the original reexported item, then + /// it has to be taken from somewhere else during doc link resolution. + pub item_id: Option<DefId>, pub doc: Symbol, pub kind: DocFragmentKind, pub indent: usize, @@ -186,7 +188,7 @@ pub fn attrs_to_doc_fragments<'a>( ) -> (Vec<DocFragment>, ast::AttrVec) { let mut doc_fragments = Vec::new(); let mut other_attrs = ast::AttrVec::new(); - for (attr, parent_module) in attrs { + for (attr, item_id) in attrs { if let Some((doc_str, comment_kind)) = attr.doc_str_and_comment_kind() { let doc = beautify_doc_string(doc_str, comment_kind); let kind = if attr.is_doc_comment() { @@ -194,7 +196,7 @@ pub fn attrs_to_doc_fragments<'a>( } else { DocFragmentKind::RawDoc }; - let fragment = DocFragment { span: attr.span, doc, kind, parent_module, indent: 0 }; + let fragment = DocFragment { span: attr.span, doc, kind, item_id, indent: 0 }; doc_fragments.push(fragment); } else if !doc_only { other_attrs.push(attr.clone()); @@ -216,7 +218,7 @@ pub fn prepare_to_doc_link_resolution( ) -> FxHashMap<Option<DefId>, String> { let mut res = FxHashMap::default(); for fragment in doc_fragments { - let out_str = res.entry(fragment.parent_module).or_default(); + let out_str = res.entry(fragment.item_id).or_default(); add_doc_fragment(out_str, fragment); } res |
