Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-def/src/signatures.rs')
-rw-r--r--crates/hir-def/src/signatures.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/crates/hir-def/src/signatures.rs b/crates/hir-def/src/signatures.rs
index a13ef484ba..0dd88edbfb 100644
--- a/crates/hir-def/src/signatures.rs
+++ b/crates/hir-def/src/signatures.rs
@@ -185,6 +185,9 @@ impl UnionSignature {
bitflags! {
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub struct EnumFlags: u8 {
+ /// Indicates whether this enum has `#[repr]`.
+ const HAS_REPR = 1 << 0;
+ /// Indicates whether the enum has a `#[rustc_has_incoherent_inherent_impls]` attribute.
const RUSTC_HAS_INCOHERENT_INHERENT_IMPLS = 1 << 1;
}
}
@@ -205,6 +208,9 @@ impl EnumSignature {
if attrs.contains(AttrFlags::RUSTC_HAS_INCOHERENT_INHERENT_IMPLS) {
flags |= EnumFlags::RUSTC_HAS_INCOHERENT_INHERENT_IMPLS;
}
+ if attrs.contains(AttrFlags::HAS_REPR) {
+ flags |= EnumFlags::HAS_REPR;
+ }
let InFile { file_id, value: source } = loc.source(db);
let (store, generic_params, source_map) = lower_generic_params(
@@ -233,6 +239,11 @@ impl EnumSignature {
_ => IntegerType::Pointer(true),
}
}
+
+ #[inline]
+ pub fn repr(&self, db: &dyn DefDatabase, id: EnumId) -> Option<ReprOptions> {
+ if self.flags.contains(EnumFlags::HAS_REPR) { AttrFlags::repr(db, id.into()) } else { None }
+ }
}
bitflags::bitflags! {
#[derive(Debug, Clone, Copy, Eq, PartialEq, Default)]