Open tspiteri opened 7 years ago
Thanks, that’s very helpful. I’ll work on adding these.
Adding the first group was simple. I’m uncertain about the remaining groups. At present, the formatting for write!
cheats and assumes the first comma it encounters denotes the end of the first argument, which I figure should be good enough since you’re usually calling it with a single variable in that position (write!(out, "foo")
). All the assert
macros, in contrast, can easily contain commas along the lines of assert!(foo(bar, baz), "works")
, and to deal with that I need a way to skip over Rust expressions. I’m going to give it a shot but I have no idea how feasible it is.
What about quite popular macros for logging from here: info!
, warn!
, error!
, debug!
?
That’s a good idea, but I’d be more hesitant to add those since they’re not builtin per se. Having sed said that, you could add them to your config manually if you like:
;; you will need to either restart Emacs or hit C-M-x on
;; `rust-mode-font-lock-keywords' after hitting C-x C-e on this
(dolist (macro '("debug" "error" "info" "warn"))
(add-to-list 'rust-builtin-formatting-macros macro))
The new argument interpolation highlighting from #220 handles the macros
eprint!
,eprintln!
,format!
,print!
,println!
,write!
andwriteln!
.It can be extended to also handle other macros that take format strings. I'm including a list below (I hope I didn't miss any).
eprint!
,eprintln!
,format!
,print!
,println!
)format_args!
panic!
unreachable!
unimplemented!
(not in 1.19.0, but in the beta that is to become 1.20.0)write!
,writeln!
):assert!
debug_assert!
assert_eq!
assert_ne!
debug_assert_eq!
debug_assert_ne!