-
Notifications
You must be signed in to change notification settings - Fork 61
Update to Rust 1.53.0 #559
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
New clippy warnings. Fixed most of the easy ones, but some will require more thought. For example this one:
This occurs because the code is duplicated, it wants to pull out the last line of the if and else bodies: let chunk = if new {
self.chunks.insert(cpos, Chunk::new(cpos));
self.chunks.get_mut(&cpos).unwrap()
} else {
if !self.chunks.contains_key(&cpos) {
return Ok(());
}
self.chunks.get_mut(&cpos).unwrap()
};
if new {
self.chunks.insert(cpos, Chunk::new(cpos));
} else {
if !self.chunks.contains_key(&cpos) {
return Ok(());
}
};
let chunk = self.chunks.get_mut(&cpos).unwrap() because the |
The other clippy issue, this time an error, is:
impl ComponentMem {
fn new<T>() -> ComponentMem {
ComponentMem {
data: vec![],
component_size: mem::size_of::<T>(),
drop_func: Box::new(|data| unsafe {
let mut val: T = mem::MaybeUninit::uninit().assume_init();
ptr::copy(data as *mut T, &mut val, 1);
mem::drop(val);
}),
}
} git blame shows this code was last changed in 518b6a07 Reformat all source with cargo fmt. Before reformatting, mem::MaybeUninit::uninit was added in 8502c03 "Update to Rust 1.40.0. Closes #253" --- a/src/ecs/mod.rs
+++ b/src/ecs/mod.rs
@@ -481,7 +481,7 @@ impl ComponentMem {
component_size: mem::size_of::<T>(),
drop_func: Box::new(|data| {
unsafe {
- let mut val: T = mem::uninitialized();
+ let mut val: T = mem::MaybeUninit::uninit().assume_init();
ptr::copy(data as *mut T, &mut val, 1);
mem::drop(val);
} This is in The lint was added in rust-lang/rust-clippy#4272
Sure enough, I added this in #253 (comment) for this reason, and the GitHub query results for this anti-pattern includes this project. The author continues:
|
ce75a0b
to
dbdbaba
Compare
https://blog.rust-lang.org/2021/03/25/Rust-1.51.0.html#cargos-new-feature-resolver In my testing, the target release binary is 136 bytes smaller (insignificant).
No description provided.