1
Fork 0

rustc_metadata: Store a flag telling whether an item may have doc links in its attributes

This should be cheap on rustc side, but it's significant optimization for rustdoc that won't need to decode and process attributes unnecessarily
This commit is contained in:
Vadim Petrochenkov 2022-04-16 23:49:37 +03:00
parent f5ca02c334
commit e2d3a4f631
9 changed files with 48 additions and 20 deletions

View file

@ -9,6 +9,7 @@ use crate::token::{self, CommentKind, Token};
use crate::tokenstream::{AttrAnnotatedTokenStream, AttrAnnotatedTokenTree};
use crate::tokenstream::{DelimSpan, Spacing, TokenTree, TreeAndSpacing};
use crate::tokenstream::{LazyTokenStream, TokenStream};
use crate::util::comments;
use rustc_index::bit_set::GrowableBitSet;
use rustc_span::source_map::BytePos;
@ -262,6 +263,10 @@ impl Attribute {
}
}
pub fn may_have_doc_links(&self) -> bool {
self.doc_str().map_or(false, |s| comments::may_have_doc_links(s.as_str()))
}
pub fn get_normal_item(&self) -> &AttrItem {
match self.kind {
AttrKind::Normal(ref item, _) => item,