Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vscode freezes when trying to apply clippy suggestion #1713

Closed
matthiaskrgr opened this issue Aug 21, 2019 · 19 comments
Closed

vscode freezes when trying to apply clippy suggestion #1713

matthiaskrgr opened this issue Aug 21, 2019 · 19 comments

Comments

@matthiaskrgr
Copy link
Member

matthiaskrgr commented Aug 21, 2019

code

fn main() {
    let x = 1;
    let b = 3;

    if x == b {
        if b == x {
            println!("y");
        }
    }
}

when trying to apply the clippy::collapsible_if fix hint via the rla plugin, vscode freezes with 100% cpu load.

rla @ 5fd9a5b
code

1.37.1
f06011ac164ae4dc8e753a3fe7f9549844d15e35
x64
@kiljacken
Copy link
Contributor

@matthiaskrgr Are you still encountering this issue on the latest rust-analyzer?

@matthiaskrgr
Copy link
Member Author

Right now vscode only freezes for around 10 seconds before applying the suggestion

@kiljacken
Copy link
Contributor

kiljacken commented Jan 13, 2020

Could you try settings the env variable RA_PROFILE=*, launch VSCode, apply the suggestion and then share the Rust Analyzer Language Server output from the output tab at the bottom of VSCode?

@matthiaskrgr
Copy link
Member Author

The "Ouput" where it also says "Problems", "Debug Console" and "Terminal"? I couldn't get anything to show up there. :/
I tried

export RA_PROFILE=*
code .  --log debug

@kiljacken
Copy link
Contributor

Yeah, that one. It has a drop-down out in the right side where you should be able to select Rust Analyzer Language Server

@matthiaskrgr
Copy link
Member Author

I can see

    3ms - handle_inlay_hints
        2ms - get_inlay_hints
            2ms - SourceAnalyzer::new
                1ms - body_with_source_map_query
                    0ms - crate_def_map (4 calls)
                    0ms - parse_macro_query (1 calls)
                0ms - crate_def_map (1 calls)
                0ms - def_with_body_from_child_node (1 calls)
                0ms - infer (1 calls)
        0ms - get_inlay_hints (35 calls)
    1ms - publish_decorations
        1ms - highlight
            1ms - classify_name_ref
                1ms - SourceAnalyzer::new
                    0ms - crate_def_map (1 calls)
                    0ms - def_with_body_from_child_node (1 calls)
                    0ms - infer (1 calls)
                    1ms - ???
                0ms - Module::from_definition (1 calls)
                0ms - crate_def_map (2 calls)
            0ms - classify_name (3 calls)
            0ms - crate_def_map (3 calls)
            0ms - infer (3 calls)
    1ms - handle_code_action
        0ms - diagnostics (1 calls)
    2ms - publish_diagnostics
        2ms - diagnostics
            1ms - Module::diagnostics
                1ms - Function::diagnostics
                    1ms - infer
                        1ms - body_with_source_map_query
                            0ms - crate_def_map (4 calls)
                            0ms - parse_macro_query (1 calls)
                        0ms - do_infer (1 calls)
                0ms - crate_def_map (3 calls)
            0ms - Module::from_definition (1 calls)
            0ms - parse_query (1 calls)
    2ms - handle_inlay_hints
        1ms - get_inlay_hints
            1ms - SourceAnalyzer::new
                0ms - crate_def_map (1 calls)
                0ms - def_with_body_from_child_node (1 calls)
                0ms - infer (1 calls)
                1ms - ???
        0ms - get_inlay_hints (34 calls)
    2ms - handle_code_action
        0ms - diagnostics (1 calls)
        2ms - ???
    9ms - handle_formatting
        0ms - Module::from_definition (1 calls)
        9ms - ???
    2ms - handle_code_action
        0ms - diagnostics (1 calls)
        2ms - ???
    1ms - handle_hover
        0ms - SourceAnalyzer::new (2 calls)

but that's from before I tried to apply the clippy suggestion and applying the suggestion does not add any additional output, hmm...

I found this though:

ExtensionService#_doActivateExtension matklad.rust-analyzer {"startup":true,"extensionId":{"value":"matklad.rust-analyzer","_lower":"matklad.rust-analyzer"},"activationEvent":"workspaceContains:**/Cargo.toml"}
[2020-01-13 17:18:35.210] [exthost] [info] ExtensionService#loadCommonJSModule file:///home/matthias/.vscode/extensions/matklad.rust-analyzer-0.1.0/out/main
[2020-01-13 17:18:35.622] [exthost] [info] eager extensions activated
[2020-01-13 17:20:26.698] [exthost] [warning] matklad.rust-analyzer - Code actions of kind 'quickfix 'requested but returned code action is of kind 'refactor.extract.variable'. Code action will be dropped. Please check 'CodeActionContext.only' to only return requested code actions.
[2020-01-13 17:20:26.698] [exthost] [warning] matklad.rust-analyzer - Code actions of kind 'quickfix 'requested but returned code action does not have a 'kind'. Code action will be dropped. Please set 'CodeAction.kind'.

