Skip to main content

rustc_attr_ir/
target.rs

1//! This module lists attribute targets, with conversions from other types.
2
3use std::fmt::{self, Display};
4
5pub use rustc_ast::visit::AssocCtxt;
6use rustc_ast::{AssocItemKind, ForeignItemKind, ast};
7use rustc_macros::StableHash;
8
9#[derive(#[automatically_derived]
impl ::core::marker::Copy for GenericParamKind { }Copy, #[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for GenericParamKind { }
#[automatically_derived]
impl ::core::clone::Clone for GenericParamKind {
    #[inline]
    fn clone(&self) -> GenericParamKind { *self }
}Clone, #[automatically_derived]
impl ::core::marker::StructuralPartialEq for GenericParamKind { }
#[automatically_derived]
impl ::core::cmp::PartialEq for GenericParamKind {
    #[inline]
    fn eq(&self, other: &GenericParamKind) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr
    }
}PartialEq, #[automatically_derived]
impl ::core::fmt::Debug for GenericParamKind {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                GenericParamKind::Type => "Type",
                GenericParamKind::Lifetime => "Lifetime",
                GenericParamKind::Const => "Const",
            })
    }
}Debug, #[automatically_derived]
impl ::core::cmp::Eq for GenericParamKind {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {}
}Eq, const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for
            GenericParamKind {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                ::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
                match *self {
                    GenericParamKind::Type => {}
                    GenericParamKind::Lifetime => {}
                    GenericParamKind::Const => {}
                }
            }
        }
    };StableHash)]
10pub enum GenericParamKind {
11    Type,
12    Lifetime,
13    Const,
14}
15
16#[derive(#[automatically_derived]
impl ::core::marker::Copy for MethodKind { }Copy, #[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for MethodKind { }
#[automatically_derived]
impl ::core::clone::Clone for MethodKind {
    #[inline]
    fn clone(&self) -> MethodKind {
        let _: ::core::clone::AssertParamIsClone<bool>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::marker::StructuralPartialEq for MethodKind { }
#[automatically_derived]
impl ::core::cmp::PartialEq for MethodKind {
    #[inline]
    fn eq(&self, other: &MethodKind) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr &&
            match (self, other) {
                (MethodKind::Trait { body: __self_0 }, MethodKind::Trait {
                    body: __arg1_0 }) => __self_0 == __arg1_0,
                _ => true,
            }
    }
}PartialEq, #[automatically_derived]
impl ::core::fmt::Debug for MethodKind {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            MethodKind::Trait { body: __self_0 } =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f, "Trait",
                    "body", &__self_0),
            MethodKind::TraitImpl =>
                ::core::fmt::Formatter::write_str(f, "TraitImpl"),
            MethodKind::Inherent =>
                ::core::fmt::Formatter::write_str(f, "Inherent"),
        }
    }
}Debug, #[automatically_derived]
impl ::core::cmp::Eq for MethodKind {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<bool>;
    }
}Eq, const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for MethodKind {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                ::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
                match *self {
                    MethodKind::Trait { body: ref __binding_0 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                    MethodKind::TraitImpl => {}
                    MethodKind::Inherent => {}
                }
            }
        }
    };StableHash)]
