From 334102b0388b9079d96f6817a946ce04394b97ea Mon Sep 17 00:00:00 2001 From: Margaret Meyerhofer Date: Thu, 28 Jun 2012 10:56:03 -0700 Subject: [PATCH] cleaned up more warnings and a few copies --- src/servo/dom/rcu.rs | 2 +- src/servo/parser/css_lexer.rs | 3 ++- src/servo/parser/html_lexer.rs | 15 ++++++++------- src/servo/parser/lexer_util.rs | 7 ++----- src/servo/servo.rc | 2 ++ 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/servo/dom/rcu.rs b/src/servo/dom/rcu.rs index 7931d06639b..a1a3eae34f4 100644 --- a/src/servo/dom/rcu.rs +++ b/src/servo/dom/rcu.rs @@ -65,7 +65,7 @@ type ScopeData = { class ScopeResource { let d : ScopeData; - new(d : ScopeData) { + new(-d : ScopeData) { self.d = d; } drop unsafe { diff --git a/src/servo/parser/css_lexer.rs b/src/servo/parser/css_lexer.rs index 6ce3f762f46..3f56300e4b2 100644 --- a/src/servo/parser/css_lexer.rs +++ b/src/servo/parser/css_lexer.rs @@ -1,6 +1,7 @@ import comm::{port, chan}; import dom::style; import option::is_none; +import str::from_bytes; import lexer_util::*; @@ -208,7 +209,7 @@ impl css_methods for CssLexer { } } - ret Description(desc_name.to_str(), desc_val.to_str()); + ret Description(from_bytes(desc_name), from_bytes(desc_val)); } } diff --git a/src/servo/parser/html_lexer.rs b/src/servo/parser/html_lexer.rs index de203a9ad12..ad171afeab8 100644 --- a/src/servo/parser/html_lexer.rs +++ b/src/servo/parser/html_lexer.rs @@ -1,6 +1,7 @@ import comm::{port, chan}; import dom::style; import option::is_none; +import str::from_bytes; import lexer_util::*; enum Token { @@ -81,11 +82,11 @@ impl html_methods for HtmlLexer { CoeChar(c) { if c == ('<' as u8) { self.input_state.unget(c); - ret s.to_html_token(); + ret Text(from_bytes(s)); } s += [c]; } - CoeEof { ret s.to_html_token(); } + CoeEof { ret Text(from_bytes(s)); } } } } @@ -127,7 +128,8 @@ impl html_methods for HtmlLexer { attribute_name += [c]; } CoeEof { - ret Attr(attribute_name.to_str(), attribute_name.to_str()); + let name = from_bytes(attribute_name); + ret Attr(copy name, name); } } } @@ -142,7 +144,7 @@ impl html_methods for HtmlLexer { attribute_value += [c]; } CoeEof { - ret Attr(attribute_name.to_str(), attribute_value.to_str()); + ret Attr(from_bytes(attribute_name), from_bytes(attribute_value)); } } } @@ -150,13 +152,12 @@ impl html_methods for HtmlLexer { // Eat whitespacpe. self.input_state.eat_whitespace(); - ret Attr(attribute_name.to_str(), attribute_value.to_str()); + ret Attr(from_bytes(attribute_name), from_bytes(attribute_value)); } } fn lexer(reader: io::reader, state : ParseState) -> HtmlLexer { - ret { input_state: {mut lookahead: none, reader: reader}, - mut parser_state: state }; + ret { input_state: {mut lookahead: none, reader: reader}, mut parser_state: state }; } #[warn(no_non_implicitly_copyable_typarams)] diff --git a/src/servo/parser/lexer_util.rs b/src/servo/parser/lexer_util.rs index 86f4082a49e..f925c82e858 100644 --- a/src/servo/parser/lexer_util.rs +++ b/src/servo/parser/lexer_util.rs @@ -1,4 +1,6 @@ import option::is_none; +import str::from_bytes; + enum CharOrEof { CoeChar(u8), @@ -21,11 +23,6 @@ impl u8_methods for u8 { } } -impl u8_vec_methods for [u8] { - fn to_html_token() -> html_lexer::Token { ret html_lexer::Text(self.to_str()); } - fn to_str() -> str { ret str::from_bytes(self); } -} - impl util_methods for InputState { fn get() -> CharOrEof { alt copy self.lookahead { diff --git a/src/servo/servo.rc b/src/servo/servo.rc index f0fa4e3e793..0a17e259e33 100755 --- a/src/servo/servo.rc +++ b/src/servo/servo.rc @@ -7,6 +7,8 @@ #[license = "MPL"]; #[crate_type = "lib"]; +#[warn(no_old_vecs)]; + use std; use sdl; use azure;