Don't escape 'static

As it is a valid lifetime without escaping.

It does need to be escaped as a label, but we have no way to distinguish that.
This commit is contained in:
Chayim Refael Friedman 2025-04-26 21:20:43 +03:00
parent d781d02cf4
commit e6ebf0b8a1
2 changed files with 10 additions and 2 deletions

View file

@ -207,6 +207,14 @@ struct Display<'a> {
impl fmt::Display for Display<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut symbol = self.name.symbol.as_str();
if symbol == "'static" {
// FIXME: '`static` can also be a label, and there it does need escaping.
// But knowing where it is will require adding a parameter to `display()`,
// and that is an infectious change.
return f.write_str(symbol);
}
if let Some(s) = symbol.strip_prefix('\'') {
f.write_str("'")?;
symbol = s;