Skip to content

fix!: make lsp-server Response type closer aligned to JSON-RPC#22753

Merged
Veykril merged 1 commit into
rust-lang:masterfrom
ribru17:response_typing
Jul 11, 2026
Merged

fix!: make lsp-server Response type closer aligned to JSON-RPC#22753
Veykril merged 1 commit into
rust-lang:masterfrom
ribru17:response_typing

Conversation

@ribru17

@ribru17 ribru17 commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

From the JSON-RPC 2.0 protocol:

result
This member is REQUIRED on success.
This member MUST NOT exist if there was an error invoking the method.
The value of this member is determined by the method invoked on the Server.
error
This member is REQUIRED on error.
This member MUST NOT exist if there was no error triggered during invocation.
The value for this member MUST be an Object as defined in section 5.1.

...

Either the result member or error member MUST be included, but both members MUST NOT be included.

The current typing of the Response object allows both the result and error members to be present, or for neither to be present. This commit strengthens the typing of the response to prevent these cases from being expressed. This is a breaking change.

The response kind definition is borrowed from the
tower-lsp definition.

From [the JSON-RPC 2.0 protocol](https://www.jsonrpc.org/specification#response_object):

> result
>  This member is REQUIRED on success.
>  This member MUST NOT exist if there was an error invoking the method.
>  The value of this member is determined by the method invoked on the Server.
> error
>  This member is REQUIRED on error.
>  This member MUST NOT exist if there was no error triggered during invocation.
>  The value for this member MUST be an Object as defined in section 5.1.
>
> ...
>
> Either the result member or error member MUST be included, but both members MUST NOT be included.

The current typing of the `Response` object allows both the `result` and
`error` members to be present, or for neither to be present. This commit
strengthens the typing of the response to prevent these cases from being
expressed. This is a breaking change.

The response kind definition is borrowed from the
[tower-lsp](https://github.com/ebkalderon/tower-lsp) definition.
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 10, 2026
@Veykril
Veykril added this pull request to the merge queue Jul 11, 2026
@Veykril

Veykril commented Jul 11, 2026

Copy link
Copy Markdown
Member

Thanks!

Merged via the queue into rust-lang:master with commit b7f5154 Jul 11, 2026
18 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 11, 2026
@ribru17
ribru17 deleted the response_typing branch July 11, 2026 14:49
@ChayimFriedman2

Copy link
Copy Markdown
Contributor

Shouldn't we, then, just use Result?

@ribru17

ribru17 commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

Good point- I'll draft a PR

ribru17 added a commit to ribru17/rust-analyzer that referenced this pull request Jul 14, 2026
We don't need a new type here thanks to serde's `remote`. This is a
follow-up to
rust-lang#22753 (comment).
ribru17 added a commit to ribru17/rust-analyzer that referenced this pull request Jul 16, 2026
We don't need a new type here thanks to serde's `remote`. This is a
follow-up to
rust-lang#22753 (comment).
lnicola pushed a commit to lnicola/rust that referenced this pull request Jul 20, 2026
We don't need a new type here thanks to serde's `remote`. This is a
follow-up to
rust-lang/rust-analyzer#22753 (comment).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants