rust-lang / rust-lang/rust-analyzer

rust-analyzer crash

Open
#10,311 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-ssr C-bug S-actionable
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

% rust-analyzer --version
rust-analyzer f1d7f98ed 2021-09-20 stable
% rust-analyzer ssr 'fn $a() -> $d { $e } ==>> pub fn $a() -> $d { $e }'
thread 'main' panicked at 'assertion failed: check_disjoint(indels)', crates/text_edit/src/lib.rs:191:5                                                                                                                                       
stack backtrace:
   0: rust_begin_unwind
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/std/src/panicking.rs:515:5
   1: core::panicking::panic_fmt
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/core/src/panicking.rs:92:14
   2: core::panicking::panic
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/core/src/panicking.rs:50:5
   3: text_edit::assert_disjoint
   4: ide_ssr::replacing::matches_to_edit_at_offset
   5: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
   6: ide_ssr::MatchFinder::edits                                                                                                                                                                                                             
   7: rust_analyzer::cli::ssr::<impl rust_analyzer::cli::flags::Ssr>::run                                                                                                                                                                     
   8: rust_analyzer::main                                                                                                                                                                                                                     
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Cargo.toml

[package]
name = "pfe"
version = "0.1.0"
authors = []
edition = "2018"

[dependencies]

Cargo.lock

# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3

[[package]]
name = "pfe"
version = "0.1.0"

src/lib.rs

use std::collections::BTreeMap;

#[derive(Debug, PartialEq, Clone, Eq, Ord, PartialOrd, Hash)]
pub struct NonEmpty<T> {
    pub head: T,
    pub tail: Vec<T>,
}

impl<T> From<T> for NonEmpty<T> {
    fn from(head: T) -> NonEmpty<T> {
        NonEmpty { head, tail: vec![] }
    }
}

#[derive(Debug, PartialEq, Clone)]
pub struct Bag<K> {
    items: BTreeMap<K, usize>,
}

impl<K: Ord> Default for Bag<K> {
    fn default() -> Self {
        Bag::new()
    }
}

impl<K: Ord> Bag<K> {
    pub fn new() -> Self {
        Bag {
            items: BTreeMap::new(),
        }
    }
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the crash with the shown rust-analyzer ssr command and example Rust source, then start at crates/text_edit/src/lib.rs:191 and follow ide_ssr::replacing::matches_to_edit_at_offset. Done means this SSR input no longer panics while preserving the intended edit behavior; add or update coverage if the relevant test location is found.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.