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 -->
This commit is contained in:
bors-servo 2015-11-27 04:48:38 +05:30
commit f96e8ce9e8
4 changed files with 11 additions and 7 deletions

View file

@ -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) {

View file

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

View file

@ -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() {

View file

@ -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):