softdevteam / grmtools

Rust grammar tool libraries and binaries
Other
507 stars 31 forks source link

Remove debug formatting in non-debug locations #323

Open ltratt opened 2 years ago

ltratt commented 2 years ago

In a couple of places (e.g. https://github.com/softdevteam/grmtools/blob/master/lrlex/src/lib/ctbuilder.rs#L419) we use debug formatting in a non-debug location. This feels somewhat unsatisfactory, particularly as there are fewer guarantees about stability.

ratmice commented 1 year ago

I had a look through these, and it appears to me that these just want to be turned into \"{}\". I.e. they are all names, etc that we wouldn't expect to contain any escape sequences. So I don't think we need to go as far as something like \"{}\", x.escape_default(), to try mirroring that debug also escapes.

Edit: The above may not be right, I think actually '\' and '"' may be valid lex names that need escaping here.

ltratt commented 1 year ago

I think actually '\' and '"' may be valid lex names that need escaping here.

Good point! Yes, this needs checking.