Skip to content

#[derive] sometimes uses incorrect bounds (aka lack of "perfect derive") #26925

Open
@comex

Description

@comex

In the following code:

#[derive(Copy, Clone)]
struct Y<T>(&'static fn(T));

both derives expand to impls that require the corresponding trait to be implemented on the type parameter, e.g.:

#[automatically_derived]
impl<T: ::std::marker::Copy> ::std::marker::Copy for Y<T>
where
     T: ::std::marker::Copy
{}

However, this isn't actually necessary, as Y<T> will still be eligible for Copy regardless of whether T is.

This may be hard to fix, given the compilation phase at which #[derive] works...

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-proc-macrosArea: Procedural macrosA-trait-systemArea: Trait systemC-bugCategory: This is a bug.P-lowLow priorityT-langRelevant to the language team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions