Skip to content

Commit

Permalink
analyze: pointer_id: better panic when indexing with PointerId::NONE
Browse files Browse the repository at this point in the history
  • Loading branch information
spernsteiner committed May 10, 2023
1 parent 8226b27 commit 853c1b7
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions c2rust-analyze/src/pointer_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ impl<'a, T> PointerTable<'a, T> {
impl<'a, T> Index<PointerId> for PointerTable<'a, T> {
type Output = T;
fn index(&self, id: PointerId) -> &T {
debug_assert!(!id.is_none());
if id.is_global() {
&self.global[id]
} else {
Expand Down Expand Up @@ -372,6 +373,7 @@ impl<'a, T> PointerTableMut<'a, T> {
impl<'a, T> Index<PointerId> for PointerTableMut<'a, T> {
type Output = T;
fn index(&self, id: PointerId) -> &T {
debug_assert!(!id.is_none());
if id.is_global() {
&self.global[id]
} else {
Expand All @@ -382,6 +384,7 @@ impl<'a, T> Index<PointerId> for PointerTableMut<'a, T> {

impl<'a, T> IndexMut<PointerId> for PointerTableMut<'a, T> {
fn index_mut(&mut self, id: PointerId) -> &mut T {
debug_assert!(!id.is_none());
if id.is_global() {
&mut self.global[id]
} else {
Expand Down Expand Up @@ -438,6 +441,7 @@ impl<T> OwnedPointerTable<T> {
impl<T> Index<PointerId> for OwnedPointerTable<T> {
type Output = T;
fn index(&self, id: PointerId) -> &T {
debug_assert!(!id.is_none());
if id.is_global() {
&self.global[id]
} else {
Expand All @@ -448,6 +452,7 @@ impl<T> Index<PointerId> for OwnedPointerTable<T> {

impl<T> IndexMut<PointerId> for OwnedPointerTable<T> {
fn index_mut(&mut self, id: PointerId) -> &mut T {
debug_assert!(!id.is_none());
if id.is_global() {
&mut self.global[id]
} else {
Expand Down

0 comments on commit 853c1b7

Please sign in to comment.