1 //! Type inference-based diagnostics.
10 use hir_def::ModuleDefId;
11 use hir_expand::HirFileId;
12 use syntax::{ast, AstPtr};
14 use crate::db::HirDatabase;
16 pub use crate::diagnostics::{
18 record_literal_missing_fields, record_pattern_missing_fields, BodyValidationDiagnostic,
20 unsafe_check::missing_unsafe,
23 pub fn validate_module_item(
27 ) -> Vec<IncorrectCase> {
28 let _p = profile::span("validate_module_item");
29 let mut validator = decl_check::DeclValidator::new(db, krate);
30 validator.validate_item(owner);
44 impl fmt::Display for CaseType {
45 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
46 let repr = match self {
47 CaseType::LowerSnakeCase => "snake_case",
48 CaseType::UpperSnakeCase => "UPPER_SNAKE_CASE",
49 CaseType::UpperCamelCase => "CamelCase",
69 impl fmt::Display for IdentType {
70 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
71 let repr = match self {
72 IdentType::Constant => "Constant",
73 IdentType::Enum => "Enum",
74 IdentType::Field => "Field",
75 IdentType::Function => "Function",
76 IdentType::Parameter => "Parameter",
77 IdentType::StaticVariable => "Static variable",
78 IdentType::Structure => "Structure",
79 IdentType::Variable => "Variable",
80 IdentType::Variant => "Variant",
88 pub struct IncorrectCase {
90 pub ident: AstPtr<ast::Name>,
91 pub expected_case: CaseType,
92 pub ident_type: IdentType,
93 pub ident_text: String,
94 pub suggested_text: String,