diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 3e7e311cfc5..9019a6c49ec 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -878,10 +878,6 @@ pub(crate) trait AttributesExt { fn iter<'a>(&'a self) -> Self::Attributes<'a>; - fn span(&self) -> Option { - self.iter().find(|attr| attr.doc_str().is_some()).map(|attr| attr.span) - } - fn cfg(&self, tcx: TyCtxt<'_>, hidden_cfg: &FxHashSet) -> Option> { let sess = tcx.sess; let doc_cfg_active = tcx.features().doc_cfg; diff --git a/src/librustdoc/doctest.rs b/src/librustdoc/doctest.rs index aaa83ecce48..1a896b411ab 100644 --- a/src/librustdoc/doctest.rs +++ b/src/librustdoc/doctest.rs @@ -1239,8 +1239,9 @@ impl<'a, 'hir, 'tcx> HirCollector<'a, 'hir, 'tcx> { if let Some(doc) = attrs.collapsed_doc_value() { // Use the outermost invocation, so that doctest names come from where the docs were written. let span = ast_attrs - .span() - .map(|span| span.ctxt().outer_expn().expansion_cause().unwrap_or(span)) + .iter() + .find(|attr| attr.doc_str().is_some()) + .map(|attr| attr.span.ctxt().outer_expn().expansion_cause().unwrap_or(attr.span)) .unwrap_or(DUMMY_SP); self.collector.set_position(span); markdown::find_testable_code(