Skip to content

Trait bounds are not checked on type aliases until they are used #51626

Open
@glandium

Description

@glandium

Consider the following code:

#![crate_type = "lib"]

pub trait Trait {}

pub struct Foo<T: Trait>(T);

pub struct Qux;

pub type Bar<T=Qux> = Foo<T>;

This builds without an error although Qux doesn't respect the trait bound.

Build failure only occurs when one actually uses the type alias, like the following:

fn foo(_: Bar) {}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-trait-systemArea: Trait systemC-bugCategory: This is a bug.P-mediumMedium priorityT-compilerRelevant to the compiler 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