From c2c1bd0c137cf50e578d8749142c21eaf0946f3d Mon Sep 17 00:00:00 2001 From: David Richey Date: Wed, 28 Aug 2024 14:49:53 -0500 Subject: [PATCH] Fix incorrect symbol definitions in SCIP output --- src/tools/rust-analyzer/crates/rust-analyzer/src/cli/scip.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/cli/scip.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/cli/scip.rs index a8a02712fe2..ceb8534fdf5 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/cli/scip.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/cli/scip.rs @@ -142,7 +142,9 @@ impl flags::Scip { let mut symbol_roles = Default::default(); if let Some(def) = token.definition { - if def.range == text_range { + // if the the range of the def and the range of the token are the same, this must be the definition. + // they also must be in the same file. See https://github.com/rust-lang/rust-analyzer/pull/17988 + if def.file_id == file_id && def.range == text_range { symbol_roles |= scip_types::SymbolRole::Definition as i32; }