Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

attributes: implement checking and handling of attributes #930

Merged
merged 31 commits into from
Aug 31, 2023
Merged

Conversation

feds01
Copy link
Contributor

@feds01 feds01 commented Aug 25, 2023

  • attrs: introduce new crate and add Attribute representations
  • attrs: add AttrTyMap
  • ast: add initial code for running macro/attribute checks in hash-expand
  • core: more dependency cleanups
  • parser: don't include macros in parent span of macro-able items
  • tir: use From<...> for implementing conversion to Lit kinds
  • ir: use attr_store() for attributes and add Instance::has_attr
  • core: rename CompilerStageKind::DeSugar to CompilerStageKind::Expand
  • untyped-semantics: cleanup old code, and remove commented out directive checking code
  • tir: register more AstNodeIds to items, specifically sequences of ids
  • hash-tir: improve ParamError diagnostic messages
  • expand: implement attribute checking
  • expand: correctly apply attrs on attribute subject
  • attrs: implement attribute specific error/warning checking and hookup to expand
  • tir: move primitives.rs into hash-tir from `hash-intrinsics
  • tir: introduce HasNodeId and re-implement directive handling
  • parser: fix improper span on grouped macro invocations
  • target: introduce HasTarget trait to query current target() from any implementor
  • lower: re-implement #layout_of
  • lower: implement applying repr and add discriminant option
  • lower: re-implement #dump_ir

closes #924
closes #925
closes #926
closes #927
closes #896
closes #915

@feds01 feds01 self-assigned this Aug 25, 2023
@feds01 feds01 requested a review from kontheocharis August 25, 2023 20:08
@feds01 feds01 added core Relating to the core internals of the compiler. language Issues that are language/compiler wide landmark labels Aug 25, 2023
compiler/hash-attrs/src/target.rs Outdated Show resolved Hide resolved
compiler/hash-attrs/src/target.rs Show resolved Hide resolved
compiler/hash-attrs/src/target.rs Outdated Show resolved Hide resolved
compiler/hash-attrs/src/target.rs Outdated Show resolved Hide resolved
compiler/hash-attrs/src/target.rs Show resolved Hide resolved
compiler/hash-attrs/src/ty.rs Outdated Show resolved Hide resolved
compiler/hash-attrs/src/ty.rs Outdated Show resolved Hide resolved
compiler/hash-attrs/src/ty.rs Outdated Show resolved Hide resolved
compiler/hash-codegen/src/symbols/mangle.rs Outdated Show resolved Hide resolved
feds01 added 22 commits August 31, 2023 09:24
The `AttrTyMap` is used to store metadata about builtin compiler attributes.
This information is used to check that the attributes are used correctly.
Additionally, introduce a `AstNodeId::null()` which is used to represent
a null-node which is never taken up by any other node, and is used
to represent the absence of a node.
`HasNodeId` is a helper trait which specifies that a certain type
has an associated node-id on it, and hence `node_id()` can be
called to retrieve it. This is useful for things like `TermId`,
`FnDefId`, `Pat`, etc.

With this change, handling of `#run`, `#dump_tir`, `#pure`,
`#entry_point` have been re-implemented.

Additionally, lots of code cleanup around other places because
of this change.
This patch reworks the way `repr` attributes are checked by
introducing a `hash-attrs` specific `ReprAttr` representation
which is parsed from a `Attr`. During parsing, various semantic
checks are perfomed, and can be emitted to the `AttrChecker`.

Additionally, this logic is re-used in `hash-lower` to actually
apply the attribute onto `Adt`s that specify a representation
attribute.

Furthemore, since `repr` supports `u8`, `u16`, ...  as well, this
meant that `discriminant` option on `AdtRepresentation` is now
also supported.
kontheocharis
kontheocharis previously approved these changes Aug 31, 2023
@feds01 feds01 merged commit 60f64dd into main Aug 31, 2023
1 check passed
@feds01 feds01 deleted the attrs branch August 31, 2023 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment