No bug - Revendor rust dependencies

This commit is contained in:
Servo VCS Sync 2017-07-06 22:11:55 +00:00
Родитель 94ab53b2b8
Коммит 3805d91f4d
10 изменённых файлов: 91 добавлений и 155 удалений

Просмотреть файл

@ -1 +1 @@
{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".travis.yml":"f1fb4b65964c81bc1240544267ea334f554ca38ae7a74d57066f4d47d2b5d568","Cargo.toml":"54e2f60d6d494286a1d7f3ad8cadcd374d343b2becf1955bc1faa7d91ea51e93","LICENSE":"fab3dd6bdab226f1c08630b1dd917e11fcb4ec5e1e020e2c16f83a0a13863e85","README.md":"c5781e673335f37ed3d7acb119f8ed33efdf6eb75a7094b7da2abe0c3230adb8","build.rs":"950bcc47a196f07f99f59637c28cc65e02a885130011f90a2b2608248b4724a2","build/match_byte.rs":"89e8b941af74df2c204abf808672d3ff278bdec75abc918c41a843260b924677","docs/.nojekyll":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","docs/404.html":"025861f76f8d1f6d67c20ab624c6e418f4f824385e2dd8ad8732c4ea563c6a2e","docs/index.html":"025861f76f8d1f6d67c20ab624c6e418f4f824385e2dd8ad8732c4ea563c6a2e","src/big-data-url.css":"04a8f6197ea1181123bca48bd1ebd016268e1da40f01b8f21055814e44bf62b8","src/color.rs":"4b7ab1cb0271340aee65bfd535dfa19ba9c56222fbf7165807aae7c67e321665","src/compact_cow_str.rs":"7f5abdae953febe5a833604e6868d6f60518f1b4ece8de6a8aa8d521f21b8daa","src/css-parsing-tests/An+B.json":"d24559c1dad55d3da9d1fca29383edefdfc6046988435d6388a9bc0f28850257","src/css-parsing-tests/LICENSE":"5f9019a92f4aa8917aadc8e035aa673c2c1bf08d5ca2e535a0564106599f44eb","src/css-parsing-tests/README.rst":"233ce4fdc3e7306db23787fed0b67b0eb81a4600281ec0f7ff22270f2679ca8e","src/css-parsing-tests/color3.json":"9db91fd04a0424dcbde2b1bf530d4dbaa7502c887978aaaca75a613fbee028e9","src/css-parsing-tests/color3_hsl.json":"61c3b7d8d5ae02f94769d64458e0dd29e4c22c5068e5ea44040d14b88f9616b0","src/css-parsing-tests/color3_keywords.json":"95609bf9fe762c316878a30f371fa375a2e51c21a6fda24fa188a95cd9118f5c","src/css-parsing-tests/component_value_list.json":"516f9495fe089fa669321660bc431d7884839da8fb73e45edcbcd98625cb09dc","src/css-parsing-tests/declaration_list.json":"0b85cc3f19e945f838432acbfb9edb003abea13debc4ea27bcdcef25d117eac5","src/css-parsing-tests/make_color3_hsl.py":"3df7dd908ee719f78fd097ab24622f75edd10fcb67514230c172cbfc842c8ab7","src/css-parsing-tests/make_color3_keywords.py":"66bccab3f1dea18698fcfd854be79b1fd1cd724dd487e25b1f057b522163aad2","src/css-parsing-tests/one_component_value.json":"8798017709002e14cf11e203c9d716f82d308ce6ba0f6e64ee4eea331b8485c6","src/css-parsing-tests/one_declaration.json":"a34c9da56edfff9e2e21615f059e141b0e878e90f794dc8fa58d65b47cd193ed","src/css-parsing-tests/one_rule.json":"88f7b1b6049be88e1e2827673b75fc9261986b216e8ee6bf09621fecbe274e3c","src/css-parsing-tests/rule_list.json":"97c45e80fb83abef149a4016c5625a74f053e7ad70a2ce5a95c02fce1c195686","src/css-parsing-tests/stylesheet.json":"05f1e10fc486bfbda2c059c313a74ff78c0063c0768b99737cab41969c0c87ce","src/css-parsing-tests/stylesheet_bytes.json":"890fd856a596e61f82cf7ed77920ffe95df89209fdb5ee0afe0b26bdfdb80a42","src/css-parsing-tests/urange.json":"62720b143ddf52508baad42921473dd69519aad6c1cd49f37f3f264dc29e1c13","src/from_bytes.rs":"331fe63af2123ae3675b61928a69461b5ac77799fff3ce9978c55cf2c558f4ff","src/lib.rs":"a612f377e1b8a4bf1830c4a1da5b4d52296e965fc59ef2d8f915a49fd8db3a37","src/macros.rs":"adb9773c157890381556ea83d7942dcc676f99eea71abbb6afeffee1e3f28960","src/nth.rs":"5304dc5056164c4c6fe4f9682114b0126a28a912fc7af5b63ee86ef4eb728225","src/parser.rs":"a5f8755d0f522ab54a5fce8bcc71b7269101025f7612892f0f0340ccc3300dee","src/rules_and_declarations.rs":"0e4d871d9d0f92f303e97ec6f1fa1d3b5a18edc24922b706d279f6ccebc0d6b5","src/serializer.rs":"c872921703dc029155a8019b51df0d23066b072c7e1f553422e448e66218fbdc","src/size_of_tests.rs":"fdcc0a12e274cc86b057e607e099b9b3f6af842d0edf9b65e40c0fcdd76fbf17","src/tests.rs":"35aff1f516da80fbeb72175b716a76d8c58dac0f3664d8ea8f56ac61c5768360","src/tokenizer.rs":"6498c8f1e14c0bd4e36e87651007f03eb37583d11dbcebd428afbdb81336d00e","src/unicode_range.rs":"efd937ab97ab6a38e2cfe2e89a44e259c33d111ee73ba4a6c4388b8517607d2d"},"package":"e7063452c60432cb306ed54d538178c20792d47fa960c240ce6c083239ee55ec"}
{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",".travis.yml":"f1fb4b65964c81bc1240544267ea334f554ca38ae7a74d57066f4d47d2b5d568","Cargo.toml":"48c6ae2b34febe2e7287b10e46fd77e6a9c7bb0a7e7f55de551e8113c1abba70","LICENSE":"fab3dd6bdab226f1c08630b1dd917e11fcb4ec5e1e020e2c16f83a0a13863e85","README.md":"9afe084d70a5d9396674a2624012d6ac749df35f81e322d2d75b042bf208f523","build.rs":"950bcc47a196f07f99f59637c28cc65e02a885130011f90a2b2608248b4724a2","build/match_byte.rs":"89e8b941af74df2c204abf808672d3ff278bdec75abc918c41a843260b924677","docs/.nojekyll":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","docs/404.html":"025861f76f8d1f6d67c20ab624c6e418f4f824385e2dd8ad8732c4ea563c6a2e","docs/index.html":"025861f76f8d1f6d67c20ab624c6e418f4f824385e2dd8ad8732c4ea563c6a2e","src/big-data-url.css":"04a8f6197ea1181123bca48bd1ebd016268e1da40f01b8f21055814e44bf62b8","src/color.rs":"4b7ab1cb0271340aee65bfd535dfa19ba9c56222fbf7165807aae7c67e321665","src/compact_cow_str.rs":"7f5abdae953febe5a833604e6868d6f60518f1b4ece8de6a8aa8d521f21b8daa","src/css-parsing-tests/An+B.json":"d24559c1dad55d3da9d1fca29383edefdfc6046988435d6388a9bc0f28850257","src/css-parsing-tests/LICENSE":"5f9019a92f4aa8917aadc8e035aa673c2c1bf08d5ca2e535a0564106599f44eb","src/css-parsing-tests/README.rst":"233ce4fdc3e7306db23787fed0b67b0eb81a4600281ec0f7ff22270f2679ca8e","src/css-parsing-tests/color3.json":"9db91fd04a0424dcbde2b1bf530d4dbaa7502c887978aaaca75a613fbee028e9","src/css-parsing-tests/color3_hsl.json":"61c3b7d8d5ae02f94769d64458e0dd29e4c22c5068e5ea44040d14b88f9616b0","src/css-parsing-tests/color3_keywords.json":"95609bf9fe762c316878a30f371fa375a2e51c21a6fda24fa188a95cd9118f5c","src/css-parsing-tests/component_value_list.json":"516f9495fe089fa669321660bc431d7884839da8fb73e45edcbcd98625cb09dc","src/css-parsing-tests/declaration_list.json":"0b85cc3f19e945f838432acbfb9edb003abea13debc4ea27bcdcef25d117eac5","src/css-parsing-tests/make_color3_hsl.py":"3df7dd908ee719f78fd097ab24622f75edd10fcb67514230c172cbfc842c8ab7","src/css-parsing-tests/make_color3_keywords.py":"66bccab3f1dea18698fcfd854be79b1fd1cd724dd487e25b1f057b522163aad2","src/css-parsing-tests/one_component_value.json":"8798017709002e14cf11e203c9d716f82d308ce6ba0f6e64ee4eea331b8485c6","src/css-parsing-tests/one_declaration.json":"a34c9da56edfff9e2e21615f059e141b0e878e90f794dc8fa58d65b47cd193ed","src/css-parsing-tests/one_rule.json":"88f7b1b6049be88e1e2827673b75fc9261986b216e8ee6bf09621fecbe274e3c","src/css-parsing-tests/rule_list.json":"97c45e80fb83abef149a4016c5625a74f053e7ad70a2ce5a95c02fce1c195686","src/css-parsing-tests/stylesheet.json":"05f1e10fc486bfbda2c059c313a74ff78c0063c0768b99737cab41969c0c87ce","src/css-parsing-tests/stylesheet_bytes.json":"890fd856a596e61f82cf7ed77920ffe95df89209fdb5ee0afe0b26bdfdb80a42","src/css-parsing-tests/urange.json":"62720b143ddf52508baad42921473dd69519aad6c1cd49f37f3f264dc29e1c13","src/from_bytes.rs":"331fe63af2123ae3675b61928a69461b5ac77799fff3ce9978c55cf2c558f4ff","src/lib.rs":"a612f377e1b8a4bf1830c4a1da5b4d52296e965fc59ef2d8f915a49fd8db3a37","src/macros.rs":"adb9773c157890381556ea83d7942dcc676f99eea71abbb6afeffee1e3f28960","src/nth.rs":"5304dc5056164c4c6fe4f9682114b0126a28a912fc7af5b63ee86ef4eb728225","src/parser.rs":"ec2d8a9e47ef0a33ea9f42fc575094ef00255424bfed7d12de9a7807c2eb5628","src/rules_and_declarations.rs":"2bf4e1dcbdedf99e08ca8ee1d83abda4471fd41dfac35a42c18b78408c70fdf8","src/serializer.rs":"c212770541ac73e0e7269576abec580e6a7dd73e01e1663870514ddfca3a15b2","src/size_of_tests.rs":"fdcc0a12e274cc86b057e607e099b9b3f6af842d0edf9b65e40c0fcdd76fbf17","src/tests.rs":"6435cbb95b0865b9bfc3ec36e107dc653fd65b779103fc99a60e2acf691f9c25","src/tokenizer.rs":"f63aa6b443ca710122e54c223925dfd21573ad560fa30dcf531b4619933b3af7","src/unicode_range.rs":"efd937ab97ab6a38e2cfe2e89a44e259c33d111ee73ba4a6c4388b8517607d2d"},"package":"2842253baded8e712e9d8d80ebfe5ea8e95c5b27071e6a6db6080ca1e81c07d1"}

