Address issues uncovered by rust-1.78 beta (#32130)

This change makes changes to allow Servo to compile with the 1.78
version of Rust:

 - Dead code is removd (Rust seems to have gotten better at detecting
   it).
 - The `FlowRef` `DerefMut` is updated according to @SimonSapin's advice
   [^1].
 - The `imports.rs` now explicitly silences warnings about unused
   imports.

[^1]: https://github.com/servo/servo/issues/6503#issuecomment-2066088179

<!-- Please describe your changes on the following line: -->


---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by
`[X]` when the step is complete, and replace `___` with appropriate
data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes do not require tests because they should not change
behavior.

<!-- Also, please make sure that "Allow edits from maintainers" checkbox
is checked, so that we can help you if you get stuck somewhere along the
way.-->

<!-- Pull requests that do not address these steps are welcome, but they
will require additional verification as part of the review process. -->
This commit is contained in:
Martin Robinson 2024-04-22 20:20:47 +02:00 committed by GitHub
parent f65010c97d
commit a0640c8524
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 6 additions and 146 deletions

View file

@ -2,6 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
#[allow(unused_imports)]
pub mod base {
pub use std::ptr;
pub use std::rc::Rc;
@ -41,6 +42,7 @@ pub mod base {
pub use crate::script_runtime::JSContext as SafeJSContext;
}
#[allow(unused_imports)]
pub mod module {
pub use std::cmp;
pub use std::ffi::CString;

View file

@ -31,8 +31,7 @@ use std::marker::PhantomData;
use std::ops::Deref;
use std::{mem, ptr};
use js::jsapi::{Heap, JSObject, JSTracer};
use js::rust::GCMethods;
use js::jsapi::{JSObject, JSTracer};
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
use script_layout_interface::TrustedNodeAddress;
use style::thread_state;
@ -772,32 +771,3 @@ where
&*(slice as *const [Dom<T>] as *const [LayoutDom<T>])
}
}
/// Helper trait for safer manipulations of `Option<Heap<T>>` values.
pub trait OptionalHeapSetter {
type Value;
/// Update this optional heap value with a new value.
fn set(&mut self, v: Option<Self::Value>);
}
impl<T: GCMethods + Copy> OptionalHeapSetter for Option<Heap<T>>
where
Heap<T>: Default,
{
type Value = T;
fn set(&mut self, v: Option<T>) {
let v = match v {
None => {
*self = None;
return;
},
Some(v) => v,
};
if self.is_none() {
*self = Some(Heap::default());
}
self.as_ref().unwrap().set(v);
}
}

View file

@ -1376,7 +1376,6 @@ impl MicrotaskRunnable for ImageElementMicrotask {
}
pub trait LayoutHTMLImageElementHelpers {
fn image(self) -> Option<Arc<Image>>;
fn image_url(self) -> Option<ServoUrl>;
fn image_density(self) -> Option<f64>;
fn image_data(self) -> (Option<Arc<Image>>, Option<ImageMetadata>);
@ -1392,10 +1391,6 @@ impl<'dom> LayoutDom<'dom, HTMLImageElement> {
}
impl LayoutHTMLImageElementHelpers for LayoutDom<'_, HTMLImageElement> {
fn image(self) -> Option<Arc<Image>> {
self.current_request().image.clone()
}
fn image_url(self) -> Option<ServoUrl> {
self.current_request().parsed_url.clone()
}

View file

@ -974,8 +974,6 @@ pub trait LayoutHTMLInputElementHelpers<'dom> {
fn value_for_layout(self) -> Cow<'dom, str>;
fn size_for_layout(self) -> u32;
fn selection_for_layout(self) -> Option<Range<usize>>;
fn checked_state_for_layout(self) -> bool;
fn indeterminate_state_for_layout(self) -> bool;
}
#[allow(unsafe_code)]
@ -1077,18 +1075,6 @@ impl<'dom> LayoutHTMLInputElementHelpers<'dom> for LayoutDom<'dom, HTMLInputElem
_ => None,
}
}
fn checked_state_for_layout(self) -> bool {
self.upcast::<Element>()
.get_state_for_layout()
.contains(ElementState::CHECKED)
}
fn indeterminate_state_for_layout(self) -> bool {
self.upcast::<Element>()
.get_state_for_layout()
.contains(ElementState::INDETERMINATE)
}
}
impl TextControlElement for HTMLInputElement {

View file

@ -1329,8 +1329,6 @@ pub trait LayoutNodeHelpers<'dom> {
unsafe fn get_flag(self, flag: NodeFlags) -> bool;
unsafe fn set_flag(self, flag: NodeFlags, value: bool);
fn children_count(self) -> u32;
fn style_data(self) -> Option<&'dom StyleData>;
fn layout_data(self) -> Option<&'dom GenericLayoutData>;
@ -1473,11 +1471,6 @@ impl<'dom> LayoutNodeHelpers<'dom> for LayoutDom<'dom, Node> {
(this).flags.set(flags);
}
#[inline]
fn children_count(self) -> u32 {
self.unsafe_get().children_count.get()
}
// FIXME(nox): How we handle style and layout data needs to be completely
// revisited so we can do that more cleanly and safely in layout 2020.
#[inline]

View file

@ -2,7 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use std::any::Any;
use std::ptr::NonNull;
use js::jsapi::JSObject;
@ -27,7 +26,6 @@ pub trait WebGLExtensionWrapper: JSTraceable + MallocSizeOf {
fn is_enabled(&self) -> bool;
fn enable(&self, ext: &WebGLExtensions);
fn name(&self) -> &'static str;
fn as_any(&self) -> &dyn Any;
}
#[crown::unrooted_must_root_lint::must_root]
@ -86,8 +84,4 @@ where
fn name(&self) -> &'static str {
T::name()
}
fn as_any(&self) -> &dyn Any {
self
}
}

View file

@ -4960,16 +4960,6 @@ impl WebGLMessageSender {
}
}
pub trait Size2DExt {
fn to_u64(&self) -> Size2D<u64>;
}
impl Size2DExt for Size2D<u32> {
fn to_u64(&self) -> Size2D<u64> {
Size2D::new(self.width as u64, self.height as u64)
}
}
fn array_buffer_type_to_sized_type(type_: Type) -> Option<SizedDataType> {
match type_ {
Type::Uint8 | Type::Uint8Clamped => Some(SizedDataType::Uint8),

View file

@ -1,21 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use euclid::default::Rect;
pub trait RectExt {
fn to_u64(&self) -> Rect<u64>;
}
impl RectExt for Rect<f64> {
fn to_u64(&self) -> Rect<u64> {
self.cast()
}
}
impl RectExt for Rect<u32> {
fn to_u64(&self) -> Rect<u64> {
self.cast()
}
}

View file

@ -42,7 +42,6 @@ pub mod document_loader;
mod dom;
#[warn(deprecated)]
mod canvas_state;
mod euclidext;
#[warn(deprecated)]
pub mod fetch;
#[warn(deprecated)]