Unnamed repository; edit this file 'description' to name the repository.
Merge #10987
10987: fix: respect inner attributes for Structs and Enums r=lnicola a=rainy-me fix: #10980 (the allow/deny issue is not fully resolved though.) Co-authored-by: rainy-me <[email protected]>
bors[bot] 2021-12-12
parent 4f04d84 · parent a0c5279 · commit 0eb6039
-rw-r--r--crates/hir_ty/src/diagnostics/decl_check.rs8
-rw-r--r--crates/ide_diagnostics/src/handlers/incorrect_case.rs9
2 files changed, 15 insertions, 2 deletions
diff --git a/crates/hir_ty/src/diagnostics/decl_check.rs b/crates/hir_ty/src/diagnostics/decl_check.rs
index a1e7198bc2..9a0f457905 100644
--- a/crates/hir_ty/src/diagnostics/decl_check.rs
+++ b/crates/hir_ty/src/diagnostics/decl_check.rs
@@ -181,8 +181,12 @@ impl<'a> DeclValidator<'a> {
AttrDefId::ExternBlockId(id) => Some(id.lookup(self.db.upcast()).container.into()),
// These warnings should not explore macro definitions at all
AttrDefId::MacroDefId(_) => None,
- // Will never occur under an enum/struct/union/type alias
- AttrDefId::AdtId(_) => None,
+ AttrDefId::AdtId(aid) => match aid {
+ AdtId::StructId(sid) => Some(sid.lookup(self.db.upcast()).container.into()),
+ AdtId::EnumId(eid) => Some(eid.lookup(self.db.upcast()).container.into()),
+ // Unions aren't yet supported
+ AdtId::UnionId(_) => None,
+ },
AttrDefId::FieldId(_) => None,
AttrDefId::EnumVariantId(_) => None,
AttrDefId::TypeAliasId(_) => None,
diff --git a/crates/ide_diagnostics/src/handlers/incorrect_case.rs b/crates/ide_diagnostics/src/handlers/incorrect_case.rs
index 3206a63a90..6a78c08d44 100644
--- a/crates/ide_diagnostics/src/handlers/incorrect_case.rs
+++ b/crates/ide_diagnostics/src/handlers/incorrect_case.rs
@@ -332,6 +332,15 @@ fn main() {
check_diagnostics(
r#"
#![allow(non_snake_case)]
+#![allow(non_camel_case_types)]
+
+struct S {
+ fooBar: bool,
+}
+
+enum E {
+ fooBar,
+}
mod F {
fn CheckItWorksWithCrateAttr(BAD_NAME_HI: u8) {}