71
third_party/rust/cssparser/Cargo.toml поставляемый
Просмотреть файл

@ -1,60 +1,39 @@
# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
#
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
# to registry (e.g. crates.io) dependencies
#
# If you believe there's an error in this file please file an
# issue against the rust-lang/cargo repository. If you're
# editing this file be aware that the upstream Cargo.toml
# will likely look very different (and much more reasonable)
[package]
name = "cssparser"
version = "0.17.0"
authors = ["Simon Sapin <simon.sapin@exyr.org>"]
build = "build.rs"
exclude = ["src/css-parsing-tests"]
version = "0.16.1"
authors = [ "Simon Sapin <simon.sapin@exyr.org>" ]
description = "Rust implementation of CSS Syntax Level 3"
documentation = "https://docs.rs/cssparser/"
repository = "https://github.com/servo/rust-cssparser"
readme = "README.md"
keywords = ["css", "syntax", "parser"]
license = "MPL-2.0"
repository = "https://github.com/servo/rust-cssparser"
[dependencies.phf]
version = "0.7"
build = "build.rs"
[dependencies.matches]
version = "0.1"
exclude = ["src/css-parsing-tests"]
[dependencies.heapsize]
version = ">= 0.3, < 0.5"
optional = true
[dev-dependencies]
rustc-serialize = "0.3"
difference = "1.0"
encoding_rs = "0.5"
[dependencies.cssparser-macros]
version = "0.3"
[dependencies]
cssparser-macros = {path = "./macros", version = "0.3"}
heapsize = {version = ">= 0.3, < 0.5", optional = true}
matches = "0.1"
phf = "0.7"
procedural-masquerade = {path = "./procedural-masquerade", version = "0.1"}
serde = {version = "1.0", optional = true}
[dependencies.procedural-masquerade]
version = "0.1"
[dependencies.serde]
version = "1.0"
optional = true
[dev-dependencies.encoding_rs]
version = "0.5"
[dev-dependencies.rustc-serialize]
version = "0.3"
[dev-dependencies.difference]
version = "1.0"
[build-dependencies.syn]
version = "0.11"
[build-dependencies.quote]
version = "0.3"
[build-dependencies]
syn = "0.11"
quote = "0.3"
[features]
dummy_match_byte = []
bench = []
dummy_match_byte = []
[workspace]
members = [".", "./macros", "./procedural-masquerade"]