17pub enum MethodKind {
18    /// Method in a `trait Trait` block
19    Trait {
20        /// Whether a default is provided for this method
21        body: bool,
22    },
23    /// Method in a `impl Trait for Type` block
24    TraitImpl,
25    /// Method in a `impl Type` block
26    Inherent,
27}
28
29#[derive(#[automatically_derived]
impl ::core::marker::Copy for Target { }Copy, #[automatically_derived]
#[doc(hidden)]
unsafe impl ::core::clone::TrivialClone for Target { }
#[automatically_derived]
impl ::core::clone::Clone for Target {
    #[inline]
    fn clone(&self) -> Target {
        let _: ::core::clone::AssertParamIsClone<bool>;
        let _: ::core::clone::AssertParamIsClone<AssocCtxt>;
        let _: ::core::clone::AssertParamIsClone<MethodKind>;
        let _: ::core::clone::AssertParamIsClone<GenericParamKind>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::marker::StructuralPartialEq for Target { }
#[automatically_derived]
impl ::core::cmp::PartialEq for Target {
    #[inline]
    fn eq(&self, other: &Target) -> bool {
        let __self_discr = ::core::intrinsics::discriminant_value(self);
        let __arg1_discr = ::core::intrinsics::discriminant_value(other);
        __self_discr == __arg1_discr &&
            match (self, other) {
                (Target::Impl { of_trait: __self_0 }, Target::Impl {
                    of_trait: __arg1_0 }) => __self_0 == __arg1_0,
                (Target::AssocConst(__self_0), Target::AssocConst(__arg1_0))
                    => __self_0 == __arg1_0,
                (Target::Method(__self_0), Target::Method(__arg1_0)) =>
                    __self_0 == __arg1_0,
                (Target::AssocTy(__self_0), Target::AssocTy(__arg1_0)) =>
                    __self_0 == __arg1_0,
                (Target::GenericParam { kind: __self_0, has_default: __self_1
                    }, Target::GenericParam {
                    kind: __arg1_0, has_default: __arg1_1 }) =>
                    __self_1 == __arg1_1 && __self_0 == __arg1_0,
                (Target::Delegation { mac: __self_0 }, Target::Delegation {
                    mac: __arg1_0 }) => __self_0 == __arg1_0,
                _ => true,
            }
    }
}PartialEq, #[automatically_derived]
impl ::core::fmt::Debug for Target {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            Target::ExternCrate =>
                ::core::fmt::Formatter::write_str(f, "ExternCrate"),
            Target::Use => ::core::fmt::Formatter::write_str(f, "Use"),
            Target::Static => ::core::fmt::Formatter::write_str(f, "Static"),
            Target::Const => ::core::fmt::Formatter::write_str(f, "Const"),
            Target::Fn => ::core::fmt::Formatter::write_str(f, "Fn"),
            Target::Closure =>
                ::core::fmt::Formatter::write_str(f, "Closure"),
            Target::Mod => ::core::fmt::Formatter::write_str(f, "Mod"),
            Target::ForeignMod =>
                ::core::fmt::Formatter::write_str(f, "ForeignMod"),
            Target::GlobalAsm =>
                ::core::fmt::Formatter::write_str(f, "GlobalAsm"),
            Target::TyAlias =>
                ::core::fmt::Formatter::write_str(f, "TyAlias"),
            Target::Enum => ::core::fmt::Formatter::write_str(f, "Enum"),
            Target::Variant =>
                ::core::fmt::Formatter::write_str(f, "Variant"),
            Target::Struct => ::core::fmt::Formatter::write_str(f, "Struct"),
            Target::Field => ::core::fmt::Formatter::write_str(f, "Field"),
            Target::Union => ::core::fmt::Formatter::write_str(f, "Union"),
            Target::Trait => ::core::fmt::Formatter::write_str(f, "Trait"),
            Target::TraitAlias =>
                ::core::fmt::Formatter::write_str(f, "TraitAlias"),
            Target::Impl { of_trait: __self_0 } =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f, "Impl",
                    "of_trait", &__self_0),
            Target::Expression =>
                ::core::fmt::Formatter::write_str(f, "Expression"),
            Target::Statement =>
                ::core::fmt::Formatter::write_str(f, "Statement"),
            Target::Arm => ::core::fmt::Formatter::write_str(f, "Arm"),
            Target::AssocConst(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "AssocConst", &__self_0),
            Target::Method(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f, "Method",
                    &__self_0),
            Target::AssocTy(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "AssocTy", &__self_0),
            Target::ForeignFn =>
                ::core::fmt::Formatter::write_str(f, "ForeignFn"),
            Target::ForeignStatic =>
                ::core::fmt::Formatter::write_str(f, "ForeignStatic"),
            Target::ForeignTy =>
                ::core::fmt::Formatter::write_str(f, "ForeignTy"),
            Target::GenericParam { kind: __self_0, has_default: __self_1 } =>
                ::core::fmt::Formatter::debug_struct_field2_finish(f,
                    "GenericParam", "kind", __self_0, "has_default", &__self_1),
            Target::MacroDef =>
                ::core::fmt::Formatter::write_str(f, "MacroDef"),
            Target::Param => ::core::fmt::Formatter::write_str(f, "Param"),
            Target::PatField =>
                ::core::fmt::Formatter::write_str(f, "PatField"),
            Target::ExprField =>
                ::core::fmt::Formatter::write_str(f, "ExprField"),
            Target::WherePredicate =>
                ::core::fmt::Formatter::write_str(f, "WherePredicate"),
            Target::MacroCall =>
                ::core::fmt::Formatter::write_str(f, "MacroCall"),
            Target::Crate => ::core::fmt::Formatter::write_str(f, "Crate"),
            Target::Delegation { mac: __self_0 } =>
                ::core::fmt::Formatter::debug_struct_field1_finish(f,
                    "Delegation", "mac", &__self_0),
            Target::ForLoop =>
                ::core::fmt::Formatter::write_str(f, "ForLoop"),
            Target::While => ::core::fmt::Formatter::write_str(f, "While"),
            Target::Loop => ::core::fmt::Formatter::write_str(f, "Loop"),
            Target::Break => ::core::fmt::Formatter::write_str(f, "Break"),
        }
    }
}Debug, #[automatically_derived]
impl ::core::cmp::Eq for Target {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<bool>;
        let _: ::core::cmp::AssertParamIsEq<AssocCtxt>;
        let _: ::core::cmp::AssertParamIsEq<MethodKind>;
        let _: ::core::cmp::AssertParamIsEq<GenericParamKind>;
    }
}Eq, const _: () =
    {
        impl ::rustc_data_structures::stable_hash::StableHash for Target {
            #[inline]
            fn stable_hash<__Hcx: ::rustc_data_structures::stable_hash::StableHashCtxt>(&self,
                __hcx: &mut __Hcx,
                __hasher:
                    &mut ::rustc_data_structures::stable_hash::StableHasher) {
                ::std::mem::discriminant(self).stable_hash(__hcx, __hasher);
                match *self {
                    Target::ExternCrate => {}
                    Target::Use => {}
                    Target::Static => {}
                    Target::Const => {}
                    Target::Fn => {}
                    Target::Closure => {}
                    Target::Mod => {}
                    Target::ForeignMod => {}
                    Target::GlobalAsm => {}
                    Target::TyAlias => {}
                    Target::Enum => {}
                    Target::Variant => {}
                    Target::Struct => {}
                    Target::Field => {}
                    Target::Union => {}
                    Target::Trait => {}
                    Target::TraitAlias => {}
                    Target::Impl { of_trait: ref __binding_0 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                    Target::Expression => {}
                    Target::Statement => {}
                    Target::Arm => {}
                    Target::AssocConst(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                    Target::Method(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                    Target::AssocTy(ref __binding_0) => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                    Target::ForeignFn => {}
                    Target::ForeignStatic => {}
                    Target::ForeignTy => {}
                    Target::GenericParam {
                        kind: ref __binding_0, has_default: ref __binding_1 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                        { __binding_1.stable_hash(__hcx, __hasher); }
                    }
                    Target::MacroDef => {}
                    Target::Param => {}
                    Target::PatField => {}
                    Target::ExprField => {}
                    Target::WherePredicate => {}
                    Target::MacroCall => {}
                    Target::Crate => {}
                    Target::Delegation { mac: ref __binding_0 } => {
                        { __binding_0.stable_hash(__hcx, __hasher); }
                    }
                    Target::ForLoop => {}
                    Target::While => {}
                    Target::Loop => {}
                    Target::Break => {}
                }
            }
        }
    };StableHash)]
30pub enum Target {
31    ExternCrate,
32    Use,
33    Static,
34    Const,
35    Fn,
36    Closure,
37    Mod,
38    ForeignMod,
39    GlobalAsm,
40    TyAlias,
41    Enum,
42    Variant,
43    Struct,
44    Field,
45    Union,
46    Trait,
47    TraitAlias,
48    Impl { of_trait: bool },
49    Expression,
50    Statement,
51    Arm,
52    AssocConst(AssocCtxt),
53    Method(MethodKind),
54    AssocTy(AssocCtxt),
55    ForeignFn,
56    ForeignStatic,
57    ForeignTy,
58    GenericParam { kind: GenericParamKind, has_default: bool },
59    MacroDef,
60    Param,
61    PatField,
62    ExprField,
63    WherePredicate,
64    MacroCall,
65    Crate,
66    Delegation { mac: bool },
67    ForLoop,
68    While,
69    Loop,
70    Break,
71}
72
73impl Display for Target {
74    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
75        f.write_fmt(format_args!("{0}", Self::name(*self)))write!(f, "{}", Self::name(*self))
76    }
77}
78
79impl ::rustc_error_messages::IntoDiagArg for Target {
    fn into_diag_arg(self, path: &mut Option<std::path::PathBuf>)
        -> ::rustc_error_messages::DiagArgValue {
        self.to_string().into_diag_arg(path)
    }
}rustc_error_messages::into_diag_arg_using_display!(Target);
80
81impl Target {
82    pub fn is_associated_item(self) -> bool {
83        match self {
84            Target::AssocConst(_) | Target::AssocTy(_) | Target::Method(_) => true,
85            Target::ExternCrate
86            | Target::Use
87            | Target::Static
88            | Target::Const
89            | Target::Fn
90            | Target::Closure
91            | Target::Mod
92            | Target::ForeignMod
93            | Target::GlobalAsm
94            | Target::TyAlias
95            | Target::Enum
96            | Target::Variant
97            | Target::Struct
98            | Target::Field
99            | Target::Union
100            | Target::Trait
101            | Target::TraitAlias
102            | Target::Impl { .. }
103            | Target::Expression
104            | Target::Statement
105            | Target::Arm
106            | Target::ForeignFn
107            | Target::ForeignStatic
108            | Target::ForeignTy
109            | Target::GenericParam { .. }
110            | Target::MacroDef
111            | Target::Param
112            | Target::PatField
113            | Target::ExprField
114            | Target::MacroCall
115            | Target::Crate
116            | Target::WherePredicate
117            | Target::Delegation { .. }
118            | Target::Loop
119            | Target::While
120            | Target::ForLoop
121            | Target::Break => false,
122        }
123    }
124    pub fn from_ast_item(item: &ast::Item) -> Target {
125        match item.kind {
126            ast::ItemKind::ExternCrate(..) => Target::ExternCrate,
127            ast::ItemKind::Use(..) => Target::Use,
128            ast::ItemKind::Static { .. } => Target::Static,
129            ast::ItemKind::Const(..) => Target::Const,
130            ast::ItemKind::ConstBlock(..) => Target::Const,
131            ast::ItemKind::Fn { .. } => Target::Fn,
132            ast::ItemKind::Mod(..) => Target::Mod,
133            ast::ItemKind::ForeignMod { .. } => Target::ForeignMod,
134            ast::ItemKind::GlobalAsm { .. } => Target::GlobalAsm,
135            ast::ItemKind::TyAlias(..) => Target::TyAlias,
136            ast::ItemKind::Enum(..) => Target::Enum,
137            ast::ItemKind::Struct(..) => Target::Struct,
138            ast::ItemKind::Union(..) => Target::Union,
139            ast::ItemKind::Trait(..) => Target::Trait,
140            ast::ItemKind::TraitAlias(..) => Target::TraitAlias,
141            ast::ItemKind::Impl(ref i) => Target::Impl { of_trait: i.of_trait.is_some() },
142            ast::ItemKind::MacCall(..) => Target::MacroCall,
143            ast::ItemKind::MacroDef(..) => Target::MacroDef,
144            ast::ItemKind::Delegation(..) => Target::Delegation { mac: false },
145            ast::ItemKind::DelegationMac(..) => Target::Delegation { mac: true },
146            ast::ItemKind::TestBinderConstraints(..) => Target::MacroCall,
147        }
148    }
149
150    pub fn from_foreign_item_kind(kind: &ast::ForeignItemKind) -> Target {
151        match kind {
152            ForeignItemKind::Static(_) => Target::ForeignStatic,
153            ForeignItemKind::Fn(_) => Target::ForeignFn,
154            ForeignItemKind::TyAlias(_) => Target::ForeignTy,
155            ForeignItemKind::MacCall(_) => Target::MacroCall,
156        }
157    }
158
159    pub fn from_assoc_item_kind(kind: &ast::AssocItemKind, assoc_ctxt: AssocCtxt) -> Target {
160        match kind {
161            AssocItemKind::Const(_) => Target::AssocConst(assoc_ctxt),
162            AssocItemKind::Fn(f) => Target::Method(match assoc_ctxt {
163                AssocCtxt::Trait => MethodKind::Trait { body: f.body.is_some() },
164                AssocCtxt::Impl { of_trait, .. } => {
165                    if of_trait {
166                        MethodKind::TraitImpl
167                    } else {
168                        MethodKind::Inherent
169                    }
170                }
171            }),
172            AssocItemKind::Type(_) => Target::AssocTy(assoc_ctxt),
173            AssocItemKind::Delegation(_) => Target::Delegation { mac: false },
174            AssocItemKind::DelegationMac(_) => Target::Delegation { mac: true },
175            AssocItemKind::MacCall(_) => Target::MacroCall,
176        }
177    }
178
179    pub fn from_expr(expr: &ast::Expr) -> Self {
180        match &expr.kind {
181            ast::ExprKind::Closure(..) | ast::ExprKind::Gen(..) => Self::Closure,
182            ast::ExprKind::Paren(e) => Self::from_expr(&e),
183            ast::ExprKind::ForLoop { .. } => Self::ForLoop,
184            ast::ExprKind::Loop(..) => Self::Loop,
185            ast::ExprKind::While(..) => Self::While,
186            ast::ExprKind::Break(..) => Self::Break,
187            _ => Self::Expression,
188        }
189    }
190
191    pub fn name(self) -> &'static str {
192        match self {
193            Target::ExternCrate => "extern crate",
194            Target::Use => "use",
195            Target::Static => "static",
196            Target::Const => "constant",
197            Target::Fn => "function",
198            Target::Closure => "closure",
199            Target::Mod => "module",
200            Target::ForeignMod => "foreign module",
201            Target::GlobalAsm => "global asm",
202            Target::TyAlias => "type alias",
203            Target::Enum => "enum",
204            Target::Variant => "enum variant",
205            Target::Struct => "struct",
206            Target::Field => "struct field",
207            Target::Union => "union",
208            Target::Trait => "trait",
209            Target::TraitAlias => "trait alias",
210            Target::Impl { .. } => "implementation block",
211            Target::Expression => "expression",
212            Target::Statement => "statement",
213            Target::Arm => "match arm",
214            Target::AssocConst(_) => "associated const",
215            Target::Method(kind) => match kind {
216                MethodKind::Inherent => "inherent method",
217                MethodKind::Trait { body: false } => "required trait method",
218                MethodKind::Trait { body: true } => "provided trait method",
219                MethodKind::TraitImpl => "trait method in an impl block",
220            },
221            Target::AssocTy(_) => "associated type",
222            Target::ForeignFn => "foreign function",
223            Target::ForeignStatic => "foreign static item",
224            Target::ForeignTy => "foreign type",
225            Target::GenericParam { kind, .. } => match kind {
226                GenericParamKind::Type => "type parameter",
227                GenericParamKind::Lifetime => "lifetime parameter",
228                GenericParamKind::Const => "const parameter",
229            },
230            Target::MacroDef => "macro def",
231            Target::Param => "function param",
232            Target::PatField => "pattern field",
233            Target::ExprField => "struct field",
234            Target::WherePredicate => "where predicate",
235            Target::MacroCall => "macro call",
236            Target::Crate => "crate",
237            Target::Delegation { .. } => "delegation",
238            Target::Loop => "loop",
239            Target::ForLoop => "for loop",
240            Target::While => "while loop",
241            Target::Break => "break expression",
242        }
243    }
244
245    pub fn plural_name(self) -> &'static str {
246        match self {
247            Target::ExternCrate => "extern crates",
248            Target::Use => "use statements",
249            Target::Static => "statics",
250            Target::Const => "constants",
251            Target::Fn => "functions",
252            Target::Closure => "closures",
253            Target::Mod => "modules",
254            Target::ForeignMod => "foreign modules",
255            Target::GlobalAsm => "global asms",
256            Target::TyAlias => "type aliases",
257            Target::Enum => "enums",
258            Target::Variant => "enum variants",
259            Target::Struct => "structs",
260            Target::Field => "struct fields",
261            Target::Union => "unions",
262            Target::Trait => "traits",
263            Target::TraitAlias => "trait aliases",
264            Target::Impl { of_trait: false } => "inherent impl blocks",
265            Target::Impl { of_trait: true } => "trait impl blocks",
266            Target::Expression => "expressions",
267            Target::Statement => "statements",
268            Target::Arm => "match arms",
269            Target::AssocConst(_) => "associated consts",
270            Target::Method(kind) => match kind {
271                MethodKind::Inherent => "inherent methods",
272                MethodKind::Trait { body: false } => "required trait methods",
273                MethodKind::Trait { body: true } => "provided trait methods",
274                MethodKind::TraitImpl => "trait methods in impl blocks",
275            },
276            Target::AssocTy(_) => "associated types",
277            Target::ForeignFn => "foreign functions",
278            Target::ForeignStatic => "foreign statics",
279            Target::ForeignTy => "foreign types",
280            Target::GenericParam { kind, has_default: _ } => match kind {
281                GenericParamKind::Type => "type parameters",
282                GenericParamKind::Lifetime => "lifetime parameters",
283                GenericParamKind::Const => "const parameters",
284            },
285            Target::MacroDef => "macro defs",
286            Target::Param => "function params",
287            Target::PatField => "pattern fields",
288            Target::ExprField => "struct fields",
289            Target::WherePredicate => "where predicates",
290            Target::MacroCall => "macro calls",
291            Target::Crate => "crates",
292            Target::Delegation { .. } => "delegations",
293            Target::ForLoop => "for loops",
294            Target::Loop => "loops",
295            Target::While => "while loops",
296            Target::Break => "break expressions",
297        }
298    }
299}