mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 02:57:37 +00:00
Merge #8206
8206: Ignore main functions not in root module r=Veykril a=ivan770 Closes #8195 Co-authored-by: ivan770 <leshenko.ivan770@gmail.com>
This commit is contained in:
commit
20e32fc946
@ -226,7 +226,9 @@ pub(crate) fn runnable_fn(sema: &Semantics<RootDatabase>, def: hir::Function) ->
|
||||
let func = def.source(sema.db)?;
|
||||
let name_string = def.name(sema.db).to_string();
|
||||
|
||||
let kind = if name_string == "main" {
|
||||
let root = def.krate(sema.db)?.root_module(sema.db);
|
||||
|
||||
let kind = if name_string == "main" && def.module(sema.db) == root {
|
||||
RunnableKind::Bin
|
||||
} else {
|
||||
let canonical_path = {
|
||||
@ -444,6 +446,10 @@ fn test_foo() {}
|
||||
|
||||
#[bench]
|
||||
fn bench() {}
|
||||
|
||||
mod not_a_root {
|
||||
fn main() {}
|
||||
}
|
||||
"#,
|
||||
&[&BIN, &TEST, &TEST, &BENCH],
|
||||
expect![[r#"
|
||||
|
Loading…
Reference in New Issue
Block a user