mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-28 18:43:01 +00:00
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:
parent
d781d02cf4
commit
e6ebf0b8a1
2 changed files with 10 additions and 2 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -116,13 +116,13 @@ fn foo<'lifetime>(foo: &'a$0) {}
|
|||
check(
|
||||
r#"
|
||||
struct Foo;
|
||||
impl<'impl> Foo {
|
||||
impl<'r#impl> Foo {
|
||||
fn foo<'func>(&'a$0 self) {}
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
lt 'func
|
||||
lt 'impl
|
||||
lt 'r#impl
|
||||
lt 'static
|
||||
"#]],
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue