diff --git a/chat-cli/src/main.rs b/chat-cli/src/main.rs index d01c87aa49..00d609ab7a 100644 --- a/chat-cli/src/main.rs +++ b/chat-cli/src/main.rs @@ -1,3 +1,5 @@ +#![deny(unsafe_code)] + use client::{Client, Event}; use common::{clock::Clock, comp}; use log::{error, info}; diff --git a/client/src/lib.rs b/client/src/lib.rs index 37d70a6011..00f64c5025 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -1,3 +1,4 @@ +#![deny(unsafe_code)] #![feature(label_break_value, duration_float, euclidean_division)] pub mod error; diff --git a/common/src/lib.rs b/common/src/lib.rs index e128100c78..9a16148edf 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -1,3 +1,4 @@ +#![deny(unsafe_code)] #![type_length_limit = "1664759"] #![feature( euclidean_division, diff --git a/common/src/terrain/chonk.rs b/common/src/terrain/chonk.rs index 42541166e2..b365ae5357 100644 --- a/common/src/terrain/chonk.rs +++ b/common/src/terrain/chonk.rs @@ -122,40 +122,6 @@ impl ReadVol for Chonk { } } } - - #[inline(always)] - unsafe fn get_unchecked(&self, pos: Vec3) -> &Block { - if pos.z < self.z_offset { - // Below the terrain - &self.below - } else if pos.z >= self.z_offset + SUB_CHUNK_HEIGHT as i32 * self.sub_chunks.len() as i32 { - // Above the terrain - &self.above - } else { - // Within the terrain - - let sub_chunk_idx = self.sub_chunk_idx(pos.z); - - match &self.sub_chunks[sub_chunk_idx] { - // Can't fail - SubChunk::Homogeneous(block) => block, - SubChunk::Hash(cblock, map) => { - let rpos = pos - - Vec3::unit_z() - * (self.z_offset + sub_chunk_idx as i32 * SUB_CHUNK_HEIGHT as i32); - - map.get(&rpos.map(|e| e as u8)).unwrap_or(cblock) - } - SubChunk::Heterogeneous(chunk) => { - let rpos = pos - - Vec3::unit_z() - * (self.z_offset + sub_chunk_idx as i32 * SUB_CHUNK_HEIGHT as i32); - - chunk.get_unchecked(rpos) - } - } - } - } } impl WriteVol for Chonk { diff --git a/common/src/vol.rs b/common/src/vol.rs index 266a3193a9..f77e696bc4 100644 --- a/common/src/vol.rs +++ b/common/src/vol.rs @@ -72,10 +72,6 @@ pub trait ReadVol: BaseVol { /// Get a reference to the voxel at the provided position in the volume. fn get(&self, pos: Vec3) -> Result<&Self::Vox, Self::Err>; - unsafe fn get_unchecked(&self, pos: Vec3) -> &Self::Vox { - self.get(pos).unwrap() - } - fn ray( &self, from: Vec3, diff --git a/common/src/volumes/chunk.rs b/common/src/volumes/chunk.rs index 9386485297..0168686278 100644 --- a/common/src/volumes/chunk.rs +++ b/common/src/volumes/chunk.rs @@ -60,11 +60,6 @@ impl ReadVol for Chunk { .and_then(|idx| self.vox.get(idx)) .ok_or(ChunkErr::OutOfBounds) } - - #[inline(always)] - unsafe fn get_unchecked(&self, pos: Vec3) -> &V { - self.vox.get_unchecked(Self::idx_for_unchecked(pos)) - } } impl WriteVol for Chunk { diff --git a/common/src/volumes/dyna.rs b/common/src/volumes/dyna.rs index e88ccd3de7..4acebe6f1e 100644 --- a/common/src/volumes/dyna.rs +++ b/common/src/volumes/dyna.rs @@ -57,12 +57,6 @@ impl ReadVol for Dyna { .and_then(|idx| self.vox.get(idx)) .ok_or(DynaErr::OutOfBounds) } - - #[inline(always)] - unsafe fn get_unchecked(&self, pos: Vec3) -> &V { - self.vox - .get_unchecked(Self::idx_for_unchecked(self.sz, pos)) - } } impl WriteVol for Dyna { diff --git a/common/src/volumes/vol_map_2d.rs b/common/src/volumes/vol_map_2d.rs index b3ba4d3d9d..86fac2c251 100644 --- a/common/src/volumes/vol_map_2d.rs +++ b/common/src/volumes/vol_map_2d.rs @@ -60,13 +60,6 @@ impl ReadVol for VolMap2d { chunk.get(co).map_err(VolMap2dErr::ChunkErr) }) } - - #[inline(always)] - unsafe fn get_unchecked(&self, pos: Vec3) -> &V::Vox { - let ck = Self::chunk_key(pos); - let co = Self::chunk_offs(pos); - self.chunks.get(&ck).unwrap().get_unchecked(co) - } } // TODO: This actually breaks the API: samples are supposed to have an offset of zero! diff --git a/server-cli/src/main.rs b/server-cli/src/main.rs index 8f3cec9130..feafbdd6d0 100644 --- a/server-cli/src/main.rs +++ b/server-cli/src/main.rs @@ -1,3 +1,5 @@ +#![deny(unsafe_code)] + use common::clock::Clock; use heaptrack::track_mem; use log::info; diff --git a/server/src/lib.rs b/server/src/lib.rs index 6d36427b2e..1a1db64ab9 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -1,3 +1,4 @@ +#![deny(unsafe_code)] #![feature(drain_filter, bind_by_move_pattern_guards)] pub mod auth_provider; diff --git a/voxygen/src/main.rs b/voxygen/src/main.rs index 0822fe73bb..d345ad05ae 100644 --- a/voxygen/src/main.rs +++ b/voxygen/src/main.rs @@ -1,3 +1,4 @@ +#![deny(unsafe_code)] #![feature(duration_float, drain_filter)] #![recursion_limit = "2048"] diff --git a/world/src/lib.rs b/world/src/lib.rs index e9273d34e1..d3de575a89 100644 --- a/world/src/lib.rs +++ b/world/src/lib.rs @@ -1,3 +1,4 @@ +#![deny(unsafe_code)] #![feature(euclidean_division, bind_by_move_pattern_guards, option_flattening)] mod all;