@kiljacken
Copy link
Contributor

Ahh, you are probably using a rust-analyzer from before #2668 which majorly changed how we do cargo check. Updating might fix your issue, but should at least make it easier to debug.

@matthiaskrgr
Copy link
Member Author

No, I'm updating ra almost daily.

ra_lsp_server --version
rust-analyzer 875352b

using cargo xtask install unless something changed about the installation procedure..?

@kiljacken
Copy link
Contributor

Ahh, it seems running with RA_PROFILE is a little more complicated than i thought, with regards to getting it to output the data. I will investigate further and return with a good way to diagnose the issue :)

@kiljacken
Copy link
Contributor

Okay, if you add RUST_LOG=ra_lsp_server=info as environment variable as well, you should get a boatload of output, if you could share that somewhere, it should point us in the right direction

@matthiaskrgr
Copy link
Member Author

output:

[2020-01-13T17:29:29Z INFO  ra_lsp_server] lifecycle: server started
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] server_config: ServerConfig {
        publish_decorations: true,
        exclude_globs: [],
        use_client_watching: true,
        lru_capacity: Some(
            20,
        ),
        max_inlay_hint_length: Some(
            20,
        ),
        cargo_watch_enable: true,
        cargo_watch_args: [],
        cargo_watch_command: "clippy",
        cargo_watch_all_targets: true,
        with_sysroot: true,
        feature_flags: {},
        cargo_features: CargoFeatures {
            no_default_features: false,
            all_features: false,
            features: [],
        },
    }
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] feature_flags: FeatureFlags {
        flags: {
            "lsp.diagnostics": true,
            "completion.insertion.add-call-parenthesis": true,
            "completion.enable-postfix": true,
            "notifications.workspace-loaded": true,
            "notifications.cargo-toml-not-found": true,
        },
    }
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] server initialized, serving requests
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] loop turn = VfsTask { ... }
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] loop turn = Notification { method: "textDocument/didOpen" }
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] queued count = 2
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] indexing SourceRootId(0) ... 
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] loop turn = VfsTask { ... }
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] queued count = 1
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] loop turn = VfsTask { ... }
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] queued count = 2
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] indexing SourceRootId(1) ... 
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] loop turn = Response(Response { id: RequestId(U64(1)), result: None, error: None })
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] queued count = 2
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] loop turn = VfsTask { ... }
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] queued count = 2
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] indexing SourceRootId(2) ... 
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] loop turn = VfsTask { ... }
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] queued count = 2
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] indexing SourceRootId(3) ... 
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] loop turn = VfsTask { ... }
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] queued count = 2
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] indexing SourceRootId(4) ... 
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] loop turn = Request(Request { id: RequestId(U64(1)), method: "textDocument/documentSymbol", params: Object({"textDocument": Object({"uri": String("file:///tmp/ra_freeze/src/main.rs")})}) })
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] queued count = 1
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] loop turn = VfsTask { ... }
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] queued count = 2
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] loop turn = Response { id: RequestId(U64(1)), error: Some(ResponseError { code: -32801, message: "content modified", data: None }) }
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] queued count = 1
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] handled req#1 in 2.501788ms
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] loop turn = VfsTask { ... }
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] queued count = 1
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] loop turn = VfsTask { ... }
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] queued count = 1
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] loop turn = VfsTask { ... }
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] queued count = 1
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] loop turn = VfsTask { ... }
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] loop turn = LibraryData { root_id: SourceRootId(1), root_change: AnalysisChange { added: 1, removed: 0 }, n_symbols: 12 }
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] queued count = 1
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] loop turn = VfsTask { ... }
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] queued count = 1
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] loop turn = VfsTask { ... }
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] queued count = 2
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] indexing SourceRootId(10) ... 
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] loop turn = VfsTask { ... }
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] queued count = 1
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] loop turn = VfsTask { ... }
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] queued count = 1
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] loop turn = Notification { method: "textDocument/publishDiagnostics" }
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] loop turn = Request(Request { id: RequestId(U64(2)), method: "rust-analyzer/inlayHints", params: Object({"textDocument": Object({"uri": String("file:///tmp/ra_freeze/src/main.rs")})}) })
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] loop turn = Request(Request { id: RequestId(U64(3)), method: "textDocument/hover", params: Object({"position": Object({"character": Number(10), "line": Number(6)}), "textDocument": Object({"uri": String("file:///tmp/ra_freeze/src/main.rs")})}) })
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] loop turn = Notification { method: "rust-analyzer/publishDecorations" }
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] loop turn = Response { id: RequestId(U64(2)), error: None }
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] handled req#2 in 3.9082ms
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] loop turn = Response { id: RequestId(U64(3)), error: None }
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] handled req#3 in 632.261µs
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] loop turn = LibraryData { root_id: SourceRootId(3), root_change: AnalysisChange { added: 2, removed: 0 }, n_symbols: 1 }
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] indexing SourceRootId(13) ... 
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] loop turn = LibraryData { root_id: SourceRootId(4), root_change: AnalysisChange { added: 2, removed: 0 }, n_symbols: 1 }
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] indexing SourceRootId(12) ... 
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] loop turn = Notification(Notification { method: "$/cancelRequest", params: Object({"id": Number(2)}) })
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] loop turn = Request(Request { id: RequestId(U64(4)), method: "rust-analyzer/inlayHints", params: Object({"textDocument": Object({"uri": String("file:///tmp/ra_freeze/src/main.rs")})}) })
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] loop turn = Response { id: RequestId(U64(4)), error: None }
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] handled req#4 in 521.818µs
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] loop turn = Request(Request { id: RequestId(U64(5)), method: "textDocument/foldingRange", params: Object({"textDocument": Object({"uri": String("file:///tmp/ra_freeze/src/main.rs")})}) })
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] loop turn = Response { id: RequestId(U64(5)), error: None }
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] handled req#5 in 2.820604ms
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] loop turn = Request(Request { id: RequestId(U64(6)), method: "textDocument/codeLens", params: Object({"textDocument": Object({"uri": String("file:///tmp/ra_freeze/src/main.rs")})}) })
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] loop turn = Response { id: RequestId(U64(6)), error: None }
[2020-01-13T17:29:29Z INFO  ra_lsp_server::main_loop] handled req#6 in 346.863µs
[2020-01-13T17:29:30Z INFO  ra_lsp_server::main_loop] loop turn = Request(Request { id: RequestId(U64(7)), method: "textDocument/hover", params: Object({"position": Object({"character": Number(12), "line": Number(5)}), "textDocument": Object({"uri": String("file:///tmp/ra_freeze/src/main.rs")})}) })
[2020-01-13T17:29:30Z INFO  ra_lsp_server::main_loop] loop turn = Response { id: RequestId(U64(7)), error: None }
[2020-01-13T17:29:30Z INFO  ra_lsp_server::main_loop] handled req#7 in 699.984µs
[2020-01-13T17:29:30Z INFO  ra_lsp_server::main_loop] loop turn = LibraryData { root_id: SourceRootId(12), root_change: AnalysisChange { added: 22, removed: 0 }, n_symbols: 343 }
[2020-01-13T17:29:30Z INFO  ra_lsp_server::main_loop] indexing SourceRootId(11) ... 
[2020-01-13T17:29:30Z INFO  ra_lsp_server::main_loop] loop turn = LibraryData { root_id: SourceRootId(11), root_change: AnalysisChange { added: 9, removed: 0 }, n_symbols: 131 }
[2020-01-13T17:29:30Z INFO  ra_lsp_server::main_loop] indexing SourceRootId(9) ... 
[2020-01-13T17:29:30Z INFO  ra_lsp_server::main_loop] loop turn = LibraryData { root_id: SourceRootId(13), root_change: AnalysisChange { added: 364, removed: 0 }, n_symbols: 9977 }
[2020-01-13T17:29:30Z INFO  ra_lsp_server::main_loop] indexing SourceRootId(8) ... 
[2020-01-13T17:29:30Z INFO  ra_lsp_server::main_loop] loop turn = LibraryData { root_id: SourceRootId(2), root_change: AnalysisChange { added: 11, removed: 0 }, n_symbols: 280 }
[2020-01-13T17:29:30Z INFO  ra_lsp_server::main_loop] indexing SourceRootId(7) ... 
[2020-01-13T17:29:30Z INFO  ra_lsp_server::main_loop] loop turn = LibraryData { root_id: SourceRootId(0), root_change: AnalysisChange { added: 9, removed: 0 }, n_symbols: 98 }
[2020-01-13T17:29:30Z INFO  ra_lsp_server::main_loop] indexing SourceRootId(6) ... 
[2020-01-13T17:29:30Z INFO  ra_lsp_server::main_loop] loop turn = LibraryData { root_id: SourceRootId(8), root_change: AnalysisChange { added: 3, removed: 0 }, n_symbols: 30 }
[2020-01-13T17:29:30Z INFO  ra_lsp_server::main_loop] indexing SourceRootId(5) ... 
[2020-01-13T17:29:30Z INFO  ra_lsp_server::main_loop] loop turn = LibraryData { root_id: SourceRootId(6), root_change: AnalysisChange { added: 2, removed: 0 }, n_symbols: 1 }
[2020-01-13T17:29:30Z INFO  ra_lsp_server::main_loop] loop turn = LibraryData { root_id: SourceRootId(10), root_change: AnalysisChange { added: 125, removed: 0 }, n_symbols: 3448 }
[2020-01-13T17:29:30Z INFO  ra_lsp_server::main_loop] loop turn = LibraryData { root_id: SourceRootId(5), root_change: AnalysisChange { added: 2, removed: 0 }, n_symbols: 1 }
[2020-01-13T17:29:30Z INFO  ra_lsp_server::main_loop] loop turn = LibraryData { root_id: SourceRootId(9), root_change: AnalysisChange { added: 31, removed: 0 }, n_symbols: 1622 }
[2020-01-13T17:29:30Z INFO  ra_lsp_server::main_loop] loop turn = LibraryData { root_id: SourceRootId(7), root_change: AnalysisChange { added: 31, removed: 0 }, n_symbols: 1098 }
[2020-01-13T17:29:30Z INFO  ra_lsp_server::main_loop] loop turn = Status(Begin(WorkDoneProgressBegin { title: "Running \'cargo check\'", cancellable: Some(false), message: None, percentage: None }))
[2020-01-13T17:29:30Z INFO  ra_lsp_server::main_loop] loop turn = Notify(Notification { method: "$/progress", params: Object({"token": String("rustAnalyzer/cargoWatcher"), "value": Object({"cancellable": Bool(false), "kind": String("begin"), "title": String("Running \'cargo check\'")})}) })
[2020-01-13T17:29:30Z INFO  ra_lsp_server::main_loop] loop turn = Update("file:///tmp/ra_freeze/src/main.rs")
[2020-01-13T17:29:38Z INFO  ra_lsp_server::main_loop] loop turn = Notification { method: "textDocument/publishDiagnostics" }
[2020-01-13T17:29:38Z INFO  ra_lsp_server::main_loop] loop turn = Update("file:///tmp/ra_freeze/src/main.rs")
[2020-01-13T17:29:38Z INFO  ra_lsp_server::main_loop] loop turn = Status(Report(WorkDoneProgressReport { cancellable: Some(false), message: Some("ra_freeze"), percentage: None }))
[2020-01-13T17:29:38Z INFO  ra_lsp_server::main_loop] loop turn = Request(Request { id: RequestId(U64(8)), method: "textDocument/codeAction", params: Object({"context": Object({"diagnostics": Array([])}), "range": Object({"end": Object({"character": Number(13), "line": Number(5)}), "start": Object({"character": Number(13), "line": Number(5)})}), "textDocument": Object({"uri": String("file:///tmp/ra_freeze/src/main.rs")})}) })
[2020-01-13T17:29:38Z INFO  ra_lsp_server::main_loop] loop turn = Update("file:///tmp/ra_freeze/src/main.rs")
[2020-01-13T17:29:38Z INFO  ra_lsp_server::main_loop] queued count = 1
[2020-01-13T17:29:38Z INFO  ra_lsp_server::main_loop] loop turn = Notification { method: "textDocument/publishDiagnostics" }
[2020-01-13T17:29:38Z INFO  ra_lsp_server::main_loop] loop turn = Update("file:///tmp/ra_freeze/src/main.rs")
[2020-01-13T17:29:38Z INFO  ra_lsp_server::main_loop] loop turn = Notify(Notification { method: "$/progress", params: Object({"token": String("rustAnalyzer/cargoWatcher"), "value": Object({"cancellable": Bool(false), "kind": String("report"), "message": String("ra_freeze")})}) })
[2020-01-13T17:29:38Z INFO  ra_lsp_server::main_loop] loop turn = Notification { method: "textDocument/publishDiagnostics" }
[2020-01-13T17:29:38Z INFO  ra_lsp_server::main_loop] loop turn = Notification { method: "textDocument/publishDiagnostics" }
[2020-01-13T17:29:38Z INFO  ra_lsp_server::main_loop] loop turn = Notification(Notification { method: "$/cancelRequest", params: Object({"id": Number(8)}) })
[2020-01-13T17:29:38Z INFO  ra_lsp_server::main_loop] loop turn = Status(Report(WorkDoneProgressReport { cancellable: Some(false), message: Some("ra_freeze"), percentage: None }))
[2020-01-13T17:29:38Z INFO  ra_lsp_server::main_loop] loop turn = Notify(Notification { method: "$/progress", params: Object({"token": String("rustAnalyzer/cargoWatcher"), "value": Object({"cancellable": Bool(false), "kind": String("report"), "message": String("ra_freeze")})}) })
[2020-01-13T17:29:38Z INFO  ra_lsp_server::main_loop] loop turn = Status(End(WorkDoneProgressEnd { message: None }))
[2020-01-13T17:29:38Z INFO  ra_lsp_server::main_loop] loop turn = Notify(Notification { method: "$/progress", params: Object({"token": String("rustAnalyzer/cargoWatcher"), "value": Object({"kind": String("end")})}) })
[2020-01-13T17:29:38Z INFO  ra_lsp_server::main_loop] loop turn = Response { id: RequestId(U64(8)), error: None }
[2020-01-13T17:29:39Z INFO  ra_lsp_server::main_loop] loop turn = Request(Request { id: RequestId(U64(9)), method: "textDocument/hover", params: Object({"position": Object({"character": Number(14), "line": Number(5)}), "textDocument": Object({"uri": String("file:///tmp/ra_freeze/src/main.rs")})}) })
[2020-01-13T17:29:39Z INFO  ra_lsp_server::main_loop] loop turn = Response { id: RequestId(U64(9)), error: None }
[2020-01-13T17:29:39Z INFO  ra_lsp_server::main_loop] handled req#9 in 1.275057ms
[2020-01-13T17:29:40Z INFO  ra_lsp_server::main_loop] loop turn = Request(Request { id: RequestId(U64(10)), method: "textDocument/codeAction", params: Object({"context": Object({"diagnostics": Array([Object({"code": String("collapsible_if"), "message": String("this if statement can be collapsed\n`#[warn(clippy::collapsible_if)]` on by default\nfor further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if"), "range": Object({"end": Object({"character": Number(5), "line": Number(8)}), "start": Object({"character": Number(4), "line": Number(4)})}), "severity": Number(2), "source": String("clippy")})]), "only": Array([String("quickfix")])}), "range": Object({"end": Object({"character": Number(5), "line": Number(8)}), "start": Object({"character": Number(4), "line": Number(4)})}), "textDocument": Object({"uri": String("file:///tmp/ra_freeze/src/main.rs")})}) })
[2020-01-13T17:29:40Z INFO  ra_lsp_server::main_loop] loop turn = Response { id: RequestId(U64(10)), error: None }
[2020-01-13T17:29:40Z INFO  ra_lsp_server::main_loop] handled req#10 in 4.406381ms
[2020-01-13T17:29:40Z INFO  ra_lsp_server::main_loop] loop turn = Request(Request { id: RequestId(U64(11)), method: "textDocument/codeAction", params: Object({"context": Object({"diagnostics": Array([Object({"code": String("collapsible_if"), "message": String("this if statement can be collapsed\n`#[warn(clippy::collapsible_if)]` on by default\nfor further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if"), "range": Object({"end": Object({"character": Number(5), "line": Number(8)}), "start": Object({"character": Number(4), "line": Number(4)})}), "severity": Number(2), "source": String("clippy")})])}), "range": Object({"end": Object({"character": Number(14), "line": Number(5)}), "start": Object({"character": Number(14), "line": Number(5)})}), "textDocument": Object({"uri": String("file:///tmp/ra_freeze/src/main.rs")})}) })
[2020-01-13T17:29:40Z INFO  ra_lsp_server::main_loop] loop turn = Response { id: RequestId(U64(11)), error: None }
[2020-01-13T17:29:40Z INFO  ra_lsp_server::main_loop] handled req#11 in 2.703445ms
[2020-01-13T17:29:43Z INFO  ra_lsp_server::main_loop] loop turn = Request(Request { id: RequestId(U64(12)), method: "textDocument/hover", params: Object({"position": Object({"character": Number(15), "line": Number(5)}), "textDocument": Object({"uri": String("file:///tmp/ra_freeze/src/main.rs")})}) })
[2020-01-13T17:29:43Z INFO  ra_lsp_server::main_loop] loop turn = Response { id: RequestId(U64(12)), error: None }
[2020-01-13T17:29:43Z INFO  ra_lsp_server::main_loop] handled req#12 in 2.406033ms
[2020-01-13T17:29:43Z INFO  ra_lsp_server::main_loop] loop turn = Request(Request { id: RequestId(U64(13)), method: "textDocument/codeAction", params: Object({"context": Object({"diagnostics": Array([Object({"code": String("collapsible_if"), "message": String("this if statement can be collapsed\n`#[warn(clippy::collapsible_if)]` on by default\nfor further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if"), "range": Object({"end": Object({"character": Number(5), "line": Number(8)}), "start": Object({"character": Number(4), "line": Number(4)})}), "severity": Number(2), "source": String("clippy")})]), "only": Array([String("quickfix")])}), "range": Object({"end": Object({"character": Number(5), "line": Number(8)}), "start": Object({"character": Number(4), "line": Number(4)})}), "textDocument": Object({"uri": String("file:///tmp/ra_freeze/src/main.rs")})}) })
[2020-01-13T17:29:43Z INFO  ra_lsp_server::main_loop] loop turn = Response { id: RequestId(U64(13)), error: None }
[2020-01-13T17:29:43Z INFO  ra_lsp_server::main_loop] handled req#13 in 4.015719ms
[2020-01-13T17:29:58Z INFO  ra_lsp_server::main_loop] loop turn = Notification { method: "textDocument/didChange" }
[2020-01-13T17:29:58Z INFO  ra_lsp_server::main_loop] loop turn = Notification { method: "textDocument/publishDiagnostics" }
[2020-01-13T17:29:58Z INFO  ra_lsp_server::main_loop] loop turn = Notification { method: "rust-analyzer/publishDecorations" }
[2020-01-13T17:29:58Z INFO  ra_lsp_server::main_loop] loop turn = Request(Request { id: RequestId(U64(14)), method: "rust-analyzer/inlayHints", params: Object({"textDocument": Object({"uri": String("file:///tmp/ra_freeze/src/main.rs")})}) })
[2020-01-13T17:29:58Z INFO  ra_lsp_server::main_loop] loop turn = Response { id: RequestId(U64(14)), error: None }
[2020-01-13T17:29:58Z INFO  ra_lsp_server::main_loop] handled req#14 in 233.257µs
[2020-01-13T17:29:58Z INFO  ra_lsp_server::main_loop] loop turn = Request(Request { id: RequestId(U64(15)), method: "textDocument/codeAction", params: Object({"context": Object({"diagnostics": Array([Object({"code": String("collapsible_if"), "message": String("this if statement can be collapsed\n`#[warn(clippy::collapsible_if)]` on by default\nfor further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if"), "range": Object({"end": Object({"character": Number(5), "line": Number(8)}), "start": Object({"character": Number(4), "line": Number(4)})}), "severity": Number(2), "source": String("clippy")})])}), "range": Object({"end": Object({"character": Number(1), "line": Number(6)}), "start": Object({"character": Number(1), "line": Number(6)})}), "textDocument": Object({"uri": String("file:///tmp/ra_freeze/src/main.rs")})}) })
[2020-01-13T17:29:58Z INFO  ra_lsp_server::main_loop] loop turn = Response { id: RequestId(U64(15)), error: None }
[2020-01-13T17:29:58Z INFO  ra_lsp_server::main_loop] handled req#15 in 651.979µs
[2020-01-13T17:29:58Z INFO  ra_lsp_server::main_loop] loop turn = Request(Request { id: RequestId(U64(16)), method: "textDocument/foldingRange", params: Object({"textDocument": Object({"uri": String("file:///tmp/ra_freeze/src/main.rs")})}) })
[2020-01-13T17:29:58Z INFO  ra_lsp_server::main_loop] loop turn = Response { id: RequestId(U64(16)), error: None }
[2020-01-13T17:29:58Z INFO  ra_lsp_server::main_loop] handled req#16 in 1.099644ms
[2020-01-13T17:29:58Z INFO  ra_lsp_server::main_loop] loop turn = Request(Request { id: RequestId(U64(17)), method: "textDocument/codeLens", params: Object({"textDocument": Object({"uri": String("file:///tmp/ra_freeze/src/main.rs")})}) })
[2020-01-13T17:29:58Z INFO  ra_lsp_server::main_loop] loop turn = Response { id: RequestId(U64(17)), error: None }
[2020-01-13T17:29:58Z INFO  ra_lsp_server::main_loop] handled req#17 in 670.387µs
[2020-01-13T17:29:58Z INFO  ra_lsp_server::main_loop] loop turn = Request(Request { id: RequestId(U64(18)), method: "textDocument/codeAction", params: Object({"context": Object({"diagnostics": Array([Object({"code": String("collapsible_if"), "message": String("this if statement can be collapsed\n`#[warn(clippy::collapsible_if)]` on by default\nfor further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if"), "range": Object({"end": Object({"character": Number(5), "line": Number(8)}), "start": Object({"character": Number(4), "line": Number(4)})}), "severity": Number(2), "source": String("clippy")})])}), "range": Object({"end": Object({"character": Number(1), "line": Number(6)}), "start": Object({"character": Number(1), "line": Number(6)})}), "textDocument": Object({"uri": String("file:///tmp/ra_freeze/src/main.rs")})}) })
[2020-01-13T17:29:58Z INFO  ra_lsp_server::main_loop] loop turn = Response { id: RequestId(U64(18)), error: None }
[2020-01-13T17:29:58Z INFO  ra_lsp_server::main_loop] handled req#18 in 1.227469ms
[2020-01-13T17:29:58Z INFO  ra_lsp_server::main_loop] loop turn = Request(Request { id: RequestId(U64(19)), method: "textDocument/documentSymbol", params: Object({"textDocument": Object({"uri": String("file:///tmp/ra_freeze/src/main.rs")})}) })
[2020-01-13T17:29:58Z INFO  ra_lsp_server::main_loop] loop turn = Response { id: RequestId(U64(19)), error: None }
[2020-01-13T17:29:58Z INFO  ra_lsp_server::main_loop] handled req#19 in 386.073µs
[2020-01-13T17:29:59Z INFO  ra_lsp_server::main_loop] loop turn = Notification(Notification { method: "textDocument/didSave", params: Object({"textDocument": Object({"uri": String("file:///tmp/ra_freeze/src/main.rs"), "version": Number(2)})}) })
[2020-01-13T17:29:59Z INFO  ra_lsp_server::main_loop] loop turn = Update("file:///tmp/ra_freeze/src/main.rs")
[2020-01-13T17:29:59Z INFO  ra_lsp_server::main_loop] loop turn = Notification { method: "textDocument/publishDiagnostics" }
[2020-01-13T17:29:59Z INFO  ra_lsp_server::main_loop] loop turn = Status(Begin(WorkDoneProgressBegin { title: "Running \'cargo check\'", cancellable: Some(false), message: None, percentage: None }))
[2020-01-13T17:29:59Z INFO  ra_lsp_server::main_loop] loop turn = Notify(Notification { method: "$/progress", params: Object({"token": String("rustAnalyzer/cargoWatcher"), "value": Object({"cancellable": Bool(false), "kind": String("begin"), "title": String("Running \'cargo check\'")})}) })
[2020-01-13T17:29:59Z INFO  ra_lsp_server::main_loop] loop turn = Notification(Notification { method: "workspace/didChangeWatchedFiles", params: Object({"changes": Array([Object({"type": Number(2), "uri": String("file:///tmp/ra_freeze/src/main.rs")})])}) })
[2020-01-13T17:29:59Z INFO  ra_lsp_server::main_loop] loop turn = VfsTask { ... }
[2020-01-13T17:29:59Z INFO  ra_lsp_server::main_loop] loop turn = Request(Request { id: RequestId(U64(20)), method: "textDocument/codeAction", params: Object({"context": Object({"diagnostics": Array([])}), "range": Object({"end": Object({"character": Number(1), "line": Number(6)}), "start": Object({"character": Number(1), "line": Number(6)})}), "textDocument": Object({"uri": String("file:///tmp/ra_freeze/src/main.rs")})}) })
[2020-01-13T17:29:59Z INFO  ra_lsp_server::main_loop] loop turn = Response { id: RequestId(U64(20)), error: None }
[2020-01-13T17:29:59Z INFO  ra_lsp_server::main_loop] handled req#20 in 1.073737ms
[2020-01-13T17:29:59Z INFO  ra_lsp_server::main_loop] loop turn = Update("file:///tmp/ra_freeze/src/main.rs")
[2020-01-13T17:29:59Z INFO  ra_lsp_server::main_loop] loop turn = Notification { method: "textDocument/publishDiagnostics" }
[2020-01-13T17:29:59Z INFO  ra_lsp_server::main_loop] loop turn = Update("file:///tmp/ra_freeze/src/main.rs")
[2020-01-13T17:29:59Z INFO  ra_lsp_server::main_loop] loop turn = Notification { method: "textDocument/publishDiagnostics" }
[2020-01-13T17:29:59Z INFO  ra_lsp_server::main_loop] loop turn = Status(Report(WorkDoneProgressReport { cancellable: Some(false), message: Some("ra_freeze"), percentage: None }))
[2020-01-13T17:29:59Z INFO  ra_lsp_server::main_loop] loop turn = Notify(Notification { method: "$/progress", params: Object({"token": String("rustAnalyzer/cargoWatcher"), "value": Object({"cancellable": Bool(false), "kind": String("report"), "message": String("ra_freeze")})}) })
[2020-01-13T17:29:59Z INFO  ra_lsp_server::main_loop] loop turn = Status(Report(WorkDoneProgressReport { cancellable: Some(false), message: Some("ra_freeze"), percentage: None }))
[2020-01-13T17:29:59Z INFO  ra_lsp_server::main_loop] loop turn = Notify(Notification { method: "$/progress", params: Object({"token": String("rustAnalyzer/cargoWatcher"), "value": Object({"cancellable": Bool(false), "kind": String("report"), "message": String("ra_freeze")})}) })
[2020-01-13T17:29:59Z INFO  ra_lsp_server::main_loop] loop turn = Status(End(WorkDoneProgressEnd { message: None }))
[2020-01-13T17:29:59Z INFO  ra_lsp_server::main_loop] loop turn = Notify(Notification { method: "$/progress", params: Object({"token": String("rustAnalyzer/cargoWatcher"), "value": Object({"kind": String("end")})}) })
[2020-01-13T17:29:59Z INFO  ra_lsp_server::main_loop] loop turn = Request(Request { id: RequestId(U64(21)), method: "textDocument/codeAction", params: Object({"context": Object({"diagnostics": Array([])}), "range": Object({"end": Object({"character": Number(1), "line": Number(6)}), "start": Object({"character": Number(1), "line": Number(6)})}), "textDocument": Object({"uri": String("file:///tmp/ra_freeze/src/main.rs")})}) })
[2020-01-13T17:29:59Z INFO  ra_lsp_server::main_loop] loop turn = Response { id: RequestId(U64(21)), error: None }
[2020-01-13T17:29:59Z INFO  ra_lsp_server::main_loop] handled req#21 in 3.397718ms

@kiljacken
Copy link
Contributor

[2020-01-13T17:29:40Z INFO ra_lsp_server::main_loop] loop turn = Request(Request { id: RequestId(U64(10)), method: "textDocument/codeAction", params: Object({"context": Object({"diagnostics": Array([Object({"code": String("collapsible_if"), "message": String("this if statement can be collapsed\n#[warn(clippy::collapsible_if)] on by default\nfor further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if"), "range": Object({"end": Object({"character": Number(5), "line": Number(8)}), "start": Object({"character": Number(4), "line": Number(4)})}), "severity": Number(2), "source": String("clippy")})]), "only": Array([String("quickfix")])}), "range": Object({"end": Object({"character": Number(5), "line": Number(8)}), "start": Object({"character": Number(4), "line": Number(4)})}), "textDocument": Object({"uri": String("file:///tmp/ra_freeze/src/main.rs")})}) })
[2020-01-13T17:29:40Z INFO ra_lsp_server::main_loop] loop turn = Response { id: RequestId(U64(10)), error: None }
[2020-01-13T17:29:40Z INFO ra_lsp_server::main_loop] handled req#10 in 4.406381ms

The codeAction seems to get run in 4.4ms which is around what I'd expect. I'm not really sure where to take it from here, as it seems like an issue with VSCode or your computer/OS. Maybe an issue on VSCode can bring more light on the issue?

