diff options
author | João Oliveira <hello@jxs.pt> | 2015-08-15 02:27:04 +0100 |
---|---|---|
committer | João Oliveira <hello@jxs.pt> | 2015-08-15 02:27:39 +0100 |
commit | 0038580abf08d40b41136d1350a48da0c757ed77 (patch) | |
tree | 2e1158c846591476f24d38425783b4eeaa365bc0 | |
parent | 13e7de482c0f58ca5af30dbca5d94e6b9cedd1cd (diff) | |
download | servo-0038580abf08d40b41136d1350a48da0c757ed77.tar.gz servo-0038580abf08d40b41136d1350a48da0c757ed77.zip |
Replace uses of `for foo in bar.iter()` and `for foo in bar.iter_mut()`
closes #7197
55 files changed, 141 insertions, 154 deletions
diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs index b885bcb5a82..91e885c880e 100644 --- a/components/compositing/compositor.rs +++ b/components/compositing/compositor.rs @@ -658,7 +658,7 @@ impl<Window: WindowMethods> IOCompositor<Window> { -> Rc<Layer<CompositorData>> { let root_layer = self.create_root_layer_for_pipeline_and_rect(&frame_tree.pipeline, frame_rect); - for kid in frame_tree.children.iter() { + for kid in &frame_tree.children { root_layer.add_child(self.create_frame_tree_root_layers(kid, kid.rect)); } return root_layer; @@ -1085,7 +1085,7 @@ impl<Window: WindowMethods> IOCompositor<Window> { process_layer(&**layer, &window_size, &mut new_visible_rects) } - for (pipeline_id, new_visible_rects) in new_visible_rects.iter() { + for (pipeline_id, new_visible_rects) in &new_visible_rects { if let Some(pipeline_details) = self.pipeline_details.get(&pipeline_id) { if let Some(ref pipeline) = pipeline_details.pipeline { let LayoutControlChan(ref sender) = pipeline.layout_chan; @@ -1109,7 +1109,7 @@ impl<Window: WindowMethods> IOCompositor<Window> { /// If there are any animations running, dispatches appropriate messages to the constellation. fn process_animations(&mut self) { - for (pipeline_id, pipeline_details) in self.pipeline_details.iter() { + for (pipeline_id, pipeline_details) in &self.pipeline_details { if pipeline_details.animations_running || pipeline_details.animation_callbacks_running { self.tick_animations_for_pipeline(*pipeline_id) @@ -1225,7 +1225,7 @@ impl<Window: WindowMethods> IOCompositor<Window> { } fn fill_paint_request_with_cached_layer_buffers(&mut self, paint_request: &mut PaintRequest) { - for buffer_request in paint_request.buffer_requests.iter_mut() { + for buffer_request in &mut paint_request.buffer_requests { if self.surface_map.mem() == 0 { return; } @@ -1261,7 +1261,7 @@ impl<Window: WindowMethods> IOCompositor<Window> { // All the BufferRequests are in layer/device coordinates, but the paint task // wants to know the page coordinates. We scale them before sending them. - for request in layer_requests.iter_mut() { + for request in &mut layer_requests { request.page_rect = request.page_rect / scale.get(); } @@ -1393,7 +1393,7 @@ impl<Window: WindowMethods> IOCompositor<Window> { // This gets sent to the constellation for comparison with the current // frame tree. let mut pipeline_epochs = HashMap::new(); - for (id, details) in self.pipeline_details.iter() { + for (id, details) in &self.pipeline_details { // If animations are currently running, then don't bother checking // with the constellation if the output image is stable. if details.animations_running || details.animation_callbacks_running { diff --git a/components/compositing/constellation.rs b/components/compositing/constellation.rs index 2c5493370c2..9794d23af50 100644 --- a/components/compositing/constellation.rs +++ b/components/compositing/constellation.rs @@ -1148,7 +1148,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> { let pipeline = self.pipelines.get(&frame.current).unwrap(); let _ = pipeline.script_chan.send(ConstellationControlMsg::Resize(pipeline.id, new_size)); - for pipeline_id in frame.prev.iter().chain(frame.next.iter()) { + for pipeline_id in frame.prev.iter().chain(&frame.next) { let pipeline = self.pipelines.get(pipeline_id).unwrap(); let _ = pipeline.script_chan.send(ConstellationControlMsg::ResizeInactive(pipeline.id, new_size)); } diff --git a/components/devtools/actors/timeline.rs b/components/devtools/actors/timeline.rs index 8f55b9853ea..b6e0193d7fb 100644 --- a/components/devtools/actors/timeline.rs +++ b/components/devtools/actors/timeline.rs @@ -211,7 +211,7 @@ impl TimelineActor { } // Emit all markers - for (_, queue) in queues.iter_mut() { + for (_, queue) in &mut queues { let start_payload = queue.pop_front(); group(queue, 0, start_payload, &mut emitter); } diff --git a/components/devtools/lib.rs b/components/devtools/lib.rs index ff42550d826..f38e66ab596 100644 --- a/components/devtools/lib.rs +++ b/components/devtools/lib.rs @@ -347,7 +347,7 @@ fn run_server(sender: Sender<DevtoolsControlMsg>, __type__: "networkEvent".to_string(), eventActor: actor.event_actor(), }; - for stream in connections.iter_mut() { + for stream in &mut connections { stream.write_json_packet(&msg); } } @@ -363,7 +363,7 @@ fn run_server(sender: Sender<DevtoolsControlMsg>, response: actor.response_start() }; - for stream in connections.iter_mut() { + for stream in &mut connections { stream.write_json_packet(&msg); } } @@ -429,7 +429,7 @@ fn run_server(sender: Sender<DevtoolsControlMsg>, request_id, network_event))) => { // copy the accepted_connections vector let mut connections = Vec::<TcpStream>::new(); - for stream in accepted_connections.iter() { + for stream in &accepted_connections { connections.push(stream.try_clone().unwrap()); } //TODO: Get pipeline_id from NetworkEventMessage after fixing the send in http_loader @@ -441,7 +441,7 @@ fn run_server(sender: Sender<DevtoolsControlMsg>, Err(RecvError) => break } } - for connection in accepted_connections.iter_mut() { + for connection in &mut accepted_connections { let _ = connection.shutdown(Shutdown::Both); } } diff --git a/components/gfx/display_list/mod.rs b/components/gfx/display_list/mod.rs index fe72d926c0d..f8d9d6ec8d4 100644 --- a/components/gfx/display_list/mod.rs +++ b/components/gfx/display_list/mod.rs @@ -153,22 +153,22 @@ impl DisplayList { /// inefficient and should only be used for debugging. pub fn all_display_items(&self) -> Vec<DisplayItem> { let mut result = Vec::new(); - for display_item in self.background_and_borders.iter() { + for display_item in &self.background_and_borders { result.push((*display_item).clone()) } - for display_item in self.block_backgrounds_and_borders.iter() { + for display_item in &self.block_backgrounds_and_borders { result.push((*display_item).clone()) } - for display_item in self.floats.iter() { + for display_item in &self.floats { result.push((*display_item).clone()) } - for display_item in self.content.iter() { + for display_item in &self.content { result.push((*display_item).clone()) } - for display_item in self.positioned_content.iter() { + for display_item in &self.positioned_content { result.push((*display_item).clone()) } - for display_item in self.outlines.iter() { + for display_item in &self.outlines { result.push((*display_item).clone()) } result @@ -178,7 +178,7 @@ impl DisplayList { pub fn print_items(&self, indentation: String) { // Closures are so nice! let doit = |items: &Vec<DisplayItem>| { - for item in items.iter() { + for item in items { match *item { DisplayItem::SolidColorClass(ref solid_color) => { println!("{} SolidColor({},{},{},{}). {:?}", @@ -217,7 +217,7 @@ impl DisplayList { println!("{} Children stacking contexts list length: {}", indentation, self.children.len()); - for stacking_context in self.children.iter() { + for stacking_context in &self.children { stacking_context.print(indentation.clone() + &indentation[0..MIN_INDENTATION_LENGTH]); } @@ -319,7 +319,7 @@ impl StackingContext { // Sort positioned children according to z-index. let mut positioned_children: SmallVec<[Arc<StackingContext>; 8]> = SmallVec::new(); - for kid in display_list.children.iter() { + for kid in &display_list.children { if kid.layer.is_none() { positioned_children.push((*kid).clone()); } @@ -335,7 +335,7 @@ impl StackingContext { paint_subcontext.push_clip_if_applicable(); // Steps 1 and 2: Borders and background for the root. - for display_item in display_list.background_and_borders.iter() { + for display_item in &display_list.background_and_borders { display_item.draw_into_context(&mut paint_subcontext) } @@ -360,24 +360,24 @@ impl StackingContext { } // Step 4: Block backgrounds and borders. - for display_item in display_list.block_backgrounds_and_borders.iter() { + for display_item in &display_list.block_backgrounds_and_borders { display_item.draw_into_context(&mut paint_subcontext) } // Step 5: Floats. - for display_item in display_list.floats.iter() { + for display_item in &display_list.floats { display_item.draw_into_context(&mut paint_subcontext) } // TODO(pcwalton): Step 6: Inlines that generate stacking contexts. // Step 7: Content. - for display_item in display_list.content.iter() { + for display_item in &display_list.content { display_item.draw_into_context(&mut paint_subcontext) } // Step 8: Positioned descendants with `z-index: auto`. - for display_item in display_list.positioned_content.iter() { + for display_item in &display_list.positioned_content { display_item.draw_into_context(&mut paint_subcontext) } @@ -402,7 +402,7 @@ impl StackingContext { } // Step 10: Outlines. - for display_item in display_list.outlines.iter() { + for display_item in &display_list.outlines { display_item.draw_into_context(&mut paint_subcontext) } diff --git a/components/gfx/filters.rs b/components/gfx/filters.rs index 38db24ec318..7da418b3c1a 100644 --- a/components/gfx/filters.rs +++ b/components/gfx/filters.rs @@ -23,7 +23,7 @@ pub fn create_filters(draw_target: &DrawTarget, let mut opacity = 1.0; let mut filter = draw_target.create_filter(FilterType::Composite); filter.set_input(CompositeInput, &temporary_draw_target.snapshot()); - for style_filter in style_filters.filters.iter() { + for style_filter in &style_filters.filters { match *style_filter { filter::Filter::HueRotate(angle) => { let hue_rotate = draw_target.create_filter(FilterType::ColorMatrix); @@ -108,7 +108,7 @@ pub fn create_filters(draw_target: &DrawTarget, /// Determines if we need a temporary draw target for the given set of filters. pub fn temporary_draw_target_needed_for_style_filters(filters: &filter::T) -> bool { - for filter in filters.filters.iter() { + for filter in &filters.filters { match *filter { filter::Filter::Opacity(value) if value == 1.0 => continue, _ => return true, @@ -121,7 +121,7 @@ pub fn temporary_draw_target_needed_for_style_filters(filters: &filter::T) -> bo // to expand the draw target size. pub fn calculate_accumulated_blur(style_filters: &filter::T) -> Au { let mut accum_blur = Au::new(0); - for style_filter in style_filters.filters.iter() { + for style_filter in &style_filters.filters { match *style_filter { filter::Filter::Blur(amount) => { accum_blur = accum_blur.clone() + amount; @@ -222,4 +222,3 @@ fn sepia(amount: AzFloat) -> Matrix5x4 { m14: 0.0, m24: 0.0, m34: 0.0, m44: 1.0, m54: 0.0, } } - diff --git a/components/gfx/font_cache_task.rs b/components/gfx/font_cache_task.rs index 995428e21e6..69440197edb 100644 --- a/components/gfx/font_cache_task.rs +++ b/components/gfx/font_cache_task.rs @@ -41,7 +41,7 @@ impl FontFamily { // TODO(Issue #190): if not in the fast path above, do // expensive matching of weights, etc. - for template in self.templates.iter_mut() { + for template in &mut self.templates { let maybe_template = template.get_if_matches(fctx, desc); if maybe_template.is_some() { return maybe_template; @@ -51,7 +51,7 @@ impl FontFamily { // If a request is made for a font family that exists, // pick the first valid font in the family if we failed // to find an exact match for the descriptor. - for template in self.templates.iter_mut() { + for template in &mut self.templates { let maybe_template = template.get(); if maybe_template.is_some() { return maybe_template; @@ -62,7 +62,7 @@ impl FontFamily { } fn add_template(&mut self, identifier: Atom, maybe_data: Option<Vec<u8>>) { - for template in self.templates.iter() { + for template in &self.templates { if *template.identifier() == identifier { return; } @@ -235,7 +235,7 @@ impl FontCache { -> Arc<FontTemplateData> { let last_resort = get_last_resort_font_families(); - for family in last_resort.iter() { + for family in &last_resort { let family = LowercaseString::new(family); let maybe_font_in_family = self.find_font_in_local_family(&family, desc); if maybe_font_in_family.is_some() { diff --git a/components/gfx/font_context.rs b/components/gfx/font_context.rs index 7d2b1740393..7d5a26fe06f 100644 --- a/components/gfx/font_context.rs +++ b/components/gfx/font_context.rs @@ -161,10 +161,10 @@ impl FontContext { let mut fonts: SmallVec<[Rc<RefCell<Font>>; 8]> = SmallVec::new(); - for family in style.font_family.0.iter() { + for family in &style.font_family.0 { // GWTODO: Check on real pages if this is faster as Vec() or HashMap(). let mut cache_hit = false; - for cached_font_entry in self.layout_font_cache.iter() { + for cached_font_entry in &self.layout_font_cache { if cached_font_entry.family == family.name() { match cached_font_entry.font { None => { @@ -224,7 +224,7 @@ impl FontContext { // list of last resort fonts for this platform. if fonts.is_empty() { let mut cache_hit = false; - for cached_font_entry in self.fallback_font_cache.iter() { + for cached_font_entry in &self.fallback_font_cache { let cached_font = cached_font_entry.font.borrow(); if cached_font.descriptor == desc && cached_font.requested_pt_size == style.font_size && @@ -265,7 +265,7 @@ impl FontContext { template: &Arc<FontTemplateData>, pt_size: Au) -> Rc<RefCell<ScaledFont>> { - for cached_font in self.paint_font_cache.iter() { + for cached_font in &self.paint_font_cache { if cached_font.pt_size == pt_size && cached_font.identifier == template.identifier { return cached_font.font.clone(); diff --git a/components/gfx/paint_context.rs b/components/gfx/paint_context.rs index 9f6df9287f0..f70d8a03cd3 100644 --- a/components/gfx/paint_context.rs +++ b/components/gfx/paint_context.rs @@ -1128,7 +1128,7 @@ impl<'a> PaintContext<'a> { pub fn remove_transient_clip_if_applicable(&mut self) { if let Some(old_transient_clip) = mem::replace(&mut self.transient_clip, None) { - for _ in old_transient_clip.complex.iter() { + for _ in &old_transient_clip.complex { self.draw_pop_clip() } self.draw_pop_clip() @@ -1141,7 +1141,7 @@ impl<'a> PaintContext<'a> { self.remove_transient_clip_if_applicable(); self.draw_push_clip(&clip_region.main); - for complex_region in clip_region.complex.iter() { + for complex_region in &clip_region.complex { // FIXME(pcwalton): Actually draw a rounded rect. self.push_rounded_rect_clip(&complex_region.rect.to_nearest_azure_rect(), &complex_region.radii.to_radii_px()) diff --git a/components/gfx/paint_task.rs b/components/gfx/paint_task.rs index 9b893160424..6e8b84ae4c5 100644 --- a/components/gfx/paint_task.rs +++ b/components/gfx/paint_task.rs @@ -172,7 +172,7 @@ impl<C> PaintTask<C> where C: PaintListener + Send + 'static { }, reporter_name, chrome_to_paint_chan, ChromeToPaintMsg::CollectReports); // Tell all the worker threads to shut down. - for worker_thread in paint_task.worker_threads.iter_mut() { + for worker_thread in &mut paint_task.worker_threads { worker_thread.exit() } } diff --git a/components/layout/animation.rs b/components/layout/animation.rs index a3f27267c00..f22865592c3 100644 --- a/components/layout/animation.rs +++ b/components/layout/animation.rs @@ -60,7 +60,7 @@ pub fn process_new_animations(rw_data: &mut LayoutTaskData, pipeline_id: Pipelin // Expire old running animations. let now = clock_ticks::precise_time_s(); - for (_, running_animations) in running_animations.iter_mut() { + for (_, running_animations) in &mut running_animations { running_animations.retain(|running_animation| now < running_animation.end_time); } @@ -97,7 +97,7 @@ pub fn recalc_style_for_animations(flow: &mut Flow, let mut damage = RestyleDamage::empty(); flow.mutate_fragments(&mut |fragment| { if let Some(ref animations) = animations.get(&OpaqueNode(fragment.node.id())) { - for animation in animations.iter() { + for animation in *animations { let now = clock_ticks::precise_time_s(); let mut progress = (now - animation.start_time) / animation.duration(); if progress > 1.0 { @@ -130,4 +130,3 @@ pub fn tick_all_animations(layout_task: &LayoutTask, rw_data: &mut LayoutTaskDat layout_task.script_chan.send(ConstellationControlMsg::TickAllAnimations(layout_task.id)).unwrap(); } - diff --git a/components/layout/construct.rs b/components/layout/construct.rs index e8a1167a4fc..a918e35463b 100644 --- a/components/layout/construct.rs +++ b/components/layout/construct.rs @@ -438,7 +438,7 @@ impl<'a> FlowConstructor<'a> { // Build a list of all the inline-block fragments before fragments is moved. let mut inline_block_flows = vec!(); - for fragment in fragments.fragments.iter() { + for fragment in &fragments.fragments { match fragment.specific { SpecificFragmentInfo::InlineBlock(ref info) => { inline_block_flows.push(info.flow_ref.clone()) @@ -464,7 +464,7 @@ impl<'a> FlowConstructor<'a> { node.style().writing_mode)); // Add all the inline-block fragments as children of the inline flow. - for inline_block_flow in inline_block_flows.iter() { + for inline_block_flow in &inline_block_flows { inline_flow_ref.add_new_child(inline_block_flow.clone()); } diff --git a/components/layout/css/matching.rs b/components/layout/css/matching.rs index 62315fb26e2..1392fea7067 100644 --- a/components/layout/css/matching.rs +++ b/components/layout/css/matching.rs @@ -108,7 +108,7 @@ impl<'a> PartialEq for ApplicableDeclarationsCacheQuery<'a> { if self.declarations.len() != other.declarations.len() { return false } - for (this, other) in self.declarations.iter().zip(other.declarations.iter()) { + for (this, other) in self.declarations.iter().zip(other.declarations) { if !arc_ptr_eq(&this.declarations, &other.declarations) { return false } @@ -127,7 +127,7 @@ impl<'a> PartialEq<ApplicableDeclarationsCacheEntry> for ApplicableDeclarationsC impl<'a> Hash for ApplicableDeclarationsCacheQuery<'a> { fn hash<H: Hasher>(&self, state: &mut H) { - for declaration in self.declarations.iter() { + for declaration in self.declarations { let ptr: usize = unsafe { mem::transmute_copy(declaration) }; @@ -173,7 +173,7 @@ pub struct StyleSharingCandidateCache { fn create_common_style_affecting_attributes_from_element(element: &LayoutElement) -> CommonStyleAffectingAttributes { let mut flags = CommonStyleAffectingAttributes::empty(); - for attribute_info in common_style_affecting_attributes().iter() { + for attribute_info in &common_style_affecting_attributes() { match attribute_info.mode { CommonStyleAffectingAttributeMode::IsPresent(flag) => { if element.get_attr(&ns!(""), &attribute_info.atom).is_some() { @@ -295,7 +295,7 @@ impl StyleSharingCandidate { // FIXME(pcwalton): It's probably faster to iterate over all the element's attributes and // use the {common, rare}-style-affecting-attributes tables as lookup tables. - for attribute_info in common_style_affecting_attributes().iter() { + for attribute_info in &common_style_affecting_attributes() { match attribute_info.mode { CommonStyleAffectingAttributeMode::IsPresent(flag) => { if self.common_style_affecting_attributes.contains(flag) != @@ -322,7 +322,7 @@ impl StyleSharingCandidate { } } - for attribute_name in rare_style_affecting_attributes().iter() { + for attribute_name in &rare_style_affecting_attributes() { if element.get_attr(&ns!(""), attribute_name).is_some() { return false } @@ -447,7 +447,7 @@ impl<'ln> PrivateMatchMethods for LayoutNode<'ln> { if let Some(ref mut style) = *style { let this_opaque = self.opaque(); if let Some(ref animations) = layout_context.running_animations.get(&this_opaque) { - for animation in animations.iter() { + for animation in *animations { animation.property_animation.update(&mut *Arc::make_unique(style), 1.0); } } diff --git a/components/layout/data.rs b/components/layout/data.rs index 75831d7c2ff..4b551e2fd9e 100644 --- a/components/layout/data.rs +++ b/components/layout/data.rs @@ -74,7 +74,7 @@ impl LayoutDataWrapper { ConstructionResult::ConstructionItem(ref construction_item) => { match construction_item { &ConstructionItem::InlineFragments(ref inline_fragments) => { - for fragment in inline_fragments.fragments.fragments.iter() { + for fragment in &inline_fragments.fragments.fragments { fragment.remove_compositor_layers(constellation_chan.clone()); } } diff --git a/components/layout/display_list_builder.rs b/components/layout/display_list_builder.rs index e597757fabc..06e6e004865 100644 --- a/components/layout/display_list_builder.rs +++ b/components/layout/display_list_builder.rs @@ -1771,7 +1771,7 @@ impl InlineFlowDisplayListBuilding for InlineFlow { let mut display_list = box DisplayList::new(); let mut has_stacking_context = false; - for fragment in self.fragments.fragments.iter_mut() { + for fragment in &mut self.fragments.fragments { fragment.build_display_list(&mut *display_list, layout_context, &self.base.stacking_relative_position, @@ -2026,4 +2026,3 @@ pub enum StackingContextCreationMode { OuterScrollWrapper, InnerScrollWrapper, } - diff --git a/components/layout/flow.rs b/components/layout/flow.rs index d2843b7d021..d7dab549958 100644 --- a/components/layout/flow.rs +++ b/components/layout/flow.rs @@ -1086,7 +1086,7 @@ impl BaseFlow { DisplayListBuildingResult::Normal(ref display_list) => display_list.all_display_items(), }; - for item in all_items.iter() { + for item in &all_items { let paint_bounds = item.base().clip.clone().intersect_rect(&item.base().bounds); if !paint_bounds.might_be_nonempty() { continue; diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs index ffbcd1845a2..a512db3670c 100644 --- a/components/layout/fragment.rs +++ b/components/layout/fragment.rs @@ -1041,7 +1041,7 @@ impl Fragment { containing_block_inline_size).specified_or_zero(); if let Some(ref inline_context) = self.inline_context { - for node in inline_context.nodes.iter() { + for node in &inline_context.nodes { let margin = node.style.logical_margin(); self.margin.inline_start = self.margin.inline_start + MaybeAuto::from_style(margin.inline_start, @@ -1155,7 +1155,7 @@ impl Fragment { }; if let Some(ref inline_fragment_context) = self.inline_context { - for node in inline_fragment_context.nodes.iter() { + for node in &inline_fragment_context.nodes { if node.style.get_box().position == position::T::relative { rel_pos = rel_pos + from_style(&*node.style, containing_block_size); } @@ -1309,7 +1309,7 @@ impl Fragment { // Take borders and padding for parent inline fragments into account, if necessary. if self.is_primary_fragment() { if let Some(ref context) = self.inline_context { - for node in context.nodes.iter() { + for node in &context.nodes { let border_width = node.style.logical_border_width().inline_start_end(); let padding_inline_size = model::padding_from_style(&*node.style, Au(0)).inline_start_end(); @@ -2042,7 +2042,7 @@ impl Fragment { let mut overflow = border_box; // Box shadows cause us to draw outside our border box. - for box_shadow in self.style().get_effects().box_shadow.0.iter() { + for box_shadow in &self.style().get_effects().box_shadow.0 { let offset = Point2D::new(box_shadow.offset_x, box_shadow.offset_y); let inflation = box_shadow.spread_radius + box_shadow.blur_radius * BLUR_INFLATION_FACTOR; @@ -2345,4 +2345,3 @@ impl WhitespaceStrippingResult { } } } - diff --git a/components/layout/generated_content.rs b/components/layout/generated_content.rs index a125c497d80..639fa1e3cc6 100644 --- a/components/layout/generated_content.rs +++ b/components/layout/generated_content.rs @@ -261,12 +261,12 @@ impl<'a,'b> ResolveGeneratedContentFragmentMutator<'a,'b> { } // Truncate down counters. - for (_, counter) in self.traversal.counters.iter_mut() { + for (_, counter) in &mut self.traversal.counters { counter.truncate_to_level(self.level); } self.traversal.list_item.truncate_to_level(self.level); - for &(ref counter_name, value) in fragment.style().get_counters().counter_reset.0.iter() { + for &(ref counter_name, value) in &fragment.style().get_counters().counter_reset.0 { if let Some(ref mut counter) = self.traversal.counters.get_mut(counter_name) { counter.reset(self.level, value); continue @@ -386,7 +386,7 @@ impl Counter { } RenderingMode::All(separator) => { let mut first = true; - for value in self.values.iter() { + for value in &self.values { if !first { string.push_str(separator) } diff --git a/components/layout/incremental.rs b/components/layout/incremental.rs index c5f80511c5f..4b976ec6138 100644 --- a/components/layout/incremental.rs +++ b/components/layout/incremental.rs @@ -102,7 +102,7 @@ impl fmt::Display for RestyleDamage { , (RECONSTRUCT_FLOW, "ReconstructFlow") ]; - for &(damage, damage_str) in to_iter.iter() { + for &(damage, damage_str) in &to_iter { if self.contains(damage) { if !first_elem { try!(write!(f, " | ")); } try!(write!(f, "{}", damage_str)); @@ -248,4 +248,3 @@ impl<'a> LayoutDamageComputation for &'a mut (Flow + 'a) { } } } - diff --git a/components/layout/inline.rs b/components/layout/inline.rs index 22e6366cf82..89c71958289 100644 --- a/components/layout/inline.rs +++ b/components/layout/inline.rs @@ -802,7 +802,7 @@ pub struct InlineFragments { impl fmt::Debug for InlineFragments { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - for fragment in self.fragments.iter() { + for fragment in &self.fragments { try!(write!(f, "\n * {:?}", fragment)) } Ok(()) @@ -889,7 +889,7 @@ impl InlineFlow { first_line_indentation: Au(0), }; - for fragment in flow.fragments.fragments.iter() { + for fragment in &flow.fragments.fragments { if fragment.is_generated_content() { flow.base.restyle_damage.insert(RESOLVE_GENERATED_CONTENT) } @@ -1223,7 +1223,7 @@ impl InlineFlow { // According to CSS 2.1 § 10.8, `line-height` of any inline element specifies the minimal // height of line boxes within the element. - for frag in self.fragments.fragments.iter() { + for frag in &self.fragments.fragments { match frag.inline_context { Some(ref inline_context) => { for node in inline_context.nodes.iter() { @@ -1248,7 +1248,7 @@ impl InlineFlow { fn update_restyle_damage(&mut self) { let mut damage = self.base.restyle_damage; - for frag in self.fragments.fragments.iter() { + for frag in &self.fragments.fragments { damage.insert(frag.restyle_damage()); } @@ -1321,7 +1321,7 @@ impl Flow for InlineFlow { let mut intrinsic_sizes_for_flow = IntrinsicISizesContribution::new(); let mut intrinsic_sizes_for_inline_run = IntrinsicISizesContribution::new(); let mut intrinsic_sizes_for_nonbroken_run = IntrinsicISizesContribution::new(); - for fragment in self.fragments.fragments.iter_mut() { + for fragment in &mut self.fragments.fragments { let intrinsic_sizes_for_fragment = fragment.compute_intrinsic_inline_sizes().finish(); match fragment.style.get_inheritedtext().white_space { white_space::T::nowrap => { @@ -1420,7 +1420,7 @@ impl Flow for InlineFlow { // Assign the block-size and late-computed inline-sizes for the inline fragments. let containing_block_block_size = self.base.block_container_explicit_block_size; - for fragment in self.fragments.fragments.iter_mut() { + for fragment in &mut self.fragments.fragments { fragment.update_late_computed_replaced_inline_size_if_necessary(); fragment.assign_replaced_block_size_if_necessary(containing_block_block_size); } @@ -1619,7 +1619,7 @@ impl Flow for InlineFlow { // Then compute the positions of all of our fragments. let mut containing_block_positions = containing_block_positions.iter(); - for fragment in self.fragments.fragments.iter_mut() { + for fragment in &mut self.fragments.fragments { let stacking_relative_border_box = fragment.stacking_relative_border_box(&self.base.stacking_relative_position, &self.base @@ -1688,7 +1688,7 @@ impl Flow for InlineFlow { fn compute_overflow(&self) -> Rect<Au> { let mut overflow = ZERO_RECT; - for fragment in self.fragments.fragments.iter() { + for fragment in &self.fragments.fragments { overflow = overflow.union(&fragment.compute_overflow()) } overflow @@ -1699,7 +1699,7 @@ impl Flow for InlineFlow { level: i32, stacking_context_position: &Point2D<Au>) { // FIXME(#2795): Get the real container size. - for fragment in self.fragments.fragments.iter() { + for fragment in &self.fragments.fragments { if !iterator.should_process(fragment) { continue } @@ -1720,7 +1720,7 @@ impl Flow for InlineFlow { } fn mutate_fragments(&mut self, mutator: &mut FnMut(&mut Fragment)) { - for fragment in self.fragments.fragments.iter_mut() { + for fragment in &mut self.fragments.fragments { (*mutator)(fragment) } } @@ -1784,7 +1784,7 @@ impl InlineFragmentContext { if self.nodes.len() != other.nodes.len() { return false } - for (this_node, other_node) in self.nodes.iter().zip(other.nodes.iter()) { + for (this_node, other_node) in self.nodes.iter().zip(&other.nodes) { if !util::arc_ptr_eq(&this_node.style, &other_node.style) { return false } @@ -1871,4 +1871,3 @@ enum LineFlushMode { No, Flush, } - diff --git a/components/layout/layout_task.rs b/components/layout/layout_task.rs index 80403c1dca3..6028c8c3b6a 100644 --- a/components/layout/layout_task.rs +++ b/components/layout/layout_task.rs @@ -296,7 +296,7 @@ impl<'a> DerefMut for RWGuard<'a> { fn add_font_face_rules(stylesheet: &Stylesheet, device: &Device, font_cache_task: &FontCacheTask) { for font_face in stylesheet.effective_rules(&device).font_face() { - for source in font_face.sources.iter() { + for source in &font_face.sources { font_cache_task.add_web_font(font_face.family.clone(), source.clone()); } } @@ -1213,7 +1213,7 @@ impl LayoutTask { let inflation_amount = Size2D::new(rw_data.screen_size.width * DISPLAY_PORT_THRESHOLD_SIZE_FACTOR, rw_data.screen_size.height * DISPLAY_PORT_THRESHOLD_SIZE_FACTOR); - for &(ref layer_id, ref new_visible_rect) in new_visible_rects.iter() { + for &(ref layer_id, ref new_visible_rect) in &new_visible_rects { match rw_data.visible_rects.get(layer_id) { None => { old_visible_rects.insert(*layer_id, *new_visible_rect); @@ -1236,7 +1236,7 @@ impl LayoutTask { } debug!("regenerating display lists!"); - for &(ref layer_id, ref new_visible_rect) in new_visible_rects.iter() { + for &(ref layer_id, ref new_visible_rect) in &new_visible_rects { old_visible_rects.insert(*layer_id, *new_visible_rect); } rw_data.visible_rects = Arc::new(old_visible_rects); @@ -1556,4 +1556,3 @@ fn get_root_flow_background_color(flow: &mut Flow) -> AzColor { .resolve_color(kid_block_flow.fragment.style.get_background().background_color) .to_gfx_color() } - diff --git a/components/layout/table.rs b/components/layout/table.rs index 86eec90ffdd..c3c63b85762 100644 --- a/components/layout/table.rs +++ b/components/layout/table.rs @@ -87,7 +87,7 @@ impl TableFlow { -> IntrinsicISizes { let mut total_inline_sizes = IntrinsicISizes::new(); let mut column_index = 0; - for child_cell_inline_size in child_cell_inline_sizes.iter() { + for child_cell_inline_size in child_cell_inline_sizes { for _ in 0..child_cell_inline_size.column_span { if column_index < parent_inline_sizes.len() { // We already have some intrinsic size information for this column. Merge it in @@ -150,7 +150,7 @@ impl TableFlow { // // FIXME(pcwalton): This is really inefficient. We should stop after the first row! if first_row { - for cell_inline_size in row.cell_intrinsic_inline_sizes.iter() { + for cell_inline_size in &row.cell_intrinsic_inline_sizes { column_inline_sizes.push(cell_inline_size.column_size); } } @@ -289,7 +289,7 @@ impl Flow for TableFlow { }; if kid.is_table_colgroup() { - for specified_inline_size in kid.as_table_colgroup().inline_sizes.iter() { + for specified_inline_size in &kid.as_table_colgroup().inline_sizes { self.column_intrinsic_inline_sizes.push(ColumnIntrinsicInlineSize { minimum_length: match *specified_inline_size { LengthOrPercentageOrAuto::Auto | @@ -400,7 +400,7 @@ impl Flow for TableFlow { let mut num_unspecified_inline_sizes = 0; let mut total_column_inline_size = Au(0); - for column_inline_size in self.column_intrinsic_inline_sizes.iter() { + for column_inline_size in &self.column_intrinsic_inline_sizes { if column_inline_size.constrained { total_column_inline_size = total_column_inline_size + column_inline_size.minimum_length @@ -432,14 +432,14 @@ impl Flow for TableFlow { if num_unspecified_inline_sizes == 0 { let ratio = content_inline_size.to_f32_px() / total_column_inline_size.to_f32_px(); - for column_inline_size in self.column_intrinsic_inline_sizes.iter() { + for column_inline_size in &self.column_intrinsic_inline_sizes { self.column_computed_inline_sizes.push(ColumnComputedInlineSize { size: column_inline_size.minimum_length.scale_by(ratio), }); } } else if num_unspecified_inline_sizes != 0 { let extra_column_inline_size = content_inline_size - total_column_inline_size; - for column_inline_size in self.column_intrinsic_inline_sizes.iter() { + for column_inline_size in &self.column_intrinsic_inline_sizes { if !column_inline_size.constrained && column_inline_size.percentage == 0.0 { self.column_computed_inline_sizes.push(ColumnComputedInlineSize { @@ -861,4 +861,3 @@ enum NextBlockCollapsedBorders<'a> { FromTable(CollapsedBorder), NotCollapsingBorders, } - diff --git a/components/layout/table_colgroup.rs b/components/layout/table_colgroup.rs index 65990e40599..c562149d5f2 100644 --- a/components/layout/table_colgroup.rs +++ b/components/layout/table_colgroup.rs @@ -64,7 +64,7 @@ impl Flow for TableColGroupFlow { let _scope = layout_debug_scope!("table_colgroup::bubble_inline_sizes {:x}", self.base.debug_id()); - for fragment in self.cols.iter() { + for fragment in &self.cols { // Retrieve the specified value from the appropriate CSS property. let inline_size = fragment.style().content_inline_size(); let span = match fragment.specific { diff --git a/components/layout/table_row.rs b/components/layout/table_row.rs index 583749e65bb..acd537c27f7 100644 --- a/components/layout/table_row.rs +++ b/components/layout/table_row.rs @@ -325,7 +325,7 @@ impl Flow for TableRowFlow { // Spread out the completed inline sizes among columns with spans > 1. let mut computed_inline_size_for_cells = Vec::new(); let mut column_computed_inline_size_iterator = self.column_computed_inline_sizes.iter(); - for cell_intrinsic_inline_size in self.cell_intrinsic_inline_sizes.iter() { + for cell_intrinsic_inline_size in &self.cell_intrinsic_inline_sizes { // Start with the computed inline size for the first column in the span. let mut column_computed_inline_size = match column_computed_inline_size_iterator.next() { @@ -836,4 +836,3 @@ fn perform_inline_direction_border_collapse_for_row( CollapsedBorderProvenance::FromPreviousTableCell); preliminary_collapsed_borders.block_end.push_or_mutate(child_index, block_end_border); } - diff --git a/components/layout/table_wrapper.rs b/components/layout/table_wrapper.rs index 57a1a1f0b9c..459d58a4875 100644 --- a/components/layout/table_wrapper.rs +++ b/components/layout/table_wrapper.rs @@ -163,7 +163,7 @@ impl TableWrapperFlow { if excess_inline_size > Au(0) && selection == SelectedAutoLayoutCandidateGuess::UsePreferredGuessAndDistributeExcessInlineSize { let mut info = ExcessInlineSizeDistributionInfo::new(); - for column_intrinsic_inline_size in self.column_intrinsic_inline_sizes.iter() { + for column_intrinsic_inline_size in &self.column_intrinsic_inline_sizes { info.update(column_intrinsic_inline_size) } @@ -791,4 +791,3 @@ impl ISizeAndMarginsComputer for FloatedTable { FloatNonReplaced.solve_inline_size_constraints(block, input) } } - diff --git a/components/layout/wrapper.rs b/components/layout/wrapper.rs index 98826e81a28..82fe6df054a 100644 --- a/components/layout/wrapper.rs +++ b/components/layout/wrapper.rs @@ -520,7 +520,7 @@ impl<'le> ::selectors::Element for LayoutElement<'le> { match (*self.element.unsafe_get()).get_classes_for_layout() { None => {} Some(ref classes) => { - for class in classes.iter() { + for class in *classes { callback(class) } } diff --git a/components/net/http_loader.rs b/components/net/http_loader.rs index d53de8a5ecc..05d6ef74cea 100644 --- a/components/net/http_loader.rs +++ b/components/net/http_loader.rs @@ -298,7 +298,7 @@ reason: \"certificate verify failed\" }]))"; } if let Some(cookies) = response.headers.get_raw("set-cookie") { - for cookie in cookies.iter() { + for cookie in cookies { if let Ok(cookies) = String::from_utf8(cookie.clone()) { resource_mgr_chan.send(ControlMsg::SetCookiesForUrl(doc_url.clone(), cookies, @@ -395,7 +395,7 @@ reason: \"certificate verify failed\" }]))"; let mut encoding_str: Option<String> = None; //FIXME: Implement Content-Encoding Header https://github.com/hyperium/hyper/issues/391 if let Some(encodings) = response.headers.get_raw("content-encoding") { - for encoding in encodings.iter() { + for encoding in encodings { if let Ok(encodings) = String::from_utf8(encoding.clone()) { if encodings == "gzip" || encodings == "deflate" { encoding_str = Some(encodings); diff --git a/components/net/mime_classifier.rs b/components/net/mime_classifier.rs index 1c038174018..3495d9a22ba 100644 --- a/components/net/mime_classifier.rs +++ b/components/net/mime_classifier.rs @@ -141,7 +141,7 @@ impl <'a, T: Iterator<Item=&'a u8> + Clone> Matches for T { // Side effects // moves the iterator when match is found fn matches(&mut self, matches: &[u8]) -> bool { - for (byte_a, byte_b) in self.clone().take(matches.len()).zip(matches.iter()) { + for (byte_a, byte_b) in self.clone().take(matches.len()).zip(matches) { if byte_a != byte_b { return false; } diff --git a/components/net_traits/hosts.rs b/components/net_traits/hosts.rs index 7a80c6e815e..862223b4b34 100644 --- a/components/net_traits/hosts.rs +++ b/components/net_traits/hosts.rs @@ -41,7 +41,7 @@ pub fn parse_hostsfile(hostsfile_content: &str) -> Box<HashMap<String, String>> let mut host_table = HashMap::new(); let lines: Vec<&str> = hostsfile_content.split('\n').collect(); - for line in lines.iter() { + for line in &lines { let ip_host: Vec<&str> = line.trim().split(|c: char| c == ' ' || c == '\t').collect(); if ip_host.len() > 1 { if !IPV4_REGEX.is_match(ip_host[0]) && !IPV6_REGEX.is_match(ip_host[0]) { continue; } diff --git a/components/net_traits/lib.rs b/components/net_traits/lib.rs index 2ee8f160d10..e4a93f56673 100644 --- a/components/net_traits/lib.rs +++ b/components/net_traits/lib.rs @@ -283,7 +283,7 @@ impl Metadata { Some(mime) => { self.content_type = Some(ContentType(mime.clone())); let &Mime(_, _, ref parameters) = mime; - for &(ref k, ref v) in parameters.iter() { + for &(ref k, ref v) in parameters { if &Attr::Charset == k { self.charset = Some(v.to_string()); } diff --git a/components/plugins/jstraceable.rs b/components/plugins/jstraceable.rs index 2d6a71fbcf3..39df8614784 100644 --- a/components/plugins/jstraceable.rs +++ b/components/plugins/jstraceable.rs @@ -80,7 +80,7 @@ fn jstraceable_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substru _ => cx.span_bug(trait_span, "impossible substructure in `jstraceable`") }; - for &FieldInfo { ref self_, span, .. } in fields.iter() { + for &FieldInfo { ref self_, span, .. } in fields { stmts.push(call_trace(span, self_.clone())); } diff --git a/components/plugins/lints/inheritance_integrity.rs b/components/plugins/lints/inheritance_integrity.rs index fbb0c0c65df..0e48a198fa2 100644 --- a/components/plugins/lints/inheritance_integrity.rs +++ b/components/plugins/lints/inheritance_integrity.rs @@ -69,7 +69,7 @@ impl LintPass for InheritancePass { if cx.current_level(INHERITANCE_INTEGRITY) != Level::Allow { let sess = cx.sess(); sess.span_note(sp, "Reflector found here"); - for span in dom_spans.iter() { + for span in &dom_spans { sess.span_note(*span, "Bare DOM struct found here"); } } @@ -79,7 +79,7 @@ impl LintPass for InheritancePass { cx.span_lint(INHERITANCE_INTEGRITY, cx.tcx.map.expect_item(id).span, "This DOM struct has multiple DOM struct members, only one is allowed"); if cx.current_level(INHERITANCE_INTEGRITY) != Level::Allow { - for span in dom_spans.iter() { + for span in &dom_spans { cx.sess().span_note(*span, "Bare DOM struct found here"); } } diff --git a/components/plugins/lints/privatize.rs b/components/plugins/lints/privatize.rs index 3a96b1873dd..430edf50d30 100644 --- a/components/plugins/lints/privatize.rs +++ b/components/plugins/lints/privatize.rs @@ -28,7 +28,7 @@ impl LintPass for PrivatizePass { _gen: &ast::Generics, id: ast::NodeId) { if cx.tcx.has_attr(ast_util::local_def(id), "privatize") { - for field in def.fields.iter() { + for field in &def.fields { match field.node { ast::StructField_ { kind: ast::NamedField(ident, visibility), .. } if visibility == Public => { cx.span_lint(PRIVATIZE, field.span, diff --git a/components/plugins/lints/unrooted_must_root.rs b/components/plugins/lints/unrooted_must_root.rs index 3bdb94b59ac..190ce92292a 100644 --- a/components/plugins/lints/unrooted_must_root.rs +++ b/components/plugins/lints/unrooted_must_root.rs @@ -88,7 +88,7 @@ impl LintPass for UnrootedPass { _ => cx.tcx.map.expect_item(cx.tcx.map.get_parent(id)), }; if item.attrs.iter().all(|a| !a.check_name("must_root")) { - for ref field in def.fields.iter() { + for ref field in &def.fields { if is_unrooted_ty(cx, cx.tcx.node_id_to_type(field.node.id), false) { cx.span_lint(UNROOTED_MUST_ROOT, field.span, "Type must be rooted, use #[must_root] on the struct definition to propagate") @@ -102,7 +102,7 @@ impl LintPass for UnrootedPass { if map.expect_item(map.get_parent(var.node.id)).attrs.iter().all(|a| !a.check_name("must_root")) { match var.node.kind { ast::TupleVariantKind(ref vec) => { - for ty in vec.iter() { + for ty in vec { ast_ty_to_prim_ty(cx.tcx, &*ty.ty).map(|t| { if is_unrooted_ty(cx, t, false) { cx.span_lint(UNROOTED_MUST_ROOT, ty.ty.span, @@ -141,7 +141,7 @@ impl LintPass for UnrootedPass { match block.rules { ast::DefaultBlock => { - for arg in decl.inputs.iter() { + for arg in &decl.inputs { ast_ty_to_prim_ty(cx.tcx, &*arg.ty).map(|t| { if is_unrooted_ty(cx, t, false) { cx.span_lint(UNROOTED_MUST_ROOT, arg.ty.span, "Type must be rooted") diff --git a/components/profile/mem.rs b/components/profile/mem.rs index 598acfb04e8..6c8e2c4b55a 100644 --- a/components/profile/mem.rs +++ b/components/profile/mem.rs @@ -144,7 +144,7 @@ impl Profiler { reporter.collect_reports(ReportsChan(chan)); if let Ok(mut reports) = port.recv() { - for report in reports.iter_mut() { + for report in &mut reports { // Add "explicit" to the start of the path, when appropriate. match report.kind { @@ -242,7 +242,7 @@ impl ReportsTree { // Insert the path and size into the tree, adding any nodes as necessary. fn insert(&mut self, path: &[String], size: usize) { let mut t: &mut ReportsTree = self; - for path_seg in path.iter() { + for path_seg in path { let i = match t.find_child(&path_seg) { Some(i) => i, None => { @@ -268,7 +268,7 @@ impl ReportsTree { // This will occur if e.g. we have paths ["a", "b"] and ["a", "b", "c"]. panic!("one report's path is a sub-path of another report's path"); } - for child in self.children.iter_mut() { + for child in &mut self.children { self.size += child.compute_interior_node_sizes_and_sort(); } // Now that child sizes have been computed, we can sort the children. @@ -292,7 +292,7 @@ impl ReportsTree { println!("|{}{:8.2} MiB -- {}{}", indent_str, (self.size as f64) / mebi, self.path_seg, count_str); - for child in self.children.iter() { + for child in &self.children { child.print(depth + 1); } } @@ -326,7 +326,7 @@ impl ReportsForest { fn print(&mut self) { // Fill in sizes of interior nodes, and recursively sort the sub-trees. - for (_, tree) in self.trees.iter_mut() { + for (_, tree) in &mut self.trees { tree.compute_interior_node_sizes_and_sort(); } @@ -334,7 +334,7 @@ impl ReportsForest { // single node) come after non-degenerate trees. Secondary sort: alphabetical order of the // root node's path_seg. let mut v = vec![]; - for (_, tree) in self.trees.iter() { + for (_, tree) in &self.trees { v.push(tree); } v.sort_by(|a, b| { @@ -348,7 +348,7 @@ impl ReportsForest { }); // Print the forest. - for tree in v.iter() { + for tree in &v { tree.print(0); // Print a blank line after non-degenerate trees. if !tree.children.is_empty() { @@ -390,7 +390,7 @@ mod system_reporter { report(path!["resident"], get_resident()); // Memory segments, as reported by the OS. - for seg in get_resident_segments().iter() { + for seg in get_resident_segments() { report(path!["resident-according-to-smaps", seg.0], Some(seg.1)); } diff --git a/components/profile/time.rs b/components/profile/time.rs index 02e9f44c294..484cb882bf9 100644 --- a/components/profile/time.rs +++ b/components/profile/time.rs @@ -178,7 +178,7 @@ impl Profiler { "_category_", "_incremental?_", "_iframe?_", " _url_", " _mean (ms)_", " _median (ms)_", " _min (ms)_", " _max (ms)_", " _events_"); - for (&(ref category, ref meta), ref mut data) in self.buckets.iter_mut() { + for (&(ref category, ref meta), ref mut data) in &mut self.buckets { data.sort_by(|a, b| { if a < b { Ordering::Less diff --git a/components/script/cors.rs b/components/script/cors.rs index f9170edc020..35111966fde 100644 --- a/components/script/cors.rs +++ b/components/script/cors.rs @@ -259,7 +259,7 @@ impl CORSRequest { // This cache should come from the user agent, creating a new one here to check // for compile time errors let cache = &mut CORSCache(vec!()); - for m in methods.iter() { + for m in methods { let cache_match = cache.match_method_and_update(self, m, max_age); if !cache_match { cache.insert(CORSCacheEntry::new(self.origin.clone(), self.destination.clone(), diff --git a/components/script/devtools.rs b/components/script/devtools.rs index 06a2141d3b1..25a0da81a40 100644 --- a/components/script/devtools.rs +++ b/components/script/devtools.rs @@ -158,7 +158,7 @@ pub fn handle_modify_attribute(page: &Rc<Page>, let node = find_node_by_unique_id(&*page, pipeline, node_id); let elem = ElementCast::to_ref(node.r()).expect("should be getting layout of element"); - for modification in modifications.iter(){ + for modification in &modifications { match modification.newValue { Some(ref string) => { let _ = elem.SetAttribute(modification.attributeName.clone(), string.clone()); diff --git a/components/script/dom/bindings/js.rs b/components/script/dom/bindings/js.rs index c6199e5dff7..b622485f602 100644 --- a/components/script/dom/bindings/js.rs +++ b/components/script/dom/bindings/js.rs @@ -386,7 +386,7 @@ pub unsafe fn trace_roots(tracer: *mut JSTracer) { STACK_ROOTS.with(|ref collection| { let RootCollectionPtr(collection) = collection.get().unwrap(); let collection = &*(*collection).roots.get(); - for root in collection.iter() { + for root in collection { trace_reflector(tracer, "reflector", &**root); } }); diff --git a/components/script/dom/bindings/trace.rs b/components/script/dom/bindings/trace.rs index 7b9a7999706..423aa62844a 100644 --- a/components/script/dom/bindings/trace.rs +++ b/components/script/dom/bindings/trace.rs @@ -429,7 +429,7 @@ impl RootedTraceableSet { } unsafe fn trace(&self, tracer: *mut JSTracer) { - for info in self.set.iter() { + for info in &self.set { (info.trace)(info.ptr, tracer); } } diff --git a/components/script/dom/bindings/utils.rs b/components/script/dom/bindings/utils.rs index 80db27bd894..d5c7d589ed4 100644 --- a/components/script/dom/bindings/utils.rs +++ b/components/script/dom/bindings/utils.rs @@ -235,7 +235,7 @@ pub fn do_create_interface_objects(cx: *mut JSContext, members, s.as_ptr()) } - for ctor in named_constructors.iter() { + for ctor in named_constructors { let (cnative, cname, cnargs) = *ctor; let cs = CString::new(cname).unwrap(); @@ -321,7 +321,7 @@ fn create_interface_object(cx: *mut JSContext, /// Fails on JSAPI failure. fn define_constants(cx: *mut JSContext, obj: HandleObject, constants: &'static [ConstantSpec]) { - for spec in constants.iter() { + for spec in constants { let value = RootedValue::new(cx, spec.get_value()); unsafe { assert!(JS_DefineProperty(cx, obj, spec.name.as_ptr() as *const libc::c_char, diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 9c7ea6d9085..dfd0024960e 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -752,7 +752,7 @@ impl<'a> DocumentHelpers<'a> for &'a Document { // Build a list of elements that are currently under the mouse. let mouse_over_addresses = self.get_nodes_under_mouse(&point); let mut mouse_over_targets: RootedVec<JS<Node>> = RootedVec::new(); - for node_address in mouse_over_addresses.iter() { + for node_address in &mouse_over_addresses { let node = node::from_untrusted_node_address(js_runtime, *node_address); mouse_over_targets.push(node.r().inclusive_ancestors() .find(|node| node.r().is_element()) diff --git a/components/script/dom/domtokenlist.rs b/components/script/dom/domtokenlist.rs index 450a4ab224c..df7dadb2b44 100644 --- a/components/script/dom/domtokenlist.rs +++ b/components/script/dom/domtokenlist.rs @@ -101,7 +101,7 @@ impl<'a> DOMTokenListMethods for &'a DOMTokenList { fn Add(self, tokens: Vec<DOMString>) -> ErrorResult { let element = self.element.root(); let mut atoms = element.r().get_tokenlist_attribute(&self.local_name); - for token in tokens.iter() { + for token in &tokens { let token = try!(self.check_token_exceptions(&token)); if !atoms.iter().any(|atom| *atom == token) { atoms.push(token); @@ -115,7 +115,7 @@ impl<'a> DOMTokenListMethods for &'a DOMTokenList { fn Remove(self, tokens: Vec<DOMString>) -> ErrorResult { let element = self.element.root(); let mut atoms = element.r().get_tokenlist_attribute(&self.local_name); - for token in tokens.iter() { + for token in &tokens { let token = try!(self.check_token_exceptions(&token)); atoms.iter().position(|atom| *atom == token).map(|index| { atoms.remove(index) diff --git a/components/script/dom/eventdispatcher.rs b/components/script/dom/eventdispatcher.rs index 0c6c7e14b18..a99acb7b911 100644 --- a/components/script/dom/eventdispatcher.rs +++ b/components/script/dom/eventdispatcher.rs @@ -45,7 +45,7 @@ pub fn dispatch_event<'a, 'b>(target: &'a EventTarget, let stopped = match cur_target.get_listeners_for(&type_, ListenerPhase::Capturing) { Some(listeners) => { event.set_current_target(cur_target); - for listener in listeners.iter() { + for listener in &listeners { // Explicitly drop any exception on the floor. let _ = listener.HandleEvent_(*cur_target, event, Report); @@ -90,7 +90,7 @@ pub fn dispatch_event<'a, 'b>(target: &'a EventTarget, let stopped = match cur_target.get_listeners_for(&type_, ListenerPhase::Bubbling) { Some(listeners) => { event.set_current_target(cur_target); - for listener in listeners.iter() { + for listener in &listeners { // Explicitly drop any exception on the floor. let _ = listener.HandleEvent_(*cur_target, event, Report); diff --git a/components/script/dom/htmlformelement.rs b/components/script/dom/htmlformelement.rs index 920d5d326b0..ca523bb42cd 100644 --- a/components/script/dom/htmlformelement.rs +++ b/components/script/dom/htmlformelement.rs @@ -350,7 +350,7 @@ impl<'a> HTMLFormElementHelpers for &'a HTMLFormElement { // TODO: Handle `dirnames` (needs directionality support) // https://html.spec.whatwg.org/multipage/#the-directionality let mut ret: Vec<FormDatum> = data_set.collect(); - for datum in ret.iter_mut() { + for datum in &mut ret { match &*datum.ty { "file" | "textarea" => (), _ => { diff --git a/components/script/dom/htmliframeelement.rs b/components/script/dom/htmliframeelement.rs index 220e55c8b07..978489f3f3b 100644 --- a/components/script/dom/htmliframeelement.rs +++ b/components/script/dom/htmliframeelement.rs @@ -380,7 +380,7 @@ impl<'a> VirtualMethods for &'a HTMLIFrameElement { &atom!("sandbox") => { let mut modes = SandboxAllowance::AllowNothing as u8; if let Some(ref tokens) = attr.value().tokens() { - for token in tokens.iter() { + for token in *tokens { modes |= match &*token.to_ascii_lowercase() { "allow-same-origin" => SandboxAllowance::AllowSameOrigin, "allow-forms" => SandboxAllowance::AllowForms, @@ -459,4 +459,3 @@ impl<'a> VirtualMethods for &'a HTMLIFrameElement { } } } - diff --git a/components/script/dom/xmlhttprequest.rs b/components/script/dom/xmlhttprequest.rs index 739d5de6fba..6e6e5ce3081 100644 --- a/components/script/dom/xmlhttprequest.rs +++ b/components/script/dom/xmlhttprequest.rs @@ -1038,7 +1038,7 @@ impl<'a> PrivateXMLHttpRequestHelpers for &'a XMLHttpRequest { let mut encoding = UTF_8 as EncodingRef; match self.response_headers.borrow().get() { Some(&ContentType(mime::Mime(_, _, ref params))) => { - for &(ref name, ref value) in params.iter() { + for &(ref name, ref value) in params { if name == &mime::Attr::Charset { encoding = encoding_from_whatwg_label(&value.to_string()).unwrap_or(encoding); } diff --git a/components/script/timers.rs b/components/script/timers.rs index ac7142914ad..6455e50bd7e 100644 --- a/components/script/timers.rs +++ b/components/script/timers.rs @@ -266,4 +266,3 @@ impl TimerManager { } } } - diff --git a/components/style/animation.rs b/components/style/animation.rs index f8fb9f92bf7..469c7c39ee9 100644 --- a/components/style/animation.rs +++ b/components/style/animation.rs @@ -715,7 +715,7 @@ fn can_interpolate_list(from_list: &Vec<TransformOperation>, } // Each transform operation must match primitive type in other list - for (from, to) in from_list.iter().zip(to_list.iter()) { + for (from, to) in from_list.iter().zip(to_list) { match (from, to) { (&TransformOperation::Matrix(..), &TransformOperation::Matrix(..)) | (&TransformOperation::Skew(..), &TransformOperation::Skew(..)) | @@ -740,7 +740,7 @@ fn interpolate_transform_list(from_list: &Vec<TransformOperation>, let mut result = vec!(); if can_interpolate_list(from_list, to_list) { - for (from, to) in from_list.iter().zip(to_list.iter()) { + for (from, to) in from_list.iter().zip(to_list) { match (from, to) { (&TransformOperation::Matrix(from), &TransformOperation::Matrix(_to)) => { @@ -870,4 +870,3 @@ impl<T> GetMod for Vec<T> { &(*self)[i % self.len()] } } - diff --git a/components/style/properties.mako.rs b/components/style/properties.mako.rs index 56dd9a47e0b..953caa675b5 100644 --- a/components/style/properties.mako.rs +++ b/components/style/properties.mako.rs @@ -1112,7 +1112,7 @@ pub mod longhands { impl ToCss for SpecifiedValue { fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { let mut first = true; - for pair in self.0.iter() { + for pair in &self.0 { if !first { try!(dest.write_str(" ")); } @@ -1186,7 +1186,7 @@ pub mod longhands { impl ToCss for SpecifiedValue { fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { let mut first = true; - for pair in self.0.iter() { + for pair in &self.0 { if !first { try!(dest.write_str(" ")); } @@ -3313,7 +3313,7 @@ pub mod longhands { pub fn opacity(&self) -> CSSFloat { let mut opacity = 1.0; - for filter in self.filters.iter() { + for filter in &self.filters { if let Filter::Opacity(ref opacity_value) = *filter { opacity *= *opacity_value } @@ -3635,7 +3635,7 @@ pub mod longhands { impl ToCss for SpecifiedValue { fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { let mut first = true; - for operation in self.0.iter() { + for operation in &self.0 { if !first { try!(dest.write_str(" ")); } @@ -3889,7 +3889,7 @@ pub mod longhands { } let mut result = vec!(); - for operation in self.0.iter() { + for operation in &self.0 { match *operation { SpecifiedOperation::Matrix(ref matrix) => { result.push(computed_value::ComputedOperation::Matrix(*matrix)); @@ -6219,7 +6219,7 @@ pub fn cascade(viewport_size: Size2D<Au>, // Initialize `context` // Declarations blocks are already stored in increasing precedence order. - for sub_list in applicable_declarations.iter() { + for sub_list in applicable_declarations { // Declarations are stored in reverse source order, we want them in forward order here. for declaration in sub_list.declarations.iter().rev() { match *declaration { diff --git a/components/style/selector_matching.rs b/components/style/selector_matching.rs index 6d4c22e399b..6aa016e67d1 100644 --- a/components/style/selector_matching.rs +++ b/components/style/selector_matching.rs @@ -60,7 +60,7 @@ impl Stylist { // FIXME: Add iso-8859-9.css when the document’s encoding is ISO-8859-8. // FIXME: presentational-hints.css should be at author origin with zero specificity. // (Does it make a difference?) - for &filename in ["user-agent.css", "servo.css", "presentational-hints.css"].iter() { + for &filename in &["user-agent.css", "servo.css", "presentational-hints.css"] { match read_resource_file(&[filename]) { Ok(res) => { let ua_stylesheet = Stylesheet::from_bytes( @@ -104,7 +104,7 @@ impl Stylist { self.after_map = PerPseudoElementSelectorMap::new(); self.rules_source_order = 0; - for stylesheet in self.stylesheets.iter() { + for stylesheet in &self.stylesheets { let (mut element_map, mut before_map, mut after_map) = match stylesheet.origin { Origin::UserAgent => ( &mut self.element_map.user_agent, @@ -129,7 +129,7 @@ impl Stylist { macro_rules! append( ($style_rule: ident, $priority: ident) => { if $style_rule.declarations.$priority.len() > 0 { - for selector in $style_rule.selectors.iter() { + for selector in &$style_rule.selectors { let map = match selector.pseudo_element { None => &mut element_map, Some(PseudoElement::Before) => &mut before_map, diff --git a/components/style/values.rs b/components/style/values.rs index da542f812fe..134008c175b 100644 --- a/components/style/values.rs +++ b/components/style/values.rs @@ -671,7 +671,7 @@ pub mod specified { fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { try!(dest.write_str("linear-gradient(")); try!(self.angle_or_corner.to_css(dest)); - for stop in self.stops.iter() { + for stop in &self.stops { try!(dest.write_str(", ")); try!(stop.to_css(dest)); } @@ -1160,7 +1160,7 @@ pub mod computed { fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { try!(dest.write_str("linear-gradient(")); try!(self.angle_or_corner.to_css(dest)); - for stop in self.stops.iter() { + for stop in &self.stops { try!(dest.write_str(", ")); try!(stop.to_css(dest)); } @@ -1172,7 +1172,7 @@ pub mod computed { impl fmt::Debug for LinearGradient { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let _ = write!(f, "{:?}", self.angle_or_corner); - for stop in self.stops.iter() { + for stop in &self.stops { let _ = write!(f, ", {:?}", stop); } Ok(()) diff --git a/components/style/viewport.rs b/components/style/viewport.rs index 6236c3cd048..53de7d718ea 100644 --- a/components/style/viewport.rs +++ b/components/style/viewport.rs @@ -363,7 +363,7 @@ impl ViewportConstraints { let mut orientation = Orientation::Auto; // collapse the list of declarations into descriptor values - for declaration in rule.declarations.iter() { + for declaration in &rule.declarations { match declaration.descriptor { ViewportDescriptor::MinWidth(value) => min_width = Some(value), ViewportDescriptor::MaxWidth(value) => max_width = Some(value), diff --git a/components/util/cache.rs b/components/util/cache.rs index a0babae263b..074f4514f35 100644 --- a/components/util/cache.rs +++ b/components/util/cache.rs @@ -162,7 +162,7 @@ impl<K:Clone+Eq+Hash,V:Clone> SimpleHashCache<K,V> { } pub fn evict_all(&mut self) { - for slot in self.entries.iter_mut() { + for slot in &mut self.entries { *slot = None } } diff --git a/components/util/workqueue.rs b/components/util/workqueue.rs index a4c80359a9b..2727f036c7e 100644 --- a/components/util/workqueue.rs +++ b/components/util/workqueue.rs @@ -305,7 +305,7 @@ impl<QueueData: Sync, WorkData: Send> WorkQueue<QueueData, WorkData> { pub fn run(&mut self, data: &QueueData) { // Tell the workers to start. let mut work_count = AtomicUsize::new(self.work_count); - for worker in self.workers.iter_mut() { + for worker in &mut self.workers { worker.chan.send(WorkerMsg::Start(worker.deque.take().unwrap(), &mut work_count, data)).unwrap() @@ -316,7 +316,7 @@ impl<QueueData: Sync, WorkData: Send> WorkQueue<QueueData, WorkData> { self.work_count = 0; // Tell everyone to stop. - for worker in self.workers.iter() { + for worker in &self.workers { worker.chan.send(WorkerMsg::Stop).unwrap() } @@ -333,7 +333,7 @@ impl<QueueData: Sync, WorkData: Send> WorkQueue<QueueData, WorkData> { /// Synchronously measure memory usage of any thread-local storage. pub fn heap_size_of_tls(&self, f: fn() -> usize) -> Vec<usize> { // Tell the workers to measure themselves. - for worker in self.workers.iter() { + for worker in &self.workers { worker.chan.send(WorkerMsg::HeapSizeOfTLS(f)).unwrap() } @@ -351,7 +351,7 @@ impl<QueueData: Sync, WorkData: Send> WorkQueue<QueueData, WorkData> { } pub fn shutdown(&mut self) { - for worker in self.workers.iter() { + for worker in &self.workers { worker.chan.send(WorkerMsg::Exit).unwrap() } } |