clippy: Fix default_constructed_unit_structs warnings in components (#31827)

* clippy: Fix default constructed unit structs warnings

* refactor: Allow default constructed unit structs to avoid gfx build error
This commit is contained in:
Oluwatobi Sofela 2024-03-24 18:24:34 +01:00 committed by GitHub
parent 0a771169b8
commit 1ab38fcd3f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 5 additions and 3 deletions

View file

@ -491,6 +491,7 @@ impl FontCacheThread {
// TODO: Allow users to specify these. // TODO: Allow users to specify these.
let generic_fonts = populate_generic_fonts(); let generic_fonts = populate_generic_fonts();
#[allow(clippy::default_constructed_unit_structs)]
let mut cache = FontCache { let mut cache = FontCache {
port, port,
channel_to_self, channel_to_self,

View file

@ -65,6 +65,7 @@ pub struct FontContext<S: FontSource> {
impl<S: FontSource> FontContext<S> { impl<S: FontSource> FontContext<S> {
pub fn new(font_source: S) -> FontContext<S> { pub fn new(font_source: S) -> FontContext<S> {
#[allow(clippy::default_constructed_unit_structs)]
let handle = FontContextHandle::default(); let handle = FontContextHandle::default();
FontContext { FontContext {
platform_handle: handle, platform_handle: handle,

View file

@ -77,7 +77,7 @@ where
let heap_buffer_source = match init { let heap_buffer_source = match init {
HeapTypedArrayInit::Buffer(buffer_source) => HeapBufferSource { HeapTypedArrayInit::Buffer(buffer_source) => HeapBufferSource {
buffer_source, buffer_source,
phantom: PhantomData::default(), phantom: PhantomData,
}, },
HeapTypedArrayInit::Info { len, cx } => { HeapTypedArrayInit::Info { len, cx } => {
rooted!(in (*cx) let mut array = ptr::null_mut::<JSObject>()); rooted!(in (*cx) let mut array = ptr::null_mut::<JSObject>());
@ -125,7 +125,7 @@ where
pub fn default() -> HeapBufferSource<T> { pub fn default() -> HeapBufferSource<T> {
HeapBufferSource { HeapBufferSource {
buffer_source: BufferSource::Default(Box::new(Heap::default())), buffer_source: BufferSource::Default(Box::new(Heap::default())),
phantom: PhantomData::default(), phantom: PhantomData,
} }
} }
@ -436,7 +436,7 @@ where
HeapBufferSource { HeapBufferSource {
buffer_source: BufferSource::ArrayBuffer(Heap::boxed(*array_buffer)), buffer_source: BufferSource::ArrayBuffer(Heap::boxed(*array_buffer)),
phantom: PhantomData::default(), phantom: PhantomData,
} }
} }
} }