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
commit 908c17bfa6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 1 deletions

View file

@ -957,7 +957,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

@ -3508,6 +3508,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
"#]],
);