7
third_party/rust/cssparser/README.md поставляемый
Просмотреть файл

@ -55,3 +55,10 @@ Parsing CSS involves a series of steps:
See [Servos `style` crate](https://github.com/mozilla/servo/tree/master/components/style)
for an example of a parser based on rust-cssparser.
TODO
----
* Figure out float and integer overflow in parsing. (Clamp instead?)
* Make it fast! (Add a fast path in identifier tokenization?)

20
third_party/rust/cssparser/src/parser.rs поставляемый
Просмотреть файл

@ -25,12 +25,12 @@ pub struct SourcePosition {
pub enum BasicParseError<'a> {
/// An unexpected token was encountered.
UnexpectedToken(Token<'a>),
/// A particular token was expected but not found.
ExpectedToken(Token<'a>),
/// The end of the input was encountered unexpectedly.
EndOfInput,
/// An `@` rule was encountered that was invalid.
AtRuleInvalid(CompactCowStr<'a>),
/// The body of an '@' rule was invalid.
AtRuleBodyInvalid,
AtRuleInvalid,
/// A qualified rule was encountered that was invalid.
QualifiedRuleInvalid,
}
@ -188,11 +188,6 @@ impl<'i: 't, 't> Parser<'i, 't> {
}
}
/// Return the current line that is being parsed.
pub fn current_line(&self) -> &'i str {
self.tokenizer.0.current_source_line()
}
/// Check whether the input is exhausted. That is, if `.next()` would return a token.
///
/// This ignores whitespace and comments.
@ -362,9 +357,9 @@ impl<'i: 't, 't> Parser<'i, 't> {
#[inline]
pub fn parse_entirely<F, T, E>(&mut self, parse: F) -> Result<T, ParseError<'i, E>>
where F: FnOnce(&mut Parser<'i, 't>) -> Result<T, ParseError<'i, E>> {
let result = parse(self)?;
let result = parse(self);
self.expect_exhausted()?;
Ok(result)
result
}
/// Parse a list of comma-separated values, all with the same syntax.
@ -487,7 +482,8 @@ impl<'i: 't, 't> Parser<'i, 't> {
match self.next()? {
Token::UnquotedUrl(value) => Ok(value),
Token::Function(ref name) if name.eq_ignore_ascii_case("url") => {
self.parse_nested_block(|input| input.expect_string().map_err(ParseError::Basic))
self.parse_nested_block(|input| input.expect_string()
.map_err(|e| ParseError::Basic(e)))
.map_err(ParseError::<()>::basic)
},
t => Err(BasicParseError::UnexpectedToken(t))
@ -501,7 +497,7 @@ impl<'i: 't, 't> Parser<'i, 't> {
Token::UnquotedUrl(value) => Ok(value),
Token::QuotedString(value) => Ok(value),
Token::Function(ref name) if name.eq_ignore_ascii_case("url") => {
self.parse_nested_block(|input| input.expect_string().map_err(ParseError::Basic))
self.parse_nested_block(|input| input.expect_string().map_err(|e| ParseError::Basic(e)))
.map_err(ParseError::<()>::basic)
},
t => Err(BasicParseError::UnexpectedToken(t))

Просмотреть файл

@ -116,7 +116,7 @@ pub trait AtRuleParser<'i> {
-> Result<AtRuleType<Self::Prelude, Self::AtRule>, ParseError<'i, Self::Error>> {
let _ = name;
let _ = input;
Err(ParseError::Basic(BasicParseError::AtRuleInvalid(name)))
Err(ParseError::Basic(BasicParseError::AtRuleInvalid))
}
/// Parse the content of a `{ /* ... */ }` block for the body of the at-rule.
@ -131,7 +131,7 @@ pub trait AtRuleParser<'i> {
-> Result<Self::AtRule, ParseError<'i, Self::Error>> {
let _ = prelude;
let _ = input;
Err(ParseError::Basic(BasicParseError::AtRuleBodyInvalid))
Err(ParseError::Basic(BasicParseError::AtRuleInvalid))
}
/// An `OptionalBlock` prelude was followed by `;`.
@ -257,9 +257,9 @@ where P: DeclarationParser<'i, Declaration = I, Error = E> +
Ok(Token::AtKeyword(name)) => {
return Some(parse_at_rule(start_position, name, self.input, &mut self.parser))
}
Ok(t) => {
Ok(_) => {
return Some(self.input.parse_until_after(Delimiter::Semicolon,
|_| Err(ParseError::Basic(BasicParseError::UnexpectedToken(t))))
|_| Err(ParseError::Basic(BasicParseError::ExpectedToken(Token::Semicolon))))
.map_err(|e| PreciseParseError {
error: e,
span: start_position..self.input.position()
@ -462,14 +462,16 @@ fn parse_at_rule<'i: 't, 't, P, E>(start_position: SourcePosition, name: Compact
_ => unreachable!()
}
}
Err(error) => {
Err(_) => {
let end_position = input.position();
match input.next() {
Ok(Token::CurlyBracketBlock) | Ok(Token::Semicolon) | Err(_) => {},
let error = match input.next() {
Ok(Token::CurlyBracketBlock) => BasicParseError::UnexpectedToken(Token::CurlyBracketBlock),
Ok(Token::Semicolon) => BasicParseError::UnexpectedToken(Token::Semicolon),
Err(e) => e,
_ => unreachable!()
};
Err(PreciseParseError {
error: error,
error: ParseError::Basic(error),
span: start_position..end_position,
})
}

Просмотреть файл

@ -129,8 +129,8 @@ impl<'a> ToCss for Token<'a> {
Token::SquareBracketBlock => dest.write_str("[")?,
Token::CurlyBracketBlock => dest.write_str("{")?,
Token::BadUrl(_) => dest.write_str("url(<bad url>)")?,
Token::BadString(_) => dest.write_str("\"<bad string>\n")?,
Token::BadUrl => dest.write_str("url(<bad url>)")?,
Token::BadString => dest.write_str("\"<bad string>\n")?,
Token::CloseParenthesis => dest.write_str(")")?,
Token::CloseSquareBracket => dest.write_str("]")?,
Token::CloseCurlyBracket => dest.write_str("}")?,
@ -376,7 +376,7 @@ impl<'a> Token<'a> {
TokenSerializationType(match *self {
Token::Ident(_) => Ident,
Token::AtKeyword(_) | Token::Hash(_) | Token::IDHash(_) => AtKeywordOrHash,
Token::UnquotedUrl(_) | Token::BadUrl(_) => UrlOrBadUrl,
Token::UnquotedUrl(_) | Token::BadUrl => UrlOrBadUrl,
Token::Delim('#') => DelimHash,
Token::Delim('@') => DelimAt,
Token::Delim('.') | Token::Delim('+') => DelimDotOrPlus,
@ -400,7 +400,7 @@ impl<'a> Token<'a> {
Token::ParenthesisBlock => OpenParen,
Token::SquareBracketBlock | Token::CurlyBracketBlock |
Token::CloseParenthesis | Token::CloseSquareBracket | Token::CloseCurlyBracket |
Token::QuotedString(_) | Token::BadString(_) |
Token::QuotedString(_) | Token::BadString |
Token::Delim(_) | Token::Colon | Token::Semicolon | Token::Comma | Token::CDO |
Token::IncludeMatch | Token::PrefixMatch | Token::SuffixMatch
=> Other,

51
third_party/rust/cssparser/src/tests.rs поставляемый
Просмотреть файл

@ -451,26 +451,26 @@ fn serialize_rgba_two_digit_float_if_roundtrips() {
fn line_numbers() {
let mut input = ParserInput::new("foo bar\nbaz\r\n\n\"a\\\r\nb\"");
let mut input = Parser::new(&mut input);
assert_eq!(input.current_source_location(), SourceLocation { line: 0, column: 0 });
assert_eq!(input.current_source_location(), SourceLocation { line: 1, column: 1 });
assert_eq!(input.next_including_whitespace(), Ok(Token::Ident("foo".into())));
assert_eq!(input.current_source_location(), SourceLocation { line: 0, column: 3 });
assert_eq!(input.current_source_location(), SourceLocation { line: 1, column: 4 });
assert_eq!(input.next_including_whitespace(), Ok(Token::WhiteSpace(" ")));
assert_eq!(input.current_source_location(), SourceLocation { line: 0, column: 4 });
assert_eq!(input.current_source_location(), SourceLocation { line: 1, column: 5 });
assert_eq!(input.next_including_whitespace(), Ok(Token::Ident("bar".into())));
assert_eq!(input.current_source_location(), SourceLocation { line: 0, column: 7 });
assert_eq!(input.current_source_location(), SourceLocation { line: 1, column: 8 });
assert_eq!(input.next_including_whitespace(), Ok(Token::WhiteSpace("\n")));
assert_eq!(input.current_source_location(), SourceLocation { line: 1, column: 0 });
assert_eq!(input.current_source_location(), SourceLocation { line: 2, column: 1 });
assert_eq!(input.next_including_whitespace(), Ok(Token::Ident("baz".into())));
assert_eq!(input.current_source_location(), SourceLocation { line: 1, column: 3 });
assert_eq!(input.current_source_location(), SourceLocation { line: 2, column: 4 });
let position = input.position();
assert_eq!(input.next_including_whitespace(), Ok(Token::WhiteSpace("\r\n\n")));
assert_eq!(input.current_source_location(), SourceLocation { line: 3, column: 0 });
assert_eq!(input.current_source_location(), SourceLocation { line: 4, column: 1 });
assert_eq!(input.source_location(position), SourceLocation { line: 1, column: 3 });
assert_eq!(input.source_location(position), SourceLocation { line: 2, column: 4 });
assert_eq!(input.next_including_whitespace(), Ok(Token::QuotedString("ab".into())));
assert_eq!(input.current_source_location(), SourceLocation { line: 4, column: 2 });
assert_eq!(input.current_source_location(), SourceLocation { line: 5, column: 3 });
assert!(input.next_including_whitespace().is_err());
}
@ -848,8 +848,8 @@ fn one_component_value_to_json(token: Token, input: &mut Parser) -> Json {
v.extend(nested(input));
v
}),
Token::BadUrl(_) => JArray!["error", "bad-url"],
Token::BadString(_) => JArray!["error", "bad-string"],
Token::BadUrl => JArray!["error", "bad-url"],
Token::BadString => JArray!["error", "bad-string"],
Token::CloseParenthesis => JArray!["error", ")"],
Token::CloseSquareBracket => JArray!["error", "]"],
Token::CloseCurlyBracket => JArray!["error", "}"],
@ -920,32 +920,3 @@ fn parse_until_before_stops_at_delimiter_or_end_of_input() {
}
}
}
#[test]
fn parser_maintains_current_line() {
let mut input = ParserInput::new("ident ident;\nident ident ident;\nident");
let mut parser = Parser::new(&mut input);
assert_eq!(parser.current_line(), "ident ident;");
assert_eq!(parser.next(), Ok(Token::Ident("ident".into())));
assert_eq!(parser.next(), Ok(Token::Ident("ident".into())));
assert_eq!(parser.next(), Ok(Token::Semicolon));
assert_eq!(parser.next(), Ok(Token::Ident("ident".into())));
assert_eq!(parser.current_line(), "ident ident ident;");
assert_eq!(parser.next(), Ok(Token::Ident("ident".into())));
assert_eq!(parser.next(), Ok(Token::Ident("ident".into())));
assert_eq!(parser.next(), Ok(Token::Semicolon));
assert_eq!(parser.next(), Ok(Token::Ident("ident".into())));
assert_eq!(parser.current_line(), "ident");
}
#[test]
fn parse_entirely_reports_first_error() {
#[derive(PartialEq, Debug)]
enum E { Foo }
let mut input = ParserInput::new("ident");
let mut parser = Parser::new(&mut input);
let result: Result<(), _> = parser.parse_entirely(|_| Err(ParseError::Custom(E::Foo)));
assert_eq!(result, Err(ParseError::Custom(E::Foo)));
}

45
third_party/rust/cssparser/src/tokenizer.rs поставляемый
Просмотреть файл

@ -157,12 +157,12 @@ pub enum Token<'a> {
/// A `<bad-url-token>`
///
/// This token always indicates a parse error.
BadUrl(CompactCowStr<'a>),
BadUrl,
/// A `<bad-string-token>`
///
/// This token always indicates a parse error.
BadString(CompactCowStr<'a>),
BadString,
/// A `<)-token>`
///
@ -194,7 +194,7 @@ impl<'a> Token<'a> {
pub fn is_parse_error(&self) -> bool {
matches!(
*self,
BadUrl(_) | BadString(_) | CloseParenthesis | CloseSquareBracket | CloseCurlyBracket
BadUrl | BadString | CloseParenthesis | CloseSquareBracket | CloseCurlyBracket
)
}
}
@ -226,7 +226,7 @@ impl<'a> Tokenizer<'a> {
input: input,
position: 0,
last_known_source_location: Cell::new((SourcePosition(0),
SourceLocation { line: 0, column: 0 })),
SourceLocation { line: 1, column: 1 })),
var_functions: SeenStatus::DontCare,
viewport_percentages: SeenStatus::DontCare,
}
@ -287,17 +287,6 @@ impl<'a> Tokenizer<'a> {
self.source_location(position)
}
pub fn current_source_line(&self) -> &'a str {
let current = self.position;
let start = self.input[0..current]
.rfind(|c| matches!(c, '\r' | '\n' | '\x0C'))
.map_or(0, |start| start + 1);
let end = self.input[current..]
.find(|c| matches!(c, '\r' | '\n' | '\x0C'))
.map_or(self.input.len(), |end| current + end);
&self.input[start..end]
}
pub fn source_location(&self, position: SourcePosition) -> SourceLocation {
let target = position.0;
let mut location;
@ -312,7 +301,7 @@ impl<'a> Tokenizer<'a> {
// So if the requested position is before the last known one,
// start over from the beginning.
position = 0;
location = SourceLocation { line: 0, column: 0 };
location = SourceLocation { line: 1, column: 1 };
}
let mut source = &self.input[position..target];
while let Some(newline_position) = source.find(|c| matches!(c, '\n' | '\r' | '\x0C')) {
@ -321,7 +310,7 @@ impl<'a> Tokenizer<'a> {
source = &source[offset..];
position += offset;
location.line += 1;
location.column = 0;
location.column = 1;
}
debug_assert!(position <= target);
location.column += (target - position) as u32;
@ -397,10 +386,10 @@ pub struct SourcePosition(usize);
/// The line and column number for a given position within the input.
#[derive(PartialEq, Eq, Debug, Clone, Copy)]
pub struct SourceLocation {
/// The line number, starting at 0 for the first line.
/// The line number, starting at 1 for the first line.
pub line: u32,
/// The column number within a line, starting at 0 for first the character of the line.
/// The column number within a line, starting at 1 for first the character of the line.
pub column: u32,
}
@ -567,14 +556,14 @@ fn next_token<'a>(tokenizer: &mut Tokenizer<'a>) -> Result<Token<'a>, ()> {
fn consume_string<'a>(tokenizer: &mut Tokenizer<'a>, single_quote: bool) -> Token<'a> {
match consume_quoted_string(tokenizer, single_quote) {
Ok(value) => QuotedString(value),
Err(value) => BadString(value)
Err(()) => BadString
}
}
/// Return `Err(())` on syntax error (ie. unescaped newline)
fn consume_quoted_string<'a>(tokenizer: &mut Tokenizer<'a>, single_quote: bool)
-> Result<CompactCowStr<'a>, CompactCowStr<'a>> {
-> Result<CompactCowStr<'a>, ()> {
tokenizer.advance(1); // Skip the initial quote
// start_pos is at code point boundary, after " or '
let start_pos = tokenizer.position();
@ -607,9 +596,7 @@ fn consume_quoted_string<'a>(tokenizer: &mut Tokenizer<'a>, single_quote: bool)
string_bytes = tokenizer.slice_from(start_pos).as_bytes().to_owned();
break
}
b'\n' | b'\r' | b'\x0C' => {
return Err(tokenizer.slice_from(start_pos).into())
},
b'\n' | b'\r' | b'\x0C' => { return Err(()) },
_ => {}
}
tokenizer.consume_byte();
@ -617,12 +604,7 @@ fn consume_quoted_string<'a>(tokenizer: &mut Tokenizer<'a>, single_quote: bool)
while !tokenizer.is_eof() {
if matches!(tokenizer.next_byte_unchecked(), b'\n' | b'\r' | b'\x0C') {
return Err(
// string_bytes is well-formed UTF-8, see other comments.
unsafe {
from_utf8_release_unchecked(string_bytes)
}.into()
);
return Err(());
}
let b = tokenizer.consume_byte();
match_byte! { b,
@ -1031,7 +1013,6 @@ fn consume_unquoted_url<'a>(tokenizer: &mut Tokenizer<'a>) -> Result<Token<'a>,
}
fn consume_bad_url<'a>(tokenizer: &mut Tokenizer<'a>) -> Token<'a> {
let start_pos = tokenizer.position();
// Consume up to the closing )
while !tokenizer.is_eof() {
match_byte! { tokenizer.consume_byte(),
@ -1042,7 +1023,7 @@ fn consume_unquoted_url<'a>(tokenizer: &mut Tokenizer<'a>) -> Result<Token<'a>,
_ => {},
}
}
BadUrl(tokenizer.slice_from(start_pos).into())
BadUrl
}
}

