Skip to content

Commit

Permalink
chore: add lints to papyrus_common (#1783)
Browse files Browse the repository at this point in the history
* chore: add free inherit lints in crates

All crates not inheriting from workspace lints fail the workspace lints
and will be handled separately.

Motivation: consistent linting across project and in the CI.

Note: found an unrelated cargo doc bug in starknet_api_test_utils,
not sure why this wasn't triggered thus far, lints are unrelated.

* chore: add lints to papyrus_common

Lior banned `as` repo-wide, unless absolutely necessary.

Nearly all `as` uses can be replaced with `[Try]From` which doesn't have
implicit coercions like `as` (we encountered several bugs due to these
coersions).

Motivation: we are standardizing lints across the repo and CI, instead
of each crate having separate sets of lints.

Co-Authored-By: Gilad Chase <[email protected]>
  • Loading branch information
giladchase and Gilad Chase authored Nov 4, 2024
1 parent 18d6b55 commit 7e95594
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions crates/papyrus_common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ assert_matches.workspace = true
papyrus_test_utils.workspace = true
pretty_assertions.workspace = true
serde_json = { workspace = true, features = ["arbitrary_precision"] }

[lints]
workspace = true
2 changes: 1 addition & 1 deletion crates/papyrus_common/src/python_json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl Formatter for PythonJsonFormatter {
let mut buf = [0u16; 2];
for ch in fragment.chars() {
if ch.is_ascii() {
writer.write_all(&[ch as u8])?;
writer.write_all(&[u8::try_from(ch).expect("ASCII fits in u8")])?;
} else {
let slice = ch.encode_utf16(&mut buf);
for num in slice {
Expand Down

0 comments on commit 7e95594

Please sign in to comment.