aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2015-11-27 04:48:38 +0530
committerbors-servo <lbergstrom+bors@mozilla.com>2015-11-27 04:48:38 +0530
commitf96e8ce9e8c0a2c9de9574f538718defdcd93c11 (patch)
tree3605399b0f796ecd9505c2d9a79beaad96a53dae
parentf5ef2f4f75cd58a3c6f1f123e413dc9d3a24f841 (diff)
parentdf49cf2b132ae89ac71f316efd2e40a6f74dab2c (diff)
downloadservo-f96e8ce9e8c0a2c9de9574f538718defdcd93c11.tar.gz
servo-f96e8ce9e8c0a2c9de9574f538718defdcd93c11.zip
Auto merge of #8685 - jmr0:master, r=Ms2ger
tidy rule to warn against use of &String and refactoring Fixes #8681 <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8685) <!-- Reviewable:end -->
-rw-r--r--components/net/mime_classifier.rs4
-rw-r--r--components/profile/mem.rs2
-rw-r--r--components/webdriver_server/lib.rs8
-rw-r--r--python/tidy.py4
4 files changed, 11 insertions, 7 deletions
diff --git a/components/net/mime_classifier.rs b/components/net/mime_classifier.rs
index 948425890e3..29f559a4738 100644
--- a/components/net/mime_classifier.rs
+++ b/components/net/mime_classifier.rs
@@ -129,8 +129,8 @@ impl MIMEClassifier {
}
}
- fn get_media_type(media_type: &String,
- media_subtype: &String) -> Option<MediaType> {
+ fn get_media_type(media_type: &str,
+ media_subtype: &str) -> Option<MediaType> {
if MIMEClassifier::is_xml(media_type, media_subtype) {
Some(MediaType::Xml)
} else if MIMEClassifier::is_html(media_type, media_subtype) {
diff --git a/components/profile/mem.rs b/components/profile/mem.rs
index 0bd91f7afed..becd2d05554 100644
--- a/components/profile/mem.rs
+++ b/components/profile/mem.rs
@@ -225,7 +225,7 @@ impl ReportsTree {
// Searches the tree's children for a path_seg match, and returns the index if there is a
// match.
- fn find_child(&self, path_seg: &String) -> Option<usize> {
+ fn find_child(&self, path_seg: &str) -> Option<usize> {
for (i, child) in self.children.iter().enumerate() {
if child.path_seg == *path_seg {
return Some(i);
diff --git a/components/webdriver_server/lib.rs b/components/webdriver_server/lib.rs
index 9bad724d164..22acb46d52d 100644
--- a/components/webdriver_server/lib.rs
+++ b/components/webdriver_server/lib.rs
@@ -525,11 +525,11 @@ impl Handler {
}
}
- fn handle_element_attribute(&self, element: &WebElement, name: &String) -> WebDriverResult<WebDriverResponse> {
+ fn handle_element_attribute(&self, element: &WebElement, name: &str) -> WebDriverResult<WebDriverResponse> {
let pipeline_id = try!(self.frame_pipeline());
let (sender, receiver) = ipc::channel().unwrap();
- let cmd = WebDriverScriptCommand::GetElementAttribute(element.id.clone(), name.clone(), sender);
+ let cmd = WebDriverScriptCommand::GetElementAttribute(element.id.clone(), name.to_owned(), sender);
let cmd_msg = WebDriverCommandMsg::ScriptCommand(pipeline_id, cmd);
self.constellation_chan.send(ConstellationMsg::WebDriverCommand(cmd_msg)).unwrap();
match receiver.recv().unwrap() {
@@ -539,11 +539,11 @@ impl Handler {
}
}
- fn handle_element_css(&self, element: &WebElement, name: &String) -> WebDriverResult<WebDriverResponse> {
+ fn handle_element_css(&self, element: &WebElement, name: &str) -> WebDriverResult<WebDriverResponse> {
let pipeline_id = try!(self.frame_pipeline());
let (sender, receiver) = ipc::channel().unwrap();
- let cmd = WebDriverScriptCommand::GetElementCSS(element.id.clone(), name.clone(), sender);
+ let cmd = WebDriverScriptCommand::GetElementCSS(element.id.clone(), name.to_owned(), sender);
let cmd_msg = WebDriverCommandMsg::ScriptCommand(pipeline_id, cmd);
self.constellation_chan.send(ConstellationMsg::WebDriverCommand(cmd_msg)).unwrap();
match receiver.recv().unwrap() {
diff --git a/python/tidy.py b/python/tidy.py
index dd2ef9d29cc..499fb8c5efc 100644
--- a/python/tidy.py
+++ b/python/tidy.py
@@ -369,6 +369,10 @@ def check_rust(file_name, contents):
if ": &Vec<" in line:
yield (idx + 1, "use &[T] instead of &Vec<T>")
+ # No benefit over using &str
+ if ": &String" in line:
+ yield (idx + 1, "use &str instead of &String")
+
# Avoid flagging <Item=Foo> constructs
def is_associated_type(match, line, index):