Skip to content

Commit

Permalink
Migrate to Rust 1.61.0 (+WSL fixes) (#1849)
Browse files Browse the repository at this point in the history
  • Loading branch information
R3DP1XL authored Jun 1, 2022
1 parent ae63a06 commit 672d644
Show file tree
Hide file tree
Showing 26 changed files with 560 additions and 583 deletions.
2 changes: 1 addition & 1 deletion .monorepo/lints.toml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ warn = [
"clippy::suspicious_operation_groupings",
"clippy::trailing_empty_array",
"clippy::trivial_regex",
"clippy::use_self",
# "clippy::use_self", // disabling for Rust 1.61, see https://github.com/rust-lang/rust-clippy/issues/6902
"clippy::useless_let_if_seq",
"clippy::useless_transmute",
# Clippy restriction lints, usually not considered bad, but useful in specific cases
Expand Down
7 changes: 0 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<a href="https://github.com/legion-labs/legion/actions/workflows/ci_test.yml"><img src="https://github.com/legion-labs/legion/actions/workflows/ci_test.yml/badge.svg" alt="CI - Test" style="max-width: 100%;"></a>
<a href="https://github.com/legion-labs/legion/actions/workflows/release.yml"><img src="https://github.com/legion-labs/legion/actions/workflows/release.yml/badge.svg" alt="CI - Release" style="max-width: 100%;"></a>
<a href="https://cov.legionengine.com/index.html" rel="nofollow"><img src="https://github.com/legion-labs/legion/raw/main/.github/images/coverage.svg" alt="Coverage" style="max-width: 100%;"></a>
<a href="https://www.rust-lang.org/tools/install"><img src="https://img.shields.io/badge/msrv-1.60.0-green" alt="MSRV" style="max-width: 100%;"></a></p>
<a href="https://www.rust-lang.org/tools/install"><img src="https://img.shields.io/badge/msrv-1.61.0-green" alt="MSRV" style="max-width: 100%;"></a></p>
</p>

<p align="center">
Expand Down
16 changes: 8 additions & 8 deletions crates/lgn-api-codegen/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,14 +195,14 @@ pub enum Method {
impl std::fmt::Display for Method {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(match self {
Method::Get => "GET",
Method::Post => "POST",
Method::Delete => "DELETE",
Method::Put => "PUT",
Method::Patch => "PATCH",
Method::Head => "HEAD",
Method::Options => "OPTIONS",
Method::Trace => "TRACE",
Self::Get => "GET",
Self::Post => "POST",
Self::Delete => "DELETE",
Self::Put => "PUT",
Self::Patch => "PATCH",
Self::Head => "HEAD",
Self::Options => "OPTIONS",
Self::Trace => "TRACE",
})
}
}
Expand Down
1 change: 0 additions & 1 deletion crates/lgn-async/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ lgn-app = { path = "../lgn-app", version = "0.1.0" }
lgn-tracing = { path = "../lgn-tracing", version = "0.1.0" }
lgn-tasks = { path = "../lgn-tasks", version = "0.1.0" }
tokio = { version = "1.13", features = ["full", "tracing"] }
retain_mut = "0.1"
futures-lite = "1.12"

[dev-dependencies]
Expand Down
4 changes: 1 addition & 3 deletions crates/lgn-async/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,7 @@ impl TokioAsyncRuntime {
pub fn poll(&mut self) -> u32 {
let mut num_completed = 0;

// TODO: #1886 Fix after we move to 1.61
#[allow(deprecated)]
retain_mut::RetainMut::retain_mut(&mut self.result_handlers, |handler| {
self.result_handlers.retain_mut(|handler| {
let is_complete = handler.try_complete();

if is_complete {
Expand Down
2 changes: 1 addition & 1 deletion crates/lgn-content-store/src/content_providers/hash_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub enum HashAlgorithm {
impl Display for HashAlgorithm {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
HashAlgorithm::Blake3 => write!(f, "blake3"),
Self::Blake3 => write!(f, "blake3"),
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/lgn-data-codegen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ impl GenerationType {
/// Returns the name of the generation type
pub fn name(self) -> &'static str {
match self {
GenerationType::OfflineFormat => "offline",
GenerationType::RuntimeFormat => "runtime",
Self::OfflineFormat => "offline",
Self::RuntimeFormat => "runtime",
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions crates/lgn-data-compiler/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ pub enum Target {
impl fmt::Display for Target {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
Target::Game => write!(f, "game"),
Target::Server => write!(f, "server"),
Target::Backend => write!(f, "backend"),
Self::Game => write!(f, "game"),
Self::Server => write!(f, "server"),
Self::Backend => write!(f, "backend"),
}
}
}
Expand Down Expand Up @@ -141,9 +141,9 @@ pub enum Platform {
impl fmt::Display for Platform {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
Platform::Windows => write!(f, "windows"),
Platform::Unix => write!(f, "unix"),
Platform::ConsoleX => write!(f, "consolex"),
Self::Windows => write!(f, "windows"),
Self::Unix => write!(f, "unix"),
Self::ConsoleX => write!(f, "consolex"),
}
}
}
Expand Down
16 changes: 8 additions & 8 deletions crates/lgn-data-model/src/array_descriptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,23 +66,23 @@ macro_rules! implement_array_descriptor {
static ref ARRAY_DESCRIPTOR: $crate::ArrayDescriptor = $crate::ArrayDescriptor {
base_descriptor : $crate::create_base_descriptor!(Vec<$type_id>, concat!("Vec<",stringify!($type_id),">").into(), Result::<Vec::<$type_id>, $crate::ReflectionError>::Ok(Vec::<$type_id>::new())),
inner_type: <$type_id as $crate::TypeReflection>::get_type_def(),
len: |array: *const ()| unsafe { (*(array as *const Vec<$type_id>)).len() },
len: |array: *const ()| unsafe { (*array.cast::<Vec<$type_id>>()).len() },
get: |array: *const (), index: usize| unsafe {
(*(array as *const Vec<$type_id>))
(*array.cast::<Vec<$type_id>>())
.get(index).ok_or_else(|| $crate::ReflectionError::InvalidArrayIndex(index, concat!("Vec<",stringify!($type_id),">")))
.and_then(|value| Ok((value as *const $type_id).cast::<()>()))
},
get_mut:|array: *mut (), index: usize| unsafe {
(*(array as *mut Vec<$type_id>))
(*array.cast::<Vec<$type_id>>())
.get_mut(index).ok_or_else(|| $crate::ReflectionError::InvalidArrayIndex(index, concat!("Vec<",stringify!($type_id),">")))
.and_then(|value| Ok((value as *mut $type_id).cast::<()>()))
},
clear:|array: *mut ()| unsafe {
(*(array as *mut Vec<$type_id>)).clear();
(*array.cast::<Vec<$type_id>>()).clear();
},

insert_element : |array: *mut(), index : Option<usize>, deserializer: &mut dyn::erased_serde::Deserializer<'_>| unsafe {
let array = &mut (*(array as *mut Vec<$type_id>));
let array = &mut (*array.cast::<Vec<$type_id>>());
let new_element : $type_id = ::erased_serde::deserialize(deserializer)
.map_err(|err|$crate::utils::ReflectionError::ErrorErasedSerde(err))?;

Expand All @@ -95,7 +95,7 @@ macro_rules! implement_array_descriptor {
},

delete_element : |array: *mut(), index : usize, old_value_ser: Option<&mut dyn::erased_serde::Serializer> | unsafe {
let array = &mut (*(array as *mut Vec<$type_id>));
let array = &mut (*array.cast::<Vec<$type_id>>());
if index >= array.len() {
return Err($crate::ReflectionError::InvalidArrayIndex(index, concat!("Vec<",stringify!($type_id),">")));
}
Expand All @@ -107,7 +107,7 @@ macro_rules! implement_array_descriptor {
Ok(())
},
reorder_element : |array: *mut(), old_index : usize, new_index : usize | unsafe {
let array = &mut (*(array as *mut Vec<$type_id>));
let array = &mut (*array.cast::<Vec<$type_id>>());
if old_index >= array.len() {
return Err($crate::ReflectionError::InvalidArrayIndex(old_index, concat!("Vec<",stringify!($type_id),">")));
}
Expand All @@ -123,7 +123,7 @@ macro_rules! implement_array_descriptor {
let value_to_delete = ::erased_serde::deserialize::<$type_id>(value_de)
.map_err(|err| $crate::ReflectionError::ErrorErasedSerde(err))?;

let array = &mut (*(array as *mut Vec<$type_id>));
let array = &mut (*array.cast::<Vec<$type_id>>());
if let Some((old_value,index)) = $crate::array_remove_value(array,&value_to_delete) {
if let Some(serializer) = old_value_ser {
::erased_serde::serialize(&old_value, serializer)
Expand Down
4 changes: 2 additions & 2 deletions crates/lgn-data-model/src/option_descriptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ macro_rules! implement_option_descriptor {
Result::<Option::<$type_id>, $crate::ReflectionError>::Ok(Option::<$type_id>::None)),
inner_type: <$type_id as $crate::TypeReflection>::get_type_def(),
get_inner: |option: *const ()| unsafe {
(*(option as *const Option<$type_id>))
(*option.cast::<Option<$type_id>>())
.as_ref()
.map(|val| (val as *const $type_id).cast::<()>())
},
get_inner_mut: |option: *mut ()| unsafe {
(*(option as *mut Option<$type_id>))
(*option.cast::<Option<$type_id>>())
.as_mut()
.map(|val| (val as *mut $type_id).cast::<()>())
},
Expand Down
38 changes: 14 additions & 24 deletions crates/lgn-data-model/src/type_reflection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,25 +47,17 @@ impl TypeDefinition {
/// Return the name of the type
pub fn get_type_name(&self) -> &str {
match *self {
TypeDefinition::Array(array_descriptor) => {
array_descriptor.base_descriptor.type_name.as_str()
}
TypeDefinition::Struct(struct_descriptor) => {
struct_descriptor.base_descriptor.type_name.as_str()
}
TypeDefinition::Primitive(primitive_descriptor) => {
Self::Array(array_descriptor) => array_descriptor.base_descriptor.type_name.as_str(),
Self::Struct(struct_descriptor) => struct_descriptor.base_descriptor.type_name.as_str(),
Self::Primitive(primitive_descriptor) => {
primitive_descriptor.base_descriptor.type_name.as_str()
}
TypeDefinition::Option(option_descriptor) => {
option_descriptor.base_descriptor.type_name.as_str()
}
TypeDefinition::BoxDyn(box_dyn_descriptor) => {
Self::Option(option_descriptor) => option_descriptor.base_descriptor.type_name.as_str(),
Self::BoxDyn(box_dyn_descriptor) => {
box_dyn_descriptor.base_descriptor.type_name.as_str()
}
TypeDefinition::Enum(enum_descriptor) => {
enum_descriptor.base_descriptor.type_name.as_str()
}
TypeDefinition::None => "None",
Self::Enum(enum_descriptor) => enum_descriptor.base_descriptor.type_name.as_str(),
Self::None => "None",
}
}

Expand All @@ -75,27 +67,25 @@ impl TypeDefinition {
serializer: &mut dyn ::erased_serde::Serializer,
) -> Result<(), crate::ReflectionError> {
match *self {
TypeDefinition::Array(array_descriptor) => {
Self::Array(array_descriptor) => {
(array_descriptor.base_descriptor.serialize_new_instance)(serializer)
}
TypeDefinition::Struct(struct_descriptor) => {
Self::Struct(struct_descriptor) => {
(struct_descriptor.base_descriptor.serialize_new_instance)(serializer)
}
TypeDefinition::Primitive(primitive_descriptor) => {
Self::Primitive(primitive_descriptor) => {
(primitive_descriptor.base_descriptor.serialize_new_instance)(serializer)
}
TypeDefinition::Option(option_descriptor) => {
Self::Option(option_descriptor) => {
(option_descriptor.base_descriptor.serialize_new_instance)(serializer)
}
TypeDefinition::BoxDyn(box_dyn_descriptor) => {
Self::BoxDyn(box_dyn_descriptor) => {
(box_dyn_descriptor.base_descriptor.serialize_new_instance)(serializer)
}
TypeDefinition::Enum(enum_descriptor) => {
Self::Enum(enum_descriptor) => {
(enum_descriptor.base_descriptor.serialize_new_instance)(serializer)
}
TypeDefinition::None => {
Err(crate::ReflectionError::InvalidTypeDescriptor("None".into()))
}
Self::None => Err(crate::ReflectionError::InvalidTypeDescriptor("None".into())),
}
}
}
10 changes: 5 additions & 5 deletions crates/lgn-graphics-api/src/backends/vulkan/device_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ impl PhysicalDeviceType {
/// Convert to `vk::PhysicalDeviceType`
pub(crate) fn to_vk(self) -> vk::PhysicalDeviceType {
match self {
PhysicalDeviceType::Other => vk::PhysicalDeviceType::OTHER,
PhysicalDeviceType::IntegratedGpu => vk::PhysicalDeviceType::INTEGRATED_GPU,
PhysicalDeviceType::DiscreteGpu => vk::PhysicalDeviceType::DISCRETE_GPU,
PhysicalDeviceType::VirtualGpu => vk::PhysicalDeviceType::VIRTUAL_GPU,
PhysicalDeviceType::Cpu => vk::PhysicalDeviceType::CPU,
Self::Other => vk::PhysicalDeviceType::OTHER,
Self::IntegratedGpu => vk::PhysicalDeviceType::INTEGRATED_GPU,
Self::DiscreteGpu => vk::PhysicalDeviceType::DISCRETE_GPU,
Self::VirtualGpu => vk::PhysicalDeviceType::VIRTUAL_GPU,
Self::Cpu => vk::PhysicalDeviceType::CPU,
}
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/lgn-graphics-api/src/backends/vulkan/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ impl Queue {
Ok(PresentSuccessResult::Success)
}
}
#[allow(clippy::match_single_binding)]
Err(e) => match e {
// todo(jal)
//GfxError::VkError(vk::Result::ERROR_OUT_OF_DATE_KHR) => {
Expand Down
8 changes: 4 additions & 4 deletions crates/lgn-graphics-api/src/backends/vulkan/swapchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ impl VkPresentMode {
/// Convert to `vk::PresentModeKHR`
pub fn to_vk(self) -> vk::PresentModeKHR {
match self {
VkPresentMode::Immediate => vk::PresentModeKHR::IMMEDIATE,
VkPresentMode::Mailbox => vk::PresentModeKHR::MAILBOX,
VkPresentMode::Fifo => vk::PresentModeKHR::FIFO,
VkPresentMode::FifoRelaxed => vk::PresentModeKHR::FIFO_RELAXED,
Self::Immediate => vk::PresentModeKHR::IMMEDIATE,
Self::Mailbox => vk::PresentModeKHR::MAILBOX,
Self::Fifo => vk::PresentModeKHR::FIFO,
Self::FifoRelaxed => vk::PresentModeKHR::FIFO_RELAXED,
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion crates/lgn-graphics-api/src/device_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ pub(crate) struct DeviceContextInner {

impl std::fmt::Debug for DeviceContext {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("DeviceContext").field("handle", &0).finish()
f.debug_struct("DeviceContext")
.field("handle", &0_u64)
.finish()
}
}

Expand Down
4 changes: 2 additions & 2 deletions crates/lgn-graphics-api/src/shader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ pub enum ShaderPackage {
impl ShaderPackage {
pub fn module_def(&self) -> ShaderModuleDef<'_> {
match self {
ShaderPackage::SpirV(bytes) => ShaderModuleDef::SpirVBytes(bytes),
ShaderPackage::Null => ShaderModuleDef::Null(PhantomData::default()),
Self::SpirV(bytes) => ShaderModuleDef::SpirVBytes(bytes),
Self::Null => ShaderModuleDef::Null(PhantomData::default()),
}
}
}
Expand Down
Loading

0 comments on commit 672d644

Please sign in to comment.