Skip to content

server panicked on extract module action #11766

@CAD97

Description

@CAD97
Rust Analyzer Language Server output
Panic context:
> 
version: 6e13de648 2022-03-18 nightly
request: codeAction/resolve CodeAction {
    title: "Extract Module",
    group: None,
    kind: Some(
        CodeActionKind(
            "refactor.extract",
        ),
    ),
    edit: None,
    is_preferred: None,
    data: Some(
        CodeActionData {
            code_action_params: CodeActionParams {
                text_document: TextDocumentIdentifier {
                    uri: Url {
                        scheme: "file",
                        cannot_be_a_base: false,
                        username: "",
                        password: None,
                        host: None,
                        port: None,
                        path: "/d%3A/repos/cad97/tracing-filter/src/simple/mod.rs",
                        query: None,
                        fragment: None,
                    },
                },
                range: Range {
                    start: Position {
                        line: 39,
                        character: 0,
                    },
                    end: Position {
                        line: 238,
                        character: 0,
                    },
                },
                context: CodeActionContext {
                    diagnostics: [
                        Diagnostic {
                            range: Range {
                                start: Position {
                                    line: 135,
                                    character: 12,
                                },
                                end: Position {
                                    line: 141,
                                    character: 13,
                                },
                            },
                            severity: Some(
                                Hint,
                            ),
                            code: Some(
                                String(
                                    "inactive-code",
                                ),
                            ),
                            code_description: Some(
                                CodeDescription {
                                    href: Url {
                                        scheme: "https",
                                        cannot_be_a_base: false,
                                        username: "",
                                        password: None,
                                        host: Some(
                                            Domain(
                                                "rust-analyzer.github.io",
                                            ),
                                        ),
                                        port: None,
                                        path: "/manual.html",
                                        query: None,
                                        fragment: Some(
                                            "inactive-code",
                                        ),
                                    },
                                },
                            ),
                            source: Some(
                                "rust-analyzer",
                            ),
                            message: "code is inactive due to #[cfg] directives: feature = \"regex\" is enabled",
                            related_information: None,
                            tags: Some(
                                [
                                    Unnecessary,
                                ],
                            ),
                            data: None,
                        },
                    ],
                    only: None,
                },
                work_done_progress_params: WorkDoneProgressParams {
                    work_done_token: None,
                },
                partial_result_params: PartialResultParams {
                    partial_result_token: None,
                },
            },
            id: "extract_module:RefactorExtract:0",
        },
    ),
}

thread '<unnamed>' panicked at 'assertion failed: check_disjoint_and_sort(indels)', crates\text_edit\src\lib.rs:191:5
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a\/library\std\src\panicking.rs:498
   1: core::panicking::panic_fmt
             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a\/library\core\src\panicking.rs:116
   2: core::panicking::panic
             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a\/library\core\src\panicking.rs:48
   3: text_edit::assert_disjoint_or_equal
   4: ide_assists::assist_context::Assists::add::{{closure}}
   5: ide_assists::assist_context::Assists::add_impl
   6: ide_assists::handlers::extract_module::extract_module
   7: ide_assists::assists
   8: std::panicking::try
   9: ide::Analysis::assists_with_fixes
  10: rust_analyzer::handlers::handle_code_action_resolve
  11: std::panicking::try
  12: <F as threadpool::FnBox>::call_box
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

I think the panic is coming from inside this closure? Heavy inlining makes the backtrace not so useful here.

https://github.com/rust-analyzer/rust-analyzer/blob/a82caff588f602b171471661f983ee550d4494d6/crates/ide_assists/src/handlers/extract_module.rs#L116-L165

Unfortunately I'm unable to minimize the repro case at this time. However, it is open-source: run the extract module action on https://github.com/CAD97/tracing-filter/blob/a9cbb260aa38d3eb6a6c23c2f193f8c1863ffe71/src/simple/mod.rs#L40-L238 and the server panics. (The repo doesn't put a license on it yet. I hereby formally give the rust-analyzer project permission to distribute any and all of the linked git repo snapshot under MIT OR Apache-2.0, for any purpose.)

rust-analyzer version: rust-analyzer version: 6e13de6 2022-03-18 nightly

rustc version: rustc 1.60.0-beta.4 (99f967e7e 2022-03-14)

relevant settings:

{
    "rust-analyzer.procMacro.enable": true,
    "rust-analyzer.experimental.procAttrMacros": true,
    "rust-analyzer.cargo.allFeatures": true
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-idegeneral IDE featuresC-bugCategory: bugS-actionableSomeone could pick this issue up and work on it right now

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions