Bug 1713935 - Make rust mozprofile pass clippy, r=webdriver-reviewers,whimboo

Differential Revision: https://phabricator.services.mozilla.com/D116591
This commit is contained in:
James Graham 2021-06-02 20:29:51 +00:00
Родитель b97066dd63
Коммит b5e6b1b096
1 изменённых файлов: 6 добавлений и 11 удалений

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

@ -11,7 +11,6 @@ use std::fmt;
use std::io::{self, Write};
use std::iter::Iterator;
use std::mem;
use std::ops::Deref;
use std::str;
impl PrefReaderError {
@ -44,10 +43,7 @@ impl Error for PrefReaderError {
}
fn cause(&self) -> Option<&dyn Error> {
match self.parent {
None => None,
Some(ref cause) => Some(cause.deref()),
}
self.parent.as_deref()
}
}
@ -247,8 +243,7 @@ impl<'a> PrefTokenizer<'a> {
TokenType::Comma => PrefToken::Comma(position),
TokenType::String => PrefToken::String(buf, position),
TokenType::Int => {
let value =
i64::from_str_radix(buf.borrow(), 10).expect("Integer wasn't parsed as an i64");
let value = buf.parse::<i64>().expect("Integer wasn't parsed as an i64");
PrefToken::Int(value, position)
}
TokenType::Bool => {
@ -380,7 +375,7 @@ impl<'a> PrefTokenizer<'a> {
}
}
}
if first && value >= 0xD800 && value <= 0xDBFF {
if first && (0xD800..=0xDBFF).contains(&value) {
// First part of a surrogate pair
if self.get_char() != Some('\\') || self.get_char() != Some('u') {
return Err(PrefReaderError::new(
@ -395,13 +390,13 @@ impl<'a> PrefTokenizer<'a> {
let high_value = (high_surrogate - 0xD800) << 10;
let low_value = low_surrogate - 0xDC00;
value = high_value + low_value + 0x10000;
} else if first && value >= 0xDC00 && value <= 0xDFFF {
} else if first && (0xDC00..=0xDFFF).contains(&value) {
return Err(PrefReaderError::new(
"Lone low surrogate",
self.position,
None,
));
} else if !first && (value < 0xDC00 || value > 0xDFFF) {
} else if !first && !(0xDC00..=0xDFFF).contains(&value) {
return Err(PrefReaderError::new(
"Invalid low surrogate in surrogate pair",
self.position,
@ -876,7 +871,7 @@ fn skip_comments<'a>(tokenizer: &mut PrefTokenizer<'a>) -> Option<PrefToken<'a>>
}
}
pub fn parse_tokens<'a>(tokenizer: &mut PrefTokenizer<'a>) -> Result<Preferences, PrefReaderError> {
pub fn parse_tokens(tokenizer: &mut PrefTokenizer<'_>) -> Result<Preferences, PrefReaderError> {
let mut state = ParserState::Function;
let mut current_pref = PrefBuilder::new();
let mut rv = Preferences::new();