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

Bug Report: Panic When Using Japanese Function Names in Rust Analyzer(boundary issue) #18918

Open
nanae772 opened this issue Jan 12, 2025 · 0 comments · May be fixed by #18928
Open

Bug Report: Panic When Using Japanese Function Names in Rust Analyzer(boundary issue) #18918

nanae772 opened this issue Jan 12, 2025 · 0 comments · May be fixed by #18928
Assignees
Labels
C-bug Category: bug I-panic

Comments

@nanae772
Copy link

rust-analyzer version: 0.3.2257-standalone

rustc version: rustc 1.83.0 (90b35a623 2024-11-26)

editor or extension: VSCode

Code Snippet to Reproduce

fn main() {// Typing "あ" here causes a panic.
}

fn あい() {}

Expected Behavior

Rust Analyzer should handle the input without errors.

Actual Behavior

Rust Analyzer panics with the following error message:

Panic context:
> 
version: 0.3.2257-standalone
request: textDocument/completion CompletionParams {
    text_document_position: TextDocumentPositionParams {
        text_document: TextDocumentIdentifier {
            uri: Url {
                scheme: "file",
                cannot_be_a_base: false,
                username: "",
                password: None,
                host: None,
                port: None,
                path: "/home/kazune/workspace/hoge/src/main.rs",
                query: None,
                fragment: None,
            },
        },
        position: Position {
            line: 1,
            character: 5,
        },
    },
    work_done_progress_params: WorkDoneProgressParams {
        work_done_token: None,
    },
    partial_result_params: PartialResultParams {
        partial_result_token: None,
    },
    context: Some(
        CompletionContext {
            trigger_kind: Invoked,
            trigger_character: None,
        },
    ),
}

thread 'Worker' panicked at crates/hir-def/src/import_map.rs:323:41:
byte index 1 is not a char boundary; it is inside 'あ' (bytes 0..3) of `あい`
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::str::slice_error_fail_rt
   3: core::str::slice_error_fail
   4: hir_def::import_map::SearchMode::check
   5: ide_db::symbol_index::Query::search_maps
   6: ide_db::items_locator::items_with_name
   7: ide_db::imports::import_assets::ImportAssets::search_for
   8: ide_db::imports::import_assets::ImportAssets::search_for_imports
   9: ide_completion::completions::flyimport::import_on_the_fly_path
  10: ide_completion::completions::complete_name_ref
  11: ide_completion::completions
  12: ide::Analysis::completions
  13: rust_analyzer::handlers::request::handle_completion
  14: core::ops::function::FnOnce::call_once{{vtable.shim}}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[Error - 10:10:50 AM] Request textDocument/completion failed.
  Message: request handler panicked: byte index 1 is not a char boundary; it is inside 'あ' (bytes 0..3) of `あい`
  Code: -32603

Additional Information

The error appears to be related to how Rust Analyzer handles Unicode input, specifically in the context of Japanese characters. The error suggests a boundary issue with UTF-8 characters.

Please let me know if further details or logs are needed. Thank you for your support!

@nanae772 nanae772 added the C-bug Category: bug label Jan 12, 2025
@roife roife self-assigned this Jan 12, 2025
@roife roife linked a pull request Jan 12, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug I-panic
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants