Add lint check for &DomRoot<T>

`&DomRoot<T> is strictly less expressive than `&T`, so using it is
pointless.
This commit is contained in:
lberrymage 2019-12-21 12:44:34 -09:00
parent bac9903fbe
commit cd9195056c
9 changed files with 13 additions and 13 deletions

View file

@ -6,7 +6,6 @@
//! (https://html.spec.whatwg.org/multipage/#serializable-objects).
use crate::dom::bindings::reflector::DomObject;
use crate::dom::bindings::root::DomRoot;
use crate::dom::bindings::structuredclone::StructuredDataHolder;
use crate::dom::globalscope::GlobalScope;
@ -25,7 +24,7 @@ pub trait Serializable: DomObject {
fn serialize(&self, sc_holder: &mut StructuredDataHolder) -> Result<StorageKey, ()>;
/// <https://html.spec.whatwg.org/multipage/#deserialization-steps>
fn deserialize(
owner: &DomRoot<GlobalScope>,
owner: &GlobalScope,
sc_holder: &mut StructuredDataHolder,
extra_data: StorageKey,
) -> Result<(), ()>;

View file

@ -56,7 +56,7 @@ enum StructuredCloneTags {
}
unsafe fn read_blob(
owner: &DomRoot<GlobalScope>,
owner: &GlobalScope,
r: *mut JSStructuredCloneReader,
mut sc_holder: &mut StructuredDataHolder,
) -> *mut JSObject {
@ -88,7 +88,7 @@ unsafe fn read_blob(
}
unsafe fn write_blob(
owner: &DomRoot<GlobalScope>,
owner: &GlobalScope,
blob: DomRoot<Blob>,
w: *mut JSStructuredCloneWriter,
sc_holder: &mut StructuredDataHolder,

View file

@ -6,7 +6,6 @@
//! (https://html.spec.whatwg.org/multipage/#transferable-objects).
use crate::dom::bindings::reflector::DomObject;
use crate::dom::bindings::root::DomRoot;
use crate::dom::bindings::structuredclone::StructuredDataHolder;
use crate::dom::globalscope::GlobalScope;
use js::jsapi::MutableHandleObject;
@ -14,7 +13,7 @@ use js::jsapi::MutableHandleObject;
pub trait Transferable: DomObject {
fn transfer(&self, sc_holder: &mut StructuredDataHolder) -> Result<u64, ()>;
fn transfer_receive(
owner: &DomRoot<GlobalScope>,
owner: &GlobalScope,
sc_holder: &mut StructuredDataHolder,
extra_data: u64,
return_object: MutableHandleObject,

View file

@ -125,7 +125,7 @@ impl Serializable for Blob {
/// <https://w3c.github.io/FileAPI/#ref-for-deserialization-steps>
fn deserialize(
owner: &DomRoot<GlobalScope>,
owner: &GlobalScope,
sc_holder: &mut StructuredDataHolder,
storage_key: StorageKey,
) -> Result<(), ()> {
@ -159,7 +159,7 @@ impl Serializable for Blob {
*blob_impls = None;
}
let deserialized_blob = Blob::new(&**owner, blob_impl);
let deserialized_blob = Blob::new(&*owner, blob_impl);
let blobs = blobs.get_or_insert_with(|| HashMap::new());
blobs.insert(storage_key, deserialized_blob);

View file

@ -892,7 +892,7 @@ impl GlobalScope {
}
/// Start tracking a blob
pub fn track_blob(&self, dom_blob: &DomRoot<Blob>, blob_impl: BlobImpl) {
pub fn track_blob(&self, dom_blob: &Blob, blob_impl: BlobImpl) {
let blob_id = blob_impl.blob_id();
let blob_info = BlobInfo {
@ -905,7 +905,7 @@ impl GlobalScope {
}
/// Start tracking a file
pub fn track_file(&self, file: &DomRoot<File>, blob_impl: BlobImpl) {
pub fn track_file(&self, file: &File, blob_impl: BlobImpl) {
let blob_id = blob_impl.blob_id();
let blob_info = BlobInfo {

View file

@ -199,7 +199,7 @@ impl Transferable for MessagePort {
/// https://html.spec.whatwg.org/multipage/#message-ports:transfer-receiving-steps
fn transfer_receive(
owner: &DomRoot<GlobalScope>,
owner: &GlobalScope,
sc_holder: &mut StructuredDataHolder,
extra_data: u64,
return_object: MutableHandleObject,
@ -249,7 +249,7 @@ impl Transferable for MessagePort {
};
let transferred_port =
MessagePort::new_transferred(&**owner, id.clone(), port_impl.entangled_port_id());
MessagePort::new_transferred(&*owner, id.clone(), port_impl.entangled_port_id());
owner.track_message_port(&transferred_port, Some(port_impl));
return_object.set(transferred_port.reflector().rootable().get());

View file

@ -623,6 +623,7 @@ def check_rust(file_name, lines):
(r"DomRefCell<Heap<.+>>", "Banned type DomRefCell<Heap<T>> detected. Use MutDom<T> instead", no_filter),
# No benefit to using &Root<T>
(r": &Root<", "use &T instead of &Root<T>", no_filter),
(r": &DomRoot<", "use &T instead of &DomRoot<T>", no_filter),
(r"^&&", "operators should go at the end of the first line", no_filter),
# This particular pattern is not reentrant-safe in script_thread.rs
(r"match self.documents.borrow", "use a separate variable for the match expression",

View file

@ -38,7 +38,7 @@ impl test {
}
}
fn test_fun2(y : &String, z : &Vec<f32>, r: &Root<isize>) -> () {
fn test_fun2(y : &String, z : &Vec<f32>, r: &Root<isize>, s: &DomRoot<isize>) -> () {
let x = true;
x
&& x;

View file

@ -112,6 +112,7 @@ class CheckTidiness(unittest.TestCase):
self.assertEqual('use &[T] instead of &Vec<T>', next(errors)[2])
self.assertEqual('use &str instead of &String', next(errors)[2])
self.assertEqual('use &T instead of &Root<T>', next(errors)[2])
self.assertEqual('use &T instead of &DomRoot<T>', next(errors)[2])
self.assertEqual('encountered function signature with -> ()', next(errors)[2])
self.assertEqual('operators should go at the end of the first line', next(errors)[2])
self.assertNoMoreErrors(errors)