Lower string literals with real val, not default

This commit is contained in:
Tianyi Song 2022-03-01 15:44:53 +08:00
parent 9d473a0b9f
commit 89a19f57f8
2 changed files with 25 additions and 1 deletions

View file

@ -923,7 +923,10 @@ impl From<ast::LiteralKind> for Literal {
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()),

View file

@ -3487,6 +3487,27 @@ const FOO$0: usize = 1 << 100;
---
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
"#]],
);