Skip to content

type in expression position followed by :: should suggest <...>:: #53776

Closed
@durka

Description

@durka

When you write a macro that tries to call a method on the type...

macro_rules! call {
    ($t:ty) => {
        $t::foo()
    }
}

...and try to call it...

call!(Foo);

...you get an error that doesn't make any sense:

error: expected expression, found `Foo`
  --> expr.rs:18:45
   |
18 |     match {macro_rules! call { ($t:ty) => { $t::foo() } } call!(Foo);} {
   |                                             ^^            ----------- in this macro invocation
   |                                             |
   |                                             expected expression

The syntax that works is <$t>::foo(), but there's no way to discover this, so the error message should suggest it.

cc @eddyb

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lints

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions