The TOML parser used by verus-mode.el does not support single-quoted strings, which causes issues when using Rust's built-in quick fixes and code suggestions. These often generate TOML with single quotes, leading to an opaque error message (Bad readable value).
Why This Matters
Breaks the workflow when following Rust's own tooling suggestions
The error message is not user-friendly or actionable
Users might waste time debugging what appears to be a problem with their TOML when it's actually a parser limitation
Steps to Reproduce
Use latest Rust compiler, have some cfg(flag) it does not recognize.
Apply the suggestion (which uses single quotes)
Try to use verus-mode.el
Example problematic TOML:
[lints.rust]
# (I was migrating from prusti to verus, this was copied and pasted from the warning rust gave me)
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(prusti)'] }
Solution
I simply added support for single quote strings in the TOML library with these following changes:
First, I wrote a simple macro to generate a string reading function. A higher order function would also be a fine
alternative:
Adjusted the special-escape-characters constant to include single quotes:
(defconst toml->special-escape-characters
'(?b ?t ?n ?f ?r ?\" ?\' ?\/ ?\\)
"Characters which are escaped in TOML.
\\b - backspace (U+0008)
\\t - tab (U+0009)
\\n - linefeed (U+000A)
\\f - form feed (U+000C)
\\r - carriage return (U+000D)
\\\" - quote (U+0022)
\\\' - single-quote (U+0027)
\\\/ - slash (U+002F)
\\\\ - backslash (U+005C)
notes:
Excluded four hex (\\uXXXX). Do check in `toml:read-escaped-char'")
This is the solution I am currently using, which works and passes the toml library's tests. My chain is quite minimal, so I have not performed a great deal of testing, however it does fix the issue.
The toml library has not seen much maintenance, and users have been annoyed by this, so I am not sure what the best way of integrating this fix is.
Problem
The TOML parser used by verus-mode.el does not support single-quoted strings, which causes issues when using Rust's built-in quick fixes and code suggestions. These often generate TOML with single quotes, leading to an opaque error message (
Bad readable value
).Why This Matters
Steps to Reproduce
cfg(flag)
it does not recognize.Example problematic TOML:
Solution
I simply added support for single quote strings in the TOML library with these following changes:
First, I wrote a simple macro to generate a string reading function. A higher order function would also be a fine alternative:
Added these to the
read-table
:Adjusted the
special-escape-characters
constant to include single quotes:This is the solution I am currently using, which works and passes the toml library's tests. My chain is quite minimal, so I have not performed a great deal of testing, however it does fix the issue.
The toml library has not seen much maintenance, and users have been annoyed by this, so I am not sure what the best way of integrating this fix is.