clippy:fix various clippy problems in components/scripts (#31907)

* manual implementation of an assign operation

* manual implementation of an assign operation

* single-character string

* manual cjheck for common ascii range
This commit is contained in:
Rosemary Ajayi 2024-03-27 22:14:41 +00:00 committed by GitHub
parent 1c8c287f01
commit 072b892706
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 14 additions and 14 deletions

View file

@ -136,7 +136,7 @@ impl CharacterDataMethods for CharacterData {
// and then transcoded that to UTF-8 lossily, // and then transcoded that to UTF-8 lossily,
// since our DOMString is currently strict UTF-8. // since our DOMString is currently strict UTF-8.
if astral.is_some() { if astral.is_some() {
substring = substring + "\u{FFFD}"; substring += "\u{FFFD}";
} }
remaining = s; remaining = s;
}, },
@ -145,7 +145,7 @@ impl CharacterDataMethods for CharacterData {
} }
match split_at_utf16_code_unit_offset(remaining, count, replace_surrogates) { match split_at_utf16_code_unit_offset(remaining, count, replace_surrogates) {
// Steps 3. // Steps 3.
Err(()) => substring = substring + remaining, Err(()) => substring += remaining,
// Steps 4. // Steps 4.
Ok((s, astral, _)) => { Ok((s, astral, _)) => {
substring = substring + s; substring = substring + s;
@ -153,7 +153,7 @@ impl CharacterDataMethods for CharacterData {
// and then transcoded that to UTF-8 lossily, // and then transcoded that to UTF-8 lossily,
// since our DOMString is currently strict UTF-8. // since our DOMString is currently strict UTF-8.
if astral.is_some() { if astral.is_some() {
substring = substring + "\u{FFFD}"; substring += "\u{FFFD}";
} }
}, },
}; };

View file

@ -90,7 +90,7 @@ fn stringify_handle_value(message: HandleValue) -> DOMString {
) -> DOMString { ) -> DOMString {
rooted!(in(cx) let mut obj = value.to_object()); rooted!(in(cx) let mut obj = value.to_object());
let mut object_class = ESClass::Other; let mut object_class = ESClass::Other;
if !GetBuiltinClass(cx, obj.handle().into(), &mut object_class as *mut _) { if !GetBuiltinClass(cx, obj.handle(), &mut object_class as *mut _) {
return DOMString::from("/* invalid */"); return DOMString::from("/* invalid */");
} }
let mut ids = IdVector::new(cx); let mut ids = IdVector::new(cx);
@ -120,9 +120,9 @@ fn stringify_handle_value(message: HandleValue) -> DOMString {
let mut is_none = false; let mut is_none = false;
if !JS_GetOwnPropertyDescriptorById( if !JS_GetOwnPropertyDescriptorById(
cx, cx,
obj.handle().into(), obj.handle(),
id.handle().into(), id.handle(),
desc.handle_mut().into(), desc.handle_mut(),
&mut is_none, &mut is_none,
) { ) {
return DOMString::from("/* invalid */"); return DOMString::from("/* invalid */");
@ -191,7 +191,7 @@ fn stringify_handle_value(message: HandleValue) -> DOMString {
parents.push(value_bits); parents.push(value_bits);
stringify_object_from_handle_value(cx, value, parents) stringify_object_from_handle_value(cx, value, parents)
} }
stringify_inner(cx, message.into(), Vec::new()) stringify_inner(cx, message, Vec::new())
} }
} }

View file

@ -361,8 +361,8 @@ lazy_static! {
enabled_longhands.sort_unstable_by(|a, b| { enabled_longhands.sort_unstable_by(|a, b| {
let a = a.name(); let a = a.name();
let b = b.name(); let b = b.name();
let is_a_vendor_prefixed = a.starts_with("-"); let is_a_vendor_prefixed = a.starts_with('-');
let is_b_vendor_prefixed = b.starts_with("-"); let is_b_vendor_prefixed = b.starts_with('-');
if is_a_vendor_prefixed == is_b_vendor_prefixed { if is_a_vendor_prefixed == is_b_vendor_prefixed {
a.partial_cmp(b).unwrap() a.partial_cmp(b).unwrap()
} else if is_b_vendor_prefixed { } else if is_b_vendor_prefixed {

View file

@ -290,7 +290,7 @@ impl CustomElementRegistryMethods for CustomElementRegistry {
.definitions .definitions
.borrow() .borrow()
.iter() .iter()
.any(|(_, ref def)| def.constructor == constructor_) .any(|(_, def)| def.constructor == constructor_)
{ {
return Err(Error::NotSupported); return Err(Error::NotSupported);
} }
@ -1035,7 +1035,7 @@ pub fn is_valid_custom_element_name(name: &str) -> bool {
// PotentialCustomElementName ::= [a-z] (PCENChar)* '-' (PCENChar)* // PotentialCustomElementName ::= [a-z] (PCENChar)* '-' (PCENChar)*
let mut chars = name.chars(); let mut chars = name.chars();
if !chars.next().map_or(false, |c| ('a'..='z').contains(&c)) { if !chars.next().map_or(false, |c| c.is_ascii_lowercase()) {
return false; return false;
} }
@ -1078,8 +1078,8 @@ fn is_potential_custom_element_char(c: char) -> bool {
c == '.' || c == '.' ||
c == '_' || c == '_' ||
c == '\u{B7}' || c == '\u{B7}' ||
('0'..='9').contains(&c) || c.is_ascii_digit() ||
('a'..='z').contains(&c) || c.is_ascii_lowercase() ||
('\u{C0}'..='\u{D6}').contains(&c) || ('\u{C0}'..='\u{D6}').contains(&c) ||
('\u{D8}'..='\u{F6}').contains(&c) || ('\u{D8}'..='\u{F6}').contains(&c) ||
('\u{F8}'..='\u{37D}').contains(&c) || ('\u{F8}'..='\u{37D}').contains(&c) ||