diff options
Diffstat (limited to 'crates/ide/src/runnables.rs')
-rw-r--r-- | crates/ide/src/runnables.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/crates/ide/src/runnables.rs b/crates/ide/src/runnables.rs index 5b488e2c5..7e4c5a078 100644 --- a/crates/ide/src/runnables.rs +++ b/crates/ide/src/runnables.rs | |||
@@ -226,7 +226,9 @@ pub(crate) fn runnable_fn(sema: &Semantics<RootDatabase>, def: hir::Function) -> | |||
226 | let func = def.source(sema.db)?; | 226 | let func = def.source(sema.db)?; |
227 | let name_string = def.name(sema.db).to_string(); | 227 | let name_string = def.name(sema.db).to_string(); |
228 | 228 | ||
229 | let kind = if name_string == "main" { | 229 | let root = def.krate(sema.db)?.root_module(sema.db); |
230 | |||
231 | let kind = if name_string == "main" && def.module(sema.db) == root { | ||
230 | RunnableKind::Bin | 232 | RunnableKind::Bin |
231 | } else { | 233 | } else { |
232 | let canonical_path = { | 234 | let canonical_path = { |
@@ -444,6 +446,10 @@ fn test_foo() {} | |||
444 | 446 | ||
445 | #[bench] | 447 | #[bench] |
446 | fn bench() {} | 448 | fn bench() {} |
449 | |||
450 | mod not_a_root { | ||
451 | fn main() {} | ||
452 | } | ||
447 | "#, | 453 | "#, |
448 | &[&BIN, &TEST, &TEST, &BENCH], | 454 | &[&BIN, &TEST, &TEST, &BENCH], |
449 | expect![[r#" | 455 | expect![[r#" |