Skip to content

Panic on path_resolution #10259

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

Closed
mscofield0 opened this issue Sep 16, 2021 · 1 comment
Closed

Panic on path_resolution #10259

mscofield0 opened this issue Sep 16, 2021 · 1 comment

Comments

@mscofield0
Copy link

mscofield0 commented Sep 16, 2021

I just randomly selected the entire file and it happened.

Here's the error message:

Panic context:
> 
version: 516eb40ba 2021-09-13 stable
request: textDocument/hover HoverParams {
    text_document: TextDocumentIdentifier {
        uri: Url {
            scheme: "file",
            cannot_be_a_base: false,
            username: "",
            password: None,
            host: None,
            port: None,
            path: "/home/bloo/Coding/Rust/belot-service/src/core/limbo.rs",
            query: None,
            fragment: None,
        },
    },
    position: Position(
        Position {
            line: 12,
            character: 20,
        },
    ),
    work_done_progress_params: WorkDoneProgressParams {
        work_done_token: None,
    },
}

> impl_trait_query(ImplId(10748) -> ItemLoc { container: ModuleId { krate: CrateId(595), block: None, local_id: Idx::<ModuleData>(1) }, id: ItemTreeId { tree: TreeId { file: HirFileId(FileId(FileId(2785))), block: None }, value: Idx::<Impl>(0) } } -> ImplData { target_trait: Some(TraitRef { path: Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("ops")), Name(Text("Deref"))] }, generic_args: [None, None] } }), self_ty: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("CowBytes"))] }, generic_args: [Some(GenericArgs { args: [Lifetime(LifetimeRef { name: Name(Text("'a")) })], has_self_type: false, bindings: [] })] }), items: [TypeAliasId(TypeAliasId(5354)), FunctionId(FunctionId(28032))], is_negative: false })

> impl_self_ty_query(ImplId(10748) -> ItemLoc { container: ModuleId { krate: CrateId(595), block: None, local_id: Idx::<ModuleData>(1) }, id: ItemTreeId { tree: TreeId { file: HirFileId(FileId(FileId(2785))), block: None }, value: Idx::<Impl>(0) } } -> ImplData { target_trait: Some(TraitRef { path: Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("ops")), Name(Text("Deref"))] }, generic_args: [None, None] } }), self_ty: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("CowBytes"))] }, generic_args: [Some(GenericArgs { args: [Lifetime(LifetimeRef { name: Name(Text("'a")) })], has_self_type: false, bindings: [] })] }), items: [TypeAliasId(TypeAliasId(5354)), FunctionId(FunctionId(28032))], is_negative: false })

> DefMap CrateId(595) crate_name=Some(CrateDisplayName { crate_name: CrateName("build_script_build"), canonical_name: "build-script-build" }) block=None path=CowBytes

thread '<unnamed>' panicked at 'index out of bounds: the len is 1 but the index is 1', crates/hir_def/src/nameres/path_resolution.rs:395:33
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_bounds_check
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/core/src/panicking.rs:69:5
   3: hir_def::nameres::path_resolution::<impl hir_def::nameres::DefMap>::resolve_path_fp_with_macro_single
   4: hir_def::resolver::Resolver::resolve_path_in_type_ns
   5: hir_ty::lower::TyLoweringContext::lower_ty_ext
   6: hir_ty::lower::impl_self_ty_query
   7: salsa::runtime::Runtime::execute_query_implementation
   8: salsa::derived::slot::Slot<Q,MP>::read_upgrade
   9: salsa::derived::slot::Slot<Q,MP>::read
  10: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  11: <DB as hir_ty::db::HirDatabase>::impl_self_ty
  12: hir_ty::lower::impl_trait_query
  13: salsa::runtime::Runtime::execute_query_implementation
  14: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  15: salsa::derived::slot::Slot<Q,MP>::maybe_changed_since
  16: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::maybe_changed_since
  17: salsa::derived::slot::MemoRevisions::validate_memoized_value
  18: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  19: salsa::derived::slot::Slot<Q,MP>::read
  20: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  21: <DB as hir_ty::db::HirDatabase>::trait_impls_in_crate
  22: hir::Impl::all_for_type
  23: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  24: <core::iter::adapters::flatten::Flatten<I> as core::iter::traits::iterator::Iterator>::next
  25: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  26: ide::goto_implementation::goto_implementation
  27: std::panicking::try
  28: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  29: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  30: rust_analyzer::handlers::handle_hover
  31: std::panicking::try
  32: <F as threadpool::FnBox>::call_box
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Panic context:
> 
version: 516eb40ba 2021-09-13 stable
request: textDocument/hover HoverParams {
    text_document: TextDocumentIdentifier {
        uri: Url {
            scheme: "file",
            cannot_be_a_base: false,
            username: "",
            password: None,
            host: None,
            port: None,
            path: "/home/bloo/Coding/Rust/belot-service/src/core/limbo.rs",
            query: None,
            fragment: None,
        },
    },
    position: Position(
        Position {
            line: 4,
            character: 27,
        },
    ),
    work_done_progress_params: WorkDoneProgressParams {
        work_done_token: None,
    },
}

