mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-28 05:53:45 +00:00
Auto merge of #16691 - Veykril:completion-analysis-panic, r=Veykril
fix: Fix completions panicking with certain macro setups Unable to figure out a test case for this but managed to run into it in r-a reproducably. Fixes https://github.com/rust-lang/rust-analyzer/issues/16266 Fixes https://github.com/rust-lang/rust-analyzer/issues/13255
This commit is contained in:
commit
d4d9d0c85a
6 changed files with 19 additions and 6 deletions
|
@ -28,6 +28,10 @@ incremental = true
|
|||
# Set this to 1 or 2 to get more useful backtraces in debugger.
|
||||
debug = 0
|
||||
|
||||
[profile.dev-rel]
|
||||
inherits = "release"
|
||||
debug = 2
|
||||
|
||||
[patch.'crates-io']
|
||||
# rowan = { path = "../rowan" }
|
||||
|
||||
|
|
|
@ -1148,7 +1148,6 @@ fn iterate_trait_method_candidates(
|
|||
) -> ControlFlow<()> {
|
||||
let db = table.db;
|
||||
let env = table.trait_env.clone();
|
||||
let self_is_array = matches!(self_ty.kind(Interner), chalk_ir::TyKind::Array(..));
|
||||
|
||||
let canonical_self_ty = table.canonicalize(self_ty.clone()).value;
|
||||
|
||||
|
@ -1160,7 +1159,9 @@ fn iterate_trait_method_candidates(
|
|||
// 2021.
|
||||
// This is to make `[a].into_iter()` not break code with the new `IntoIterator` impl for
|
||||
// arrays.
|
||||
if data.skip_array_during_method_dispatch && self_is_array {
|
||||
if data.skip_array_during_method_dispatch
|
||||
&& matches!(self_ty.kind(Interner), chalk_ir::TyKind::Array(..))
|
||||
{
|
||||
// FIXME: this should really be using the edition of the method name's span, in case it
|
||||
// comes from a macro
|
||||
if db.crate_graph()[env.krate].edition < Edition::Edition2021 {
|
||||
|
|
|
@ -969,8 +969,10 @@ impl<'db> SemanticsImpl<'db> {
|
|||
match value.parent() {
|
||||
Some(parent) => Some(InFile::new(file_id, parent)),
|
||||
None => {
|
||||
self.cache(value.clone(), file_id);
|
||||
Some(file_id.macro_file()?.call_node(db))
|
||||
let call_node = file_id.macro_file()?.call_node(db);
|
||||
// cache the node
|
||||
self.parse_or_expand(call_node.file_id);
|
||||
Some(call_node)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
@ -963,6 +963,7 @@ fn classify_name_ref(
|
|||
|
||||
match find_node_in_file_compensated(sema, original_file, &expr) {
|
||||
Some(it) => {
|
||||
// buggy
|
||||
let innermost_ret_ty = sema
|
||||
.ancestors_with_macros(it.syntax().clone())
|
||||
.find_map(find_ret_ty)
|
||||
|
|
|
@ -23,6 +23,8 @@ xflags::xflags! {
|
|||
optional --mimalloc
|
||||
/// Use jemalloc allocator for server
|
||||
optional --jemalloc
|
||||
/// build in release with debug info set to 2
|
||||
optional --dev-rel
|
||||
}
|
||||
|
||||
cmd fuzz-tests {}
|
||||
|
@ -80,6 +82,7 @@ pub struct Install {
|
|||
pub server: bool,
|
||||
pub mimalloc: bool,
|
||||
pub jemalloc: bool,
|
||||
pub dev_rel: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
@ -187,7 +190,7 @@ impl Install {
|
|||
} else {
|
||||
Malloc::System
|
||||
};
|
||||
Some(ServerOpt { malloc })
|
||||
Some(ServerOpt { malloc, dev_rel: self.dev_rel })
|
||||
}
|
||||
pub(crate) fn client(&self) -> Option<ClientOpt> {
|
||||
if !self.client && self.server {
|
||||
|
|
|
@ -31,6 +31,7 @@ const VS_CODES: &[&str] = &["code", "code-exploration", "code-insiders", "codium
|
|||
|
||||
pub(crate) struct ServerOpt {
|
||||
pub(crate) malloc: Malloc,
|
||||
pub(crate) dev_rel: bool,
|
||||
}
|
||||
|
||||
pub(crate) enum Malloc {
|
||||
|
@ -135,8 +136,9 @@ fn install_server(sh: &Shell, opts: ServerOpt) -> anyhow::Result<()> {
|
|||
Malloc::Mimalloc => &["--features", "mimalloc"],
|
||||
Malloc::Jemalloc => &["--features", "jemalloc"],
|
||||
};
|
||||
let profile = if opts.dev_rel { "dev-rel" } else { "release" };
|
||||
|
||||
let cmd = cmd!(sh, "cargo install --path crates/rust-analyzer --locked --force --features force-always-assert {features...}");
|
||||
let cmd = cmd!(sh, "cargo install --path crates/rust-analyzer --profile={profile} --locked --force --features force-always-assert {features...}");
|
||||
cmd.run()?;
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue