Merge pull request #20392 from rust-lang/veykril/push-pxplxplxvvyy

Report the incorrect payload when failing to deserialize lsp messages
This commit is contained in:
Lukas Wirth 2025-08-06 15:42:24 +00:00 committed by GitHub
commit 23504e1675
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 8 additions and 4 deletions

View file

@ -228,9 +228,9 @@ fn hints(
chaining::hints(hints, famous_defs, config, display_target, &expr);
adjustment::hints(hints, famous_defs, config, display_target, &expr);
match expr {
ast::Expr::CallExpr(it) => param_name::hints(hints, famous_defs, config, ast::Expr::from(it)),
ast::Expr::CallExpr(it) => param_name::hints(hints, famous_defs, config, file_id, ast::Expr::from(it)),
ast::Expr::MethodCallExpr(it) => {
param_name::hints(hints, famous_defs, config, ast::Expr::from(it))
param_name::hints(hints, famous_defs, config, file_id, ast::Expr::from(it))
}
ast::Expr::ClosureExpr(it) => {
closure_captures::hints(hints, famous_defs, config, it.clone());

View file

@ -7,7 +7,7 @@
use std::iter::zip;
use either::Either;
use hir::Semantics;
use hir::{EditionedFileId, Semantics};
use ide_db::{RootDatabase, famous_defs::FamousDefs};
use stdx::to_lower_snake_case;
@ -19,6 +19,7 @@ pub(super) fn hints(
acc: &mut Vec<InlayHint>,
FamousDefs(sema, krate): &FamousDefs<'_, '_>,
config: &InlayHintsConfig,
file_id: EditionedFileId,
expr: ast::Expr,
) -> Option<()> {
if !config.parameter_hints {
@ -39,6 +40,9 @@ pub(super) fn hints(
.filter_map(|(p, arg)| {
// Only annotate hints for expressions that exist in the original file
let range = sema.original_range_opt(arg.syntax())?;
if range.file_id != file_id {
return None;
}
let param_name = p.name(sema.db)?;
Some((p, param_name, arg, range))
})

View file

@ -175,7 +175,7 @@ impl Message {
let msg = match serde_json::from_str(&text) {
Ok(msg) => msg,
Err(e) => {
return Err(invalid_data!("malformed LSP payload: {:?}", e));
return Err(invalid_data!("malformed LSP payload `{e:?}`: {text:?}"));
}
};