Skip to content

Trait bounds on trait type parameters never checked #7266

Closed
@msullivan

Description

@msullivan

Type parameters to traits can have trait bounds, but these bounds are not checked when implementing the trait.

pub trait Clone2 {
    fn clone(&self) -> Self;
}


trait Getter<T: Clone2> {
    fn get(&self) -> T;
}

impl Getter<int> for int {
    fn get(&self) -> int { *self }
}

int doesn't implement Clone2, but this program is accepted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions