Skip to content

RPIT type parameters not checked for well-formedness #110925

Description

@Jules-Bertholet

I tried this code:

trait Test<T: ?Sized> {}

impl<T: ?Sized, U: ?Sized> Test<U> for T {}

fn foo() -> impl Test<(str, str)> {
    ()
}

fn main() {
    foo();
}

I expected to see this happen: Compile error, (str, str) is not well-formed

Instead, this happened: Compiles and runs successfully

Meta

rustc --version --verbose:

rustc 1.71.0-nightly (1a6ae3d69 2023-04-27)
binary: rustc
commit-hash: 1a6ae3d692cfb52b21d0f45ba50b659486e53d6c
commit-date: 2023-04-27
host: x86_64-unknown-linux-gnu
release: 1.71.0-nightly
LLVM version: 16.0.2

@rustbot label +A-impl-trait +T-types

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.C-bugCategory: This is a bug.T-typesRelevant to the types team, which will review and decide on the PR/issue.

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions