Skip to content

Commit 22a0801

Browse files
committed
Auto merge of rust-lang#17064 - Veykril:inlay-hints-fix, r=Veykril
minor: Carry inlay hint resolve hash as a string
2 parents aaaadf3 + a851cd5 commit 22a0801

File tree

4 files changed

+11
-13
lines changed

4 files changed

+11
-13
lines changed

src/tools/rust-analyzer/crates/rust-analyzer/src/handlers/request.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1504,12 +1504,9 @@ pub(crate) fn handle_inlay_hints_resolve(
15041504
) -> anyhow::Result<InlayHint> {
15051505
let _p = tracing::span!(tracing::Level::INFO, "handle_inlay_hints_resolve").entered();
15061506

1507-
let data = match original_hint.data.take() {
1508-
Some(it) => it,
1509-
None => return Ok(original_hint),
1510-
};
1511-
1507+
let Some(data) = original_hint.data.take() else { return Ok(original_hint) };
15121508
let resolve_data: lsp_ext::InlayHintResolveData = serde_json::from_value(data)?;
1509+
let Some(hash) = resolve_data.hash.parse().ok() else { return Ok(original_hint) };
15131510
let file_id = FileId::from_raw(resolve_data.file_id);
15141511
anyhow::ensure!(snap.file_exists(file_id), "Invalid LSP resolve data");
15151512

@@ -1521,14 +1518,12 @@ pub(crate) fn handle_inlay_hints_resolve(
15211518
&forced_resolve_inlay_hints_config,
15221519
file_id,
15231520
hint_position,
1524-
resolve_data.hash,
1521+
hash,
15251522
|hint| {
15261523
std::hash::BuildHasher::hash_one(
15271524
&std::hash::BuildHasherDefault::<ide_db::FxHasher>::default(),
15281525
hint,
15291526
)
1530-
// json only supports numbers up to 2^53 - 1 as integers, so mask the rest
1531-
& ((1 << 53) - 1)
15321527
},
15331528
)?;
15341529

src/tools/rust-analyzer/crates/rust-analyzer/src/lsp/ext.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,8 @@ pub struct CompletionResolveData {
794794
#[derive(Debug, Serialize, Deserialize)]
795795
pub struct InlayHintResolveData {
796796
pub file_id: u32,
797-
pub hash: u64,
797+
// This is a string instead of a u64 as javascript can't represent u64 fully
798+
pub hash: String,
798799
}
799800

800801
#[derive(Debug, Serialize, Deserialize)]

src/tools/rust-analyzer/crates/rust-analyzer/src/lsp/to_proto.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -453,8 +453,6 @@ pub(crate) fn inlay_hint(
453453
&std::hash::BuildHasherDefault::<FxHasher>::default(),
454454
&inlay_hint,
455455
)
456-
// json only supports numbers up to 2^53 - 1 as integers, so mask the rest
457-
& ((1 << 53) - 1)
458456
});
459457

460458
let mut something_to_resolve = false;
@@ -481,7 +479,11 @@ pub(crate) fn inlay_hint(
481479

482480
let data = match resolve_hash {
483481
Some(hash) if something_to_resolve => Some(
484-
to_value(lsp_ext::InlayHintResolveData { file_id: file_id.index(), hash }).unwrap(),
482+
to_value(lsp_ext::InlayHintResolveData {
483+
file_id: file_id.index(),
484+
hash: hash.to_string(),
485+
})
486+
.unwrap(),
485487
),
486488
_ => None,
487489
};

src/tools/rust-analyzer/docs/dev/lsp-extensions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!---
2-
lsp/ext.rs hash: 4aacf4cca1c9ff5e
2+
lsp/ext.rs hash: dd51139b0530147e
33
44
If you need to change the above hash to make the test pass, please check if you
55
need to adjust this doc as well and ping this issue:

0 commit comments

Comments
 (0)