diff --git a/components/gfx/display_list/mod.rs b/components/gfx/display_list/mod.rs index 1a12ec4a37c..c14f91308d1 100644 --- a/components/gfx/display_list/mod.rs +++ b/components/gfx/display_list/mod.rs @@ -1130,7 +1130,7 @@ impl DisplayItem { pub fn debug_with_level(&self, level: u32) { let mut indent = String::new(); - for _ in range(0, level) { + for _ in 0..level { indent.push_str("| ") } println!("{}+ {:?}", indent, self); diff --git a/components/layout/animation.rs b/components/layout/animation.rs index 258ac7d0a39..9cd46d4bcde 100644 --- a/components/layout/animation.rs +++ b/components/layout/animation.rs @@ -23,7 +23,7 @@ pub fn start_transitions_if_applicable(new_animations_sender: &Sender node: OpaqueNode, old_style: &ComputedValues, new_style: &mut ComputedValues) { - for i in range(0, new_style.get_animation().transition_property.0.len()) { + for i in 0..new_style.get_animation().transition_property.0.len() { // Create any property animations, if applicable. let property_animations = PropertyAnimation::from_transition(i, old_style, new_style); for property_animation in property_animations.into_iter() { diff --git a/components/layout/flow.rs b/components/layout/flow.rs index 0d31b839d7e..cb0b73b68e7 100644 --- a/components/layout/flow.rs +++ b/components/layout/flow.rs @@ -1199,7 +1199,7 @@ impl<'a> ImmutableFlowUtils for &'a (Flow + 'a) { /// Dumps the flow tree for debugging, with a prefix to indicate that we're at the given level. fn dump_with_level(self, level: u32) { let mut indent = String::new(); - for _ in range(0, level) { + for _ in 0..level { indent.push_str("| ") } diff --git a/components/layout/generated_content.rs b/components/layout/generated_content.rs index aa47ad479e0..1468213fca6 100644 --- a/components/layout/generated_content.rs +++ b/components/layout/generated_content.rs @@ -530,7 +530,7 @@ fn push_alphabetic_representation(mut value: i32, system: &[char], accumulator: value = ((value as usize) / system.len()) as i32; } - for i in range(0, string.len()).rev() { + for i in (0..string.len()).rev() { accumulator.push(*string.get(i)) } } diff --git a/components/layout/inline.rs b/components/layout/inline.rs index cf42b29577d..92c319a0c09 100644 --- a/components/layout/inline.rs +++ b/components/layout/inline.rs @@ -919,7 +919,7 @@ impl InlineFlow { } } - for fragment_index in range(line.range.begin(), line.range.end()) { + for fragment_index in line.range.begin()..line.range.end() { let fragment = fragments.get_mut(fragment_index.to_usize()); let size = fragment.border_box.size; fragment.border_box = LogicalRect::new(fragment.style.writing_mode, @@ -1008,7 +1008,7 @@ impl InlineFlow { line_distance_from_flow_block_start: Au, baseline_distance_from_block_start: Au, largest_depth_below_baseline: Au) { - for fragment_index in range(line.range.begin(), line.range.end()) { + for fragment_index in line.range.begin()..line.range.end() { // If any of the inline styles say `top` or `bottom`, adjust the vertical align // appropriately. // @@ -1224,7 +1224,7 @@ impl Flow for InlineFlow { // Now, go through each line and lay out the fragments inside. let mut line_distance_from_flow_block_start = Au(0); let line_count = self.lines.len(); - for line_index in range(0, line_count) { + for line_index in 0..line_count { let line = &mut self.lines[line_index]; // Lay out fragments in the inline direction, and justify them if necessary. @@ -1248,7 +1248,7 @@ impl Flow for InlineFlow { let (mut largest_block_size_for_top_fragments, mut largest_block_size_for_bottom_fragments) = (Au(0), Au(0)); - for fragment_index in range(line.range.begin(), line.range.end()) { + for fragment_index in line.range.begin()..line.range.end() { let fragment = &mut self.fragments.fragments[fragment_index.to_usize()]; let InlineMetrics { diff --git a/components/layout/table.rs b/components/layout/table.rs index ce337b08a67..ecf36891c50 100644 --- a/components/layout/table.rs +++ b/components/layout/table.rs @@ -98,7 +98,7 @@ impl TableFlow { let mut total_inline_sizes = IntrinsicISizes::new(); let mut column_index = 0; for child_cell_inline_size in child_cell_inline_sizes.iter() { - for _ in range(0, child_cell_inline_size.column_span) { + 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 // according to the rules specified in INTRINSIC ยง 4. diff --git a/components/layout/table_colgroup.rs b/components/layout/table_colgroup.rs index d112be8ce0b..48d303008ed 100644 --- a/components/layout/table_colgroup.rs +++ b/components/layout/table_colgroup.rs @@ -73,7 +73,7 @@ impl Flow for TableColGroupFlow { SpecificFragmentInfo::TableColumn(col_fragment) => max(col_fragment.span, 1), _ => panic!("non-table-column fragment inside table column?!"), }; - for _ in range(0, span) { + for _ in 0..span { self.inline_sizes.push(inline_size) } } diff --git a/components/layout/table_row.rs b/components/layout/table_row.rs index 5d05a5fd5b5..5a8b192d2a4 100644 --- a/components/layout/table_row.rs +++ b/components/layout/table_row.rs @@ -266,7 +266,7 @@ impl Flow for TableRowFlow { }; // Add in computed inline sizes for any extra columns in the span. - for _ in range(1, cell_intrinsic_inline_size.column_span) { + for _ in 1..cell_intrinsic_inline_size.column_span { let extra_column_computed_inline_size = match column_computed_inline_size_iterator.next() { Some(column_computed_inline_size) => column_computed_inline_size, diff --git a/components/layout/wrapper.rs b/components/layout/wrapper.rs index d1e92547bb9..816c0fabd5a 100644 --- a/components/layout/wrapper.rs +++ b/components/layout/wrapper.rs @@ -250,7 +250,7 @@ impl<'ln> LayoutNode<'ln> { fn dump_indent(self, indent: u32) { let mut s = String::new(); - for _ in range(0, indent) { + for _ in 0..indent { s.push_str(" "); } diff --git a/components/profile/mem.rs b/components/profile/mem.rs index 38e4eb7088d..3eb8d3bb72d 100644 --- a/components/profile/mem.rs +++ b/components/profile/mem.rs @@ -285,7 +285,7 @@ impl ReportsTree { } let mut indent_str = String::new(); - for _ in range(0, depth) { + for _ in 0..depth { indent_str.push_str(" "); } diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index 960a84b1717..aab81fa2ca3 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -1049,7 +1049,7 @@ class CGArgumentConverter(CGThing): variadicConversion = string.Template( "let mut vector: ${seqType} = Vec::with_capacity((${argc} - ${index}) as usize);\n" - "for variadicArg in range(${index}, ${argc}) {\n" + "for variadicArg in ${index}..${argc} {\n" "${inner}\n" " vector.push(slot);\n" "}\n" @@ -5157,7 +5157,7 @@ class CallbackMember(CGNativeMember): successCode="") if arg.variadic: conversion = string.Template( - "for idx in range(0, ${arg}.len()) {\n" + + "for idx in 0..${arg}.len() {\n" + CGIndenter(CGGeneric(conversion)).define() + "\n" "}" ).substitute({ "arg": arg.identifier.name }) diff --git a/components/script/dom/bindings/utils.rs b/components/script/dom/bindings/utils.rs index 765b28724f2..346013f6221 100644 --- a/components/script/dom/bindings/utils.rs +++ b/components/script/dom/bindings/utils.rs @@ -473,7 +473,7 @@ pub fn find_enum_string_index(cx: *mut JSContext, Ok(values.iter().position(|value| { value.len() == length as usize && - range(0, length as usize).all(|j| { + (0..length as usize).all(|j| { value.as_bytes()[j] as u16 == *chars.offset(j as isize) }) })) diff --git a/components/util/bezier.rs b/components/util/bezier.rs index 7928a1cab4e..768293b3421 100644 --- a/components/util/bezier.rs +++ b/components/util/bezier.rs @@ -59,7 +59,7 @@ impl Bezier { fn solve_curve_x(&self, x: f64, epsilon: f64) -> f64 { // Fast path: Use Newton's method. let mut t = x; - for _ in range(0, NEWTON_METHOD_ITERATIONS) { + for _ in 0..NEWTON_METHOD_ITERATIONS { let x2 = self.sample_curve_x(t); if x2.approx_eq(x, epsilon) { return t diff --git a/components/util/deque/mod.rs b/components/util/deque/mod.rs index 8ab6726e7dd..1eb3f744c95 100644 --- a/components/util/deque/mod.rs +++ b/components/util/deque/mod.rs @@ -339,7 +339,7 @@ impl Drop for Deque { let a = self.array.load(SeqCst); // Free whatever is leftover in the dequeue, and then move the buffer // back into the pool. - for i in range(t, b) { + for i in t..b { let _: T = unsafe { (*a).get(i) }; } self.pool.free(unsafe { transmute(a) }); @@ -392,7 +392,7 @@ impl Buffer { // casting delta to usize and then adding gives the desired // effect. let buf = Buffer::new(self.log_size.wrapping_add(delta as usize)); - for i in range(t, b) { + for i in t..b { buf.put(i, self.get(i)); } return buf; diff --git a/components/util/range.rs b/components/util/range.rs index 8873641cc10..e22fd478320 100644 --- a/components/util/range.rs +++ b/components/util/range.rs @@ -3,11 +3,10 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use std::cmp::{max, min}; -use std::iter; use std::fmt; -use std::num; -use std::num::Int; use std::marker::PhantomData; +use std::num::{self, Int}; +use std::ops; /// An index type to be used by a `Range` pub trait RangeIndex: Int + fmt::Debug { @@ -239,12 +238,12 @@ impl fmt::Debug for Range { /// An iterator over each index in a range pub struct EachIndex { - it: iter::Range, + it: ops::Range, phantom: PhantomData, } pub fn each_index>(start: I, stop: I) -> EachIndex { - EachIndex { it: iter::range(start.get(), stop.get()), phantom: PhantomData } + EachIndex { it: start.get()..stop.get(), phantom: PhantomData } } impl> Iterator for EachIndex { diff --git a/ports/gonk/src/input.rs b/ports/gonk/src/input.rs index c10a6038ef5..1ca7fd763f3 100644 --- a/ports/gonk/src/input.rs +++ b/ports/gonk/src/input.rs @@ -154,7 +154,7 @@ fn read_input_device(device_path: &Path, let count = read / size_of::(); let events: *mut linux_input_event = unsafe { transmute(buf.as_mut_ptr()) }; let mut tracking_updated = false; - for idx in range(0, count as int) { + for idx in 0..(count as int) { let event: &linux_input_event = unsafe { transmute(events.offset(idx)) }; match (event.evt_type, event.code) { (EV_SYN, EV_REPORT) => { diff --git a/ports/gonk/src/window.rs b/ports/gonk/src/window.rs index da54a1eff57..fe8d43825b6 100644 --- a/ports/gonk/src/window.rs +++ b/ports/gonk/src/window.rs @@ -341,7 +341,7 @@ extern fn query(base: *const ANativeWindow, extern fn dequeueBuffer(base: *mut ANativeWindow, buf: *mut *mut ANativeWindowBuffer, fence: *mut c_int) -> c_int { unsafe { let window: &mut GonkNativeWindow = transmute(base); - for idx in range(0, window.bufs.len()) { + for idx in 0..window.bufs.len() { if idx == window.last_idx as uint { continue; } @@ -363,7 +363,7 @@ extern fn dequeueBuffer(base: *mut ANativeWindow, buf: *mut *mut ANativeWindowBu extern fn queueBuffer(base: *mut ANativeWindow, buf: *mut ANativeWindowBuffer, fence: c_int) -> c_int { unsafe { let window: &mut GonkNativeWindow = transmute(base); - for idx in range(0, window.bufs.len()) { + for idx in 0..window.bufs.len() { match window.bufs[idx] { Some(_) => (), None => { @@ -381,7 +381,7 @@ extern fn queueBuffer(base: *mut ANativeWindow, buf: *mut ANativeWindowBuffer, f extern fn cancelBuffer(base: *mut ANativeWindow, buf: *mut ANativeWindowBuffer, fence: c_int) -> c_int { unsafe { let window: &mut GonkNativeWindow = transmute(base); - for idx in range(0, window.bufs.len()) { + for idx in 0..window.bufs.len() { match window.bufs[idx] { Some(_) => (), None => {