11595: fix: lower string literals with actual value instead of default r=lnicola a=tysg

Fixes #11582. Some questions below in the code review section.

Co-authored-by: Tianyi Song <42670338+tysg@users.noreply.github.com>
This commit is contained in:
bors[bot]
2022-03-04 20:21:43 +00:00
committed by GitHub
2 changed files with 25 additions and 1 deletions
+4 -1
View File
@@ -957,7 +957,10 @@ fn from(ast_lit_kind: ast::LiteralKind) -> Self {
let text = bs.value().map(Box::from).unwrap_or_else(Default::default);
Literal::ByteString(text)
}
LiteralKind::String(_) => Literal::String(Default::default()),
LiteralKind::String(s) => {
let text = s.value().map(Box::from).unwrap_or_else(Default::default);
Literal::String(text)
}
LiteralKind::Byte => Literal::Uint(Default::default(), Some(BuiltinUint::U8)),
LiteralKind::Bool(val) => Literal::Bool(val),
LiteralKind::Char => Literal::Char(Default::default()),
+21
View File
@@ -3508,6 +3508,27 @@ fn hover_const_eval() {
---
This is a doc
"#]],
);
check(
r#"
/// This is a doc
const FOO$0: &str = "bar";
"#,
expect![[r#"
*FOO*
```rust
test
```
```rust
const FOO: &str = "bar"
```
---
This is a doc
"#]],
);