zerocopy: Prevent panics statically
Issues like #200 demonstrate that the compiler is sometimes not smart enough to optimize out panics that we can prove statically won’t happen. It would be good if we could:
- Refactor to only use operations which don’t include panicking in their call graph
- Validate this in CI
Mentoring instructions
- Easy steps
- Create a new step in this CI job that runs Red Pen on zerocopy, only running the step under
if: matrix.crate == 'zerocopy' && matrix.toolchain == 'nightly' - Annotate as many functions as possible with
#[redpen::dont_panic]
- Create a new step in this CI job that runs Red Pen on zerocopy, only running the step under
- Medium to hard (depending on the code): Refactor as much code as possible to remove all panics
About this issue
- Original URL
- State: open
- Created 3 years ago
- Comments: 22 (18 by maintainers)
Commits related to this issue
- Enable `clippy::expect_used`, address warnings This enables Clippy's [`expect_used`](https://rust-lang.github.io/rust-clippy/master/index.html#/expect_used) lint, which errors on calls to `Option::ex... — committed to jrvanwhy/zerocopy by deleted user 3 years ago
- Enable `clippy::expect_used`, address warnings This enables Clippy's [`expect_used`](https://rust-lang.github.io/rust-clippy/master/index.html#/expect_used) lint, which errors on calls to `Option::ex... — committed to jrvanwhy/zerocopy by deleted user 3 years ago
- Enable `clippy::expect_used`, address warnings This enables Clippy's [`expect_used`](https://rust-lang.github.io/rust-clippy/master/index.html#/expect_used) lint, which errors on calls to `Option::ex... — committed to jrvanwhy/zerocopy by deleted user 3 years ago
- Enable `clippy::expect_used`, address warnings This enables Clippy's [`expect_used`](https://rust-lang.github.io/rust-clippy/master/index.html#/expect_used) lint, which errors on calls to `Option::ex... — committed to jrvanwhy/zerocopy by deleted user 3 years ago
- Enable `clippy::expect_used`, address warnings This enables Clippy's [`expect_used`](https://rust-lang.github.io/rust-clippy/master/index.html#/expect_used) lint, which errors on calls to `Option::ex... — committed to jrvanwhy/zerocopy by deleted user 3 years ago
- Enable `clippy::expect_used`, address warnings This enables Clippy's [`expect_used`](https://rust-lang.github.io/rust-clippy/master/index.html#/expect_used) lint, which errors on calls to `Option::ex... — committed to jrvanwhy/zerocopy by deleted user 3 years ago
- Enable `clippy::expect_used`, address warnings This enables Clippy's [`expect_used`](https://rust-lang.github.io/rust-clippy/master/index.html#/expect_used) lint, which errors on calls to `Option::ex... — committed to jrvanwhy/zerocopy by deleted user 3 years ago
- Add `SplitByteSlice::{try_split_at, split_at_unchecked}` Given the importance of avoiding panic paths to some of our customers, we should, as a rule, avoid only offering (or relying upon) APIs with p... — committed to google/zerocopy by jswrenn 3 years ago
- Add `SplitByteSlice::{try_split_at, split_at_unchecked}` Given the importance of avoiding panic paths to some of our customers, we should, as a rule, avoid only offering (or relying upon) APIs with p... — committed to google/zerocopy by jswrenn 3 years ago
- Enable `clippy::expect_used`, address warnings This enables Clippy's [`expect_used`](https://rust-lang.github.io/rust-clippy/master/index.html#/expect_used) lint, which errors on calls to `Option::ex... — committed to jrvanwhy/zerocopy by deleted user 3 years ago
- Enable `clippy::expect_used`, address warnings This enables Clippy's [`expect_used`](https://rust-lang.github.io/rust-clippy/master/index.html#/expect_used) lint, which errors on calls to `Option::ex... — committed to jrvanwhy/zerocopy by deleted user 3 years ago
- Add `SplitByteSlice::{try_split_at, split_at_unchecked}` Given the importance of avoiding panic paths to some of our customers, we should, as a rule, avoid only offering (or relying upon) APIs with p... — committed to google/zerocopy by jswrenn 3 years ago
- Add `SplitByteSlice::split_at_unchecked` Given the importance of avoiding panic paths to some of our customers, we should, as a rule, avoid only offering (or relying upon) APIs with panic paths. Rel... — committed to google/zerocopy by jswrenn 3 years ago
- Replace a panic in `IntoBytes::write_to_suffix` with an error branch. This panic is unreachable. Panicing is heavyweight, so we're trying to reduce panics (issue #202). This PR replaces the panic wit... — committed to jrvanwhy/zerocopy by deleted user 3 years ago
- Replace a panic with an error branch This panic is unreachable. Panicing is heavyweight, so we're trying to reduce panics (issue #202). This PR replaces the panic with a branch that should be lighter... — committed to jrvanwhy/zerocopy by deleted user 3 years ago
- Replace a panic with an error branch This panic is unreachable. Panicing is heavyweight, so we're trying to reduce panics (issue #202). This PR replaces the panic with a branch that should be lighter... — committed to jrvanwhy/zerocopy by deleted user 3 years ago
- Add `SplitByteSlice::split_at_unchecked` Given the importance of avoiding panic paths to some of our customers, we should, as a rule, avoid only offering (or relying upon) APIs with panic paths. Rel... — committed to google/zerocopy by jswrenn 3 years ago
- Add `SplitByteSlice::split_at_unchecked` Given the importance of avoiding panic paths to some of our customers, we should, as a rule, avoid only offering (or relying upon) APIs with panic paths. Rel... — committed to google/zerocopy by jswrenn 3 years ago
- Add `SplitByteSlice::split_at_unchecked` Given the importance of avoiding panic paths to some of our customers, we should, as a rule, avoid only offering (or relying upon) APIs with panic paths. Rel... — committed to google/zerocopy by jswrenn 3 years ago
- Replace a panic with an error branch This panic is unreachable. Panicing is heavyweight, so we're trying to reduce panics (issue #202). This PR replaces the panic with a branch that should be lighter... — committed to jrvanwhy/zerocopy by deleted user 3 years ago
IIUC https://github.com/estebank/redpen/commit/887ea4fde5839b7d041d367f30009fe6d4161e39 should fix the specific example provided in https://github.com/google/zerocopy/issues/202#issuecomment-1769693893
Awesome, thanks! I’ll assign it to you. Feel free to comment here if you have any questions.