Skip to content

Conversation

@spring4175
Copy link
Contributor

@spring4175 spring4175 commented Jan 18, 2023

Add a Clippy denylist for macros. Denies the use of the following macros:

  • serde_json::json: less flexible and performant, use structs and serde_derive
  • std::vec: the Vec::new and Vec::from methods are preferred
  • std::write: slow to compile and run, use Formatter, Display, or Debug calls instead

Closes #1628.

Todo:

  • Fix this one test I have spent too much time on

Add a Clippy denylist for macros. Denies the use of the following
macros:

- `serde_json::json`
- `std::vec`
- `std::write`

Closes #1628.
@github-actions github-actions bot added c-all Affects all crates or the project as a whole c-cache Affects the cache crate c-gateway Affects the gateway crate c-http Affects the http crate c-lavalink Affects the lavalink crate c-model Affects the model crate c-util Affects the util crate t-refactor Refactors APIs or code. labels Jan 18, 2023
@vilgotf
Copy link
Member

vilgotf commented Jan 18, 2023

Not that vec![] places the items directly on the heap whereas Vec::from([]) needs to copy the array from the stack to the heap which can cause performance degradations. vec![] also supports creating variable length vectors, i.e. let identified = vec![false; shards.len()]; compiles whereas let identified = Vec::from([false; shards.len()]); does not (example taken from next)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c-all Affects all crates or the project as a whole c-cache Affects the cache crate c-gateway Affects the gateway crate c-http Affects the http crate c-lavalink Affects the lavalink crate c-model Affects the model crate c-util Affects the util crate t-refactor Refactors APIs or code.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use clippy::disallowed_methods to warn on macros

3 participants