mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +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 {
|
||||
reflector_: Reflector::new(),
|
||||
id: id,
|
||||
kind: kind,
|
||||
label: label,
|
||||
language: language,
|
||||
id,
|
||||
kind,
|
||||
label,
|
||||
language,
|
||||
enabled: Cell::new(false),
|
||||
track_list: DomRefCell::new(track_list.map(Dom::from_ref)),
|
||||
}
|
||||
|
|
|
@ -82,14 +82,14 @@ impl TrustedPromise {
|
|||
/// lifetime.
|
||||
#[allow(crown::unrooted_must_root)]
|
||||
pub fn new(promise: Rc<Promise>) -> TrustedPromise {
|
||||
LIVE_REFERENCES.with(|ref r| {
|
||||
LIVE_REFERENCES.with(|r| {
|
||||
let r = r.borrow();
|
||||
let live_references = r.as_ref().unwrap();
|
||||
let ptr = &*promise as *const Promise;
|
||||
live_references.addref_promise(promise);
|
||||
TrustedPromise {
|
||||
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
|
||||
/// obtained.
|
||||
pub fn root(self) -> Rc<Promise> {
|
||||
LIVE_REFERENCES.with(|ref r| {
|
||||
LIVE_REFERENCES.with(|r| {
|
||||
let r = r.borrow();
|
||||
let live_references = r.as_ref().unwrap();
|
||||
assert_eq!(
|
||||
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.
|
||||
let promise = match live_references
|
||||
|
@ -176,7 +176,7 @@ impl<T: DomObject> Trusted<T> {
|
|||
fn add_live_reference(
|
||||
ptr: *const libc::c_void,
|
||||
) -> (Arc<TrustedReference>, *const LiveDOMReferences) {
|
||||
LIVE_REFERENCES.with(|ref r| {
|
||||
LIVE_REFERENCES.with(|r| {
|
||||
let r = r.borrow();
|
||||
let live_references = r.as_ref().unwrap();
|
||||
let refcount = unsafe { live_references.addref(ptr) };
|
||||
|
@ -197,7 +197,7 @@ impl<T: DomObject> Trusted<T> {
|
|||
/// obtained.
|
||||
pub fn root(&self) -> DomRoot<T> {
|
||||
fn validate(owner_thread: *const LiveDOMReferences) {
|
||||
assert!(LIVE_REFERENCES.with(|ref r| {
|
||||
assert!(LIVE_REFERENCES.with(|r| {
|
||||
let r = r.borrow();
|
||||
let live_references = r.as_ref().unwrap();
|
||||
owner_thread == live_references
|
||||
|
@ -230,7 +230,7 @@ pub struct LiveDOMReferences {
|
|||
impl LiveDOMReferences {
|
||||
/// Set up the thread-local data required for storing the outstanding DOM references.
|
||||
pub fn initialize() {
|
||||
LIVE_REFERENCES.with(|ref r| {
|
||||
LIVE_REFERENCES.with(|r| {
|
||||
*r.borrow_mut() = Some(LiveDOMReferences {
|
||||
reflectable_table: RefCell::new(HashMap::new()),
|
||||
promise_table: RefCell::new(HashMap::new()),
|
||||
|
@ -239,7 +239,7 @@ impl LiveDOMReferences {
|
|||
}
|
||||
|
||||
pub fn destruct() {
|
||||
LIVE_REFERENCES.with(|ref r| {
|
||||
LIVE_REFERENCES.with(|r| {
|
||||
*r.borrow_mut() = None;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -125,7 +125,7 @@ macro_rules! make_form_action_getter(
|
|||
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 doc = $crate::dom::node::document_from_node(self);
|
||||
let attr = element.get_attribute(&html5ever::ns!(), &html5ever::local_name!($htmlname));
|
||||
let value = attr.as_ref().map(|attr| attr.value());
|
||||
let value = match value {
|
||||
|
@ -205,7 +205,7 @@ macro_rules! make_uint_setter(
|
|||
fn $attr(&self, value: u32) {
|
||||
use $crate::dom::bindings::inheritance::Castable;
|
||||
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 {
|
||||
$default
|
||||
} else {
|
||||
|
@ -226,7 +226,7 @@ macro_rules! make_limited_uint_setter(
|
|||
fn $attr(&self, value: u32) -> $crate::dom::bindings::error::ErrorResult {
|
||||
use $crate::dom::bindings::inheritance::Castable;
|
||||
use $crate::dom::element::Element;
|
||||
use crate::dom::values::UNSIGNED_LONG_MAX;
|
||||
use $crate::dom::values::UNSIGNED_LONG_MAX;
|
||||
let value = if value == 0 {
|
||||
return Err($crate::dom::bindings::error::Error::IndexSize);
|
||||
} else if value > UNSIGNED_LONG_MAX {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue