mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 04:44:57 +00:00
Auto merge of #15736 - rmehri01:15678_module_incorrect_case_diagnostics, r=HKalbasi
fix: add incorrect case diagnostics for module names Adds diagnostics for checking both inline and file module names are snake case. Closes #15678
This commit is contained in:
commit
bd38871a98
4 changed files with 123 additions and 10 deletions
|
@ -452,15 +452,7 @@ impl HasVisibility for ModuleDef {
|
|||
impl Module {
|
||||
/// Name of this module.
|
||||
pub fn name(self, db: &dyn HirDatabase) -> Option<Name> {
|
||||
let def_map = self.id.def_map(db.upcast());
|
||||
let parent = def_map[self.id.local_id].parent?;
|
||||
def_map[parent].children.iter().find_map(|(name, module_id)| {
|
||||
if *module_id == self.id.local_id {
|
||||
Some(name.clone())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
self.id.name(db.upcast())
|
||||
}
|
||||
|
||||
/// Returns the crate this module is part of.
|
||||
|
@ -571,6 +563,7 @@ impl Module {
|
|||
if def_map[m.id.local_id].origin.is_inline() {
|
||||
m.diagnostics(db, acc)
|
||||
}
|
||||
acc.extend(def.diagnostics(db))
|
||||
}
|
||||
ModuleDef::Trait(t) => {
|
||||
for diag in db.trait_data_with_diagnostics(t.id).1.iter() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue