Skip to content

chore: Fix errors of clippy beta #20006

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

Merged
merged 3 commits into from
Apr 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/src/avm1/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl<'a> VariableDumper<'a> {
let ptr = object.as_ptr();

for (i, other) in self.objects.iter().enumerate() {
if *other == ptr {
if std::ptr::eq(*other, ptr) {
return (i, false);
}
}
Expand Down
4 changes: 2 additions & 2 deletions core/src/avm1/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ pub trait TObject<'gc>: 'gc + Collect<'gc> + Into<Object<'gc>> + Clone + Copy {
let mut proto = other.proto(activation);

while let Value::Object(proto_ob) = proto {
if self.as_ptr() == proto_ob.as_ptr() {
if std::ptr::eq(self.as_ptr(), proto_ob.as_ptr()) {
return true;
}

Expand Down Expand Up @@ -699,7 +699,7 @@ pub enum ObjectPtr {}

impl<'gc> Object<'gc> {
pub fn ptr_eq(a: Object<'gc>, b: Object<'gc>) -> bool {
a.as_ptr() == b.as_ptr()
std::ptr::eq(a.as_ptr(), b.as_ptr())
}
}

Expand Down
4 changes: 2 additions & 2 deletions core/src/avm2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ impl<'gc> Avm2<'gc> {
if self
.orphan_objects
.iter()
.all(|d| d.as_ptr() != dobj.as_ptr())
.all(|d| !std::ptr::eq(d.as_ptr(), dobj.as_ptr()))
{
self.orphan_objects_mut().push(dobj.downgrade());
}
Expand Down Expand Up @@ -493,7 +493,7 @@ impl<'gc> Avm2<'gc> {
for entry in bucket.iter() {
// Note: comparing pointers is correct because GcWeak keeps its allocation alive,
// so the pointers can't overlap by accident.
if entry.as_ptr() == object.as_ptr() {
if std::ptr::eq(entry.as_ptr(), object.as_ptr()) {
return;
}
}
Expand Down
9 changes: 3 additions & 6 deletions core/src/avm2/bytearray.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,9 +396,8 @@ impl ByteArrayStorage {

impl Write for ByteArrayStorage {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
self.write_bytes(buf).map_err(|_| {
io::Error::new(io::ErrorKind::Other, "Failed to write to ByteArrayStorage")
})?;
self.write_bytes(buf)
.map_err(|_| io::Error::other("Failed to write to ByteArrayStorage"))?;

Ok(buf.len())
}
Expand All @@ -412,9 +411,7 @@ impl Read for ByteArrayStorage {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
let bytes = self
.read_bytes(cmp::min(buf.len(), self.bytes_available()))
.map_err(|_| {
io::Error::new(io::ErrorKind::Other, "Failed to read from ByteArrayStorage")
})?;
.map_err(|_| io::Error::other("Failed to read from ByteArrayStorage"))?;
buf[..bytes.len()].copy_from_slice(bytes);
Ok(bytes.len())
}
Expand Down
15 changes: 8 additions & 7 deletions core/src/avm2/domain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ impl<'gc> Domain<'gc> {
}

pub fn is_playerglobals_domain(&self, avm2: &Avm2<'gc>) -> bool {
avm2.playerglobals_domain.0.as_ptr() == self.0.as_ptr()
std::ptr::eq(avm2.playerglobals_domain.0.as_ptr(), self.0.as_ptr())
}

pub fn children(&self, mc: &Mutation<'gc>) -> Vec<Domain<'gc>> {
Expand Down Expand Up @@ -341,11 +341,12 @@ impl<'gc> Domain<'gc> {

pub fn is_default_domain_memory(&self) -> bool {
let read = self.0.read();
read.domain_memory.expect("Missing domain memory").as_ptr()
== read
.default_domain_memory
.expect("Missing default domain memory")
.as_ptr()
let domain_memory_ptr = read.domain_memory.expect("Missing domain memory").as_ptr();
let default_domain_memory_ptr = read
.default_domain_memory
.expect("Missing default domain memory")
.as_ptr();
std::ptr::eq(domain_memory_ptr, default_domain_memory_ptr)
}

pub fn domain_memory(&self) -> ByteArrayObject<'gc> {
Expand Down Expand Up @@ -420,7 +421,7 @@ pub enum DomainPtr {}

impl PartialEq for Domain<'_> {
fn eq(&self, other: &Self) -> bool {
self.0.as_ptr() == other.0.as_ptr()
std::ptr::eq(self.0.as_ptr(), other.0.as_ptr())
}
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/avm2/filters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl ShaderObject for ObjectWrapper {

fn equals(&self, other: &dyn ShaderObject) -> bool {
if let Some(other_wrapper) = other.downcast_ref::<ObjectWrapper>() {
self.root.as_ptr() == other_wrapper.root.as_ptr()
std::ptr::eq(self.root.as_ptr(), other_wrapper.root.as_ptr())
} else {
false
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/avm2/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,7 @@ pub enum ObjectPtr {}

impl<'gc> Object<'gc> {
pub fn ptr_eq<T: TObject<'gc>>(a: T, b: T) -> bool {
a.as_ptr() == b.as_ptr()
std::ptr::eq(a.as_ptr(), b.as_ptr())
}

#[rustfmt::skip]
Expand Down
2 changes: 1 addition & 1 deletion core/src/bitmap/bitmap_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ mod wrapper {
self.0
.write(mc)
.display_objects
.retain(|c| c.as_ptr() != callback.as_ptr())
.retain(|c| !std::ptr::eq(c.as_ptr(), callback.as_ptr()))
}

pub fn add_display_object(&self, mc: &Mutation<'gc>, callback: DisplayObjectWeak<'gc>) {
Expand Down
9 changes: 3 additions & 6 deletions core/src/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use gc_arena::Collect;
use std::cmp::min;
use std::fmt::{Debug, Formatter, LowerHex, UpperHex};
use std::io::{Error as IoError, ErrorKind as IoErrorKind, Read, Result as IoResult};
use std::io::{Error as IoError, Read, Result as IoResult};
use std::ops::{Bound, Deref, RangeBounds};
use std::sync::{Arc, RwLock, RwLockReadGuard};
use thiserror::Error;
Expand Down Expand Up @@ -463,10 +463,7 @@ impl Read for SubstreamCursor {
let mut out_count = 0;
let buf_owned = self.substream.buf.clone();
let buf = buf_owned.0.read().map_err(|_| {
IoError::new(
IoErrorKind::Other,
"the underlying substream is locked by a panicked process",
)
IoError::other("the underlying substream is locked by a panicked process")
})?;

let chunks = self.substream.chunks.read().unwrap();
Expand Down Expand Up @@ -545,7 +542,7 @@ impl Deref for SliceRef<'_> {

impl PartialEq for SliceRef<'_> {
fn eq(&self, other: &SliceRef<'_>) -> bool {
self.guard.as_ptr() == other.guard.as_ptr()
std::ptr::eq(self.guard.as_ptr(), other.guard.as_ptr())
&& self.start == other.start
&& self.end == other.end
}
Expand Down
4 changes: 2 additions & 2 deletions core/src/debug_ui/display_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,7 @@ impl DisplayObjectWindow {
ui.end_row();

ui.label("AVM1 Root");
if object.avm1_root().as_ptr() != object.as_ptr() {
if !std::ptr::eq(object.avm1_root().as_ptr(), object.as_ptr()) {
open_display_object_button(
ui,
context,
Expand All @@ -987,7 +987,7 @@ impl DisplayObjectWindow {

ui.label("AVM2 Root");
if let Some(other) = object.avm2_root() {
if other.as_ptr() != object.as_ptr() {
if !std::ptr::eq(other.as_ptr(), object.as_ptr()) {
open_display_object_button(
ui,
context,
Expand Down
8 changes: 4 additions & 4 deletions core/src/debug_ui/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl Debug for DisplayObjectHandle {
impl PartialEq<DisplayObjectHandle> for DisplayObjectHandle {
#[inline(always)]
fn eq(&self, other: &DisplayObjectHandle) -> bool {
self.ptr == other.ptr
std::ptr::eq(self.ptr, other.ptr)
}
}

Expand Down Expand Up @@ -91,7 +91,7 @@ impl Debug for AVM1ObjectHandle {
impl PartialEq<AVM1ObjectHandle> for AVM1ObjectHandle {
#[inline(always)]
fn eq(&self, other: &AVM1ObjectHandle) -> bool {
self.ptr == other.ptr
std::ptr::eq(self.ptr, other.ptr)
}
}

Expand Down Expand Up @@ -134,7 +134,7 @@ impl Debug for AVM2ObjectHandle {
impl PartialEq<AVM2ObjectHandle> for AVM2ObjectHandle {
#[inline(always)]
fn eq(&self, other: &AVM2ObjectHandle) -> bool {
self.ptr == other.ptr
std::ptr::eq(self.ptr, other.ptr)
}
}

Expand Down Expand Up @@ -179,7 +179,7 @@ impl Debug for DomainHandle {
impl PartialEq<DomainHandle> for DomainHandle {
#[inline(always)]
fn eq(&self, other: &DomainHandle) -> bool {
self.ptr == other.ptr
std::ptr::eq(self.ptr, other.ptr)
}
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/display_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2557,7 +2557,7 @@ pub enum DisplayObjectPtr {}

impl<'gc> DisplayObject<'gc> {
pub fn ptr_eq(a: DisplayObject<'gc>, b: DisplayObject<'gc>) -> bool {
a.as_ptr() == b.as_ptr()
std::ptr::eq(a.as_ptr(), b.as_ptr())
}

pub fn option_ptr_eq(a: Option<DisplayObject<'gc>>, b: Option<DisplayObject<'gc>>) -> bool {
Expand Down
2 changes: 1 addition & 1 deletion core/src/display_object/interactive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ impl<'gc> Avm2MousePick<'gc> {

impl<'gc> InteractiveObject<'gc> {
pub fn ptr_eq<T: TInteractiveObject<'gc>>(a: T, b: T) -> bool {
a.as_displayobject().as_ptr() == b.as_displayobject().as_ptr()
std::ptr::eq(a.as_displayobject().as_ptr(), b.as_displayobject().as_ptr())
}

pub fn option_ptr_eq(
Expand Down
2 changes: 1 addition & 1 deletion core/src/display_object/loader_display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ impl<'gc> TInteractiveObject<'gc> for LoaderDisplay<'gc> {
.mouse_pick_avm2(context, point, require_button_mode)
.combine_with_parent((*self).into());
if let Avm2MousePick::Hit(target) = res {
if target.as_displayobject().as_ptr() == child.as_ptr() {
if std::ptr::eq(target.as_displayobject().as_ptr(), child.as_ptr()) {
if self.mouse_enabled() {
return Avm2MousePick::Hit((*self).into());
} else {
Expand Down
10 changes: 6 additions & 4 deletions core/src/font.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ impl FontFace {
);
Some(Glyph {
shape_handle: Default::default(),
shape: GlyphShape::Drawing(drawing),
shape: GlyphShape::Drawing(Box::new(drawing)),
advance,
character,
})
Expand Down Expand Up @@ -446,7 +446,9 @@ impl<'gc> Font<'gc> {
let glyph = Glyph {
shape_handle: None.into(),
advance: Twips::new(swf_glyph.advance.into()),
shape: GlyphShape::Swf(RefCell::new(SwfGlyphOrShape::Glyph(swf_glyph))),
shape: GlyphShape::Swf(RefCell::new(Box::new(SwfGlyphOrShape::Glyph(
swf_glyph,
)))),
character,
};

Expand Down Expand Up @@ -817,8 +819,8 @@ impl SwfGlyphOrShape {

#[derive(Debug, Clone)]
enum GlyphShape {
Swf(RefCell<SwfGlyphOrShape>),
Drawing(Drawing),
Swf(RefCell<Box<SwfGlyphOrShape>>),
Drawing(Box<Drawing>),
None,
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/streams.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ pub struct NetStream<'gc>(GcCell<'gc, NetStreamData<'gc>>);

impl PartialEq for NetStream<'_> {
fn eq(&self, other: &Self) -> bool {
self.0.as_ptr() == other.0.as_ptr()
std::ptr::eq(self.0.as_ptr(), other.0.as_ptr())
}
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/string/repr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ impl<'gc> AvmStringRepr<'gc> {
let first_requested = left_ptr.add(char_size * left.len());

let mut chars_available = 0;
if first_available == first_requested {
if std::ptr::eq(first_available, first_requested) {
let left_capacity_end =
left_origin_ptr.add(char_size * left_origin.capacity.get().len());
chars_available =
Expand Down
2 changes: 1 addition & 1 deletion desktop/src/player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ impl ActivePlayer {
tracing::warn!("{warning}");
}
}
content = PlayingContent::Bundle(movie_url.clone(), bundle);
content = PlayingContent::Bundle(movie_url.clone(), Box::new(bundle));
}
Err(BundleError::BundleDoesntExist)
| Err(BundleError::InvalidSource(BundleSourceError::UnknownSource)) => {
Expand Down
2 changes: 1 addition & 1 deletion frontend-utils/src/content.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use url::Url;

pub enum PlayingContent {
DirectFile(Url),
Bundle(Url, Bundle),
Bundle(Url, Box<Bundle>),
}

impl Debug for PlayingContent {
Expand Down
6 changes: 3 additions & 3 deletions render/webgl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,7 @@ impl WebGlRenderBackend {
// Set common render state, while minimizing unnecessary state changes.
// TODO: Using designated layout specifiers in WebGL2/OpenGL ES 3, we could guarantee that uniforms
// are in the same location between shaders, and avoid changing them unless necessary.
if program as *const ShaderProgram != self.active_program {
if !std::ptr::eq(program, self.active_program) {
self.gl.use_program(Some(&program.program));
self.active_program = program as *const ShaderProgram;

Expand Down Expand Up @@ -1299,7 +1299,7 @@ impl CommandHandler for WebGlRenderBackend {
// Set common render state, while minimizing unnecessary state changes.
// TODO: Using designated layout specifiers in WebGL2/OpenGL ES 3, we could guarantee that uniforms
// are in the same location between shaders, and avoid changing them unless necessary.
if program as *const ShaderProgram != self.active_program {
if !std::ptr::eq(program, self.active_program) {
self.gl.use_program(Some(&program.program));
self.active_program = program as *const ShaderProgram;

Expand Down Expand Up @@ -1391,7 +1391,7 @@ impl CommandHandler for WebGlRenderBackend {
// Set common render state, while minimizing unnecessary state changes.
// TODO: Using designated layout specifiers in WebGL2/OpenGL ES 3, we could guarantee that uniforms
// are in the same location between shaders, and avoid changing them unless necessary.
if program as *const ShaderProgram != self.active_program {
if !std::ptr::eq(program, self.active_program) {
self.gl.use_program(Some(&program.program));
self.active_program = program as *const ShaderProgram;

Expand Down
5 changes: 1 addition & 4 deletions scanner/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,7 @@ fn checkpoint<W: Write>(
writer.serialize(file_result).unwrap();

if has_error {
Err(std::io::Error::new(
std::io::ErrorKind::Other,
"Error encountered, test terminated",
))
Err(std::io::Error::other("Error encountered, test terminated"))
} else {
Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion swf/src/avm1/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl<'a> Reader<'a> {

// Verify that we parsed the correct amount of data.
let end_pos = (start.as_ptr() as usize + length) as *const u8;
if self.input.as_ptr() != end_pos {
if !std::ptr::eq(self.input.as_ptr(), end_pos) {
// We incorrectly parsed this action.
// Re-sync to the expected end of the action and throw an error.
self.input = &start[length.min(start.len())..];
Expand Down