Skip to content

Commit a0c5279

Browse files
committed
fix: lookup upwards for struct and enum
1 parent bc8efca commit a0c5279

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)