mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
clippy: Fix various warnings in components/script/dom
(#31890)
* redundant field names in struct initialization * reduthis pattern creates a reference to a reference
This commit is contained in:
parent
29f796a1de
commit
15cb9dd5fc
3 changed files with 15 additions and 15 deletions
|
@ -35,10 +35,10 @@ impl AudioTrack {
|
||||||
) -> AudioTrack {
|
) -> AudioTrack {
|
||||||
AudioTrack {
|
AudioTrack {
|
||||||
reflector_: Reflector::new(),
|
reflector_: Reflector::new(),
|
||||||
id: id,
|
id,
|
||||||
kind: kind,
|
kind,
|
||||||
label: label,
|
label,
|
||||||
language: language,
|
language,
|
||||||
enabled: Cell::new(false),
|
enabled: Cell::new(false),
|
||||||
track_list: DomRefCell::new(track_list.map(Dom::from_ref)),
|
track_list: DomRefCell::new(track_list.map(Dom::from_ref)),
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,14 +82,14 @@ impl TrustedPromise {
|
||||||
/// lifetime.
|
/// lifetime.
|
||||||
#[allow(crown::unrooted_must_root)]
|
#[allow(crown::unrooted_must_root)]
|
||||||
pub fn new(promise: Rc<Promise>) -> TrustedPromise {
|
pub fn new(promise: Rc<Promise>) -> TrustedPromise {
|
||||||
LIVE_REFERENCES.with(|ref r| {
|
LIVE_REFERENCES.with(|r| {
|
||||||
let r = r.borrow();
|
let r = r.borrow();
|
||||||
let live_references = r.as_ref().unwrap();
|
let live_references = r.as_ref().unwrap();
|
||||||
let ptr = &*promise as *const Promise;
|
let ptr = &*promise as *const Promise;
|
||||||
live_references.addref_promise(promise);
|
live_references.addref_promise(promise);
|
||||||
TrustedPromise {
|
TrustedPromise {
|
||||||
dom_object: ptr,
|
dom_object: ptr,
|
||||||
owner_thread: (&*live_references) as *const _ as *const libc::c_void,
|
owner_thread: (live_references) as *const _ as *const libc::c_void,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -98,12 +98,12 @@ impl TrustedPromise {
|
||||||
/// a different thread than the original value from which this `TrustedPromise` was
|
/// a different thread than the original value from which this `TrustedPromise` was
|
||||||
/// obtained.
|
/// obtained.
|
||||||
pub fn root(self) -> Rc<Promise> {
|
pub fn root(self) -> Rc<Promise> {
|
||||||
LIVE_REFERENCES.with(|ref r| {
|
LIVE_REFERENCES.with(|r| {
|
||||||
let r = r.borrow();
|
let r = r.borrow();
|
||||||
let live_references = r.as_ref().unwrap();
|
let live_references = r.as_ref().unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
self.owner_thread,
|
self.owner_thread,
|
||||||
(&*live_references) as *const _ as *const libc::c_void
|
(live_references) as *const _ as *const libc::c_void
|
||||||
);
|
);
|
||||||
// Borrow-check error requires the redundant `let promise = ...; promise` here.
|
// Borrow-check error requires the redundant `let promise = ...; promise` here.
|
||||||
let promise = match live_references
|
let promise = match live_references
|
||||||
|
@ -176,7 +176,7 @@ impl<T: DomObject> Trusted<T> {
|
||||||
fn add_live_reference(
|
fn add_live_reference(
|
||||||
ptr: *const libc::c_void,
|
ptr: *const libc::c_void,
|
||||||
) -> (Arc<TrustedReference>, *const LiveDOMReferences) {
|
) -> (Arc<TrustedReference>, *const LiveDOMReferences) {
|
||||||
LIVE_REFERENCES.with(|ref r| {
|
LIVE_REFERENCES.with(|r| {
|
||||||
let r = r.borrow();
|
let r = r.borrow();
|
||||||
let live_references = r.as_ref().unwrap();
|
let live_references = r.as_ref().unwrap();
|
||||||
let refcount = unsafe { live_references.addref(ptr) };
|
let refcount = unsafe { live_references.addref(ptr) };
|
||||||
|
@ -197,7 +197,7 @@ impl<T: DomObject> Trusted<T> {
|
||||||
/// obtained.
|
/// obtained.
|
||||||
pub fn root(&self) -> DomRoot<T> {
|
pub fn root(&self) -> DomRoot<T> {
|
||||||
fn validate(owner_thread: *const LiveDOMReferences) {
|
fn validate(owner_thread: *const LiveDOMReferences) {
|
||||||
assert!(LIVE_REFERENCES.with(|ref r| {
|
assert!(LIVE_REFERENCES.with(|r| {
|
||||||
let r = r.borrow();
|
let r = r.borrow();
|
||||||
let live_references = r.as_ref().unwrap();
|
let live_references = r.as_ref().unwrap();
|
||||||
owner_thread == live_references
|
owner_thread == live_references
|
||||||
|
@ -230,7 +230,7 @@ pub struct LiveDOMReferences {
|
||||||
impl LiveDOMReferences {
|
impl LiveDOMReferences {
|
||||||
/// Set up the thread-local data required for storing the outstanding DOM references.
|
/// Set up the thread-local data required for storing the outstanding DOM references.
|
||||||
pub fn initialize() {
|
pub fn initialize() {
|
||||||
LIVE_REFERENCES.with(|ref r| {
|
LIVE_REFERENCES.with(|r| {
|
||||||
*r.borrow_mut() = Some(LiveDOMReferences {
|
*r.borrow_mut() = Some(LiveDOMReferences {
|
||||||
reflectable_table: RefCell::new(HashMap::new()),
|
reflectable_table: RefCell::new(HashMap::new()),
|
||||||
promise_table: RefCell::new(HashMap::new()),
|
promise_table: RefCell::new(HashMap::new()),
|
||||||
|
@ -239,7 +239,7 @@ impl LiveDOMReferences {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn destruct() {
|
pub fn destruct() {
|
||||||
LIVE_REFERENCES.with(|ref r| {
|
LIVE_REFERENCES.with(|r| {
|
||||||
*r.borrow_mut() = None;
|
*r.borrow_mut() = None;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,7 +125,7 @@ macro_rules! make_form_action_getter(
|
||||||
use $crate::dom::bindings::inheritance::Castable;
|
use $crate::dom::bindings::inheritance::Castable;
|
||||||
use $crate::dom::element::Element;
|
use $crate::dom::element::Element;
|
||||||
let element = self.upcast::<Element>();
|
let element = self.upcast::<Element>();
|
||||||
let doc = crate::dom::node::document_from_node(self);
|
let doc = $crate::dom::node::document_from_node(self);
|
||||||
let attr = element.get_attribute(&html5ever::ns!(), &html5ever::local_name!($htmlname));
|
let attr = element.get_attribute(&html5ever::ns!(), &html5ever::local_name!($htmlname));
|
||||||
let value = attr.as_ref().map(|attr| attr.value());
|
let value = attr.as_ref().map(|attr| attr.value());
|
||||||
let value = match value {
|
let value = match value {
|
||||||
|
@ -205,7 +205,7 @@ macro_rules! make_uint_setter(
|
||||||
fn $attr(&self, value: u32) {
|
fn $attr(&self, value: u32) {
|
||||||
use $crate::dom::bindings::inheritance::Castable;
|
use $crate::dom::bindings::inheritance::Castable;
|
||||||
use $crate::dom::element::Element;
|
use $crate::dom::element::Element;
|
||||||
use crate::dom::values::UNSIGNED_LONG_MAX;
|
use $crate::dom::values::UNSIGNED_LONG_MAX;
|
||||||
let value = if value > UNSIGNED_LONG_MAX {
|
let value = if value > UNSIGNED_LONG_MAX {
|
||||||
$default
|
$default
|
||||||
} else {
|
} else {
|
||||||
|
@ -226,7 +226,7 @@ macro_rules! make_limited_uint_setter(
|
||||||
fn $attr(&self, value: u32) -> $crate::dom::bindings::error::ErrorResult {
|
fn $attr(&self, value: u32) -> $crate::dom::bindings::error::ErrorResult {
|
||||||
use $crate::dom::bindings::inheritance::Castable;
|
use $crate::dom::bindings::inheritance::Castable;
|
||||||
use $crate::dom::element::Element;
|
use $crate::dom::element::Element;
|
||||||
use crate::dom::values::UNSIGNED_LONG_MAX;
|
use $crate::dom::values::UNSIGNED_LONG_MAX;
|
||||||
let value = if value == 0 {
|
let value = if value == 0 {
|
||||||
return Err($crate::dom::bindings::error::Error::IndexSize);
|
return Err($crate::dom::bindings::error::Error::IndexSize);
|
||||||
} else if value > UNSIGNED_LONG_MAX {
|
} else if value > UNSIGNED_LONG_MAX {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue