Skip to content

Commit 0eb6039

Browse files
bors[bot]yue4u
andauthored
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]>
2 parents 4f04d84 + a0c5279 commit 0eb6039

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

crates/hir_ty/src/diagnostics/decl_check.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,12 @@ impl<'a> DeclValidator<'a> {
181181
AttrDefId::ExternBlockId(id) => Some(id.lookup(self.db.upcast()).container.into()),
182182
// These warnings should not explore macro definitions at all
183183
AttrDefId::MacroDefId(_) => None,
184-
// Will never occur under an enum/struct/union/type alias
185-
AttrDefId::AdtId(_) => None,
184+
AttrDefId::AdtId(aid) => match aid {
185+
AdtId::StructId(sid) => Some(sid.lookup(self.db.upcast()).container.into()),
186+
AdtId::EnumId(eid) => Some(eid.lookup(self.db.upcast()).container.into()),
187+
// Unions aren't yet supported
188+
AdtId::UnionId(_) => None,
189+
},
186190
AttrDefId::FieldId(_) => None,
187191
AttrDefId::EnumVariantId(_) => None,
188192
AttrDefId::TypeAliasId(_) => None,

crates/ide_diagnostics/src/handlers/incorrect_case.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,15 @@ fn main() {
332332
check_diagnostics(
333333
r#"
334334
#![allow(non_snake_case)]
335+
#![allow(non_camel_case_types)]
336+
337+
struct S {
338+
fooBar: bool,
339+
}
340+
341+
enum E {
342+
fooBar,
343+
}
335344
336345
mod F {
337346
fn CheckItWorksWithCrateAttr(BAD_NAME_HI: u8) {}

0 commit comments

Comments
 (0)