Skip to content

Commit

Permalink
feat: add nightly formatting rules (#552)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wodann authored Feb 20, 2024
1 parent 8e449e8 commit 55a3412
Show file tree
Hide file tree
Showing 264 changed files with 4,033 additions and 3,111 deletions.
1 change: 1 addition & 0 deletions .cargo-husky/hooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
./scripts/pre-commit.sh
10 changes: 9 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -275,18 +275,26 @@ jobs:
with:
submodules: true

- name: Install nightly rustfmt
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
profile: minimal
components: rustfmt

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
override: true
components: clippy, rustfmt
components: clippy

- uses: Swatinem/rust-cache@v2

- name: Run cargo fmt
uses: actions-rs/cargo@v1
with:
toolchain: nightly
command: fmt
args: --all -- --check

Expand Down
50 changes: 28 additions & 22 deletions c/include/mun/abi.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,17 @@ enum MunStructMemoryKind
#endif // __cplusplus
{
/**
* A garbage collected struct is allocated on the heap and uses reference semantics when passed
* around.
* A garbage collected struct is allocated on the heap and uses reference
* semantics when passed around.
*/
Gc,
/**
* A value struct is allocated on the stack and uses value semantics when passed around.
* A value struct is allocated on the stack and uses value semantics when
* passed around.
*
* NOTE: When a value struct is used in an external API, a wrapper is created that _pins_ the
* value on the heap. The heap-allocated value needs to be *manually deallocated*!
* NOTE: When a value struct is used in an external API, a wrapper is
* created that _pins_ the value on the heap. The heap-allocated value
* needs to be *manually deallocated*!
*/
Value,
};
Expand Down Expand Up @@ -65,10 +67,11 @@ typedef struct MunArrayTypeId {
} MunArrayTypeId;

/**
* Represents a unique identifier for types. The runtime can use this to lookup the corresponding
* [`TypeInfo`]. A [`TypeId`] is a key for a [`TypeInfo`].
* Represents a unique identifier for types. The runtime can use this to lookup
* the corresponding [`TypeInfo`]. A [`TypeId`] is a key for a [`TypeInfo`].
*
* A [`TypeId`] only contains enough information to query the runtime for a [`TypeInfo`].
* A [`TypeId`] only contains enough information to query the runtime for a
* [`TypeInfo`].
*/
enum MunTypeId_Tag
#ifdef __cplusplus
Expand Down Expand Up @@ -127,8 +130,8 @@ typedef struct MunFunctionSignature {
} MunFunctionSignature;

/**
* Represents a function prototype. A function prototype contains the name, type signature, but
* not an implementation.
* Represents a function prototype. A function prototype contains the name,
* type signature, but not an implementation.
*/
typedef struct MunFunctionPrototype {
/**
Expand All @@ -142,8 +145,8 @@ typedef struct MunFunctionPrototype {
} MunFunctionPrototype;

/**
* Represents a function definition. A function definition contains the name, type signature, and
* a pointer to the implementation.
* Represents a function definition. A function definition contains the name,
* type signature, and a pointer to the implementation.
*
* `fn_ptr` can be used to call the declared function.
*/
Expand Down Expand Up @@ -189,7 +192,8 @@ typedef struct MunStructDefinition {
} MunStructDefinition;

/**
* Contains data specific to a group of types that illicit the same characteristics.
* Contains data specific to a group of types that illicit the same
* characteristics.
*/
enum MunTypeDefinitionData_Tag
#ifdef __cplusplus
Expand All @@ -216,16 +220,17 @@ typedef union MunTypeDefinitionData {
/**
* Represents the type declaration for a type that is exported by an assembly.
*
* When multiple Mun modules reference the same type, only one module exports the type; the module
* that contains the type definition. All the other Mun modules reference the type through a
* [`TypeId`].
* When multiple Mun modules reference the same type, only one module exports
* the type; the module that contains the type definition. All the other Mun
* modules reference the type through a [`TypeId`].
*
* The modules that defines the type exports the data to reduce the filesize of the assemblies and
* to ensure only one definition exists. When linking all assemblies together the type definitions
* from all assemblies are loaded and the information is shared to modules that reference the type.
* The modules that defines the type exports the data to reduce the filesize of
* the assemblies and to ensure only one definition exists. When linking all
* assemblies together the type definitions from all assemblies are loaded and
* the information is shared to modules that reference the type.
*
* TODO: add support for polymorphism, enumerations, type parameters, generic type definitions, and
* constructed generic types.
* TODO: add support for polymorphism, enumerations, type parameters, generic
* type definitions, and constructed generic types.
*/
typedef struct MunTypeDefinition {
/**
Expand Down Expand Up @@ -293,7 +298,8 @@ typedef struct MunDispatchTable {
} MunDispatchTable;

/**
* Represents a lookup table for type information. This is used for runtime linking.
* Represents a lookup table for type information. This is used for runtime
* linking.
*
* Type IDs and handles are stored separately for cache efficiency.
*/
Expand Down
Loading

0 comments on commit 55a3412

Please sign in to comment.