diff options
| author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-12-11 17:20:14 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-12-11 17:20:14 +0000 |
| commit | 0eb6039e4eee23ec6df7fdacde7a72e842af96e2 (patch) | |
| tree | d59283b098a6a2ae2cb447ebcf33c57543111209 | |
| parent | 4f04d8477a1aac357e137df47f4e1ff277325c89 (diff) | |
| parent | a0c52794bdbc83790b8a33bd9660e267556ef839 (diff) | |
| download | rust-0eb6039e4eee23ec6df7fdacde7a72e842af96e2.tar.gz rust-0eb6039e4eee23ec6df7fdacde7a72e842af96e2.zip | |
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 <github@yue.coffee>
| -rw-r--r-- | crates/hir_ty/src/diagnostics/decl_check.rs | 8 | ||||
| -rw-r--r-- | crates/ide_diagnostics/src/handlers/incorrect_case.rs | 9 |
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 a1e7198bc2c..9a0f457905f 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 3206a63a902..6a78c08d44c 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) {} |
