Closed
Description
I'd expect these method declarations to work:
struct Welp<T>(pub T);
trait Bleh {
fn foo(Welp(i): Welp<int>) {}
// ^ expected `` but found `(`
fn bar(&&&x: &&&int) {}
// ^~ expected `,` but found `&&`
fn baz((): ()) {}
// ^ expected `,` but found `:`
}
The manual says "As with let bindings, function arguments are irrefutable patterns, so any pattern that is valid in a let binding is also valid as an argument." Yet these aren't, and it seems like it would require a ton of lookahead given that newtype struct constructors can be named with arbitrarily long paths and you can have lots of &
s prefixed, or deeply nested tuples, ...
Edit: Rereading the parser code, it looks like currently the only valid patterns in trait method parameter position are a single identifier optionally prefixed with &
, &&
or mut
, and rereading the manual, the bit I quoted is in the description of functions, not trait methods, so I guess I don't have a real case here. ;)
Metadata
Metadata
Assignees
Labels
No labels