mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-11-01 20:31:59 +00:00
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:
commit
23504e1675
3 changed files with 8 additions and 4 deletions
|
|
@ -228,9 +228,9 @@ fn hints(
|
||||||
chaining::hints(hints, famous_defs, config, display_target, &expr);
|
chaining::hints(hints, famous_defs, config, display_target, &expr);
|
||||||
adjustment::hints(hints, famous_defs, config, display_target, &expr);
|
adjustment::hints(hints, famous_defs, config, display_target, &expr);
|
||||||
match 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) => {
|
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) => {
|
ast::Expr::ClosureExpr(it) => {
|
||||||
closure_captures::hints(hints, famous_defs, config, it.clone());
|
closure_captures::hints(hints, famous_defs, config, it.clone());
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
use std::iter::zip;
|
use std::iter::zip;
|
||||||
|
|
||||||
use either::Either;
|
use either::Either;
|
||||||
use hir::Semantics;
|
use hir::{EditionedFileId, Semantics};
|
||||||
use ide_db::{RootDatabase, famous_defs::FamousDefs};
|
use ide_db::{RootDatabase, famous_defs::FamousDefs};
|
||||||
|
|
||||||
use stdx::to_lower_snake_case;
|
use stdx::to_lower_snake_case;
|
||||||
|
|
@ -19,6 +19,7 @@ pub(super) fn hints(
|
||||||
acc: &mut Vec<InlayHint>,
|
acc: &mut Vec<InlayHint>,
|
||||||
FamousDefs(sema, krate): &FamousDefs<'_, '_>,
|
FamousDefs(sema, krate): &FamousDefs<'_, '_>,
|
||||||
config: &InlayHintsConfig,
|
config: &InlayHintsConfig,
|
||||||
|
file_id: EditionedFileId,
|
||||||
expr: ast::Expr,
|
expr: ast::Expr,
|
||||||
) -> Option<()> {
|
) -> Option<()> {
|
||||||
if !config.parameter_hints {
|
if !config.parameter_hints {
|
||||||
|
|
@ -39,6 +40,9 @@ pub(super) fn hints(
|
||||||
.filter_map(|(p, arg)| {
|
.filter_map(|(p, arg)| {
|
||||||
// Only annotate hints for expressions that exist in the original file
|
// Only annotate hints for expressions that exist in the original file
|
||||||
let range = sema.original_range_opt(arg.syntax())?;
|
let range = sema.original_range_opt(arg.syntax())?;
|
||||||
|
if range.file_id != file_id {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
let param_name = p.name(sema.db)?;
|
let param_name = p.name(sema.db)?;
|
||||||
Some((p, param_name, arg, range))
|
Some((p, param_name, arg, range))
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -175,7 +175,7 @@ impl Message {
|
||||||
let msg = match serde_json::from_str(&text) {
|
let msg = match serde_json::from_str(&text) {
|
||||||
Ok(msg) => msg,
|
Ok(msg) => msg,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
return Err(invalid_data!("malformed LSP payload: {:?}", e));
|
return Err(invalid_data!("malformed LSP payload `{e:?}`: {text:?}"));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue