PrintAttribute in rustc_hir::attrs - Rust
Description: This trait is used to print attributes in `rustc_hir_pretty`.

Skip to main content

## PrintAttribute

# Trait PrintAttribute

Source

    pub trait PrintAttribute {
        // Required methods
        fn should_render(&self) -> bool;
        fn print_attribute(&self, p: &mut Printer);
    }

Expand description

This trait is used to print attributes in `rustc_hir_pretty`.

For structs and enums it can be derived using `rustc_macros::PrintAttribute`. The output will look a lot like a `Debug` implementation, but fields of several types like `Span`s and empty tuples, are gracefully skipped so they don’t clutter the representation much.

## Required Methods§

Source

#### fn should_render(&self) -> bool

Whether or not this will render as something meaningful, or if it’s skipped (which will force the containing struct to also skip printing a comma and the field name).

Source

#### fn print_attribute(&self, p: &mut Printer)

## Implementations on Foreign Types§

Source§

### impl PrintAttribute for DiffActivity

Source§

#### fn should_render(&self) -> bool

Source§

#### fn print_attribute(&self, p: &mut Printer)

Source§

### impl PrintAttribute for DiffMode

Source§

#### fn should_render(&self) -> bool

Source§

#### fn print_attribute(&self, p: &mut Printer)

Source§

### impl PrintAttribute for CommentKind

Source§

#### fn should_render(&self) -> bool

Source§

#### fn print_attribute(&self, p: &mut Printer)

Source§

### impl PrintAttribute for DocFragmentKind

Source§

#### fn should_render(&self) -> bool

Source§

#### fn print_attribute(&self, p: &mut Printer)

Source§

### impl PrintAttribute for IntTy

Source§

#### fn should_render(&self) -> bool

Source§

#### fn print_attribute(&self, p: &mut Printer)

Source§

### impl PrintAttribute for UintTy

Source§

#### fn should_render(&self) -> bool

Source§

#### fn print_attribute(&self, p: &mut Printer)

Source§

### impl PrintAttribute for Transparency

Source§

#### fn should_render(&self) -> bool

Source§

#### fn print_attribute(&self, p: &mut Printer)

Source§

### impl PrintAttribute for bool

Source§

#### fn should_render(&self) -> bool

Source§

#### fn print_attribute(&self, p: &mut Printer)

Source§

### impl PrintAttribute for u8

Source§

#### fn should_render(&self) -> bool

Source§

#### fn print_attribute(&self, p: &mut Printer)

Source§

### impl PrintAttribute for u16

Source§

#### fn should_render(&self) -> bool

Source§

#### fn print_attribute(&self, p: &mut Printer)

Source§

### impl PrintAttribute for u32

Source§

#### fn should_render(&self) -> bool

Source§

#### fn print_attribute(&self, p: &mut Printer)

Source§

### impl PrintAttribute for u128

Source§

#### fn should_render(&self) -> bool

Source§

#### fn print_attribute(&self, p: &mut Printer)

Source§

### impl PrintAttribute for ()

Source§

#### fn should_render(&self) -> bool

Source§

#### fn print_attribute(&self, _: &mut Printer)

Source§

### impl PrintAttribute for usize

Source§

#### fn should_render(&self) -> bool

Source§

#### fn print_attribute(&self, p: &mut Printer)

Source§

### impl PrintAttribute for Align

Source§

#### fn should_render(&self) -> bool

Source§

#### fn print_attribute(&self, p: &mut Printer)

Source§

### impl PrintAttribute for Path

Source§

#### fn should_render(&self) -> bool

Source§

#### fn print_attribute(&self, p: &mut Printer)

Source§

### impl PrintAttribute for Span

Source§

#### fn should_render(&self) -> bool

Source§

#### fn print_attribute(&self, _: &mut Printer)

Source§

### impl PrintAttribute for ErrorGuaranteed

Source§

#### fn should_render(&self) -> bool

Source§

#### fn print_attribute(&self, _: &mut Printer)

Source§

