rust-lang / rust-analyzer

A Rust compiler front-end for IDEs
https://rust-analyzer.github.io/
Apache License 2.0
13.79k stars 1.52k forks source link

rust-analyzer crash #10311

Open pacak opened 2 years ago

pacak commented 2 years ago
% 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(),
        }
    }
}
Veykril commented 1 week ago

This is likely out of date at this point

pacak commented 1 week ago

This is likely out of date at this point

FWIW example I posted is still crashes in 1.79.0:

Error: Parse error: no resolution scope for file

Stack backtrace:
   0: <anyhow::Error as core::convert::From<ide_ssr::errors::SsrError>>::from
   1: <rust_analyzer::cli::flags::Ssr>::run
   2: rust_analyzer::main
   3: std::sys_common::backtrace::__rust_begin_short_backtrace::<fn() -> core::result::Result<std::process::ExitCode, anyhow::Error>, core::result::Result<std::process::ExitCode, anyhow::Error>>
   4: std::rt::lang_start::<core::result::Result<std::process::ExitCode, anyhow::Error>>::{closure#0}
   5: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once
             at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/ops/function.rs:284:13
   6: std::panicking::try::do_call
             at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:559:40
   7: std::panicking::try
             at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:523:19
   8: std::panic::catch_unwind
             at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panic.rs:149:14
   9: std::rt::lang_start_internal::{{closure}}
             at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/rt.rs:141:48
  10: std::panicking::try::do_call
             at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:559:40
  11: std::panicking::try
             at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:523:19
  12: std::panic::catch_unwind
             at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panic.rs:149:14
  13: std::rt::lang_start_internal
             at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/rt.rs:141:20
  14: main
  15: __libc_start_call_main
             at ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
  16: __libc_start_main_impl
             at ./csu/../csu/libc-start.c:392:3
  17: <unknown>
% rust-analyzer --version
rust-analyzer 1.79.0 (129f3b9 2024-06-10)
Veykril commented 1 week ago

That's a new one (sorry i only judget by the original backtrace which shouldnt happen anymore)