mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
adding tidy rule to warn against use of &String and refactoring instances of &String in codebase
This commit is contained in:
parent
8efc954531
commit
df49cf2b13
4 changed files with 11 additions and 7 deletions
|
@ -129,8 +129,8 @@ impl MIMEClassifier {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_media_type(media_type: &String,
|
fn get_media_type(media_type: &str,
|
||||||
media_subtype: &String) -> Option<MediaType> {
|
media_subtype: &str) -> Option<MediaType> {
|
||||||
if MIMEClassifier::is_xml(media_type, media_subtype) {
|
if MIMEClassifier::is_xml(media_type, media_subtype) {
|
||||||
Some(MediaType::Xml)
|
Some(MediaType::Xml)
|
||||||
} else if MIMEClassifier::is_html(media_type, media_subtype) {
|
} else if MIMEClassifier::is_html(media_type, media_subtype) {
|
||||||
|
|
|
@ -225,7 +225,7 @@ impl ReportsTree {
|
||||||
|
|
||||||
// Searches the tree's children for a path_seg match, and returns the index if there is a
|
// Searches the tree's children for a path_seg match, and returns the index if there is a
|
||||||
// match.
|
// 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() {
|
for (i, child) in self.children.iter().enumerate() {
|
||||||
if child.path_seg == *path_seg {
|
if child.path_seg == *path_seg {
|
||||||
return Some(i);
|
return Some(i);
|
||||||
|
|
|
@ -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 pipeline_id = try!(self.frame_pipeline());
|
||||||
|
|
||||||
let (sender, receiver) = ipc::channel().unwrap();
|
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);
|
let cmd_msg = WebDriverCommandMsg::ScriptCommand(pipeline_id, cmd);
|
||||||
self.constellation_chan.send(ConstellationMsg::WebDriverCommand(cmd_msg)).unwrap();
|
self.constellation_chan.send(ConstellationMsg::WebDriverCommand(cmd_msg)).unwrap();
|
||||||
match receiver.recv().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 pipeline_id = try!(self.frame_pipeline());
|
||||||
|
|
||||||
let (sender, receiver) = ipc::channel().unwrap();
|
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);
|
let cmd_msg = WebDriverCommandMsg::ScriptCommand(pipeline_id, cmd);
|
||||||
self.constellation_chan.send(ConstellationMsg::WebDriverCommand(cmd_msg)).unwrap();
|
self.constellation_chan.send(ConstellationMsg::WebDriverCommand(cmd_msg)).unwrap();
|
||||||
match receiver.recv().unwrap() {
|
match receiver.recv().unwrap() {
|
||||||
|
|
|
@ -369,6 +369,10 @@ def check_rust(file_name, contents):
|
||||||
if ": &Vec<" in line:
|
if ": &Vec<" in line:
|
||||||
yield (idx + 1, "use &[T] instead of &Vec<T>")
|
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
|
# Avoid flagging <Item=Foo> constructs
|
||||||
def is_associated_type(match, line, index):
|
def is_associated_type(match, line, index):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue