Function rustc_metadata::rmeta::encoder::should_encode_attr
source · fn should_encode_attr(
tcx: TyCtxt<'_>,
attr: &Attribute,
def_id: LocalDefId,
is_def_id_public: &mut Option<bool>
) -> bool
Expand description
Returns whether an attribute needs to be recorded in metadata, that is, if it’s usable and useful in downstream crates. Local-only attributes are an obvious example, but some rustdoc-specific attributes can equally be of use while documenting the current crate only.
Removing these superfluous attributes speeds up compilation by making the metadata smaller.
Note: the is_def_id_public
parameter is used to cache whether the given DefId
has a public
visibility: this is a piece of data that can be computed once per defid, and not once per
attribute. Some attributes would only be usable downstream if they are public.