auto merge of #2617 : Manishearth/servo/string-warn, r=Ms2ger

This commit is contained in:
bors-servo 2014-06-08 12:46:31 -04:00
commit 6e856f4d1c
7 changed files with 53 additions and 53 deletions

View file

@ -49,7 +49,7 @@ impl FontContextHandleMethods for FontContextHandle {
debug!("Creating font handle for {:s}", name); debug!("Creating font handle for {:s}", name);
path_from_identifier(name, &style).and_then(|file_name| { path_from_identifier(name, &style).and_then(|file_name| {
debug!("Opening font face {:s}", file_name); debug!("Opening font face {:s}", file_name);
FontHandle::new_from_file(self, file_name.to_owned(), &style) FontHandle::new_from_file(self, file_name.to_string(), &style)
}) })
} }
} }

View file

@ -130,7 +130,7 @@ impl FontListHandle {
} }
pub fn get_last_resort_font_families() -> Vec<~str> { pub fn get_last_resort_font_families() -> Vec<~str> {
vec!("Roboto".to_owned()) vec!("Roboto".to_string())
} }
} }

View file

@ -195,21 +195,21 @@ fn test_transform_discard_newline() {
/* FIXME: Fix and re-enable /* FIXME: Fix and re-enable
#[test] #[test]
fn test_transform_compress_whitespace() { fn test_transform_compress_whitespace() {
let test_strs : ~[String] = ~[" foo bar".to_owned(), let test_strs : ~[String] = ~[" foo bar".to_string(),
"foo bar ".to_owned(), "foo bar ".to_string(),
"foo\n bar".to_owned(), "foo\n bar".to_string(),
"foo \nbar".to_owned(), "foo \nbar".to_string(),
" foo bar \nbaz".to_owned(), " foo bar \nbaz".to_string(),
"foo bar baz".to_owned(), "foo bar baz".to_string(),
"foobarbaz\n\n".to_owned()]; "foobarbaz\n\n".to_string()];
let oracle_strs : ~[String] = ~[" foo bar".to_owned(), let oracle_strs : ~[String] = ~[" foo bar".to_string(),
"foo bar ".to_owned(), "foo bar ".to_string(),
"foo\n bar".to_owned(), "foo\n bar".to_string(),
"foo \nbar".to_owned(), "foo \nbar".to_string(),
" foo bar \nbaz".to_owned(), " foo bar \nbaz".to_string(),
"foo bar baz".to_owned(), "foo bar baz".to_string(),
"foobarbaz\n\n".to_owned()]; "foobarbaz\n\n".to_string()];
assert_eq!(test_strs.len(), oracle_strs.len()); assert_eq!(test_strs.len(), oracle_strs.len());
let mode = CompressWhitespace; let mode = CompressWhitespace;
@ -223,21 +223,21 @@ fn test_transform_compress_whitespace() {
#[test] #[test]
fn test_transform_compress_whitespace_newline() { fn test_transform_compress_whitespace_newline() {
let test_strs : ~[String] = ~[" foo bar".to_owned(), let test_strs : ~[String] = ~[" foo bar".to_string(),
"foo bar ".to_owned(), "foo bar ".to_string(),
"foo\n bar".to_owned(), "foo\n bar".to_string(),
"foo \nbar".to_owned(), "foo \nbar".to_string(),
" foo bar \nbaz".to_owned(), " foo bar \nbaz".to_string(),
"foo bar baz".to_owned(), "foo bar baz".to_string(),
"foobarbaz\n\n".to_owned()]; "foobarbaz\n\n".to_string()];
let oracle_strs : ~[String] = ~["foo bar".to_owned(), let oracle_strs : ~[String] = ~["foo bar".to_string(),
"foo bar ".to_owned(), "foo bar ".to_string(),
"foo bar".to_owned(), "foo bar".to_string(),
"foo bar".to_owned(), "foo bar".to_string(),
" foo bar baz".to_owned(), " foo bar baz".to_string(),
"foo bar baz".to_owned(), "foo bar baz".to_string(),
"foobarbaz ".to_owned()]; "foobarbaz ".to_string()];
assert_eq!(test_strs.len(), oracle_strs.len()); assert_eq!(test_strs.len(), oracle_strs.len());
let mode = CompressWhitespaceNewline; let mode = CompressWhitespaceNewline;

View file

@ -65,7 +65,7 @@ impl WindowMethods<Application> for Window {
fn new(_: &Application, _: bool) -> Rc<Window> { fn new(_: &Application, _: bool) -> Rc<Window> {
// Create the GLUT window. // Create the GLUT window.
glut::init_window_size(800, 600); glut::init_window_size(800, 600);
let glut_window = glut::create_window("Servo".to_owned()); let glut_window = glut::create_window("Servo".to_string());
// Create our window object. // Create our window object.
let window = Window { let window = Window {
@ -275,7 +275,7 @@ impl Window {
alert.run(); alert.run();
let value = alert.prompt_value(); let value = alert.prompt_value();
if "" == value { // To avoid crashing on Linux. if "" == value { // To avoid crashing on Linux.
self.event_queue.borrow_mut().push(LoadUrlWindowEvent("http://purple.com/".to_owned())) self.event_queue.borrow_mut().push(LoadUrlWindowEvent("http://purple.com/".to_string()))
} else { } else {
self.event_queue.borrow_mut().push(LoadUrlWindowEvent(value.clone())) self.event_queue.borrow_mut().push(LoadUrlWindowEvent(value.clone()))
} }

View file

@ -980,23 +980,23 @@ mod tests {
fn test_get_id_name(){ fn test_get_id_name(){
let rules_list = get_mock_rules([".intro", "#top"]); let rules_list = get_mock_rules([".intro", "#top"]);
assert_eq!(SelectorMap::get_id_name(rules_list.get(0).get(0)), None); assert_eq!(SelectorMap::get_id_name(rules_list.get(0).get(0)), None);
assert_eq!(SelectorMap::get_id_name(rules_list.get(1).get(0)), Some("top".to_owned())); assert_eq!(SelectorMap::get_id_name(rules_list.get(1).get(0)), Some("top".to_string()));
} }
#[test] #[test]
fn test_get_class_name(){ fn test_get_class_name(){
let rules_list = get_mock_rules([".intro.foo", "#top"]); let rules_list = get_mock_rules([".intro.foo", "#top"]);
assert_eq!(SelectorMap::get_class_name(rules_list.get(0).get(0)), Some("intro".to_owned())); assert_eq!(SelectorMap::get_class_name(rules_list.get(0).get(0)), Some("intro".to_string()));
assert_eq!(SelectorMap::get_class_name(rules_list.get(1).get(0)), None); assert_eq!(SelectorMap::get_class_name(rules_list.get(1).get(0)), None);
} }
#[test] #[test]
fn test_get_element_name(){ fn test_get_element_name(){
let rules_list = get_mock_rules(["img.foo", "#top", "IMG", "ImG"]); let rules_list = get_mock_rules(["img.foo", "#top", "IMG", "ImG"]);
assert_eq!(SelectorMap::get_element_name(rules_list.get(0).get(0)), Some("img".to_owned())); assert_eq!(SelectorMap::get_element_name(rules_list.get(0).get(0)), Some("img".to_string()));
assert_eq!(SelectorMap::get_element_name(rules_list.get(1).get(0)), None); assert_eq!(SelectorMap::get_element_name(rules_list.get(1).get(0)), None);
assert_eq!(SelectorMap::get_element_name(rules_list.get(2).get(0)), Some("img".to_owned())); assert_eq!(SelectorMap::get_element_name(rules_list.get(2).get(0)), Some("img".to_string()));
assert_eq!(SelectorMap::get_element_name(rules_list.get(3).get(0)), Some("img".to_owned())); assert_eq!(SelectorMap::get_element_name(rules_list.get(3).get(0)), Some("img".to_string()));
} }
#[test] #[test]

View file

@ -595,7 +595,7 @@ mod tests {
assert!(parse("") == None) assert!(parse("") == None)
assert!(parse("e") == Some(vec!(Selector{ assert!(parse("e") == Some(vec!(Selector{
compound_selectors: Arc::new(CompoundSelector { compound_selectors: Arc::new(CompoundSelector {
simple_selectors: vec!(LocalNameSelector("e".to_owned())), simple_selectors: vec!(LocalNameSelector("e".to_string())),
next: None, next: None,
}), }),
pseudo_element: None, pseudo_element: None,
@ -603,7 +603,7 @@ mod tests {
}))) })))
assert!(parse(".foo") == Some(vec!(Selector{ assert!(parse(".foo") == Some(vec!(Selector{
compound_selectors: Arc::new(CompoundSelector { compound_selectors: Arc::new(CompoundSelector {
simple_selectors: vec!(ClassSelector("foo".to_owned())), simple_selectors: vec!(ClassSelector("foo".to_string())),
next: None, next: None,
}), }),
pseudo_element: None, pseudo_element: None,
@ -611,7 +611,7 @@ mod tests {
}))) })))
assert!(parse("#bar") == Some(vec!(Selector{ assert!(parse("#bar") == Some(vec!(Selector{
compound_selectors: Arc::new(CompoundSelector { compound_selectors: Arc::new(CompoundSelector {
simple_selectors: vec!(IDSelector("bar".to_owned())), simple_selectors: vec!(IDSelector("bar".to_string())),
next: None, next: None,
}), }),
pseudo_element: None, pseudo_element: None,
@ -619,9 +619,9 @@ mod tests {
}))) })))
assert!(parse("e.foo#bar") == Some(vec!(Selector{ assert!(parse("e.foo#bar") == Some(vec!(Selector{
compound_selectors: Arc::new(CompoundSelector { compound_selectors: Arc::new(CompoundSelector {
simple_selectors: vec!(LocalNameSelector("e".to_owned()), simple_selectors: vec!(LocalNameSelector("e".to_string()),
ClassSelector("foo".to_owned()), ClassSelector("foo".to_string()),
IDSelector("bar".to_owned())), IDSelector("bar".to_string())),
next: None, next: None,
}), }),
pseudo_element: None, pseudo_element: None,
@ -629,10 +629,10 @@ mod tests {
}))) })))
assert!(parse("e.foo #bar") == Some(vec!(Selector{ assert!(parse("e.foo #bar") == Some(vec!(Selector{
compound_selectors: Arc::new(CompoundSelector { compound_selectors: Arc::new(CompoundSelector {
simple_selectors: vec!(IDSelector("bar".to_owned())), simple_selectors: vec!(IDSelector("bar".to_string())),
next: Some((box CompoundSelector { next: Some((box CompoundSelector {
simple_selectors: vec!(LocalNameSelector("e".to_owned()), simple_selectors: vec!(LocalNameSelector("e".to_string()),
ClassSelector("foo".to_owned())), ClassSelector("foo".to_string())),
next: None, next: None,
}, Descendant)), }, Descendant)),
}), }),
@ -645,8 +645,8 @@ mod tests {
assert!(parse_ns("[Foo]", &namespaces) == Some(vec!(Selector{ assert!(parse_ns("[Foo]", &namespaces) == Some(vec!(Selector{
compound_selectors: Arc::new(CompoundSelector { compound_selectors: Arc::new(CompoundSelector {
simple_selectors: vec!(AttrExists(AttrSelector { simple_selectors: vec!(AttrExists(AttrSelector {
name: "Foo".to_owned(), name: "Foo".to_string(),
lower_name: "foo".to_owned(), lower_name: "foo".to_string(),
namespace: SpecificNamespace(namespace::Null), namespace: SpecificNamespace(namespace::Null),
})), })),
next: None, next: None,
@ -660,8 +660,8 @@ mod tests {
assert!(parse_ns("[Foo]", &namespaces) == Some(vec!(Selector{ assert!(parse_ns("[Foo]", &namespaces) == Some(vec!(Selector{
compound_selectors: Arc::new(CompoundSelector { compound_selectors: Arc::new(CompoundSelector {
simple_selectors: vec!(AttrExists(AttrSelector { simple_selectors: vec!(AttrExists(AttrSelector {
name: "Foo".to_owned(), name: "Foo".to_string(),
lower_name: "foo".to_owned(), lower_name: "foo".to_string(),
namespace: SpecificNamespace(namespace::Null), namespace: SpecificNamespace(namespace::Null),
})), })),
next: None, next: None,
@ -674,7 +674,7 @@ mod tests {
compound_selectors: Arc::new(CompoundSelector { compound_selectors: Arc::new(CompoundSelector {
simple_selectors: vec!( simple_selectors: vec!(
NamespaceSelector(namespace::MathML), NamespaceSelector(namespace::MathML),
LocalNameSelector("e".to_owned()), LocalNameSelector("e".to_string()),
), ),
next: None, next: None,
}), }),
@ -694,7 +694,7 @@ mod tests {
compound_selectors: Arc::new(CompoundSelector { compound_selectors: Arc::new(CompoundSelector {
simple_selectors: vec!(), simple_selectors: vec!(),
next: Some((box CompoundSelector { next: Some((box CompoundSelector {
simple_selectors: vec!(LocalNameSelector("div".to_owned())), simple_selectors: vec!(LocalNameSelector("div".to_string())),
next: None, next: None,
}, Descendant)), }, Descendant)),
}), }),

View file

@ -10,7 +10,7 @@ pub type StaticCharVec = &'static [char];
pub type StaticStringVec = &'static [&'static str]; pub type StaticStringVec = &'static [&'static str];
pub fn null_str_as_empty(s: &Option<DOMString>) -> DOMString { pub fn null_str_as_empty(s: &Option<DOMString>) -> DOMString {
// We don't use map_default because it would allocate "".to_owned() even for Some. // We don't use map_default because it would allocate "".to_string() even for Some.
match *s { match *s {
Some(ref s) => s.clone(), Some(ref s) => s.clone(),
None => "".to_string() None => "".to_string()