Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions components/script/dom/characterdata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ impl CharacterDataMethods for CharacterData {
// and then transcoded that to UTF-8 lossily,
// since our DOMString is currently strict UTF-8.
if astral.is_some() {
substring = substring + "\u{FFFD}";
substring += "\u{FFFD}";
}
remaining = s;
},
Expand All @@ -145,15 +145,15 @@ impl CharacterDataMethods for CharacterData {
}
match split_at_utf16_code_unit_offset(remaining, count, replace_surrogates) {
// Steps 3.
Err(()) => substring = substring + remaining,
Err(()) => substring += remaining,
// Steps 4.
Ok((s, astral, _)) => {
substring = substring + s;
// As if we had split the UTF-16 surrogate pair in half
// and then transcoded that to UTF-8 lossily,
// since our DOMString is currently strict UTF-8.
if astral.is_some() {
substring = substring + "\u{FFFD}";
substring += "\u{FFFD}";
}
},
};
Expand Down
10 changes: 5 additions & 5 deletions components/script/dom/console.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ fn stringify_handle_value(message: HandleValue) -> DOMString {
) -> DOMString {
rooted!(in(cx) let mut obj = value.to_object());
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 */");
}
let mut ids = IdVector::new(cx);
Expand Down Expand Up @@ -120,9 +120,9 @@ fn stringify_handle_value(message: HandleValue) -> DOMString {
let mut is_none = false;
if !JS_GetOwnPropertyDescriptorById(
cx,
obj.handle().into(),
id.handle().into(),
desc.handle_mut().into(),
obj.handle(),
id.handle(),
desc.handle_mut(),
&mut is_none,
) {
return DOMString::from("/* invalid */");
Expand Down Expand Up @@ -191,7 +191,7 @@ fn stringify_handle_value(message: HandleValue) -> DOMString {
parents.push(value_bits);
stringify_object_from_handle_value(cx, value, parents)
}
stringify_inner(cx, message.into(), Vec::new())
stringify_inner(cx, message, Vec::new())
}
}

Expand Down
4 changes: 2 additions & 2 deletions components/script/dom/cssstyledeclaration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,8 @@ lazy_static! {
enabled_longhands.sort_unstable_by(|a, b| {
let a = a.name();
let b = b.name();
let is_a_vendor_prefixed = a.starts_with("-");
let is_b_vendor_prefixed = b.starts_with("-");
let is_a_vendor_prefixed = a.starts_with('-');
let is_b_vendor_prefixed = b.starts_with('-');
if is_a_vendor_prefixed == is_b_vendor_prefixed {
a.partial_cmp(b).unwrap()
} else if is_b_vendor_prefixed {
Expand Down
8 changes: 4 additions & 4 deletions components/script/dom/customelementregistry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ impl CustomElementRegistryMethods for CustomElementRegistry {
.definitions
.borrow()
.iter()
.any(|(_, ref def)| def.constructor == constructor_)
.any(|(_, def)| def.constructor == constructor_)
{
return Err(Error::NotSupported);
}
Expand Down Expand Up @@ -1035,7 +1035,7 @@ pub fn is_valid_custom_element_name(name: &str) -> bool {
// PotentialCustomElementName ::= [a-z] (PCENChar)* '-' (PCENChar)*

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;
}

Expand Down Expand Up @@ -1078,8 +1078,8 @@ fn is_potential_custom_element_char(c: char) -> bool {
c == '.' ||
c == '_' ||
c == '\u{B7}' ||
('0'..='9').contains(&c) ||
('a'..='z').contains(&c) ||
c.is_ascii_digit() ||
c.is_ascii_lowercase() ||
('\u{C0}'..='\u{D6}').contains(&c) ||
('\u{D8}'..='\u{F6}').contains(&c) ||
('\u{F8}'..='\u{37D}').contains(&c) ||
Expand Down