Skip to content

Semver breaking change not listed in book: Relaxing trait type bounds #15690

@mysteriouslyseeing

Description

@mysteriouslyseeing

Relaxing a supertrait is a breaking change not listed in the book's section on SemVer, because other crates may rely on supertraits for generic code. Note that this also applies to trait bounds on associated types:

trait Foo: Default {}

fn make_a_foo<A: Foo>() -> A {
    A::default()
}

trait Bar {
    type Baz: Default;
}

fn make_a_baz<A: Bar>() -> A::Baz {
    A::Baz::default()
}

That code fails to compile if either Default is removed. Playground

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-documenting-cargo-itselfArea: Cargo's documentationA-semverArea: semver specifications, version matching, etc.C-enhancementCategory: enhancementS-needs-mentorStatus: Issue or feature is accepted, but needs a team member to commit to helping and reviewing.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions