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

refactor: denylist macros #2072

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

zeylahellyer
Copy link
Member

@zeylahellyer zeylahellyer 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
2 participants