### impl PrintAttribute for Ident

Source§

#### fn should_render(&self) -> bool

Source§

#### fn print_attribute(&self, p: &mut Printer)

Source§

### impl PrintAttribute for Symbol

Source§

#### fn should_render(&self) -> bool

Source§

#### fn print_attribute(&self, p: &mut Printer)

Source§

### impl PrintAttribute for NonZero<u32>

Source§

#### fn should_render(&self) -> bool

Source§

#### fn print_attribute(&self, p: &mut Printer)

Source§

### impl PrintAttribute for PathBuf

Source§

#### fn should_render(&self) -> bool

Source§

#### fn print_attribute(&self, p: &mut Printer)

Source§

### impl<A: PrintAttribute, B: PrintAttribute, C: PrintAttribute, D: PrintAttribute, E: PrintAttribute, F: PrintAttribute, G: PrintAttribute, H: PrintAttribute> PrintAttribute for (A, B, C, D, E, F, G, H)

Source§

#### fn should_render(&self) -> bool

Source§

#### fn print_attribute(&self, p: &mut Printer)

Source§

### impl<B: PrintAttribute, C: PrintAttribute, D: PrintAttribute, E: PrintAttribute, F: PrintAttribute, G: PrintAttribute, H: PrintAttribute> PrintAttribute for (B, C, D, E, F, G, H)

Source§

#### fn should_render(&self) -> bool

Source§

#### fn print_attribute(&self, p: &mut Printer)

Source§

### impl<C: PrintAttribute, D: PrintAttribute, E: PrintAttribute, F: PrintAttribute, G: PrintAttribute, H: PrintAttribute> PrintAttribute for (C, D, E, F, G, H)

Source§

#### fn should_render(&self) -> bool

Source§

#### fn print_attribute(&self, p: &mut Printer)

Source§

### impl<D: PrintAttribute, E: PrintAttribute, F: PrintAttribute, G: PrintAttribute, H: PrintAttribute> PrintAttribute for (D, E, F, G, H)

Source§

#### fn should_render(&self) -> bool

Source§

#### fn print_attribute(&self, p: &mut Printer)

Source§

### impl<E: PrintAttribute, F: PrintAttribute, G: PrintAttribute, H: PrintAttribute> PrintAttribute for (E, F, G, H)

Source§

#### fn should_render(&self) -> bool

Source§

#### fn print_attribute(&self, p: &mut Printer)

Source§

### impl<F: PrintAttribute, G: PrintAttribute, H: PrintAttribute> PrintAttribute for (F, G, H)

Source§

#### fn should_render(&self) -> bool

Source§

#### fn print_attribute(&self, p: &mut Printer)

Source§

### impl<G: PrintAttribute, H: PrintAttribute> PrintAttribute for (G, H)

Source§

#### fn should_render(&self) -> bool

Source§

#### fn print_attribute(&self, p: &mut Printer)

Source§

### impl<H: PrintAttribute> PrintAttribute for (H,)

Source§

#### fn should_render(&self) -> bool

Source§

#### fn print_attribute(&self, p: &mut Printer)

Source§

### impl<T: PrintAttribute> PrintAttribute for Option<T>

Source§

#### fn should_render(&self) -> bool

Source§

#### fn print_attribute(&self, p: &mut Printer)

Source§

### impl<T: PrintAttribute> PrintAttribute for &T

Source§

#### fn should_render(&self) -> bool

Source§

#### fn print_attribute(&self, p: &mut Printer)

Source§

### impl<T: PrintAttribute> PrintAttribute for Box<T>

Source§

#### fn should_render(&self) -> bool

Source§

#### fn print_attribute(&self, p: &mut Printer)

Source§

### impl<T: PrintAttribute> PrintAttribute for ThinVec<T>

Source§

#### fn should_render(&self) -> bool

Source§

#### fn print_attribute(&self, p: &mut Printer)

Source§

### impl<T: PrintAttribute> PrintAttribute for FxIndexMap<T, Span>

Source§

