Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
durka opened this issue Aug 29, 2018 · 2 comments
Closed

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

durka opened this issue Aug 29, 2018 · 2 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints

Comments

@durka
Copy link
Contributor

durka commented Aug 29, 2018

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

@petrochenkov
Copy link
Contributor

Similar to #52307.

Parser already have necessary infra for making these suggestions, but it doesn't apply in this specific case for some reason.

error: missing angle brackets in associated item path
 --> src/main.rs:2:13
  |
2 |     let x = [u8; 1]::clone();
  |             ^^^^^^^^^^^^^^ help: try: `<[u8; 1]>::clone`

https://play.rust-lang.org/?gist=655aea8c484b9a47fef838d3dc74b395&version=nightly&mode=debug&edition=2015

@Havvy Havvy added the A-diagnostics Area: Messages for errors, warnings, and lints label Aug 30, 2018
@petrochenkov petrochenkov self-assigned this Mar 9, 2019
@petrochenkov petrochenkov removed their assignment Mar 10, 2019
@petrochenkov
Copy link
Contributor

Fixed in #59058

Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this issue Mar 22, 2019
 syntax: Better recovery for `$ty::AssocItem` and `ty!()::AssocItem`

This PR improves on rust-lang#46788 covering a few missing cases.

Fixes rust-lang#52307
Fixes rust-lang#53776
r? @estebank
bors added a commit that referenced this issue Mar 23, 2019
 syntax: Better recovery for `$ty::AssocItem` and `ty!()::AssocItem`

This PR improves on #46788 covering a few missing cases.

Fixes #52307
Fixes #53776
r? @estebank
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints
Projects
None yet
Development

No branches or pull requests

3 participants