Skip to content

Commit e6ebf0b

Browse files
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.
1 parent d781d02 commit e6ebf0b

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

crates/hir-expand/src/name.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,14 @@ struct Display<'a> {
207207
impl fmt::Display for Display<'_> {
208208
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
209209
let mut symbol = self.name.symbol.as_str();
210+
211+
if symbol == "'static" {
212+
// FIXME: '`static` can also be a label, and there it does need escaping.
213+
// But knowing where it is will require adding a parameter to `display()`,
214+
// and that is an infectious change.
215+
return f.write_str(symbol);
216+
}
217+
210218
if let Some(s) = symbol.strip_prefix('\'') {
211219
f.write_str("'")?;
212220
symbol = s;

crates/ide-completion/src/completions/lifetime.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,13 @@ fn foo<'lifetime>(foo: &'a$0) {}
116116
check(
117117
r#"
118118
struct Foo;
119-
impl<'impl> Foo {
119+
impl<'r#impl> Foo {
120120
fn foo<'func>(&'a$0 self) {}
121121
}
122122
"#,
123123
expect![[r#"
124124
lt 'func
125-
lt 'impl
125+
lt 'r#impl
126126
lt 'static
127127
"#]],
128128
);

0 commit comments

Comments
 (0)