#### fn should_render(&self) -> bool

Source§

#### fn print_attribute(&self, p: &mut Printer)

## Implementors§

Source§

### impl PrintAttribute for StabilityLevel

Source§

### impl PrintAttribute for StableSince

Source§

### impl PrintAttribute for UnstableReason

Source§

### impl PrintAttribute for AttrStyle

Source§

### impl PrintAttribute for LangItem

Source§

### impl PrintAttribute for Flag

Source§

### impl PrintAttribute for FormatArg

Source§

### impl PrintAttribute for LitOrArg

Source§

### impl PrintAttribute for Name

Source§

### impl PrintAttribute for Piece

Source§

### impl PrintAttribute for Predicate

Source§

### impl PrintAttribute for AttributeKind

Source§

### impl PrintAttribute for BorrowckGraphvizFormatKind

Source§

### impl PrintAttribute for CfgEntry

Source§

### impl PrintAttribute for CguFields

Source§

### impl PrintAttribute for CguKind

Source§

### impl PrintAttribute for CollapseMacroDebuginfo

Source§

### impl PrintAttribute for CoverageAttrKind

Source§

### impl PrintAttribute for CrateType

Source§

### impl PrintAttribute for DebuggerVisualizerType

Source§

### impl PrintAttribute for DeprecatedSince

Source§

### impl PrintAttribute for DivergingBlockBehavior

Source§

### impl PrintAttribute for DivergingFallbackBehavior

Source§

### impl PrintAttribute for DocInline

Source§

### impl PrintAttribute for EiiImplResolution

Source§

### impl PrintAttribute for HideOrShow

Source§

### impl PrintAttribute for InlineAttr

Source§

### impl PrintAttribute for InstructionSetAttr

Source§

### impl PrintAttribute for IntType

Source§

### impl PrintAttribute for Linkage

Source§

### impl PrintAttribute for MacroUseArgs

Source§

### impl PrintAttribute for MirDialect

Source§

### impl PrintAttribute for MirPhase

Source§

### impl PrintAttribute for NativeLibKind

Source§

### impl PrintAttribute for OptimizeAttr

Source§

### impl PrintAttribute for PeImportNameType

Source§

### impl PrintAttribute for ReprAttr

Source§

### impl PrintAttribute for RtsanSetting

Source§

### impl PrintAttribute for RustcAbiAttrKind

Source§

### impl PrintAttribute for RustcDumpLayoutKind

Source§

### impl PrintAttribute for RustcMirKind

Source§

### impl PrintAttribute for UsedBy

Source§

### impl PrintAttribute for WindowsSubsystemKind

Source§

### impl PrintAttribute for DefId

Source§

### impl PrintAttribute for AttrId

Source§

### impl PrintAttribute for Limit

Source§

### impl PrintAttribute for ConstStability

Source§

### impl PrintAttribute for DefaultBodyStability

Source§

### impl PrintAttribute for PartialConstStability

Source§

### impl PrintAttribute for RustcVersion

Source§

### impl PrintAttribute for Stability

Source§

### impl PrintAttribute for Directive

Source§

### impl PrintAttribute for FilterFormatString

Source§

### impl PrintAttribute for FormatString

Source§

### impl PrintAttribute for NameValue

Source§

### impl PrintAttribute for OnUnimplementedCondition

Source§

### impl PrintAttribute for CfgHideShow

Source§

### impl PrintAttribute for CfgInfo

Source§

### impl PrintAttribute for DebugVisualizer

Source§

### impl PrintAttribute for Deprecation

Source§

### impl PrintAttribute for DocAttribute

Source§

### impl PrintAttribute for EiiDecl

Source§

### impl PrintAttribute for EiiImpl

Source§

### impl PrintAttribute for LinkEntry

Source§

### impl PrintAttribute for RustcAutodiff

Source§

### impl PrintAttribute for RustcCleanAttribute

Source§

### impl PrintAttribute for RustcCleanQueries

Source§

### impl PrintAttribute for SanitizerSet