Skip to content

Commit b42562b

Browse files
committed
Make incorrect case diagnostic work inside of functions
1 parent 9ec1741 commit b42562b

File tree

4 files changed

+280
-33
lines changed

4 files changed

+280
-33
lines changed

crates/hir_def/src/item_scope.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,12 @@ impl ItemScope {
9595
self.impls.iter().copied()
9696
}
9797

98+
pub fn values(
99+
&self,
100+
) -> impl Iterator<Item = (ModuleDefId, Visibility)> + ExactSizeIterator + '_ {
101+
self.values.values().copied()
102+
}
103+
98104
pub fn visibility_of(&self, def: ModuleDefId) -> Option<Visibility> {
99105
self.name_of(ItemInNs::Types(def))
100106
.or_else(|| self.name_of(ItemInNs::Values(def)))

crates/hir_ty/src/diagnostics.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ impl Diagnostic for IncorrectCase {
281281

282282
fn message(&self) -> String {
283283
format!(
284-
"{} `{}` should have a {} name, e.g. `{}`",
284+
"{} `{}` should have {} name, e.g. `{}`",
285285
self.ident_type,
286286
self.ident_text,
287287
self.expected_case.to_string(),
@@ -339,6 +339,8 @@ mod tests {
339339
let impl_data = self.impl_data(impl_id);
340340
for item in impl_data.items.iter() {
341341
if let AssocItemId::FunctionId(f) = item {
342+
let mut sink = DiagnosticSinkBuilder::new().build(&mut cb);
343+
validate_module_item(self, ModuleDefId::FunctionId(*f), &mut sink);
342344
fns.push(*f)
343345
}
344346
}

0 commit comments

Comments
 (0)