Skip to content

add more tests for type-instantiation pat::<T> syntax in patterns #22546

Closed
@pnkfelix

Description

@pnkfelix

Spawned off of issue #22544

Consider this code:

pub struct Foo<T>(T, T);

impl<T: ::std::fmt::Display> Foo<T> {
    fn foo(&self) {
        match *self {
            Foo::<T>(ref x, ref y) =>  // <=== check out this line!
                println!("Goodbye, World! {} {}", x, y)
        }
    }
}

fn main() {
    let f = Foo(2,3);
    f.foo();
}

The above compiles and runs in the playpen today.

We probably shouldn't accept the use of Foo::<T> in a pattern, right?

(Is there some context where we would want that, i.e. as some sort of feedback into type-inference? I dunno, I still remain to be convinced that type ascription in patterns is generally useful.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions