rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
97.18k stars 12.56k forks source link

Unhelpful "add a parameter list" suggestion for double colons in generic function definition #130791

Open okaneco opened 3 days ago

okaneco commented 3 days ago

Code

fn test::<T>() {}

Current output

error: missing parameters for function definition
 --> src/lib.rs:1:8
  |
1 | fn test::<T>() {}
  |        ^
  |
help: add a parameter list
  |
1 | fn test()::<T>() {}
  |        ++

error: expected one of `->`, `<`, `where`, or `{`, found `::`
 --> src/lib.rs:1:8
  |
1 | fn test::<T>() {}
  |        ^^ expected one of `->`, `<`, `where`, or `{`

error: could not compile `playground` (lib) due to 2 previous errors

Desired output

error: *TBD*
 --> src/lib.rs:1:8
  |
1 | fn test::<T>() {}
  |        ^
  |
help: remove the double colons
  |
1 | fn test<T>() {}
  |

error: expected one of `->`, `<`, `where`, or `{`, found `::`
 --> src/lib.rs:1:8
  |
1 | fn test::<T>() {}
  |        ^^ expected one of `->`, `<`, `where`, or `{`

error: could not compile `playground` (lib) due to 2 previous errors

Rationale and extra context

No response

Other cases

No response

Rust Version

Playground nightly, I don't see a way to verbosely print this information.

1.83.0-nightly (2024-09-23 7042c269c)

Anything else?

No response

surechen commented 3 days ago

@rustbot claim