Skip to content

rustfmt on save takes unusually long #4054

Closed
@Aloso

Description

@Aloso

When I open a project in VS Code, modify a file and save, it takes several seconds to format the file:

Screenshot_20200420_150535

Invoking cargo fmt manually only takes a few milliseconds.

The bug only appears when saving a file shortly after opening VS Code, while rust-analyzer is still busy analyzing the project (which takes ~2-3 min for my project).

EDIT:

The trace contains these lines:

[Trace - 15:58:29] Sending request 'textDocument/formatting - (25)'.
[Trace - 15:58:33] Received response 'textDocument/formatting - (25)' in 3912ms.
Click to see trace
[Trace - 15:58:24] Sending request 'initialize - (0)'.
[Trace - 15:58:24] Received response 'initialize - (0)' in 42ms.
[Trace - 15:58:24] Sending notification 'initialized'.
[Trace - 15:58:24] Sending notification 'textDocument/didOpen'.
[Trace - 15:58:24] Sending request 'rust-analyzer/inlayHints - (1)'.
[Trace - 15:58:25] Sending request 'textDocument/documentSymbol - (2)'.
[Trace - 15:58:25] Sending notification '$/cancelRequest'.
[Trace - 15:58:25] Sending request 'rust-analyzer/inlayHints - (3)'.
[Trace - 15:58:25] Received request 'client/registerCapability - (1)'.
[Trace - 15:58:25] Sending response 'client/registerCapability - (1)'. Processing request took 1ms
[Trace - 15:58:25] Received request 'window/workDoneProgress/create - (2)'.
[Trace - 15:58:25] Sending response 'window/workDoneProgress/create - (2)'. Processing request took 0ms
[Trace - 15:58:25] Received notification '$/progress'.
[Trace - 15:58:25] Received response 'rust-analyzer/inlayHints - (1)' in 192ms. Request failed: content modified (-32801).
[Trace - 15:58:25] Received response 'textDocument/documentSymbol - (2)' in 104ms. Request failed: content modified (-32801).
[Trace - 15:58:25] Sending request 'rust-analyzer/inlayHints - (4)'.
[Trace - 15:58:25] Received notification '$/progress'.
[Trace - 15:58:25] Received notification '$/progress'.
[Trace - 15:58:25] Received notification '$/progress'.
[Trace - 15:58:25] Received notification '$/progress'.
[Trace - 15:58:25] Received response 'rust-analyzer/inlayHints - (4)' in 4ms. Request failed: content modified (-32801).
[Trace - 15:58:25] Received response 'rust-analyzer/inlayHints - (3)' in 132ms. Request failed: content modified (-32801).
[Trace - 15:58:25] Received notification 'textDocument/publishDiagnostics'.
[Trace - 15:58:25] Sending request 'rust-analyzer/inlayHints - (5)'.
[Trace - 15:58:25] Received response 'rust-analyzer/inlayHints - (5)' in 3ms.
[Trace - 15:58:25] Sending request 'textDocument/semanticTokens/range - (6)'.
[Trace - 15:58:25] Received response 'textDocument/semanticTokens/range - (6)' in 4ms.
[Trace - 15:58:25] Sending request 'rust-analyzer/inlayHints - (7)'.
[Trace - 15:58:25] Received response 'rust-analyzer/inlayHints - (7)' in 1ms.
[Trace - 15:58:25] Sending request 'textDocument/foldingRange - (8)'.
[Trace - 15:58:25] Sending request 'textDocument/codeLens - (9)'.
[Trace - 15:58:25] Received response 'textDocument/foldingRange - (8)' in 2ms.
[Trace - 15:58:25] Received response 'textDocument/codeLens - (9)' in 3ms.
[Trace - 15:58:25] Received notification '$/progress'.
[Trace - 15:58:25] Sending request 'textDocument/semanticTokens - (10)'.
[Trace - 15:58:25] Received response 'textDocument/semanticTokens - (10)' in 8ms.
[Trace - 15:58:25] Sending request 'rust-analyzer/onEnter - (11)'.
[Trace - 15:58:25] Received response 'rust-analyzer/onEnter - (11)' in 2ms.
[Trace - 15:58:25] Sending notification 'textDocument/didChange'.
[Trace - 15:58:25] Sending request 'rust-analyzer/inlayHints - (12)'.
[Trace - 15:58:25] Received response 'rust-analyzer/inlayHints - (12)' in 11ms.
[Trace - 15:58:25] Received notification 'textDocument/publishDiagnostics'.
[Trace - 15:58:25] Sending request 'rust-analyzer/onEnter - (13)'.
[Trace - 15:58:25] Received response 'rust-analyzer/onEnter - (13)' in 1ms.
[Trace - 15:58:25] Sending notification 'textDocument/didChange'.
[Trace - 15:58:25] Sending request 'rust-analyzer/inlayHints - (14)'.
[Trace - 15:58:25] Received notification 'textDocument/publishDiagnostics'.
[Trace - 15:58:25] Received response 'rust-analyzer/inlayHints - (14)' in 23ms.
[Trace - 15:58:26] Sending request 'textDocument/semanticTokens - (15)'.
[Trace - 15:58:26] Received response 'textDocument/semanticTokens - (15)' in 4ms.
[Trace - 15:58:26] Sending request 'textDocument/foldingRange - (16)'.
[Trace - 15:58:26] Sending request 'rust-analyzer/onEnter - (17)'.
[Trace - 15:58:26] Received response 'rust-analyzer/onEnter - (17)' in 1ms.
[Trace - 15:58:26] Received response 'textDocument/foldingRange - (16)' in 2ms.
[Trace - 15:58:26] Sending notification 'textDocument/didChange'.
[Trace - 15:58:26] Sending request 'rust-analyzer/inlayHints - (18)'.
[Trace - 15:58:26] Received response 'rust-analyzer/inlayHints - (18)' in 9ms.
[Trace - 15:58:26] Received notification 'textDocument/publishDiagnostics'.
[Trace - 15:58:26] Sending request 'rust-analyzer/onEnter - (19)'.
[Trace - 15:58:26] Received response 'rust-analyzer/onEnter - (19)' in 1ms.
[Trace - 15:58:26] Sending notification 'textDocument/didChange'.
[Trace - 15:58:26] Sending request 'rust-analyzer/inlayHints - (20)'.
[Trace - 15:58:26] Received notification 'textDocument/publishDiagnostics'.
[Trace - 15:58:26] Received response 'rust-analyzer/inlayHints - (20)' in 8ms.
[Trace - 15:58:26] Sending request 'textDocument/semanticTokens - (21)'.
[Trace - 15:58:26] Received response 'textDocument/semanticTokens - (21)' in 12ms.
[Trace - 15:58:26] Sending request 'textDocument/foldingRange - (22)'.
[Trace - 15:58:26] Received response 'textDocument/foldingRange - (22)' in 1ms.
[Trace - 15:58:26] Sending request 'textDocument/codeLens - (23)'.
[Trace - 15:58:26] Received response 'textDocument/codeLens - (23)' in 9ms.
[Trace - 15:58:26] Sending request 'textDocument/documentSymbol - (24)'.
[Trace - 15:58:26] Received response 'textDocument/documentSymbol - (24)' in 2ms.
[Trace - 15:58:27] Received notification '$/progress'.
[Trace - 15:58:28] Received notification '$/progress'.
[Trace - 15:58:28] Received notification '$/progress'.
[Trace - 15:58:28] Received notification '$/progress'.
[Trace - 15:58:28] Received notification '$/progress'.
[Trace - 15:58:28] Received notification '$/progress'.
[Trace - 15:58:28] Received notification '$/progress'.
[Trace - 15:58:28] Received notification 'textDocument/publishDiagnostics'.
[Trace - 15:58:28] Received notification 'textDocument/publishDiagnostics'.
[Trace - 15:58:28] Received notification 'textDocument/publishDiagnostics'.
[Trace - 15:58:28] Received notification 'textDocument/publishDiagnostics'.
[Trace - 15:58:28] Received notification '$/progress'.
[Trace - 15:58:29] Sending request 'textDocument/formatting - (25)'.
[Trace - 15:58:33] Received response 'textDocument/formatting - (25)' in 3912ms.
[Trace - 15:58:33] Sending notification 'textDocument/didChange'.
[Trace - 15:58:33] Sending request 'rust-analyzer/inlayHints - (26)'.
[Trace - 15:58:33] Sending notification 'textDocument/didSave'.
[Trace - 15:58:33] Received notification 'textDocument/publishDiagnostics'.
[Trace - 15:58:33] Received notification '$/progress'.
[Trace - 15:58:34] Sending request 'textDocument/foldingRange - (27)'.
[Trace - 15:58:34] Received response 'textDocument/foldingRange - (27)' in 22ms.
[Trace - 15:58:34] Received notification 'textDocument/publishDiagnostics'.
[Trace - 15:58:34] Received notification 'textDocument/publishDiagnostics'.
[Trace - 15:58:34] Sending request 'textDocument/codeLens - (28)'.
[Trace - 15:58:34] Received response 'textDocument/codeLens - (28)' in 3ms.
[Trace - 15:58:34] Sending request 'textDocument/semanticTokens - (29)'.
[Trace - 15:58:34] Received notification 'textDocument/publishDiagnostics'.
[Trace - 15:58:34] Received notification 'textDocument/publishDiagnostics'.
[Trace - 15:58:34] Received notification '$/progress'.
[Trace - 15:58:34] Sending request 'textDocument/documentSymbol - (30)'.
[Trace - 15:58:34] Sending notification 'workspace/didChangeWatchedFiles'.
[Trace - 15:58:34] Received response 'textDocument/documentSymbol - (30)' in 2ms.
[Trace - 15:58:34] Received notification '$/progress'.
[Trace - 15:58:34] Received notification '$/progress'.
[Trace - 15:58:42] Received response 'rust-analyzer/inlayHints - (26)' in 8571ms.
[Trace - 15:58:42] Received notification 'textDocument/publishDiagnostics'.
[Trace - 15:58:42] Received response 'textDocument/semanticTokens - (29)' in 8373ms.

Metadata

Metadata

Assignees

No one assigned

    Labels

    S-unactionableIssue requires feedback, design decisions or is blocked on other work

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions