diff options
| author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2022-03-04 20:21:43 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-03-04 20:21:43 +0000 |
| commit | 908c17bfa6a55fc78bb9255e02bd53eebf0386dd (patch) | |
| tree | 3c9f4775cd485d63bd912fbc8c2cb3c0fb7bb9d3 | |
| parent | a474535e44f9d4d46a74466f92cf5d8c48f5617c (diff) | |
| parent | 89a19f57f8d094826bf68641c4be76a77a7cddcf (diff) | |
| download | rust-908c17bfa6a55fc78bb9255e02bd53eebf0386dd.tar.gz rust-908c17bfa6a55fc78bb9255e02bd53eebf0386dd.zip | |
Merge #11595
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>
| -rw-r--r-- | crates/hir_def/src/body/lower.rs | 5 | ||||
| -rw-r--r-- | crates/ide/src/hover/tests.rs | 21 |
2 files changed, 25 insertions, 1 deletions
diff --git a/crates/hir_def/src/body/lower.rs b/crates/hir_def/src/body/lower.rs index 46b2ba8a254..a2b57cb5bdf 100644 --- a/crates/hir_def/src/body/lower.rs +++ b/crates/hir_def/src/body/lower.rs @@ -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()), diff --git a/crates/ide/src/hover/tests.rs b/crates/ide/src/hover/tests.rs index ab10bc6ef5c..9d516fdd6fc 100644 --- a/crates/ide/src/hover/tests.rs +++ b/crates/ide/src/hover/tests.rs @@ -3511,6 +3511,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 + "#]], + ); } #[test] |