> impl_trait_query(ImplId(11905) -> ItemLoc { container: ModuleId { krate: CrateId(1066), block: None, local_id: Idx::<ModuleData>(7) }, id: ItemTreeId { tree: TreeId { file: HirFileId(FileId(FileId(4010))), block: None }, value: Idx::<Impl>(0) } } -> ImplData { target_trait: Some(TraitRef { path: Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Sync"))] }, generic_args: [None] } }), self_ty: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("ScopedKey"))] }, generic_args: [Some(GenericArgs { args: [Type(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("T"))] }, generic_args: [None] }))], has_self_type: false, bindings: [] })] }), items: [], is_negative: false })

> impl_self_ty_query(ImplId(11905) -> ItemLoc { container: ModuleId { krate: CrateId(1066), block: None, local_id: Idx::<ModuleData>(7) }, id: ItemTreeId { tree: TreeId { file: HirFileId(FileId(FileId(4010))), block: None }, value: Idx::<Impl>(0) } } -> ImplData { target_trait: Some(TraitRef { path: Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Sync"))] }, generic_args: [None] } }), self_ty: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("ScopedKey"))] }, generic_args: [Some(GenericArgs { args: [Type(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("T"))] }, generic_args: [None] }))], has_self_type: false, bindings: [] })] }), items: [], is_negative: false })

> DefMap CrateId(1066) crate_name=Some(CrateDisplayName { crate_name: CrateName("fs_link"), canonical_name: "fs_link" }) block=None path=ScopedKey

thread '<unnamed>' panicked at 'index out of bounds: the len is 1 but the index is 7', crates/hir_def/src/nameres/path_resolution.rs:395:33
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_bounds_check
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/core/src/panicking.rs:69:5
   3: hir_def::nameres::path_resolution::<impl hir_def::nameres::DefMap>::resolve_path_fp_with_macro_single
   4: hir_def::resolver::Resolver::resolve_path_in_type_ns
   5: hir_ty::lower::TyLoweringContext::lower_ty_ext
   6: hir_ty::lower::impl_self_ty_query
   7: salsa::runtime::Runtime::execute_query_implementation
   8: salsa::derived::slot::Slot<Q,MP>::read_upgrade
   9: salsa::derived::slot::Slot<Q,MP>::read
  10: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  11: <DB as hir_ty::db::HirDatabase>::impl_self_ty
  12: hir_ty::lower::impl_trait_query
  13: salsa::runtime::Runtime::execute_query_implementation
  14: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  15: salsa::derived::slot::Slot<Q,MP>::maybe_changed_since
  16: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::maybe_changed_since
  17: salsa::derived::slot::MemoRevisions::validate_memoized_value
  18: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  19: salsa::derived::slot::Slot<Q,MP>::read
  20: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  21: <DB as hir_ty::db::HirDatabase>::trait_impls_in_crate
  22: hir::Impl::all_for_type
  23: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  24: <core::iter::adapters::flatten::Flatten<I> as core::iter::traits::iterator::Iterator>::next
  25: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  26: ide::goto_implementation::goto_implementation
  27: std::panicking::try
  28: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  29: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  30: rust_analyzer::handlers::handle_hover
  31: std::panicking::try
  32: <F as threadpool::FnBox>::call_box
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Panic context:
> 
version: 516eb40ba 2021-09-13 stable
request: textDocument/hover HoverParams {
    text_document: TextDocumentIdentifier {
        uri: Url {
            scheme: "file",
            cannot_be_a_base: false,
            username: "",
            password: None,
            host: None,
            port: None,
            path: "/home/bloo/Coding/Rust/belot-service/src/core/limbo.rs",
            query: None,
            fragment: None,
        },
    },
    position: Position(
        Position {
            line: 4,
            character: 26,
        },
    ),
    work_done_progress_params: WorkDoneProgressParams {
        work_done_token: None,
    },
}

> impl_trait_query(ImplId(11412) -> ItemLoc { container: ModuleId { krate: CrateId(623), block: None, local_id: Idx::<ModuleData>(1) }, id: ItemTreeId { tree: TreeId { file: HirFileId(FileId(FileId(2975))), block: None }, value: Idx::<Impl>(0) } } -> ImplData { target_trait: Some(TraitRef { path: Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Sync"))] }, generic_args: [None] } }), self_ty: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("OnceCell"))] }, generic_args: [Some(GenericArgs { args: [Type(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("T"))] }, generic_args: [None] }))], has_self_type: false, bindings: [] })] }), items: [], is_negative: false })

> impl_self_ty_query(ImplId(11412) -> ItemLoc { container: ModuleId { krate: CrateId(623), block: None, local_id: Idx::<ModuleData>(1) }, id: ItemTreeId { tree: TreeId { file: HirFileId(FileId(FileId(2975))), block: None }, value: Idx::<Impl>(0) } } -> ImplData { target_trait: Some(TraitRef { path: Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Sync"))] }, generic_args: [None] } }), self_ty: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("OnceCell"))] }, generic_args: [Some(GenericArgs { args: [Type(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("T"))] }, generic_args: [None] }))], has_self_type: false, bindings: [] })] }), items: [], is_negative: false })

> DefMap CrateId(623) crate_name=Some(CrateDisplayName { crate_name: CrateName("parse_self"), canonical_name: "parse_self" }) block=None path=OnceCell

thread '<unnamed>' panicked at 'index out of bounds: the len is 1 but the index is 1', crates/hir_def/src/nameres/path_resolution.rs:395:33
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_bounds_check
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/core/src/panicking.rs:69:5
   3: hir_def::nameres::path_resolution::<impl hir_def::nameres::DefMap>::resolve_path_fp_with_macro_single
   4: hir_def::resolver::Resolver::resolve_path_in_type_ns
   5: hir_ty::lower::TyLoweringContext::lower_ty_ext
   6: hir_ty::lower::impl_self_ty_query
   7: salsa::runtime::Runtime::execute_query_implementation
   8: salsa::derived::slot::Slot<Q,MP>::read_upgrade
   9: salsa::derived::slot::Slot<Q,MP>::read
  10: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  11: <DB as hir_ty::db::HirDatabase>::impl_self_ty
  12: hir_ty::lower::impl_trait_query
  13: salsa::runtime::Runtime::execute_query_implementation
  14: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  15: salsa::derived::slot::Slot<Q,MP>::maybe_changed_since
  16: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::maybe_changed_since
  17: salsa::derived::slot::MemoRevisions::validate_memoized_value
  18: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  19: salsa::derived::slot::Slot<Q,MP>::read
  20: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  21: <DB as hir_ty::db::HirDatabase>::trait_impls_in_crate
  22: hir::Impl::all_for_type
  23: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  24: <core::iter::adapters::flatten::Flatten<I> as core::iter::traits::iterator::Iterator>::next
  25: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  26: ide::goto_implementation::goto_implementation
  27: std::panicking::try
  28: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  29: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  30: rust_analyzer::handlers::handle_hover
  31: std::panicking::try
  32: <F as threadpool::FnBox>::call_box
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[Error - 5:35:35 PM] Request textDocument/hover failed.
  Message: server panicked: index out of bounds: the len is 1 but the index is 1
  Code: -32603 
Panic context:
> 
version: 516eb40ba 2021-09-13 stable
request: textDocument/hover HoverParams {
    text_document: TextDocumentIdentifier {
        uri: Url {
            scheme: "file",
            cannot_be_a_base: false,
            username: "",
            password: None,
            host: None,
            port: None,
            path: "/home/bloo/Coding/Rust/belot-service/src/core/limbo.rs",
            query: None,
            fragment: None,
        },
    },
    position: Position(
        Position {
            line: 11,
            character: 17,
        },
    ),
    work_done_progress_params: WorkDoneProgressParams {
        work_done_token: None,
    },
}

> impl_trait_query(ImplId(11412) -> ItemLoc { container: ModuleId { krate: CrateId(623), block: None, local_id: Idx::<ModuleData>(1) }, id: ItemTreeId { tree: TreeId { file: HirFileId(FileId(FileId(2975))), block: None }, value: Idx::<Impl>(0) } } -> ImplData { target_trait: Some(TraitRef { path: Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Sync"))] }, generic_args: [None] } }), self_ty: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("OnceCell"))] }, generic_args: [Some(GenericArgs { args: [Type(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("T"))] }, generic_args: [None] }))], has_self_type: false, bindings: [] })] }), items: [], is_negative: false })

> impl_self_ty_query(ImplId(11412) -> ItemLoc { container: ModuleId { krate: CrateId(623), block: None, local_id: Idx::<ModuleData>(1) }, id: ItemTreeId { tree: TreeId { file: HirFileId(FileId(FileId(2975))), block: None }, value: Idx::<Impl>(0) } } -> ImplData { target_trait: Some(TraitRef { path: Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Sync"))] }, generic_args: [None] } }), self_ty: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("OnceCell"))] }, generic_args: [Some(GenericArgs { args: [Type(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("T"))] }, generic_args: [None] }))], has_self_type: false, bindings: [] })] }), items: [], is_negative: false })

> DefMap CrateId(623) crate_name=Some(CrateDisplayName { crate_name: CrateName("parse_self"), canonical_name: "parse_self" }) block=None path=OnceCell

thread '<unnamed>' panicked at 'index out of bounds: the len is 1 but the index is 1', crates/hir_def/src/nameres/path_resolution.rs:395:33
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_bounds_check
             at /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/core/src/panicking.rs:69:5
   3: hir_def::nameres::path_resolution::<impl hir_def::nameres::DefMap>::resolve_path_fp_with_macro_single
   4: hir_def::resolver::Resolver::resolve_path_in_type_ns
   5: hir_ty::lower::TyLoweringContext::lower_ty_ext
   6: hir_ty::lower::impl_self_ty_query
   7: salsa::runtime::Runtime::execute_query_implementation
   8: salsa::derived::slot::Slot<Q,MP>::read_upgrade
   9: salsa::derived::slot::Slot<Q,MP>::read
  10: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  11: <DB as hir_ty::db::HirDatabase>::impl_self_ty
  12: hir_ty::lower::impl_trait_query
  13: salsa::runtime::Runtime::execute_query_implementation
  14: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  15: salsa::derived::slot::Slot<Q,MP>::maybe_changed_since
  16: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::maybe_changed_since
  17: salsa::derived::slot::MemoRevisions::validate_memoized_value
  18: salsa::derived::slot::Slot<Q,MP>::read_upgrade
  19: salsa::derived::slot::Slot<Q,MP>::read
  20: <salsa::derived::DerivedStorage<Q,MP> as salsa::plumbing::QueryStorageOps<Q>>::try_fetch
  21: <DB as hir_ty::db::HirDatabase>::trait_impls_in_crate
  22: hir::Impl::all_for_trait
  23: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  24: <core::iter::adapters::flatten::Flatten<I> as core::iter::traits::iterator::Iterator>::next
  25: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  26: ide::goto_implementation::goto_implementation
  27: std::panicking::try
  28: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  29: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
  30: rust_analyzer::handlers::handle_hover
  31: std::panicking::try
  32: <F as threadpool::FnBox>::call_box
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[Error - 5:38:16 PM] Request textDocument/hover failed.
  Message: server panicked: index out of bounds: the len is 1 but the index is 1
  Code: -32603 

And this is the code in question:

use dashmap::DashMap;
use arrayvec::ArrayVec;

pub struct Lobby {
    players: ArrayVec<String, 4>,
}

pub type Limbo = DashMap<usize, Lobby>;



impl std::ops::Index<usize> for Lobby {
    type Output = String;

    fn index(&self, index: usize) -> &Self::Output {
        &self.players[index]
    }
}

impl std::ops::IndexMut<usize> for Lobby {
    fn index_mut(&mut self, index: usize) -> &mut Self::Output {
        &mut self.players[index]
    }
}
@Veykril
Copy link
Member

Veykril commented Sep 16, 2021

Duplicate of #10084

@Veykril Veykril marked this as a duplicate of #10084 Sep 16, 2021
@Veykril Veykril closed this as completed Sep 16, 2021
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

2 participants