@kjeremy
Copy link
Contributor

kjeremy commented Jan 13, 2020

Is this the "convert to guarded return" fix? I can't reproduce this on windows.

Are you still on vscode 1.37.1 or are you on the latest stable 1.41.1?

@kiljacken
Copy link
Contributor

@kjeremy You have to explicitly run clippy instead of check to get the diagnostic in question, not that the diagnostic itself should change much

@kjeremy
Copy link
Contributor

kjeremy commented Jan 13, 2020

Yeah I did that and get the diagnostic but do not have an option to apply the suggestion.

@matthiaskrgr
Copy link
Member Author

it's about the collapsible_if lint
https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if

@kjeremy
Copy link
Contributor

kjeremy commented Jan 14, 2020

@matthiaskrgr Yes but I never get the option to apply the hint (though it is highlighted in my editor).

@bjorn3
Copy link
Member

bjorn3 commented Jun 19, 2020

It works just fine for me. Clippy called the suggestion try though:

warning: this `if` statement can be collapsed
 --> src/main.rs:5:5
  |
5 | /     if x == b {
6 | |         if b == x {
7 | |             println!("y");
8 | |         }
9 | |     }
  | |_____^
  |
  = note: `#[warn(clippy::collapsible_if)]` on by default
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if
help: try
  |
5 |     if x == b && b == x {
6 |         println!("y");
7 |     }
  |

Edit: opened rust-lang/rust-clippy#5732

@matthiaskrgr
Copy link
Member Author

I could not notice any delay now, closing the issue.

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

No branches or pull requests

4 participants