Skip to content

Generic type defaults should not be allowed if they don’t satisfy type constraints #28024

Closed
@nagisa

Description

@nagisa

As spotted in this internals thread:

use std::fmt::Debug;

struct Foo;

fn show<T: Debug = Foo>(t: T) {
    println!("{:?}", t)
}

compiles. Lack of early error/warning/lint here might be hiding bugs in API design if the default never actually kicks in inside the library.

Metadata

Metadata

Assignees

Labels

A-type-systemArea: Type systemC-bugCategory: This is a bug.P-mediumMedium 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