Description
I really want to see complete support for trailing commas in std
macros.
As I described on Internals, all (stable) "variadic" macros correctly support trailing commas for sufficiently long argument lists. It is only a few, select, specific argument counts that trip them up.
Here is a check list of all test cases that currently fail to compile:
Failing cases that obviously need fixing
These macros already support trailing commas when given longer argument lists, they just fail for these specific lengths:
-
{debug_,}assert!(true, );
-
{debug_,}assert!(true, "hello",);
-
{debug_,}assert_{eq,ne}!(1, 1,);
- Status: Fixed in Beta
-
panic!("hello",);
-
writeln!(&mut stdout,);
-
unreachable!("hello",);
Worth discussion
These macros technically have not yet committed to the "function-call-like" syntax and we still currently have the option to extend these with an entirely different syntax. Like, I don't know, compile_error!("a" => b)
or something.
include{,_bytes,_str}!("dumdum.rs",);
compile_error!("lel",);
try!(Ok(()),);
option_env!("PATH",);
- note:
env!
handles the trailing comma so we might want this just for consistency's sake
- note:
cfg!(unix,);
Oddball cases
- the unstable mpsc
select!
does not support trailing commas in general...- ...but it also contains numerous other papercuts and probably deserves an issue all of its own.
I offer to help with at least those macros which are implemented via macro_rules!
.