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 <github@yue.coffee>
This commit is contained in:
bors[bot] 2021-12-11 17:20:14 +00:00 committed by GitHub
commit 0eb6039e4e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 2 deletions

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