aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Zbarsky <dzbarsky@gmail.com>2015-07-07 05:32:53 -0400
committerDavid Zbarsky <dzbarsky@gmail.com>2015-07-14 14:48:16 -0400
commitbc1eb976710fac2c35995996af77f67ba32f2cbb (patch)
tree794f82ddf677e435539e5d5eddd5744b5180e169
parent2947d78e4e0e7940b86e9fbdaa784ebbd28740f4 (diff)
downloadservo-bc1eb976710fac2c35995996af77f67ba32f2cbb.tar.gz
servo-bc1eb976710fac2c35995996af77f67ba32f2cbb.zip
Remove some more unnecessary let bindings
-rw-r--r--components/script/dom/dedicatedworkerglobalscope.rs4
-rw-r--r--components/script/dom/document.rs10
-rw-r--r--components/script/dom/element.rs46
-rw-r--r--components/script/dom/errorevent.rs12
-rw-r--r--components/script/dom/event.rs4
-rw-r--r--components/script/dom/eventtarget.rs4
-rw-r--r--components/script/dom/htmlelement.rs5
-rw-r--r--components/script/dom/htmltextareaelement.rs4
-rw-r--r--components/script/dom/keyboardevent.rs8
-rw-r--r--components/script/dom/urlsearchparams.rs8
-rw-r--r--components/script/dom/xmlhttprequest.rs8
11 files changed, 29 insertions, 84 deletions
diff --git a/components/script/dom/dedicatedworkerglobalscope.rs b/components/script/dom/dedicatedworkerglobalscope.rs
index 6aea05e0e78..040024b56aa 100644
--- a/components/script/dom/dedicatedworkerglobalscope.rs
+++ b/components/script/dom/dedicatedworkerglobalscope.rs
@@ -212,11 +212,9 @@ pub trait DedicatedWorkerGlobalScopeHelpers {
impl<'a> DedicatedWorkerGlobalScopeHelpers for &'a DedicatedWorkerGlobalScope {
fn script_chan(self) -> Box<ScriptChan+Send> {
- // FIXME(https://github.com/rust-lang/rust/issues/23338)
- let worker = self.worker.borrow();
box SendableWorkerScriptChan {
sender: self.own_sender.clone(),
- worker: worker.as_ref().unwrap().clone(),
+ worker: self.worker.borrow().as_ref().unwrap().clone(),
}
}
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs
index 7f8a864dcdc..83a9e5dedd4 100644
--- a/components/script/dom/document.rs
+++ b/components/script/dom/document.rs
@@ -468,10 +468,7 @@ impl<'a> DocumentHelpers<'a> for &'a Document {
let check_anchor = |&node: &&HTMLAnchorElement| {
let elem = ElementCast::from_ref(node);
elem.get_attribute(&ns!(""), &atom!("name")).map_or(false, |attr| {
- // FIXME(https://github.com/rust-lang/rust/issues/23338)
- let attr = attr.r();
- let value = attr.value();
- &**value == &*fragid
+ &**attr.r().value() == &*fragid
})
};
let doc_node = NodeCast::from_ref(self);
@@ -1562,10 +1559,7 @@ impl<'a> DocumentMethods for &'a Document {
return false;
}
element.get_attribute(&ns!(""), &atom!("name")).map_or(false, |attr| {
- // FIXME(https://github.com/rust-lang/rust/issues/23338)
- let attr = attr.r();
- let value = attr.value();
- &**value == &*name
+ &**attr.r().value() == &*name
})
})
}
diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs
index e60946193ff..ff9864c88b8 100644
--- a/components/script/dom/element.rs
+++ b/components/script/dom/element.rs
@@ -853,21 +853,15 @@ impl<'a> AttributeHandlers for &'a Element {
// https://dom.spec.whatwg.org/#concept-element-attributes-get-by-name
fn get_attribute_by_name(self, name: DOMString) -> Option<Root<Attr>> {
let name = &self.parsed_name(name);
- // FIXME(https://github.com/rust-lang/rust/issues/23338)
- let attrs = self.attrs.borrow();
- attrs.iter().map(|attr| attr.root())
+ self.attrs.borrow().iter().map(|attr| attr.root())
.find(|a| a.r().name() == name)
}
// https://dom.spec.whatwg.org/#concept-element-attributes-get-by-name
fn get_attributes(self, local_name: &Atom, attributes: &mut RootedVec<JS<Attr>>) {
- // FIXME(https://github.com/rust-lang/rust/issues/23338)
- let attrs = self.attrs.borrow();
- for ref attr in attrs.iter() {
- // FIXME(https://github.com/rust-lang/rust/issues/23338)
+ for ref attr in self.attrs.borrow().iter() {
let attr = attr.root();
- let attr_local_name = attr.r().local_name();
- if attr_local_name == local_name {
+ if attr.r().local_name() == local_name {
attributes.push(JS::from_rooted(&attr));
}
}
@@ -1010,10 +1004,7 @@ impl<'a> AttributeHandlers for &'a Element {
Quirks => lhs.eq_ignore_ascii_case(&rhs)
};
self.get_attribute(&ns!(""), &atom!("class")).map(|attr| {
- // FIXME(https://github.com/rust-lang/rust/issues/23338)
- let attr = attr.r();
- let value = attr.value();
- value.tokens().map(|tokens| {
+ attr.r().value().tokens().map(|tokens| {
tokens.iter().any(|atom| is_equal(name, atom))
}).unwrap_or(false)
}).unwrap_or(false)
@@ -1027,12 +1018,8 @@ impl<'a> AttributeHandlers for &'a Element {
fn has_attribute(self, local_name: &Atom) -> bool {
assert!(local_name.bytes().all(|b| b.to_ascii_lowercase() == b));
- // FIXME(https://github.com/rust-lang/rust/issues/23338)
- let attrs = self.attrs.borrow();
- attrs.iter().map(|attr| attr.root()).any(|attr| {
- // FIXME(https://github.com/rust-lang/rust/issues/23338)
- let attr = attr.r();
- attr.local_name() == local_name && attr.namespace() == &ns!("")
+ self.attrs.borrow().iter().map(|attr| attr.root()).any(|attr| {
+ attr.r().local_name() == local_name && attr.r().namespace() == &ns!("")
})
}
@@ -1077,12 +1064,11 @@ impl<'a> AttributeHandlers for &'a Element {
fn get_tokenlist_attribute(self, local_name: &Atom) -> Vec<Atom> {
self.get_attribute(&ns!(""), local_name).map(|attr| {
- // FIXME(https://github.com/rust-lang/rust/issues/23338)
- let attr = attr.r();
- let value = attr.value();
- value.tokens()
- .expect("Expected a TokenListAttrValue")
- .to_vec()
+ attr.r()
+ .value()
+ .tokens()
+ .expect("Expected a TokenListAttrValue")
+ .to_vec()
}).unwrap_or(vec!())
}
@@ -1663,10 +1649,7 @@ impl<'a> ::selectors::Element for &'a Element {
}
fn get_id(&self) -> Option<Atom> {
self.get_attribute(&ns!(""), &atom!("id")).map(|attr| {
- // FIXME(https://github.com/rust-lang/rust/issues/23338)
- let attr = attr.r();
- let value = attr.value();
- match *value {
+ match *attr.r().value() {
AttrValue::Atom(ref val) => val.clone(),
_ => panic!("`id` attribute should be AttrValue::Atom"),
}
@@ -1735,10 +1718,7 @@ impl<'a> ::selectors::Element for &'a Element {
NamespaceConstraint::Specific(ref ns) => {
self.get_attribute(ns, local_name)
.map_or(false, |attr| {
- // FIXME(https://github.com/rust-lang/rust/issues/23338)
- let attr = attr.r();
- let value = attr.value();
- test(&value)
+ test(&attr.r().value())
})
},
NamespaceConstraint::Any => {
diff --git a/components/script/dom/errorevent.rs b/components/script/dom/errorevent.rs
index 7d86e0e7921..39741f48c8c 100644
--- a/components/script/dom/errorevent.rs
+++ b/components/script/dom/errorevent.rs
@@ -65,10 +65,8 @@ impl ErrorEvent {
colno: u32,
error: HandleValue) -> Root<ErrorEvent> {
let ev = ErrorEvent::new_uninitialized(global);
- // FIXME(https://github.com/rust-lang/rust/issues/23338)
{
- let ev = ev.r();
- let event = EventCast::from_ref(ev);
+ let event = EventCast::from_ref(ev.r());
event.InitEvent(type_, bubbles == EventBubbles::Bubbles,
cancelable == EventCancelable::Cancelable);
*ev.message.borrow_mut() = message;
@@ -125,15 +123,11 @@ impl<'a> ErrorEventMethods for &'a ErrorEvent {
}
fn Message(self) -> DOMString {
- // FIXME(https://github.com/rust-lang/rust/issues/23338)
- let message = self.message.borrow();
- message.clone()
+ self.message.borrow().clone()
}
fn Filename(self) -> DOMString {
- // FIXME(https://github.com/rust-lang/rust/issues/23338)
- let filename = self.filename.borrow();
- filename.clone()
+ self.filename.borrow().clone()
}
fn Error(self, _cx: *mut JSContext) -> JSVal {
diff --git a/components/script/dom/event.rs b/components/script/dom/event.rs
index 0aeda84238f..a6a83e2ea5d 100644
--- a/components/script/dom/event.rs
+++ b/components/script/dom/event.rs
@@ -180,9 +180,7 @@ impl<'a> EventMethods for &'a Event {
// https://dom.spec.whatwg.org/#dom-event-type
fn Type(self) -> DOMString {
- // FIXME(https://github.com/rust-lang/rust/issues/23338)
- let type_ = self.type_.borrow();
- type_.clone()
+ self.type_.borrow().clone()
}
// https://dom.spec.whatwg.org/#dom-event-target
diff --git a/components/script/dom/eventtarget.rs b/components/script/dom/eventtarget.rs
index b780b35b1e7..78e3eda47ff 100644
--- a/components/script/dom/eventtarget.rs
+++ b/components/script/dom/eventtarget.rs
@@ -282,9 +282,7 @@ impl<'a> EventTargetHelpers for &'a EventTarget {
}
fn has_handlers(self) -> bool {
- // FIXME(https://github.com/rust-lang/rust/issues/23338)
- let handlers = self.handlers.borrow();
- !handlers.is_empty()
+ !self.handlers.borrow().is_empty()
}
}
diff --git a/components/script/dom/htmlelement.rs b/components/script/dom/htmlelement.rs
index 77aed899fbc..97d7aa0e755 100644
--- a/components/script/dom/htmlelement.rs
+++ b/components/script/dom/htmlelement.rs
@@ -250,10 +250,7 @@ impl<'a> HTMLElementCustomAttributeHelpers for &'a HTMLElement {
let element = ElementCast::from_ref(self);
let local_name = Atom::from_slice(&to_snake_case(local_name));
element.get_attribute(&ns!(""), &local_name).map(|attr| {
- // FIXME(https://github.com/rust-lang/rust/issues/23338)
- let attr = attr.r();
- let value = attr.value();
- (**value).to_owned()
+ (**attr.r().value()).to_owned()
})
}
diff --git a/components/script/dom/htmltextareaelement.rs b/components/script/dom/htmltextareaelement.rs
index 21a7b9ab2af..17e646d71ed 100644
--- a/components/script/dom/htmltextareaelement.rs
+++ b/components/script/dom/htmltextareaelement.rs
@@ -189,9 +189,7 @@ impl<'a> HTMLTextAreaElementMethods for &'a HTMLTextAreaElement {
// https://html.spec.whatwg.org/multipage/#dom-textarea-value
fn Value(self) -> DOMString {
- // FIXME(https://github.com/rust-lang/rust/issues/23338)
- let textinput = self.textinput.borrow();
- textinput.get_content()
+ self.textinput.borrow().get_content()
}
// https://html.spec.whatwg.org/multipage/#dom-textarea-value
diff --git a/components/script/dom/keyboardevent.rs b/components/script/dom/keyboardevent.rs
index e98dd2fe90a..156ab99e899 100644
--- a/components/script/dom/keyboardevent.rs
+++ b/components/script/dom/keyboardevent.rs
@@ -784,15 +784,11 @@ impl<'a> KeyboardEventMethods for &'a KeyboardEvent {
}
fn Key(self) -> DOMString {
- // FIXME(https://github.com/rust-lang/rust/issues/23338)
- let key_string = self.key_string.borrow();
- key_string.clone()
+ self.key_string.borrow().clone()
}
fn Code(self) -> DOMString {
- // FIXME(https://github.com/rust-lang/rust/issues/23338)
- let code = self.code.borrow();
- code.clone()
+ self.code.borrow().clone()
}
fn Location(self) -> u32 {
diff --git a/components/script/dom/urlsearchparams.rs b/components/script/dom/urlsearchparams.rs
index 0b2432cac31..f51440f51df 100644
--- a/components/script/dom/urlsearchparams.rs
+++ b/components/script/dom/urlsearchparams.rs
@@ -45,15 +45,11 @@ impl URLSearchParams {
match init {
Some(eString(init)) => {
// Step 2.
- let query = query.r();
- *query.list.borrow_mut() = parse(init.as_bytes());
+ *query.r().list.borrow_mut() = parse(init.as_bytes());
},
Some(eURLSearchParams(init)) => {
// Step 3.
- // FIXME(https://github.com/rust-lang/rust/issues/23338)
- let query = query.r();
- let init = init.r();
- *query.list.borrow_mut() = init.list.borrow().clone();
+ *query.r().list.borrow_mut() = init.r().list.borrow().clone();
},
None => {}
}
diff --git a/components/script/dom/xmlhttprequest.rs b/components/script/dom/xmlhttprequest.rs
index f618877f802..d849fbdd3ba 100644
--- a/components/script/dom/xmlhttprequest.rs
+++ b/components/script/dom/xmlhttprequest.rs
@@ -623,9 +623,7 @@ impl<'a> XMLHttpRequestMethods for &'a XMLHttpRequest {
// https://xhr.spec.whatwg.org/#the-statustext-attribute
fn StatusText(self) -> ByteString {
- // FIXME(https://github.com/rust-lang/rust/issues/23338)
- let status_text = self.status_text.borrow();
- status_text.clone()
+ self.status_text.borrow().clone()
}
// https://xhr.spec.whatwg.org/#the-getresponseheader()-method
@@ -1031,11 +1029,9 @@ impl<'a> PrivateXMLHttpRequestHelpers for &'a XMLHttpRequest {
}
- // FIXME(https://github.com/rust-lang/rust/issues/23338)
- let response = self.response.borrow();
// According to Simon, decode() should never return an error, so unwrap()ing
// the result should be fine. XXXManishearth have a closer look at this later
- encoding.decode(&response, DecoderTrap::Replace).unwrap().to_owned()
+ encoding.decode(&self.response.borrow(), DecoderTrap::Replace).unwrap().to_owned()
}
fn filter_response_headers(self) -> Headers {
// https://fetch.spec.whatwg.org/#concept-response-header-list