fix: lookup upwards for struct and enum

This commit is contained in:
rainy-me 2021-12-12 01:23:27 +09:00
parent bc8efca0c8
commit a0c52794bd
2 changed files with 15 additions and 2 deletions
crates
hir_ty/src/diagnostics
ide_diagnostics/src/handlers

View file

@ -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,

View file

@ -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) {}