| 1 | use quoterust-analyzer cargo quote 1.0.47 crate/::ToTokensrust-analyzer cargo quote 1.0.47 to_tokens/ToTokens#; |
| 2 | use synrust-analyzer cargo syn 2.0.119 crate/::{spannedrust-analyzer cargo syn 2.0.119 spanned/::Spannedrust-analyzer cargo syn 2.0.119 spanned/Spanned#, Identrust-analyzer cargo proc-macro2 1.0.107 Ident#, Metarust-analyzer cargo syn 2.0.119 attr/Meta#, Variantrust-analyzer cargo syn 2.0.119 data/Variant#}; |
| 3 | |
| 4 | #[inline] |
| 5 | pub(craterust-analyzer cargo educe 0.6.0 crate/) fn unit_struct_need_namerust-analyzer cargo educe 0.6.0 trait_handlers/debug/panic/unit_struct_need_name().(name: &Identrust-analyzer cargo proc-macro2 1.0.107 Ident#) -> synrust-analyzer cargo syn 2.0.119 crate/::Errorrust-analyzer cargo syn 2.0.119 error/Error# { |
| 6 | synrust-analyzer cargo syn 2.0.119 crate/::Errorrust-analyzer cargo syn 2.0.119 error/Error#::newrust-analyzer cargo syn 2.0.119 error/impl#[Error]new().(name.spanrust-analyzer cargo proc-macro2 1.0.107 impl#[Ident]span().(), "a unit struct needs to have a name") |
| 7 | } |
| 8 | |
| 9 | #[inline] |
| 10 | pub(craterust-analyzer cargo educe 0.6.0 crate/) fn unit_variant_need_namerust-analyzer cargo educe 0.6.0 trait_handlers/debug/panic/unit_variant_need_name().(variant: &Variantrust-analyzer cargo syn 2.0.119 data/Variant#) -> synrust-analyzer cargo syn 2.0.119 crate/::Errorrust-analyzer cargo syn 2.0.119 error/Error# { |
| 11 | synrust-analyzer cargo syn 2.0.119 crate/::Errorrust-analyzer cargo syn 2.0.119 error/Error#::newrust-analyzer cargo syn 2.0.119 error/impl#[Error]new().( |
| 12 | variant.spanrust-analyzer cargo syn 2.0.119 spanned/impl#[T][Spanned]span().(), |
| 13 | "a unit variant which doesn't use an enum name needs to have a name", |
| 14 | ) |
| 15 | } |
| 16 | |
| 17 | #[inline] |
| 18 | pub(craterust-analyzer cargo educe 0.6.0 crate/) fn unit_enum_need_namerust-analyzer cargo educe 0.6.0 trait_handlers/debug/panic/unit_enum_need_name().(name: &Identrust-analyzer cargo proc-macro2 1.0.107 Ident#) -> synrust-analyzer cargo syn 2.0.119 crate/::Errorrust-analyzer cargo syn 2.0.119 error/Error# { |
| 19 | synrust-analyzer cargo syn 2.0.119 crate/::Errorrust-analyzer cargo syn 2.0.119 error/Error#::newrust-analyzer cargo syn 2.0.119 error/impl#[Error]new().(name.spanrust-analyzer cargo proc-macro2 1.0.107 impl#[Ident]span().(), "a unit enum needs to have a name") |
| 20 | } |
| 21 | |
| 22 | #[inline] |
| 23 | pub(craterust-analyzer cargo educe 0.6.0 crate/) fn union_without_unsaferust-analyzer cargo educe 0.6.0 trait_handlers/debug/panic/union_without_unsafe().(meta: &Metarust-analyzer cargo syn 2.0.119 attr/Meta#) -> synrust-analyzer cargo syn 2.0.119 crate/::Errorrust-analyzer cargo syn 2.0.119 error/Error# { |
| 24 | let mut s = meta.into_token_streamrust-analyzer cargo quote 1.0.47 to_tokens/ToTokens#into_token_stream().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().().replacerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]replace().(" , ", ", "); |
| 25 | |
| 26 | match s.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]len().() { |
| 27 | 5 => s.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().("(unsafe)"), |
| 28 | 7 => s.insert_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]insert_str().(6, "unsafe"), |
| 29 | _ => s.insert_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]insert_str().(6, "unsafe, "), |
| 30 | } |
| 31 | |
| 32 | synrust-analyzer cargo syn 2.0.119 crate/::Errorrust-analyzer cargo syn 2.0.119 error/Error#::newrust-analyzer cargo syn 2.0.119 error/impl#[Error]new().( |
| 33 | meta.spanrust-analyzer cargo syn 2.0.119 spanned/impl#[T][Spanned]span().(), |
| 34 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!( |
| 35 | "a union's `Debug` implementation may expose uninitialized memory\n* It is \ |
| 36 | recommended that, for a union where `Debug` is implemented, types that allow \ |
| 37 | uninitialized memory should not be used in it.\n* If you can ensure that the union \ |
| 38 | uses no such types, use `#[educe({s})]` to implement the `Debug` trait for it.\n* \ |
| 39 | The `unsafe` keyword should be placed as the first parameter of the `Debug` \ |
| 40 | attribute." |
| 41 | ), |
| 42 | ) |
| 43 | } |