Skip to content

Should bounds on mut trait objects be covariant? #14985

Closed
@nrc

Description

@nrc

Currently if Trait1 and Trait2 are traits, then &mut Trait1+Trait2 <: &mut Trait1. I.e., mutable trait objects are covariant. All other mutable references are invariant, that is &mut T <: &mut T' iff T /equiv T'.

Should trait objects also be invariant?

See also #12470, which is a similar issue but about lifetimes in the same situation (which must be invariant and not contravariant).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions