Description
imported from the rust repo, PR rust-lang/rust#29406
Description, as originally written by @matklad :
Rust currently allows omitting parameter names in trati methods, like this.
trait T { fn foo(i32) { } }In all other contexts, except for the fn types, parameter names are
mandatory. This makes argument names in trait methods also mandatory.This is a breaking language change.
I'm not sure that this is a bug, so feel free to close. I haven't run the tests yet ( they are in progress :( ), so build will likelly fail.
Discussion on the users.rust-lang: https://users.rust-lang.org/t/question-why-does-rust-admit-anonymous-parameters-in-traits/3420
@nikomatsakis notes in followup discussion on #29406 :
Huh. I don't believe it was intended that parameter names can be omitted in trait methods with a body -- I know we allowed it in traits initially (before default methods existed), and I guess it is still accepted just because it is a pain to parse otherwise, since you don't know whether the method has a body until later.
That said, I remember us debating about whether to change this due to parsing ambiguities between patterns and types, in particular when parsing something like fn foo(&T -- at this point we don't know if the &T is a pattern or a type. I thought we planned to require parameter names in trait definitions for this reason -- but I guess that never happened?