Skip to content

Commit

Permalink
clippy: Fix several warnings (#31710)
Browse files Browse the repository at this point in the history
Signed-off-by: RustAndMetal <111676747+RustAndMetal@users.noreply.github.com>
  • Loading branch information
RustAndMetal committed Mar 18, 2024
1 parent 1ab8fa2 commit f6a975f
Show file tree
Hide file tree
Showing 23 changed files with 75 additions and 86 deletions.
2 changes: 1 addition & 1 deletion components/gfx/text/text_run.rs
Expand Up @@ -227,7 +227,7 @@ impl<'a> TextRun {

let mut push_range = |range: &std::ops::Range<usize>, options: &ShapingOptions| {
glyphs.push(GlyphRun {
glyph_store: font.shape_text(&text[range.clone()], &options),
glyph_store: font.shape_text(&text[range.clone()], options),
range: Range::new(
ByteIndex(range.start as isize),
ByteIndex(range.len() as isize),
Expand Down
2 changes: 1 addition & 1 deletion components/layout_2020/flexbox/layout.rs
Expand Up @@ -1081,7 +1081,7 @@ impl<'a> FlexItem<'a> {
box_size,
&pbm,
);
let cross_size = flex_context.vec2_to_flex_relative(size.clone()).cross;
let cross_size = flex_context.vec2_to_flex_relative(size).cross;
let fragments = replaced.contents.make_fragments(&replaced.style, size);
FlexItemLayoutResult {
hypothetical_cross_size: cross_size.into(),
Expand Down
2 changes: 1 addition & 1 deletion components/layout_2020/flow/float.rs
Expand Up @@ -975,7 +975,7 @@ impl FloatBox {
.into();
children = replaced
.contents
.make_fragments(&replaced.style, content_size.clone().into());
.make_fragments(&replaced.style, content_size.into());
},
};

Expand Down
5 changes: 1 addition & 4 deletions components/layout_2020/flow/inline.rs
Expand Up @@ -1122,7 +1122,6 @@ impl<'a, 'b> InlineFormattingContextState<'a, 'b> {
.placement_among_floats
.get_or_init(|| self.place_line_among_floats(potential_line_size))
.size
.clone()
} else {
LogicalVec2 {
inline: self.containing_block.inline_size.into(),
Expand Down Expand Up @@ -1991,9 +1990,7 @@ impl IndependentFormattingContext {
None,
&pbm,
);
let fragments = replaced
.contents
.make_fragments(&replaced.style, size.clone());
let fragments = replaced.contents.make_fragments(&replaced.style, size);
let content_rect = LogicalRect {
start_corner: pbm_sums.start_offset(),
size,
Expand Down
8 changes: 4 additions & 4 deletions components/layout_2020/flow/mod.rs
Expand Up @@ -989,7 +989,7 @@ impl NonReplacedFormattingContext {
&collapsed_margin_block_start,
containing_block,
&pbm,
&content_size + &pbm.padding_border_sums.clone().into(),
&content_size + &pbm.padding_border_sums.into(),
&self.style,
);
} else {
Expand Down Expand Up @@ -1179,7 +1179,7 @@ fn layout_in_flow_replaced_block_level(
let margin_inline_end;
let effective_margin_inline_start;
let (margin_block_start, margin_block_end) = solve_block_margins_for_in_flow_block_level(&pbm);
let fragments = replaced.make_fragments(style, content_size.clone());
let fragments = replaced.make_fragments(style, content_size);

let clearance;
if let Some(ref mut sequential_layout_state) = sequential_layout_state {
Expand All @@ -1204,7 +1204,7 @@ fn layout_in_flow_replaced_block_level(
&collapsed_margin_block_start,
containing_block,
&pbm,
size.clone().into(),
size.into(),
style,
);

Expand Down Expand Up @@ -1498,7 +1498,7 @@ fn solve_clearance_and_inline_margins_avoiding_floats(
style.get_box().clear,
block_start_margin,
pbm,
size.clone().into(),
size.into(),
);
let (inline_margins, effective_margin_inline_start) = solve_inline_margins_avoiding_floats(
sequential_layout_state,
Expand Down
8 changes: 3 additions & 5 deletions components/layout_2020/positioned.rs
Expand Up @@ -250,13 +250,13 @@ impl PositioningContext {
new_fragment: &mut BoxFragment,
) {
let padding_rect = LogicalRect {
size: new_fragment.content_rect.size.clone(),
size: new_fragment.content_rect.size,
// Ignore the content rect’s position in its own containing block:
start_corner: LogicalVec2::zero(),
}
.inflate(&new_fragment.padding);
let containing_block = DefiniteContainingBlock {
size: padding_rect.size.clone().into(),
size: padding_rect.size.into(),
style: &new_fragment.style,
};

Expand Down Expand Up @@ -539,9 +539,7 @@ impl HoistedAbsolutelyPositionedBox {
// https://drafts.csswg.org/css2/visudet.html#abs-replaced-height
let style = &replaced.style;
content_size = computed_size.auto_is(|| unreachable!()).into();
fragments = replaced
.contents
.make_fragments(style, content_size.clone());
fragments = replaced.contents.make_fragments(style, content_size);
},
IndependentFormattingContext::NonReplaced(non_replaced) => {
// https://drafts.csswg.org/css2/#min-max-widths
Expand Down
2 changes: 1 addition & 1 deletion components/layout_2020/table/layout.rs
Expand Up @@ -1478,7 +1478,7 @@ impl<'a> TableLayout<'a> {
baselines.last = Some(row_end);
}

let column_indices = 0..self.table.size.width.clone();
let column_indices = 0..self.table.size.width;
row_fragment_layout.fragments.reserve(self.table.size.width);
for column_index in column_indices {
// The PositioningContext for cells is, in order or preference, the PositioningContext of the row,
Expand Down
2 changes: 1 addition & 1 deletion components/script/body.rs
Expand Up @@ -91,7 +91,7 @@ impl TransmitBodyConnectHandler {
source: BodySource,
) -> TransmitBodyConnectHandler {
TransmitBodyConnectHandler {
stream: stream,
stream,
task_source,
canceller,
bytes_sender: None,
Expand Down
4 changes: 2 additions & 2 deletions components/script/devtools.rs
Expand Up @@ -175,8 +175,8 @@ pub fn handle_get_layout(
paddingRight: String::from(computed_style.PaddingRight()),
paddingBottom: String::from(computed_style.PaddingBottom()),
paddingLeft: String::from(computed_style.PaddingLeft()),
width: width,
height: height,
width,
height,
}))
.unwrap();
}
Expand Down
2 changes: 1 addition & 1 deletion components/script/document_loader.rs
Expand Up @@ -86,7 +86,7 @@ impl DocumentLoader {
let initial_loads = initial_load.into_iter().map(LoadType::PageSource).collect();

DocumentLoader {
resource_threads: resource_threads,
resource_threads,
blocking_loads: initial_loads,
events_inhibited: false,
cancellers: Vec::new(),
Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/abstractworker.rs
Expand Up @@ -26,6 +26,6 @@ pub struct SimpleWorkerErrorHandler<T: DomObject> {

impl<T: DomObject> SimpleWorkerErrorHandler<T> {
pub fn new(addr: Trusted<T>) -> SimpleWorkerErrorHandler<T> {
SimpleWorkerErrorHandler { addr: addr }
SimpleWorkerErrorHandler { addr }
}
}
2 changes: 1 addition & 1 deletion components/script/dom/bindings/buffer_source.rs
Expand Up @@ -76,7 +76,7 @@ where
{
let heap_buffer_source = match init {
HeapTypedArrayInit::Buffer(buffer_source) => HeapBufferSource {
buffer_source: buffer_source,
buffer_source,
phantom: PhantomData::default(),
},
HeapTypedArrayInit::Info { len, cx } => {
Expand Down
4 changes: 2 additions & 2 deletions components/script/dom/bindings/callback.rs
Expand Up @@ -253,9 +253,9 @@ impl CallSetup {
let ais = callback.incumbent().map(AutoIncumbentScript::new);
CallSetup {
exception_global: global,
cx: cx,
cx,
old_realm: unsafe { EnterRealm(*cx, callback.callback()) },
handling: handling,
handling,
entry_script: Some(aes),
incumbent_script: ais,
}
Expand Down
5 changes: 1 addition & 4 deletions components/script/dom/bindings/guard.rs
Expand Up @@ -22,10 +22,7 @@ pub struct Guard<T: Clone + Copy> {
impl<T: Clone + Copy> Guard<T> {
/// Construct a new guarded value.
pub const fn new(condition: Condition, value: T) -> Self {
Guard {
condition: condition,
value: value,
}
Guard { condition, value }
}

/// Expose the value if the condition is satisfied.
Expand Down
10 changes: 4 additions & 6 deletions components/script/dom/bindings/interface.rs
Expand Up @@ -76,8 +76,8 @@ impl NonCallbackInterfaceObjectClass {
ext: 0 as *const _,
oOps: &OBJECT_OPS,
},
proto_id: proto_id,
proto_depth: proto_depth,
proto_id,
proto_depth,
representation: string_rep,
}
}
Expand Down Expand Up @@ -649,10 +649,8 @@ pub fn get_desired_proto(
let global = GetNonCCWObjectGlobal(*new_target);
let proto_or_iface_cache = get_proto_or_iface_array(global);
desired_proto.set((*proto_or_iface_cache)[proto_id as usize]);
if &*new_target != &*original_new_target {
if !JS_WrapObject(*cx, desired_proto.into()) {
return Err(());
}
if &*new_target != &*original_new_target && !JS_WrapObject(*cx, desired_proto.into()) {
return Err(());
}
return Ok(());
}
Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/bindings/iterable.rs
Expand Up @@ -68,7 +68,7 @@ impl<T: DomObjectIteratorWrap + JSTraceable + Iterable> IterableIterator<T> {
pub fn new(iterable: &T, type_: IteratorType) -> DomRoot<Self> {
let iterator = Box::new(IterableIterator {
reflector: Reflector::new(),
type_: type_,
type_,
iterable: Dom::from_ref(iterable),
index: Cell::new(0),
});
Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/bindings/record.rs
Expand Up @@ -163,7 +163,7 @@ where
map.insert(key, property);
}

Ok(ConversionResult::Success(Record { map: map }))
Ok(ConversionResult::Success(Record { map }))
}
}

Expand Down

0 comments on commit f6a975f

Please sign in to comment.