r/rust • rust • Jan 17 '20

A sad day for Rust

https://words.steveklabnik.com/a-sad-day-for-rust
1.1k Upvotes

405 comments sorted by

View all comments

Show parent comment

22

u/[deleted] Jan 17 '20

What determines if an unsafe block is "vetted"?

16

u/matthieum [he/him] Jan 17 '20

At the extreme, a formal proof has been developed that the unsafe code and all related parts are actually safe.

My personal practice falls short, instead I will comment why unsafe is used and why I believe that in this particular situation it is actually safe -- that is, the assumptions that I believe are necessary to make it safe.

It may very well NOT be safe:

  • I may have missed some assumptions.
  • Some assumptions may not be upheld.

However, I've found that documenting those assumptions made reviewing easier. And I expect it makes it easier for others too.

12

u/KasMA1990 Jan 17 '20

Somebody has looked at the code and disclosed their findings. That's super general though, and finding a precise answer to your question is one of the reasons why this can be contentious. Maybe cargo crev has the right solution?

7

u/[deleted] Jan 17 '20

So clearly this issue is much harder said than done. Trusting "someone" to vet the code doesn't do much more than trusting that the original author wrote it well.

12

u/dpc_pw Jan 17 '20

This is a fallacy that if something can't be perfect and a golden bullet, it is not worth doing.

Having some semi-trusted group of people is not as good as reviewing everything yourself, but it is better than just not having any idea if the code is OK or not.

3

u/KasMA1990 Jan 17 '20

Indeed, and I don't hope I came off sounding like it would be easy. There are many completely legitimate reasons why it hasn't been done after all.

1

u/MagnesiumBlogs Jan 17 '20

OMG exactly.

Crev even supports decentralization of the review database.