12
toolkit/library/gtest/rust/Cargo.lock сгенерированный
Просмотреть файл

@ -227,7 +227,7 @@ dependencies = [
[[package]]
name = "cssparser"
version = "0.17.0"
version = "0.16.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cssparser-macros 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -371,7 +371,7 @@ name = "geckoservo"
version = "0.0.1"
dependencies = [
"atomic_refcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.16.1 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
@ -818,7 +818,7 @@ name = "selectors"
version = "0.19.0"
dependencies = [
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.16.1 (registry+https://github.com/rust-lang/crates.io-index)",
"fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"matches 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
@ -914,7 +914,7 @@ dependencies = [
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cfg-if 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.16.1 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
"fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
"itoa 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
@ -959,7 +959,7 @@ version = "0.0.1"
dependencies = [
"app_units 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.16.1 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
"selectors 0.19.0",
]
@ -1263,7 +1263,7 @@ dependencies = [
"checksum core-foundation-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "41115a6aa5d3e1e5ef98148373f25971d1fad53818553f216495f9e67e90a624"
"checksum core-graphics 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a9f841e9637adec70838c537cae52cb4c751cc6514ad05669b51d107c2021c79"
"checksum core-text 5.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7c42ae17408d6b881992268f638257e67303fc7c6c88723dbc0fe5889b22c0bc"
"checksum cssparser 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e7063452c60432cb306ed54d538178c20792d47fa960c240ce6c083239ee55ec"
"checksum cssparser 0.16.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2842253baded8e712e9d8d80ebfe5ea8e95c5b27071e6a6db6080ca1e81c07d1"
"checksum cssparser-macros 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "079adec4af52bb5275eadd004292028c79eb3c5f5b4ee8086a36d4197032f6df"
"checksum dwrote 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "36e3b27cd0b8a68e00f07e8d8e1e4f4d8a6b8b873290a734f63bd56d792d23e1"
"checksum either 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "18785c1ba806c258137c937e44ada9ee7e69a37e3c72077542cd2f069d78562a"

12
toolkit/library/rust/Cargo.lock сгенерированный
Просмотреть файл

@ -225,7 +225,7 @@ dependencies = [
[[package]]
name = "cssparser"
version = "0.17.0"
version = "0.16.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cssparser-macros 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -369,7 +369,7 @@ name = "geckoservo"
version = "0.0.1"
dependencies = [
"atomic_refcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.16.1 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.24 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
@ -805,7 +805,7 @@ name = "selectors"
version = "0.19.0"
dependencies = [
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.16.1 (registry+https://github.com/rust-lang/crates.io-index)",
"fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"matches 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
@ -901,7 +901,7 @@ dependencies = [
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cfg-if 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.16.1 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
"fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
"itoa 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
@ -946,7 +946,7 @@ version = "0.0.1"
dependencies = [
"app_units 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.16.1 (registry+https://github.com/rust-lang/crates.io-index)",
"euclid 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
"selectors 0.19.0",
]
@ -1250,7 +1250,7 @@ dependencies = [
"checksum core-foundation-sys 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "41115a6aa5d3e1e5ef98148373f25971d1fad53818553f216495f9e67e90a624"
"checksum core-graphics 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a9f841e9637adec70838c537cae52cb4c751cc6514ad05669b51d107c2021c79"
"checksum core-text 5.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7c42ae17408d6b881992268f638257e67303fc7c6c88723dbc0fe5889b22c0bc"
"checksum cssparser 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e7063452c60432cb306ed54d538178c20792d47fa960c240ce6c083239ee55ec"
"checksum cssparser 0.16.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2842253baded8e712e9d8d80ebfe5ea8e95c5b27071e6a6db6080ca1e81c07d1"
"checksum cssparser-macros 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "079adec4af52bb5275eadd004292028c79eb3c5f5b4ee8086a36d4197032f6df"
"checksum dwrote 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "36e3b27cd0b8a68e00f07e8d8e1e4f4d8a6b8b873290a734f63bd56d792d23e1"
"checksum either 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "18785c1ba806c258137c937e44ada9ee7e69a37e3c72077542cd2f069d78562a"