mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 11:31:15 +00:00
Don't render multi-line literal values
This commit is contained in:
parent
a39c0493a1
commit
5b696bac5c
@ -564,7 +564,13 @@ pub(super) fn literal(sema: &Semantics<'_, RootDatabase>, token: SyntaxToken) ->
|
||||
|
||||
let mut s = format!("```rust\n{ty}\n```\n___\n\n");
|
||||
match value {
|
||||
Ok(value) => format_to!(s, "value of literal: {value}"),
|
||||
Ok(value) => {
|
||||
if let Some(newline) = value.find('\n') {
|
||||
format_to!(s, "value of literal (truncated up to newline): {}", &value[..newline])
|
||||
} else {
|
||||
format_to!(s, "value of literal: {value}")
|
||||
}
|
||||
}
|
||||
Err(error) => format_to!(s, "invalid literal: {error}"),
|
||||
}
|
||||
Some(s.into())
|
||||
|
@ -7814,6 +7814,28 @@ fn main() {
|
||||
value of literal: 🦀\u{1f980}\\\x41
|
||||
"#]],
|
||||
);
|
||||
check(
|
||||
r#"
|
||||
fn main() {
|
||||
$0r"🦀\u{1f980}\\\x41
|
||||
|
||||
|
||||
fsdghs";
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
*r"🦀\u{1f980}\\\x41
|
||||
|
||||
|
||||
fsdghs"*
|
||||
```rust
|
||||
&str
|
||||
```
|
||||
___
|
||||
|
||||
value of literal (truncated up to newline): 🦀\u{1f980}\\\x41
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
Loading…
x
Reference in New Issue
Block a user