diff options
| author | Alona Enraght-Moony <code@alona.page> | 2025-03-16 21:15:49 +0000 |
|---|---|---|
| committer | Alona Enraght-Moony <code@alona.page> | 2025-03-16 21:15:49 +0000 |
| commit | a8a913dcd23c75744486773e491a18af0555cdd8 (patch) | |
| tree | 2e77e058f39f7593639619ca6f786f434fba52a7 | |
| parent | 2ff28159d3e9915772e65955488f447cb2b98ffa (diff) | |
| download | rust-a8a913dcd23c75744486773e491a18af0555cdd8.tar.gz rust-a8a913dcd23c75744486773e491a18af0555cdd8.zip | |
rustdoc: Rename `Item::attributes` param to `is_json`
This makes it clearer what it's actually used for, and makes it easier to think about modifying `Item::attributes`.
| -rw-r--r-- | src/librustdoc/clean/types.rs | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 3f9023659db..8200fa3a35d 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -756,12 +756,7 @@ impl Item { Some(tcx.visibility(def_id)) } - pub(crate) fn attributes( - &self, - tcx: TyCtxt<'_>, - cache: &Cache, - keep_as_is: bool, - ) -> Vec<String> { + pub(crate) fn attributes(&self, tcx: TyCtxt<'_>, cache: &Cache, is_json: bool) -> Vec<String> { const ALLOWED_ATTRIBUTES: &[Symbol] = &[sym::export_name, sym::link_section, sym::no_mangle, sym::non_exhaustive]; @@ -772,7 +767,7 @@ impl Item { .other_attrs .iter() .filter_map(|attr| { - if keep_as_is { + if is_json { Some(rustc_hir_pretty::attribute_to_string(&tcx, attr)) } else if ALLOWED_ATTRIBUTES.contains(&attr.name_or_empty()) { Some( @@ -786,7 +781,8 @@ impl Item { } }) .collect(); - if !keep_as_is + + if !is_json && let Some(def_id) = self.def_id() && let ItemType::Struct | ItemType::Enum | ItemType::Union = self.type_() { |
