Consider exported_name="main" functions in test modules as tests

This commit is contained in:
Lukas Wirth 2024-04-04 14:51:10 +02:00
parent 2b62d4b2ba
commit 5957835cdf
6 changed files with 94 additions and 22 deletions

View file

@ -2006,12 +2006,15 @@ impl Function {
/// is this a `fn main` or a function with an `export_name` of `main`?
pub fn is_main(self, db: &dyn HirDatabase) -> bool {
if !self.module(db).is_crate_root() {
return false;
}
let data = db.function_data(self.id);
data.attrs.export_name() == Some("main")
|| self.module(db).is_crate_root() && data.name.to_smol_str() == "main"
}
data.name.to_smol_str() == "main" || data.attrs.export_name() == Some("main")
/// Is this a function with an `export_name` of `main`?
pub fn exported_main(self, db: &dyn HirDatabase) -> bool {
let data = db.function_data(self.id);
data.attrs.export_name() == Some("main")
}
/// Does this function have the ignore attribute?