Skip to content

allows are not propagated to auto-generated impls #392

@wprzytula

Description

@wprzytula

Problem statement

Built-in derive macros (e.g., Debug) behave differently than thiserror::Error wrt propagation of #[allow(...)] attributes.

Built-in macros

allow attributes are propagated to auto-generated impls.

thiserror::Error

allow attributes are not propagated to auto-generated impls.

Example

#[deprecated]
#[allow(deprecated, never_type_fallback_flowing_into_unsafe)]
#[derive(Debug, Error)]
#[error("B")]
pub struct B;

gets expanded into (formatted for readability):

#[deprecated]
#[allow(deprecated, never_type_fallback_flowing_into_unsafe)]
#[error("B")]
pub struct B;

#[automatically_derived]
#[allow(deprecated, never_type_fallback_flowing_into_unsafe)]
impl ::core::fmt::Debug for B {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f, "B")
    }
}

#[allow(unused_qualifications)]
#[automatically_derived]
impl ::thiserror::__private::Error for B {}

#[allow(unused_qualifications)]
#[automatically_derived]
impl ::core::fmt::Display for B {
    #[allow(clippy::used_underscore_binding)]
    fn fmt(&self, __formatter: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        #[allow(unused_variables, deprecated)]
        let Self {} = self;
        __formatter.write_str("B")
    }
}

Proposed solution

Do propagate allows to impls generated by thiserror::Error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions