diff options
Diffstat (limited to 'crates/hir_ty')
-rw-r--r-- | crates/hir_ty/src/diagnostics/decl_check.rs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/crates/hir_ty/src/diagnostics/decl_check.rs b/crates/hir_ty/src/diagnostics/decl_check.rs index 4b3e2fa8f..25587e116 100644 --- a/crates/hir_ty/src/diagnostics/decl_check.rs +++ b/crates/hir_ty/src/diagnostics/decl_check.rs | |||
@@ -26,6 +26,7 @@ use syntax::{ | |||
26 | ast::{self, NameOwner}, | 26 | ast::{self, NameOwner}, |
27 | AstNode, AstPtr, | 27 | AstNode, AstPtr, |
28 | }; | 28 | }; |
29 | use test_utils::mark; | ||
29 | 30 | ||
30 | use crate::{ | 31 | use crate::{ |
31 | db::HirDatabase, | 32 | db::HirDatabase, |
@@ -87,6 +88,11 @@ impl<'a, 'b> DeclValidator<'a, 'b> { | |||
87 | 88 | ||
88 | fn validate_func(&mut self, db: &dyn HirDatabase, func: FunctionId) { | 89 | fn validate_func(&mut self, db: &dyn HirDatabase, func: FunctionId) { |
89 | let data = db.function_data(func); | 90 | let data = db.function_data(func); |
91 | if data.is_extern { | ||
92 | mark::hit!(extern_func_incorrect_case_ignored); | ||
93 | return; | ||
94 | } | ||
95 | |||
90 | let body = db.body(func.into()); | 96 | let body = db.body(func.into()); |
91 | 97 | ||
92 | // Recursively validate inner scope items, such as static variables and constants. | 98 | // Recursively validate inner scope items, such as static variables and constants. |
@@ -648,6 +654,10 @@ impl<'a, 'b> DeclValidator<'a, 'b> { | |||
648 | 654 | ||
649 | fn validate_static(&mut self, db: &dyn HirDatabase, static_id: StaticId) { | 655 | fn validate_static(&mut self, db: &dyn HirDatabase, static_id: StaticId) { |
650 | let data = db.static_data(static_id); | 656 | let data = db.static_data(static_id); |
657 | if data.is_extern { | ||
658 | mark::hit!(extern_static_incorrect_case_ignored); | ||
659 | return; | ||
660 | } | ||
651 | 661 | ||
652 | if self.allowed(db, static_id.into(), allow::NON_UPPER_CASE_GLOBAL) { | 662 | if self.allowed(db, static_id.into(), allow::NON_UPPER_CASE_GLOBAL) { |
653 | return; | 663 | return; |
@@ -709,6 +719,8 @@ fn pat_equals_to_name(pat: Option<ast::Pat>, name: &Name) -> bool { | |||
709 | 719 | ||
710 | #[cfg(test)] | 720 | #[cfg(test)] |
711 | mod tests { | 721 | mod tests { |
722 | use test_utils::mark; | ||
723 | |||
712 | use crate::diagnostics::tests::check_diagnostics; | 724 | use crate::diagnostics::tests::check_diagnostics; |
713 | 725 | ||
714 | #[test] | 726 | #[test] |
@@ -920,4 +932,18 @@ fn main() { | |||
920 | "#, | 932 | "#, |
921 | ); | 933 | ); |
922 | } | 934 | } |
935 | |||
936 | #[test] | ||
937 | fn ignores_extern_items() { | ||
938 | mark::check!(extern_func_incorrect_case_ignored); | ||
939 | mark::check!(extern_static_incorrect_case_ignored); | ||
940 | check_diagnostics( | ||
941 | r#" | ||
942 | extern { | ||
943 | fn NonSnakeCaseName(SOME_VAR: u8) -> u8; | ||
944 | pub static SomeStatic: u8 = 10; | ||
945 | } | ||
946 | "#, | ||
947 | ); | ||
948 | } | ||
923 | } | 949 | } |