@@ -425,10 +425,22 @@ pub struct Attributes {
425425 pub cfg : Option < Arc < Cfg > > ,
426426 pub span : Option < rustc_span:: Span > ,
427427 /// map from Rust paths to resolved defs and potential URL fragments
428- pub links : Vec < ( String , Option < DefId > , Option < String > ) > ,
428+ pub links : Vec < ItemLink > ,
429429 pub inner_docs : bool ,
430430}
431431
432+ #[ derive( Clone , Debug , Default , PartialEq , Eq , Hash ) ]
433+ /// A link that has not yet been rendered.
434+ ///
435+ /// This link will be turned into a rendered link by [`Attributes::links`]
436+ pub struct ItemLink {
437+ /// The original link written in the markdown
438+ pub ( crate ) link : String ,
439+ pub ( crate ) did : Option < DefId > ,
440+ /// The url fragment to append to the link
441+ pub ( crate ) fragment : Option < String > ,
442+ }
443+
432444impl Attributes {
433445 /// Extracts the content from an attribute `#[doc(cfg(content))]`.
434446 pub fn extract_cfg ( mi : & ast:: MetaItem ) -> Option < & ast:: MetaItem > {
@@ -611,8 +623,8 @@ impl Attributes {
611623
612624 self . links
613625 . iter ( )
614- . filter_map ( |& ( ref s, did, ref fragment) | {
615- match did {
626+ . filter_map ( |ItemLink { link : s, did, fragment } | {
627+ match * did {
616628 Some ( did) => {
617629 if let Some ( ( mut href, ..) ) = href ( did) {
618630 if let Some ( ref fragment) = * fragment {
0 commit comments