clippy: Fix four warnings (#32789)

* Fixes 4 clippy rules

Signed-off-by: Danila Matveev <usurname.r@gmail.com>

* Rollbacks changes in range.rs and silences clippy::neg_cmp_op_on_partial_ord

Signed-off-by: Danila Matveev <usurname.r@gmail.com>

* Fixes a fmt issue

Signed-off-by: Danila Matveev <usurname.r@gmail.com>

---------

Signed-off-by: Danila Matveev <usurname.r@gmail.com>
This commit is contained in:
Danila Matveev 2024-07-17 13:05:02 +04:00 committed by GitHub
parent 5fd0d2f17b
commit a0d2b36ad8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 6 additions and 3 deletions

View file

@ -333,6 +333,7 @@ impl RangeMethods for Range {
} }
/// <https://dom.spec.whatwg.org/#dom-range-setstart> /// <https://dom.spec.whatwg.org/#dom-range-setstart>
#[allow(clippy::neg_cmp_op_on_partial_ord)]
fn SetStart(&self, node: &Node, offset: u32) -> ErrorResult { fn SetStart(&self, node: &Node, offset: u32) -> ErrorResult {
if node.is_doctype() { if node.is_doctype() {
// Step 1. // Step 1.
@ -352,6 +353,7 @@ impl RangeMethods for Range {
} }
/// <https://dom.spec.whatwg.org/#dom-range-setend> /// <https://dom.spec.whatwg.org/#dom-range-setend>
#[allow(clippy::neg_cmp_op_on_partial_ord)]
fn SetEnd(&self, node: &Node, offset: u32) -> ErrorResult { fn SetEnd(&self, node: &Node, offset: u32) -> ErrorResult {
if node.is_doctype() { if node.is_doctype() {
// Step 1. // Step 1.

View file

@ -272,7 +272,7 @@ fn calculate_box_size(target: &Element, observed_box: &ResizeObserverBoxOptions)
.upcast::<Node>() .upcast::<Node>()
.content_boxes() .content_boxes()
.pop() .pop()
.unwrap_or_else(|| Rect::zero()) .unwrap_or_else(Rect::zero)
}, },
// TODO(#31182): add support for border box, and device pixel size, calculations. // TODO(#31182): add support for border box, and device pixel size, calculations.
_ => Rect::zero(), _ => Rect::zero(),

View file

@ -1131,10 +1131,11 @@ impl WindowMethods for Window {
pseudo: Option<DOMString>, pseudo: Option<DOMString>,
) -> DomRoot<CSSStyleDeclaration> { ) -> DomRoot<CSSStyleDeclaration> {
// Steps 1-4. // Steps 1-4.
let pseudo = match pseudo.map(|mut s| { let pseudo = pseudo.map(|mut s| {
s.make_ascii_lowercase(); s.make_ascii_lowercase();
s s
}) { });
let pseudo = match pseudo {
Some(ref pseudo) if pseudo == ":before" || pseudo == "::before" => { Some(ref pseudo) if pseudo == ":before" || pseudo == "::before" => {
Some(PseudoElement::Before) Some(PseudoElement::Before)
}, },