Skip to content

Commit 0c409e5

Browse files
authored
Merge pull request #18727 from roife/fix-issue-18704
fix: remove `always!` check for file_id in `runnables`
2 parents 2d895a7 + 56ced3b commit 0c409e5

File tree

2 files changed

+22
-31
lines changed

2 files changed

+22
-31
lines changed

src/tools/rust-analyzer/crates/ide/src/runnables.rs

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use ide_db::{
1616
};
1717
use itertools::Itertools;
1818
use span::{Edition, TextSize};
19-
use stdx::{always, format_to};
19+
use stdx::format_to;
2020
use syntax::{
2121
ast::{self, AstNode},
2222
SmolStr, SyntaxNode, ToSmolStr,
@@ -130,14 +130,7 @@ pub(crate) fn runnables(db: &RootDatabase, file_id: FileId) -> Vec<Runnable> {
130130
// In case an expansion creates multiple runnables we want to name them to avoid emitting a bunch of equally named runnables.
131131
let mut in_macro_expansion = FxHashMap::<hir::HirFileId, Vec<Runnable>>::default();
132132
let mut add_opt = |runnable: Option<Runnable>, def| {
133-
if let Some(runnable) = runnable.filter(|runnable| {
134-
always!(
135-
runnable.nav.file_id == file_id,
136-
"tried adding a runnable pointing to a different file: {:?} for {:?}",
137-
runnable.kind,
138-
file_id
139-
)
140-
}) {
133+
if let Some(runnable) = runnable.filter(|runnable| runnable.nav.file_id == file_id) {
141134
if let Some(def) = def {
142135
let file_id = match def {
143136
Definition::Module(it) => {
@@ -161,13 +154,7 @@ pub(crate) fn runnables(db: &RootDatabase, file_id: FileId) -> Vec<Runnable> {
161154
Definition::SelfType(impl_) => runnable_impl(&sema, &impl_),
162155
_ => None,
163156
};
164-
add_opt(
165-
runnable
166-
.or_else(|| module_def_doctest(sema.db, def))
167-
// #[macro_export] mbe macros are declared in the root, while their definition may reside in a different module
168-
.filter(|it| it.nav.file_id == file_id),
169-
Some(def),
170-
);
157+
add_opt(runnable.or_else(|| module_def_doctest(sema.db, def)), Some(def));
171158
if let Definition::SelfType(impl_) = def {
172159
impl_.items(db).into_iter().for_each(|assoc| {
173160
let runnable = match assoc {

src/tools/rust-analyzer/crates/rust-analyzer/src/lsp/to_proto.rs

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1584,22 +1584,26 @@ pub(crate) fn code_lens(
15841584
};
15851585

15861586
let lens_config = snap.config.lens();
1587-
if lens_config.run && client_commands_config.run_single && has_root {
1588-
let command = command::run_single(&r, &title);
1589-
acc.push(lsp_types::CodeLens {
1590-
range: annotation_range,
1591-
command: Some(command),
1592-
data: None,
1593-
})
1594-
}
1595-
if lens_config.debug && can_debug && client_commands_config.debug_single {
1596-
let command = command::debug_single(&r);
1597-
acc.push(lsp_types::CodeLens {
1598-
range: annotation_range,
1599-
command: Some(command),
1600-
data: None,
1601-
})
1587+
1588+
if has_root {
1589+
if lens_config.run && client_commands_config.run_single {
1590+
let command = command::run_single(&r, &title);
1591+
acc.push(lsp_types::CodeLens {
1592+
range: annotation_range,
1593+
command: Some(command),
1594+
data: None,
1595+
})
1596+
}
1597+
if lens_config.debug && can_debug && client_commands_config.debug_single {
1598+
let command = command::debug_single(&r);
1599+
acc.push(lsp_types::CodeLens {
1600+
range: annotation_range,
1601+
command: Some(command),
1602+
data: None,
1603+
})
1604+
}
16021605
}
1606+
16031607
if lens_config.interpret {
16041608
let command = command::interpret_single(&r);
16051609
acc.push(lsp_types::CodeLens {

0 commit comments

Comments
 (0)