@@ -206,12 +206,24 @@ impl AttributeExt for Attribute {
206206 }
207207 }
208208
209- fn style ( & self ) -> AttrStyle {
210- self . style
209+ fn doc_resolution_scope ( & self ) -> Option < AttrStyle > {
210+ match & self . kind {
211+ AttrKind :: DocComment ( ..) => Some ( self . style ) ,
212+ AttrKind :: Normal ( normal)
213+ if normal. item . path == sym:: doc && normal. item . value_str ( ) . is_some ( ) =>
214+ {
215+ Some ( self . style )
216+ }
217+ _ => None ,
218+ }
211219 }
212220}
213221
214222impl Attribute {
223+ pub fn style ( & self ) -> AttrStyle {
224+ self . style
225+ }
226+
215227 pub fn may_have_doc_links ( & self ) -> bool {
216228 self . doc_str ( ) . is_some_and ( |s| comments:: may_have_doc_links ( s. as_str ( ) ) )
217229 }
@@ -806,7 +818,14 @@ pub trait AttributeExt: Debug {
806818 /// * `#[doc(...)]` returns `None`.
807819 fn doc_str_and_comment_kind ( & self ) -> Option < ( Symbol , CommentKind ) > ;
808820
809- fn style ( & self ) -> AttrStyle ;
821+ /// Returns outer or inner if this is a doc attribute or a sugared doc
822+ /// comment, otherwise None.
823+ ///
824+ /// This is used in the case of doc comments on modules, to decide whether
825+ /// to resolve intra-doc links against the symbols in scope within the
826+ /// commented module (for inner doc) vs within its parent module (for outer
827+ /// doc).
828+ fn doc_resolution_scope ( & self ) -> Option < AttrStyle > ;
810829}
811830
812831// FIXME(fn_delegation): use function delegation instead of manually forwarding
@@ -881,8 +900,4 @@ impl Attribute {
881900 pub fn doc_str_and_comment_kind ( & self ) -> Option < ( Symbol , CommentKind ) > {
882901 AttributeExt :: doc_str_and_comment_kind ( self )
883902 }
884-
885- pub fn style ( & self ) -> AttrStyle {
886- AttributeExt :: style ( self )
887- }
888903}
0 commit comments