mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Fix more clippy (#32740)
This commit is contained in:
parent
4e1f623666
commit
f29dd64a7b
25 changed files with 72 additions and 90 deletions
|
@ -157,14 +157,12 @@ impl Actor for BrowsingContextActor {
|
|||
fn handle_message(
|
||||
&self,
|
||||
_registry: &ActorRegistry,
|
||||
msg_type: &str,
|
||||
_msg_type: &str,
|
||||
_msg: &Map<String, Value>,
|
||||
_stream: &mut TcpStream,
|
||||
_id: StreamId,
|
||||
) -> Result<ActorMessageStatus, ()> {
|
||||
Ok(match msg_type {
|
||||
_ => ActorMessageStatus::Ignored,
|
||||
})
|
||||
Ok(ActorMessageStatus::Ignored)
|
||||
}
|
||||
|
||||
fn cleanup(&self, id: StreamId) {
|
||||
|
|
|
@ -193,11 +193,8 @@ impl Actor for WatcherActor {
|
|||
let target =
|
||||
registry.find::<BrowsingContextActor>(&self.browsing_context_actor);
|
||||
|
||||
match resource {
|
||||
"document-event" => {
|
||||
if resource == "document-event" {
|
||||
target.document_event(stream);
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
|
||||
let _ = stream.write_json_packet(&EmptyReplyMsg { from: self.name() });
|
||||
|
|
|
@ -1505,7 +1505,7 @@ impl Fragment {
|
|||
if let Some(ref inline_fragment_context) = self.inline_context {
|
||||
for node in &inline_fragment_context.nodes {
|
||||
if node.style.get_box().position == Position::Relative {
|
||||
rel_pos = rel_pos + from_style(&*node.style, containing_block_size);
|
||||
rel_pos = rel_pos + from_style(&node.style, containing_block_size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1711,14 +1711,14 @@ impl InlineFormattingContext {
|
|||
}
|
||||
|
||||
fn next_character_prevents_soft_wrap_opportunity(&self, index: usize) -> bool {
|
||||
let Some(character) = self.text_content[index..].chars().skip(1).next() else {
|
||||
let Some(character) = self.text_content[index..].chars().nth(1) else {
|
||||
return false;
|
||||
};
|
||||
char_prevents_soft_wrap_opportunity_when_before_or_after_atomic(character)
|
||||
}
|
||||
|
||||
fn previous_character_prevents_soft_wrap_opportunity(&self, index: usize) -> bool {
|
||||
let Some(character) = self.text_content[0..index].chars().rev().next() else {
|
||||
let Some(character) = self.text_content[0..index].chars().next_back() else {
|
||||
return false;
|
||||
};
|
||||
char_prevents_soft_wrap_opportunity_when_before_or_after_atomic(character)
|
||||
|
|
|
@ -306,9 +306,7 @@ impl Layout for LayoutThread {
|
|||
}
|
||||
|
||||
fn query_content_box(&self, node: OpaqueNode) -> Option<UntypedRect<Au>> {
|
||||
let Some(mut root_flow) = self.root_flow_for_query() else {
|
||||
return None;
|
||||
};
|
||||
let mut root_flow = self.root_flow_for_query()?;
|
||||
|
||||
let root_flow_ref = FlowRef::deref_mut(&mut root_flow);
|
||||
process_content_box_request(node, root_flow_ref)
|
||||
|
@ -1010,7 +1008,7 @@ impl LayoutThread {
|
|||
for stylesheet in &ua_stylesheets.user_or_user_agent_stylesheets {
|
||||
self.stylist
|
||||
.append_stylesheet(stylesheet.clone(), &ua_or_user_guard);
|
||||
self.load_all_web_fonts_from_stylesheet_with_guard(&stylesheet, &ua_or_user_guard);
|
||||
self.load_all_web_fonts_from_stylesheet_with_guard(stylesheet, &ua_or_user_guard);
|
||||
}
|
||||
|
||||
if self.stylist.quirks_mode() != QuirksMode::NoQuirks {
|
||||
|
|
|
@ -178,10 +178,10 @@ where
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub fn get<Q: ?Sized>(&self, k: &Q) -> Option<&V>
|
||||
pub fn get<Q>(&self, k: &Q) -> Option<&V>
|
||||
where
|
||||
K: std::borrow::Borrow<Q>,
|
||||
Q: Hash + Eq,
|
||||
Q: Hash + Eq + ?Sized,
|
||||
{
|
||||
self.0.get(k)
|
||||
}
|
||||
|
|
|
@ -2987,9 +2987,10 @@ impl Document {
|
|||
/// <https://drafts.csswg.org/resize-observer/#deliver-resize-loop-error-notification>
|
||||
pub(crate) fn deliver_resize_loop_error_notification(&self) {
|
||||
let global_scope = self.window.upcast::<GlobalScope>();
|
||||
let mut error_info: ErrorInfo = Default::default();
|
||||
error_info.message =
|
||||
"ResizeObserver loop completed with undelivered notifications.".to_string();
|
||||
let error_info: ErrorInfo = crate::dom::bindings::error::ErrorInfo {
|
||||
message: "ResizeObserver loop completed with undelivered notifications.".to_string(),
|
||||
..Default::default()
|
||||
};
|
||||
global_scope.report_an_error(error_info, HandleValue::null());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3107,7 +3107,7 @@ impl GlobalScope {
|
|||
DeviceLostReason::Unknown => GPUDeviceLostReason::Unknown,
|
||||
DeviceLostReason::Destroyed => GPUDeviceLostReason::Destroyed,
|
||||
};
|
||||
let _ac = enter_realm(&*self);
|
||||
let _ac = enter_realm(self);
|
||||
if let Some(device) = self
|
||||
.gpu_devices
|
||||
.borrow_mut()
|
||||
|
|
|
@ -780,7 +780,7 @@ impl HTMLMediaElement {
|
|||
// Step 9.obj.
|
||||
Mode::Object => {
|
||||
// Step 9.obj.1.
|
||||
*self.current_src.borrow_mut() = "".to_owned();
|
||||
"".clone_into(&mut self.current_src.borrow_mut());
|
||||
|
||||
// Step 9.obj.2.
|
||||
// FIXME(nox): The rest of the steps should be ran in parallel.
|
||||
|
|
|
@ -88,11 +88,8 @@ impl HTMLMetaElement {
|
|||
// https://html.spec.whatwg.org/multipage/#attr-meta-http-equiv
|
||||
} else if !self.HttpEquiv().is_empty() {
|
||||
// TODO: Implement additional http-equiv candidates
|
||||
match self.HttpEquiv().to_ascii_lowercase().as_str() {
|
||||
"refresh" => {
|
||||
if self.HttpEquiv().to_ascii_lowercase().as_str() == "refresh" {
|
||||
self.declarative_refresh();
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -529,7 +529,7 @@ impl RequestMethods for Request {
|
|||
// https://fetch.spec.whatwg.org/#dom-request-url
|
||||
fn Url(&self) -> USVString {
|
||||
let r = self.request.borrow();
|
||||
USVString(r.url_list.get(0).map_or("", |u| u.as_str()).into())
|
||||
USVString(r.url_list.first().map_or("", |u| u.as_str()).into())
|
||||
}
|
||||
|
||||
// https://fetch.spec.whatwg.org/#dom-request-headers
|
||||
|
|
|
@ -118,11 +118,11 @@ impl ResizeObserver {
|
|||
let height = box_size.height().to_f64_px();
|
||||
let size_impl = ResizeObserverSizeImpl::new(width, height);
|
||||
let window = window_from_node(&**target);
|
||||
let observer_size = ResizeObserverSize::new(&*window, size_impl);
|
||||
let observer_size = ResizeObserverSize::new(&window, size_impl);
|
||||
|
||||
// Note: content rect is built from content box size.
|
||||
let content_rect = DOMRectReadOnly::new(
|
||||
&*window.upcast(),
|
||||
window.upcast(),
|
||||
None,
|
||||
box_size.origin.x.to_f64_px(),
|
||||
box_size.origin.y.to_f64_px(),
|
||||
|
@ -130,9 +130,9 @@ impl ResizeObserver {
|
|||
height,
|
||||
);
|
||||
let entry = ResizeObserverEntry::new(
|
||||
&*window,
|
||||
&window,
|
||||
target,
|
||||
&*content_rect,
|
||||
&content_rect,
|
||||
&[],
|
||||
&[&*observer_size],
|
||||
&[],
|
||||
|
|
|
@ -206,10 +206,10 @@ impl RTCPeerConnection {
|
|||
let signaller = this.make_signaller();
|
||||
*this.controller.borrow_mut() = Some(ServoMedia::get().unwrap().create_webrtc(signaller));
|
||||
if let Some(ref servers) = config.iceServers {
|
||||
if let Some(server) = servers.get(0) {
|
||||
if let Some(server) = servers.first() {
|
||||
let server = match server.urls {
|
||||
StringOrStringSequence::String(ref s) => Some(s.clone()),
|
||||
StringOrStringSequence::StringSequence(ref s) => s.get(0).cloned(),
|
||||
StringOrStringSequence::StringSequence(ref s) => s.first().cloned(),
|
||||
};
|
||||
if let Some(server) = server {
|
||||
let policy = match config.bundlePolicy {
|
||||
|
|
|
@ -134,7 +134,7 @@ fn start_element<S: Serializer>(node: &Element, serializer: &mut S) -> io::Resul
|
|||
})
|
||||
.collect::<Vec<_>>();
|
||||
let attr_refs = attrs.iter().map(|(qname, value)| {
|
||||
let ar: AttrRef = (&qname, &**value);
|
||||
let ar: AttrRef = (qname, &**value);
|
||||
ar
|
||||
});
|
||||
serializer.start_elem(name, attr_refs)?;
|
||||
|
|
|
@ -622,8 +622,8 @@ impl TestBindingMethods for TestBinding {
|
|||
arg.type_.as_ref().map(|s| s == "success").unwrap_or(false) &&
|
||||
arg.nonRequiredNullable.is_none() &&
|
||||
arg.nonRequiredNullable2 == Some(None) &&
|
||||
arg.noCallbackImport == None &&
|
||||
arg.noCallbackImport2 == None
|
||||
arg.noCallbackImport.is_none() &&
|
||||
arg.noCallbackImport2.is_none()
|
||||
}
|
||||
|
||||
fn PassBoolean(&self, _: bool) {}
|
||||
|
|
|
@ -3134,16 +3134,14 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
|
|||
|
||||
let buff = IpcSharedMemory::from_bytes(unsafe { &src_data.as_slice()[src_byte_offset..] });
|
||||
|
||||
let expected_byte_length = match {
|
||||
self.base.validate_tex_image_2d_data(
|
||||
let expected_byte_length = match self.base.validate_tex_image_2d_data(
|
||||
width,
|
||||
height,
|
||||
format,
|
||||
data_type,
|
||||
unpacking_alignment,
|
||||
Some(&*src_data),
|
||||
)
|
||||
} {
|
||||
) {
|
||||
Ok(byte_length) => byte_length,
|
||||
Err(()) => return Ok(()),
|
||||
};
|
||||
|
@ -3968,7 +3966,7 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
|
|||
buffer.map(|b| b.id()),
|
||||
));
|
||||
|
||||
for slot in &[&generic_slot, &indexed_binding.buffer] {
|
||||
for slot in &[generic_slot, &indexed_binding.buffer] {
|
||||
if let Some(old) = slot.get() {
|
||||
old.decrement_attached_counter(Operation::Infallible);
|
||||
}
|
||||
|
@ -4046,7 +4044,7 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
|
|||
size,
|
||||
));
|
||||
|
||||
for slot in &[&generic_slot, &indexed_binding.buffer] {
|
||||
for slot in &[generic_slot, &indexed_binding.buffer] {
|
||||
if let Some(old) = slot.get() {
|
||||
old.decrement_attached_counter(Operation::Infallible);
|
||||
}
|
||||
|
|
|
@ -279,11 +279,11 @@ impl WebGLExtensions {
|
|||
}
|
||||
|
||||
pub fn is_tex_type_enabled(&self, data_type: GLenum) -> bool {
|
||||
self.features
|
||||
!self
|
||||
.features
|
||||
.borrow()
|
||||
.disabled_tex_types
|
||||
.get(&data_type)
|
||||
.is_none()
|
||||
.contains(&data_type)
|
||||
}
|
||||
|
||||
pub fn add_effective_tex_internal_format(
|
||||
|
@ -321,11 +321,11 @@ impl WebGLExtensions {
|
|||
}
|
||||
|
||||
pub fn is_filterable(&self, text_data_type: u32) -> bool {
|
||||
self.features
|
||||
!self
|
||||
.features
|
||||
.borrow()
|
||||
.not_filterable_tex_types
|
||||
.get(&text_data_type)
|
||||
.is_none()
|
||||
.contains(&text_data_type)
|
||||
}
|
||||
|
||||
pub fn enable_hint_target(&self, name: GLenum) {
|
||||
|
|
|
@ -4292,16 +4292,14 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
|
|||
|
||||
let unpacking_alignment = self.texture_unpacking_alignment.get();
|
||||
|
||||
let expected_byte_length = match {
|
||||
self.validate_tex_image_2d_data(
|
||||
let expected_byte_length = match self.validate_tex_image_2d_data(
|
||||
width,
|
||||
height,
|
||||
format,
|
||||
data_type,
|
||||
unpacking_alignment,
|
||||
pixels.as_ref(),
|
||||
)
|
||||
} {
|
||||
) {
|
||||
Ok(byte_length) => byte_length,
|
||||
Err(()) => return Ok(()),
|
||||
};
|
||||
|
@ -4479,16 +4477,14 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
|
|||
|
||||
let unpacking_alignment = self.texture_unpacking_alignment.get();
|
||||
|
||||
let expected_byte_length = match {
|
||||
self.validate_tex_image_2d_data(
|
||||
let expected_byte_length = match self.validate_tex_image_2d_data(
|
||||
width,
|
||||
height,
|
||||
format,
|
||||
data_type,
|
||||
unpacking_alignment,
|
||||
pixels.as_ref(),
|
||||
)
|
||||
} {
|
||||
) {
|
||||
Ok(byte_length) => byte_length,
|
||||
Err(()) => return Ok(()),
|
||||
};
|
||||
|
|
|
@ -1053,7 +1053,7 @@ impl XMLHttpRequest {
|
|||
},
|
||||
};
|
||||
|
||||
*self.response_url.borrow_mut() = metadata.final_url[..Position::AfterQuery].to_owned();
|
||||
metadata.final_url[..Position::AfterQuery].clone_into(&mut self.response_url.borrow_mut());
|
||||
|
||||
// XXXManishearth Clear cache entries in case of a network error
|
||||
self.process_partial_response(XHRProgress::HeadersReceived(
|
||||
|
|
|
@ -438,10 +438,7 @@ impl XRSession {
|
|||
self.outside_raf.set(false);
|
||||
let len = self.current_raf_callback_list.borrow().len();
|
||||
for i in 0..len {
|
||||
let callback = self.current_raf_callback_list.borrow()[i]
|
||||
.1
|
||||
.as_ref()
|
||||
.map(Rc::clone);
|
||||
let callback = self.current_raf_callback_list.borrow()[i].1.clone();
|
||||
if let Some(callback) = callback {
|
||||
let _ = callback.Call__(time, &frame, ExceptionHandling::Report);
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
// crate. Issue a warning if `crown` is not being used to compile, but not when
|
||||
// building rustdoc or running clippy.
|
||||
#![register_tool(crown)]
|
||||
#![cfg_attr(any(doc, clippy, feature = "cargo-clippy"), allow(unknown_lints))]
|
||||
#![cfg_attr(any(doc, clippy), allow(unknown_lints))]
|
||||
#![deny(crown_is_not_used)]
|
||||
|
||||
// These are used a lot so let's keep them for now
|
||||
|
|
|
@ -578,7 +578,7 @@ impl ModuleTree {
|
|||
|
||||
let url = ModuleTree::resolve_module_specifier(
|
||||
*cx,
|
||||
&base_url,
|
||||
base_url,
|
||||
specifier.handle().into_handle(),
|
||||
);
|
||||
|
||||
|
@ -815,7 +815,7 @@ impl ModuleTree {
|
|||
|
||||
if incomplete_count_before_remove > 0 {
|
||||
parent_tree.remove_incomplete_fetch_url(&self.url);
|
||||
parent_tree.advance_finished_and_link(&global);
|
||||
parent_tree.advance_finished_and_link(global);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -831,7 +831,7 @@ impl ModuleTree {
|
|||
(None, None) => {
|
||||
let module_record = self.get_record().borrow();
|
||||
if let Some(record) = &*module_record {
|
||||
let instantiated = self.instantiate_module_tree(&global, record.handle());
|
||||
let instantiated = self.instantiate_module_tree(global, record.handle());
|
||||
|
||||
if let Err(exception) = instantiated {
|
||||
self.set_rethrow_error(exception);
|
||||
|
|
|
@ -748,8 +748,8 @@ pub unsafe fn get_reports(cx: *mut RawJSContext, path_seg: String) -> Vec<Report
|
|||
reports
|
||||
}
|
||||
|
||||
thread_local!(static GC_CYCLE_START: Cell<Option<Instant>> = Cell::new(None));
|
||||
thread_local!(static GC_SLICE_START: Cell<Option<Instant>> = Cell::new(None));
|
||||
thread_local!(static GC_CYCLE_START: Cell<Option<Instant>> = const { Cell::new(None) });
|
||||
thread_local!(static GC_SLICE_START: Cell<Option<Instant>> = const { Cell::new(None) });
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
unsafe extern "C" fn gc_slice_callback(
|
||||
|
@ -803,7 +803,7 @@ unsafe extern "C" fn debug_gc_callback(
|
|||
}
|
||||
|
||||
thread_local!(
|
||||
static THREAD_ACTIVE: Cell<bool> = Cell::new(true);
|
||||
static THREAD_ACTIVE: Cell<bool> = const { Cell::new(true) };
|
||||
);
|
||||
|
||||
pub(crate) fn runtime_is_alive() -> bool {
|
||||
|
|
|
@ -165,7 +165,7 @@ use crate::{devtools, webdriver_handlers};
|
|||
|
||||
pub type ImageCacheMsg = (PipelineId, PendingImageResponse);
|
||||
|
||||
thread_local!(static SCRIPT_THREAD_ROOT: Cell<Option<*const ScriptThread>> = Cell::new(None));
|
||||
thread_local!(static SCRIPT_THREAD_ROOT: Cell<Option<*const ScriptThread>> = const { Cell::new(None) });
|
||||
|
||||
pub unsafe fn trace_thread(tr: *mut JSTracer) {
|
||||
SCRIPT_THREAD_ROOT.with(|root| {
|
||||
|
|
|
@ -982,7 +982,7 @@ impl<T: ClipboardProvider> TextInput<T> {
|
|||
|
||||
/// Whether the content is empty.
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.lines.len() <= 1 && self.lines.get(0).map_or(true, |line| line.is_empty())
|
||||
self.lines.len() <= 1 && self.lines.first().map_or(true, |line| line.is_empty())
|
||||
}
|
||||
|
||||
/// The length of the content in bytes.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue