clippy: Fix several warnings (#31710)

Signed-off-by: RustAndMetal <111676747+RustAndMetal@users.noreply.github.com>
This commit is contained in:
RustAndMetal 2024-03-18 09:33:43 +01:00 committed by GitHub
parent 1ab8fa2895
commit f6a975fc58
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
23 changed files with 75 additions and 86 deletions

View file

@ -91,7 +91,7 @@ impl TransmitBodyConnectHandler {
source: BodySource,
) -> TransmitBodyConnectHandler {
TransmitBodyConnectHandler {
stream: stream,
stream,
task_source,
canceller,
bytes_sender: None,

View file

@ -175,8 +175,8 @@ pub fn handle_get_layout(
paddingRight: String::from(computed_style.PaddingRight()),
paddingBottom: String::from(computed_style.PaddingBottom()),
paddingLeft: String::from(computed_style.PaddingLeft()),
width: width,
height: height,
width,
height,
}))
.unwrap();
}

View file

@ -86,7 +86,7 @@ impl DocumentLoader {
let initial_loads = initial_load.into_iter().map(LoadType::PageSource).collect();
DocumentLoader {
resource_threads: resource_threads,
resource_threads,
blocking_loads: initial_loads,
events_inhibited: false,
cancellers: Vec::new(),

View file

@ -26,6 +26,6 @@ pub struct SimpleWorkerErrorHandler<T: DomObject> {
impl<T: DomObject> SimpleWorkerErrorHandler<T> {
pub fn new(addr: Trusted<T>) -> SimpleWorkerErrorHandler<T> {
SimpleWorkerErrorHandler { addr: addr }
SimpleWorkerErrorHandler { addr }
}
}

View file

@ -76,7 +76,7 @@ where
{
let heap_buffer_source = match init {
HeapTypedArrayInit::Buffer(buffer_source) => HeapBufferSource {
buffer_source: buffer_source,
buffer_source,
phantom: PhantomData::default(),
},
HeapTypedArrayInit::Info { len, cx } => {

View file

@ -253,9 +253,9 @@ impl CallSetup {
let ais = callback.incumbent().map(AutoIncumbentScript::new);
CallSetup {
exception_global: global,
cx: cx,
cx,
old_realm: unsafe { EnterRealm(*cx, callback.callback()) },
handling: handling,
handling,
entry_script: Some(aes),
incumbent_script: ais,
}

View file

@ -22,10 +22,7 @@ pub struct Guard<T: Clone + Copy> {
impl<T: Clone + Copy> Guard<T> {
/// Construct a new guarded value.
pub const fn new(condition: Condition, value: T) -> Self {
Guard {
condition: condition,
value: value,
}
Guard { condition, value }
}
/// Expose the value if the condition is satisfied.

View file

@ -76,8 +76,8 @@ impl NonCallbackInterfaceObjectClass {
ext: 0 as *const _,
oOps: &OBJECT_OPS,
},
proto_id: proto_id,
proto_depth: proto_depth,
proto_id,
proto_depth,
representation: string_rep,
}
}
@ -649,10 +649,8 @@ pub fn get_desired_proto(
let global = GetNonCCWObjectGlobal(*new_target);
let proto_or_iface_cache = get_proto_or_iface_array(global);
desired_proto.set((*proto_or_iface_cache)[proto_id as usize]);
if &*new_target != &*original_new_target {
if !JS_WrapObject(*cx, desired_proto.into()) {
return Err(());
}
if &*new_target != &*original_new_target && !JS_WrapObject(*cx, desired_proto.into()) {
return Err(());
}
return Ok(());
}

View file

@ -68,7 +68,7 @@ impl<T: DomObjectIteratorWrap + JSTraceable + Iterable> IterableIterator<T> {
pub fn new(iterable: &T, type_: IteratorType) -> DomRoot<Self> {
let iterator = Box::new(IterableIterator {
reflector: Reflector::new(),
type_: type_,
type_,
iterable: Dom::from_ref(iterable),
index: Cell::new(0),
});

View file

@ -163,7 +163,7 @@ where
map.insert(key, property);
}
Ok(ConversionResult::Success(Record { map: map }))
Ok(ConversionResult::Success(Record { map }))
}
}

View file

@ -6,8 +6,8 @@
macro_rules! make_getter(
( $attr:ident, $htmlname:tt ) => (
fn $attr(&self) -> DOMString {
use crate::dom::bindings::inheritance::Castable;
use crate::dom::element::Element;
use $crate::dom::bindings::inheritance::Castable;
use $crate::dom::element::Element;
let element = self.upcast::<Element>();
element.get_string_attribute(&html5ever::local_name!($htmlname))
}
@ -18,8 +18,8 @@ macro_rules! make_getter(
macro_rules! make_bool_getter(
( $attr:ident, $htmlname:tt ) => (
fn $attr(&self) -> bool {
use crate::dom::bindings::inheritance::Castable;
use crate::dom::element::Element;
use $crate::dom::bindings::inheritance::Castable;
use $crate::dom::element::Element;
let element = self.upcast::<Element>();
element.has_attribute(&html5ever::local_name!($htmlname))
}
@ -30,8 +30,8 @@ macro_rules! make_bool_getter(
macro_rules! make_limited_int_setter(
($attr:ident, $htmlname:tt, $default:expr) => (
fn $attr(&self, value: i32) -> $crate::dom::bindings::error::ErrorResult {
use crate::dom::bindings::inheritance::Castable;
use crate::dom::element::Element;
use $crate::dom::bindings::inheritance::Castable;
use $crate::dom::element::Element;
let value = if value < 0 {
return Err($crate::dom::bindings::error::Error::IndexSize);
@ -50,8 +50,8 @@ macro_rules! make_limited_int_setter(
macro_rules! make_int_setter(
($attr:ident, $htmlname:tt, $default:expr) => (
fn $attr(&self, value: i32) {
use crate::dom::bindings::inheritance::Castable;
use crate::dom::element::Element;
use $crate::dom::bindings::inheritance::Castable;
use $crate::dom::element::Element;
let element = self.upcast::<Element>();
element.set_int_attribute(&html5ever::local_name!($htmlname), value)
@ -66,8 +66,8 @@ macro_rules! make_int_setter(
macro_rules! make_int_getter(
($attr:ident, $htmlname:tt, $default:expr) => (
fn $attr(&self) -> i32 {
use crate::dom::bindings::inheritance::Castable;
use crate::dom::element::Element;
use $crate::dom::bindings::inheritance::Castable;
use $crate::dom::element::Element;
let element = self.upcast::<Element>();
element.get_int_attribute(&html5ever::local_name!($htmlname), $default)
}
@ -82,8 +82,8 @@ macro_rules! make_int_getter(
macro_rules! make_uint_getter(
($attr:ident, $htmlname:tt, $default:expr) => (
fn $attr(&self) -> u32 {
use crate::dom::bindings::inheritance::Castable;
use crate::dom::element::Element;
use $crate::dom::bindings::inheritance::Castable;
use $crate::dom::element::Element;
let element = self.upcast::<Element>();
element.get_uint_attribute(&html5ever::local_name!($htmlname), $default)
}
@ -97,8 +97,8 @@ macro_rules! make_uint_getter(
macro_rules! make_url_getter(
( $attr:ident, $htmlname:tt ) => (
fn $attr(&self) -> USVString {
use crate::dom::bindings::inheritance::Castable;
use crate::dom::element::Element;
use $crate::dom::bindings::inheritance::Castable;
use $crate::dom::element::Element;
let element = self.upcast::<Element>();
element.get_url_attribute(&html5ever::local_name!($htmlname))
}
@ -109,8 +109,8 @@ macro_rules! make_url_getter(
macro_rules! make_url_setter(
( $attr:ident, $htmlname:tt ) => (
fn $attr(&self, value: USVString) {
use crate::dom::bindings::inheritance::Castable;
use crate::dom::element::Element;
use $crate::dom::bindings::inheritance::Castable;
use $crate::dom::element::Element;
let element = self.upcast::<Element>();
element.set_url_attribute(&html5ever::local_name!($htmlname),
value);
@ -122,8 +122,8 @@ macro_rules! make_url_setter(
macro_rules! make_form_action_getter(
( $attr:ident, $htmlname:tt ) => (
fn $attr(&self) -> DOMString {
use crate::dom::bindings::inheritance::Castable;
use crate::dom::element::Element;
use $crate::dom::bindings::inheritance::Castable;
use $crate::dom::element::Element;
let element = self.upcast::<Element>();
let doc = crate::dom::node::document_from_node(self);
let attr = element.get_attribute(&html5ever::ns!(), &html5ever::local_name!($htmlname));
@ -144,8 +144,8 @@ macro_rules! make_form_action_getter(
macro_rules! make_labels_getter(
( $attr:ident, $memo:ident ) => (
fn $attr(&self) -> DomRoot<NodeList> {
use crate::dom::htmlelement::HTMLElement;
use crate::dom::nodelist::NodeList;
use $crate::dom::htmlelement::HTMLElement;
use $crate::dom::nodelist::NodeList;
self.$memo.or_init(|| NodeList::new_labels_list(
self.upcast::<Node>().owner_doc().window(),
self.upcast::<HTMLElement>()
@ -159,8 +159,8 @@ macro_rules! make_labels_getter(
macro_rules! make_enumerated_getter(
( $attr:ident, $htmlname:tt, $default:expr, $($choices: pat)|+) => (
fn $attr(&self) -> DOMString {
use crate::dom::bindings::inheritance::Castable;
use crate::dom::element::Element;
use $crate::dom::bindings::inheritance::Castable;
use $crate::dom::element::Element;
let element = self.upcast::<Element>();
let mut val = element.get_string_attribute(&html5ever::local_name!($htmlname));
val.make_ascii_lowercase();
@ -179,8 +179,8 @@ macro_rules! make_enumerated_getter(
macro_rules! make_setter(
( $attr:ident, $htmlname:tt ) => (
fn $attr(&self, value: DOMString) {
use crate::dom::bindings::inheritance::Castable;
use crate::dom::element::Element;
use $crate::dom::bindings::inheritance::Castable;
use $crate::dom::element::Element;
let element = self.upcast::<Element>();
element.set_string_attribute(&html5ever::local_name!($htmlname), value)
}
@ -191,8 +191,8 @@ macro_rules! make_setter(
macro_rules! make_bool_setter(
( $attr:ident, $htmlname:tt ) => (
fn $attr(&self, value: bool) {
use crate::dom::bindings::inheritance::Castable;
use crate::dom::element::Element;
use $crate::dom::bindings::inheritance::Castable;
use $crate::dom::element::Element;
let element = self.upcast::<Element>();
element.set_bool_attribute(&html5ever::local_name!($htmlname), value)
}
@ -203,8 +203,8 @@ macro_rules! make_bool_setter(
macro_rules! make_uint_setter(
($attr:ident, $htmlname:tt, $default:expr) => (
fn $attr(&self, value: u32) {
use crate::dom::bindings::inheritance::Castable;
use crate::dom::element::Element;
use $crate::dom::bindings::inheritance::Castable;
use $crate::dom::element::Element;
use crate::dom::values::UNSIGNED_LONG_MAX;
let value = if value > UNSIGNED_LONG_MAX {
$default
@ -224,8 +224,8 @@ macro_rules! make_uint_setter(
macro_rules! make_limited_uint_setter(
($attr:ident, $htmlname:tt, $default:expr) => (
fn $attr(&self, value: u32) -> $crate::dom::bindings::error::ErrorResult {
use crate::dom::bindings::inheritance::Castable;
use crate::dom::element::Element;
use $crate::dom::bindings::inheritance::Castable;
use $crate::dom::element::Element;
use crate::dom::values::UNSIGNED_LONG_MAX;
let value = if value == 0 {
return Err($crate::dom::bindings::error::Error::IndexSize);
@ -248,8 +248,8 @@ macro_rules! make_limited_uint_setter(
macro_rules! make_atomic_setter(
( $attr:ident, $htmlname:tt ) => (
fn $attr(&self, value: DOMString) {
use crate::dom::bindings::inheritance::Castable;
use crate::dom::element::Element;
use $crate::dom::bindings::inheritance::Castable;
use $crate::dom::element::Element;
let element = self.upcast::<Element>();
element.set_atomic_attribute(&html5ever::local_name!($htmlname), value)
}
@ -260,8 +260,8 @@ macro_rules! make_atomic_setter(
macro_rules! make_legacy_color_setter(
( $attr:ident, $htmlname:tt ) => (
fn $attr(&self, value: DOMString) {
use crate::dom::bindings::inheritance::Castable;
use crate::dom::element::Element;
use $crate::dom::bindings::inheritance::Castable;
use $crate::dom::element::Element;
use style::attr::AttrValue;
let element = self.upcast::<Element>();
let value = AttrValue::from_legacy_color(value.into());
@ -274,8 +274,8 @@ macro_rules! make_legacy_color_setter(
macro_rules! make_dimension_setter(
( $attr:ident, $htmlname:tt ) => (
fn $attr(&self, value: DOMString) {
use crate::dom::bindings::inheritance::Castable;
use crate::dom::element::Element;
use $crate::dom::bindings::inheritance::Castable;
use $crate::dom::element::Element;
let element = self.upcast::<Element>();
let value = AttrValue::from_dimension(value.into());
element.set_attribute(&html5ever::local_name!($htmlname), value)
@ -287,8 +287,8 @@ macro_rules! make_dimension_setter(
macro_rules! make_nonzero_dimension_setter(
( $attr:ident, $htmlname:tt ) => (
fn $attr(&self, value: DOMString) {
use crate::dom::bindings::inheritance::Castable;
use crate::dom::element::Element;
use $crate::dom::bindings::inheritance::Castable;
use $crate::dom::element::Element;
let element = self.upcast::<Element>();
let value = AttrValue::from_nonzero_dimension(value.into());
element.set_attribute(&html5ever::local_name!($htmlname), value)

View file

@ -3369,7 +3369,7 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
}
/// <https://www.khronos.org/registry/webgl/specs/latest/2.0/#3.7.12>
#[cfg_attr(rustfmt, rustfmt_skip)]
#[rustfmt::skip]
fn DeleteQuery(&self, query: Option<&WebGLQuery>) {
if let Some(query) = query {
handle_potential_webgl_error!(self.base, self.base.validate_ownership(query), return);
@ -3431,7 +3431,7 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
}
/// <https://www.khronos.org/registry/webgl/specs/latest/2.0/#3.7.12>
#[cfg_attr(rustfmt, rustfmt_skip)]
#[rustfmt::skip]
fn BeginQuery(&self, target: u32, query: &WebGLQuery) {
handle_potential_webgl_error!(self.base, self.base.validate_ownership(query), return);
@ -3460,7 +3460,7 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
}
/// <https://www.khronos.org/registry/webgl/specs/latest/2.0/#3.7.12>
#[cfg_attr(rustfmt, rustfmt_skip)]
#[rustfmt::skip]
fn EndQuery(&self, target: u32) {
let active_query = match target {
constants::ANY_SAMPLES_PASSED |
@ -3487,7 +3487,7 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
}
/// <https://www.khronos.org/registry/webgl/specs/latest/2.0/#3.7.12>
#[cfg_attr(rustfmt, rustfmt_skip)]
#[rustfmt::skip]
fn GetQuery(&self, target: u32, pname: u32) -> Option<DomRoot<WebGLQuery>> {
if pname != constants::CURRENT_QUERY {
self.base.webgl_error(InvalidEnum);
@ -3515,7 +3515,7 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
}
/// <https://www.khronos.org/registry/webgl/specs/latest/2.0/#3.7.12>
#[cfg_attr(rustfmt, rustfmt_skip)]
#[rustfmt::skip]
fn GetQueryParameter(&self, _cx: JSContext, query: &WebGLQuery, pname: u32) -> JSVal {
handle_potential_webgl_error!(
self.base,

View file

@ -144,7 +144,7 @@ impl WebGLQuery {
self.query_result_available.set(Some(is_available));
}
#[cfg_attr(rustfmt, rustfmt_skip)]
#[rustfmt::skip]
pub fn get_parameter(
&self,
context: &WebGLRenderingContext,

View file

@ -528,9 +528,9 @@ impl JsTimers {
let oneshot_handle = global.schedule_callback(callback, duration);
// step 3
let entry = active_timers.entry(handle).or_insert(JsTimerEntry {
oneshot_handle: oneshot_handle,
});
let entry = active_timers
.entry(handle)
.or_insert(JsTimerEntry { oneshot_handle });
entry.oneshot_handle = oneshot_handle;
}
}

View file

@ -19,7 +19,6 @@ use js::rust::{
Handle as RustHandle, HandleObject as RustHandleObject, IntoHandle,
MutableHandle as RustMutableHandle, MutableHandleObject as RustMutableHandleObject,
};
use libc;
use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
use crate::dom::bindings::proxyhandler::set_property_descriptor;