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

Forbid unsafe code in the HASH graph #1064

Merged
merged 2 commits into from
Sep 15, 2022
Merged

Conversation

TimDiekmann
Copy link
Member

@TimDiekmann TimDiekmann commented Sep 15, 2022

🌟 What is the purpose of this PR?

We don't use any unsafe code in the HASH graph datastore, and we should avoid it if not strictly necessary. Forbidding unsafe also implies, that we don't require to run miri on CI, which (a) speeds up CI and (b) allows us to use toolchains, where miri is not available.

🔍 What does this change?

  • Forbid unsafe code (#![deny(...)] allows further #![allow] statements, #![forbid(...) does not)
  • Disable miri

📜 Does this require a change to the docs?

Next to the statement, I put a comment on how we want to proceed, if we require unsafe: We should prefer #![deny(...)] over removing the statement, unless this gets too verbose.

📹 Demo

error: declaration of an `unsafe` function
  --> lib/graph/src/lib.rs:78:1
   |
78 | unsafe fn test() {}
   | ^^^^^^^^^^^^^^^^^^^
   |
   = note: At the current state, unsafe code should be avoided
note: the lint level is defined here
  --> lib/graph/src/lib.rs:54:5
   |
54 |     unsafe_code,
   |     ^^^^^^^^^^^
error[E0453]: expect(unsafe_code) incompatible with previous forbid
  --> lib/graph/src/lib.rs:78:10
   |
54 |     unsafe_code,
   |     ----------- `forbid` level set here
...
78 | #[expect(unsafe_code)]
   |          ^^^^^^^^^^^ overruled by previous forbid
   |
   = note: At the current state, unsafe code should be avoided

@TimDiekmann TimDiekmann requested a review from a team September 15, 2022 08:09
@vilkinsons vilkinsons changed the title Forbid unsafe code Forbid unsafe code in the HASH graph datastore Sep 15, 2022
@Alfred-Mountfield Alfred-Mountfield changed the title Forbid unsafe code in the HASH graph datastore Forbid unsafe code in the HASH graph Sep 15, 2022
Co-authored-by: Alfred Mountfield <am@hash.ai>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/eng > backend Owned by the @backend team
Development

Successfully merging this pull request may close these issues.

None yet

3 participants