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:
Rosemary Ajayi 2024-03-27 10:19:49 +00:00 committed by GitHub
parent 29f796a1de
commit 15cb9dd5fc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 15 additions and 15 deletions

View file

@ -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;
});
}