From c7270a907756b1db1b44a6789ef5dcb009e9db71 Mon Sep 17 00:00:00 2001 From: Colin Sherratt Date: Wed, 7 Jan 2015 15:34:42 -0700 Subject: [PATCH] Update to latest rustc --- benches/common/macros.rs | 22 ++++++++++------------ benches/construction.rs | 4 ++-- benches/mat.rs | 6 +++--- benches/quat.rs | 6 +++--- benches/vec.rs | 6 +++--- src/array.rs | 6 ++++-- src/cgmath.rs | 5 ----- src/matrix.rs | 8 ++++---- src/num.rs | 4 ++-- src/point.rs | 4 ++-- src/quaternion.rs | 2 +- src/vector.rs | 2 +- tests/aabb.rs | 2 +- tests/angle.rs | 2 +- tests/approx.rs | 4 ++-- tests/line.rs | 2 +- tests/matrix.rs | 2 +- tests/plane.rs | 2 +- tests/point.rs | 2 +- tests/quaternion.rs | 2 +- tests/sphere.rs | 4 ++-- tests/transform.rs | 2 +- tests/vector.rs | 8 ++------ 23 files changed, 49 insertions(+), 58 deletions(-) diff --git a/benches/common/macros.rs b/benches/common/macros.rs index 8512d94..2ab9d0a 100644 --- a/benches/common/macros.rs +++ b/benches/common/macros.rs @@ -13,8 +13,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -#![macro_escape] - macro_rules! bench_binop( ($name: ident, $t1: ty, $t2: ty, $binop: ident) => { #[bench] @@ -23,15 +21,15 @@ macro_rules! bench_binop( let mut rng = IsaacRng::new_unseeded(); - let elems1 = Vec::from_fn(LEN, |_| rng.gen::<$t1>()); - let elems2 = Vec::from_fn(LEN, |_| rng.gen::<$t2>()); + let elems1: Vec<$t1> = range(0, LEN).map(|_| rng.gen::<$t1>()).collect(); + let elems2: Vec<$t2> = range(0, LEN).map(|_| rng.gen::<$t2>()).collect(); let mut i = 0; bh.iter(|| { i = (i + 1) & (LEN - 1); unsafe { - test::black_box(elems1.unsafe_get(i).$binop(elems2.unsafe_get(i))) + test::black_box(elems1.get_unchecked(i).$binop(elems2.get_unchecked(i))) } }) } @@ -46,15 +44,15 @@ macro_rules! bench_binop_deref( let mut rng = IsaacRng::new_unseeded(); - let elems1 = Vec::from_fn(LEN, |_| rng.gen::<$t1>()); - let elems2 = Vec::from_fn(LEN, |_| rng.gen::<$t2>()); + let elems1: Vec<$t1> = range(0, LEN).map(|_| rng.gen::<$t1>()).collect(); + let elems2: Vec<$t2> = range(0, LEN).map(|_| rng.gen::<$t2>()).collect(); let mut i = 0; bh.iter(|| { i = (i + 1) & (LEN - 1); unsafe { - test::black_box(elems1.unsafe_get(i).$binop(*elems2.unsafe_get(i))) + test::black_box(elems1.get_unchecked(i).$binop(*elems2.get_unchecked(i))) } }) } @@ -69,14 +67,14 @@ macro_rules! bench_unop( let mut rng = IsaacRng::new_unseeded(); - let mut elems = Vec::from_fn(LEN, |_| rng.gen::<$t>()); + let mut elems: Vec<$t> = range(0, LEN).map(|_| rng.gen::<$t>()).collect(); let mut i = 0; bh.iter(|| { i = (i + 1) & (LEN - 1); unsafe { - test::black_box(elems.unchecked_mut(i).$unop()) + test::black_box(elems.get_unchecked_mut(i).$unop()) } }) } @@ -91,14 +89,14 @@ macro_rules! bench_construction( let mut rng = IsaacRng::new_unseeded(); - $(let $args = Vec::from_fn(LEN, |_| rng.gen::<$types>());)* + $(let $args: Vec<$types> = range(0, LEN).map(|_| rng.gen::<$types>()).collect();)* let mut i = 0; bh.iter(|| { i = (i + 1) & (LEN - 1); unsafe { - let res: $t = $constructor($(*$args.unsafe_get(i),)*); + let res: $t = $constructor($(*$args.get_unchecked(i),)*); test::black_box(res) } }) diff --git a/benches/construction.rs b/benches/construction.rs index 5cb4ff0..c02554e 100644 --- a/benches/construction.rs +++ b/benches/construction.rs @@ -13,7 +13,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#![feature(macro_rules)] + extern crate test; extern crate cgmath; @@ -24,7 +24,7 @@ use test::Bencher; use cgmath::{Quaternion, Basis2, Basis3, Vector3, Rotation2, Rotation3, Rad}; #[path="common/macros.rs"] -mod macros; +#[macro_use] mod macros; fn bench_from_axis_angle>(bh: &mut Bencher) { const LEN: uint = 1 << 13; diff --git a/benches/mat.rs b/benches/mat.rs index e33b8e3..474191c 100644 --- a/benches/mat.rs +++ b/benches/mat.rs @@ -13,8 +13,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#![feature(macro_rules)] -#![feature(globs)] + + extern crate test; extern crate cgmath; @@ -24,7 +24,7 @@ use test::Bencher; use cgmath::*; #[path="common/macros.rs"] -mod macros; +#[macro_use] mod macros; bench_binop!(_bench_matrix2_mul_m, Matrix2, Matrix2, mul_m); bench_binop!(_bench_matrix3_mul_m, Matrix3, Matrix3, mul_m); diff --git a/benches/quat.rs b/benches/quat.rs index 77a9c05..1b00a1a 100644 --- a/benches/quat.rs +++ b/benches/quat.rs @@ -13,8 +13,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#![feature(globs)] -#![feature(macro_rules)] + + extern crate test; extern crate cgmath; @@ -24,7 +24,7 @@ use test::Bencher; use cgmath::*; #[path="common/macros.rs"] -mod macros; +#[macro_use] mod macros; bench_binop!(_bench_quat_add_q, Quaternion, Quaternion, add_q); bench_binop!(_bench_quat_sub_q, Quaternion, Quaternion, sub_q); diff --git a/benches/vec.rs b/benches/vec.rs index f6e8b19..084a841 100644 --- a/benches/vec.rs +++ b/benches/vec.rs @@ -13,8 +13,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#![feature(globs)] -#![feature(macro_rules)] + + extern crate test; extern crate cgmath; @@ -24,7 +24,7 @@ use test::Bencher; use cgmath::*; #[path="common/macros.rs"] -mod macros; +#[macro_use] mod macros; bench_binop!(_bench_vector2_add_v, Vector2, Vector2, add_v); bench_binop!(_bench_vector3_add_v, Vector3, Vector3, add_v); diff --git a/src/array.rs b/src/array.rs index 2fefbaf..f76e107 100644 --- a/src/array.rs +++ b/src/array.rs @@ -43,7 +43,8 @@ pub trait Array1: Index + IndexMut Element) -> Self; + fn map(&mut self, op: F) -> Self + where F: FnMut(Element) -> Element; } /// A column-major array @@ -86,7 +87,8 @@ pub trait Array2+'static, Row: Array1, Element: } /// Apply a function to each column. - fn map(&mut self, op: |&Column| -> Column) -> Self; + fn map(&mut self, op: F) -> Self + where F: FnMut(&Column) -> Column; } /// Homogeneous arrays of elements that can be converted to and from `[T, ..N]` diff --git a/src/cgmath.rs b/src/cgmath.rs index 5b5f816..cddc016 100644 --- a/src/cgmath.rs +++ b/src/cgmath.rs @@ -16,11 +16,6 @@ #![crate_type = "rlib"] #![crate_type = "dylib"] -#![feature(globs)] -#![feature(macro_rules)] -#![feature(old_orphan_check)] -#![feature(associated_types)] - //! Computer graphics-centric math. //! //! This crate provides useful mathematical primitives and operations on them. diff --git a/src/matrix.rs b/src/matrix.rs index 10785dd..3cdfa6f 100644 --- a/src/matrix.rs +++ b/src/matrix.rs @@ -563,7 +563,7 @@ impl Array2, Vector2, S> for Matrix2 { } #[inline] - fn map(&mut self, op: |&Vector2| -> Vector2) -> Matrix2 { + fn map(&mut self, mut op: F) -> Matrix2 where F: FnMut(&Vector2) -> Vector2 { self.x = op(&self.x); self.y = op(&self.y); *self @@ -649,7 +649,7 @@ impl Array2, Vector3, S> for Matrix3 { } #[inline] - fn map(&mut self, op: |&Vector3| -> Vector3) -> Matrix3 { + fn map(&mut self, mut op: F) -> Matrix3 where F: FnMut(&Vector3) -> Vector3 { self.x = op(&self.x); self.y = op(&self.y); self.z = op(&self.z); @@ -740,7 +740,7 @@ impl Array2, Vector4, S> for Matrix4 { } #[inline] - fn map(&mut self, op: |&Vector4| -> Vector4) -> Matrix4 { + fn map(&mut self, mut op: F) -> Matrix4 where F: FnMut(&Vector4) -> Vector4 { self.x = op(&self.x); self.y = op(&self.y); self.z = op(&self.z); @@ -1188,7 +1188,7 @@ impl Matrix> for Matrix4 { let one: S = one(); let inv_det = one / det; let t = self.transpose(); - let cf = |i, j| { + let cf = |&: i, j| { let mat = match i { 0 => Matrix3::from_cols(t.y.truncate_n(j), t.z.truncate_n(j), diff --git a/src/num.rs b/src/num.rs index 000f955..41cd46a 100644 --- a/src/num.rs +++ b/src/num.rs @@ -17,7 +17,7 @@ use approx::ApproxEq; use std::cmp; use std::fmt; -use std::num::{FloatMath, Int, NumCast, Float}; +use std::num::{Float, Int, NumCast}; use std::ops::*; /// A trait providing a [partial ordering](http://mathworld.wolfram.com/PartialOrder.html). @@ -158,7 +158,7 @@ impl BaseInt for u64 {} impl BaseInt for uint {} /// Base floating point types -pub trait BaseFloat : BaseNum + FloatMath + ApproxEq {} +pub trait BaseFloat : BaseNum + Float + ApproxEq {} impl BaseFloat for f32 {} impl BaseFloat for f64 {} diff --git a/src/point.rs b/src/point.rs index 0ad094f..b5c5f3f 100644 --- a/src/point.rs +++ b/src/point.rs @@ -153,7 +153,7 @@ impl IndexMut for Point2 { impl Array1 for Point2 { #[inline] - fn map(&mut self, op: |S| -> S) -> Point2 { + fn map(&mut self, mut op: F) -> Point2 where F: FnMut(S) -> S { self.x = op(self.x); self.y = op(self.y); *self @@ -311,7 +311,7 @@ impl IndexMut for Point3 { impl Array1 for Point3 { #[inline] - fn map(&mut self, op: |S| -> S) -> Point3 { + fn map(&mut self, mut op: F) -> Point3 where F: FnMut(S) -> S { self.x = op(self.x); self.y = op(self.y); self.z = op(self.z); diff --git a/src/quaternion.rs b/src/quaternion.rs index abd7ed4..0a762a2 100644 --- a/src/quaternion.rs +++ b/src/quaternion.rs @@ -41,7 +41,7 @@ pub trait ToQuaternion { impl Array1 for Quaternion { #[inline] - fn map(&mut self, op: |S| -> S) -> Quaternion { + fn map(&mut self, mut op: F) -> Quaternion where F: FnMut(S) -> S { self.s = op(self.s); self.v.x = op(self.v.x); self.v.y = op(self.v.y); diff --git a/src/vector.rs b/src/vector.rs index eab3cf3..c3ae121 100644 --- a/src/vector.rs +++ b/src/vector.rs @@ -271,7 +271,7 @@ macro_rules! vec( impl<$S: Copy> Array1<$S> for $Self<$S> { #[inline] - fn map(&mut self, op: |$S| -> $S) -> $Self<$S> { + fn map(&mut self, mut op: F) -> $Self<$S> where F: FnMut($S) -> $S { $(self.$field = op(self.$field);)+ *self } } diff --git a/tests/aabb.rs b/tests/aabb.rs index 228d111..f2386cf 100644 --- a/tests/aabb.rs +++ b/tests/aabb.rs @@ -13,7 +13,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#![feature(globs)] + extern crate cgmath; diff --git a/tests/angle.rs b/tests/angle.rs index c0ace6e..b07e9bf 100644 --- a/tests/angle.rs +++ b/tests/angle.rs @@ -13,7 +13,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#![feature(globs)] + extern crate cgmath; diff --git a/tests/approx.rs b/tests/approx.rs index 38157f1..72619b0 100644 --- a/tests/approx.rs +++ b/tests/approx.rs @@ -13,10 +13,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -#![feature(globs)] + #![feature(phase)] -#[phase(plugin, link)] +#[macro_use] extern crate cgmath; use cgmath::*; diff --git a/tests/line.rs b/tests/line.rs index ff22dbb..8f9611d 100644 --- a/tests/line.rs +++ b/tests/line.rs @@ -13,7 +13,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#![feature(globs)] + extern crate cgmath; diff --git a/tests/matrix.rs b/tests/matrix.rs index 1bab3e5..163de3d 100644 --- a/tests/matrix.rs +++ b/tests/matrix.rs @@ -13,7 +13,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#![feature(globs)] + extern crate cgmath; diff --git a/tests/plane.rs b/tests/plane.rs index 25492ea..11861a2 100644 --- a/tests/plane.rs +++ b/tests/plane.rs @@ -13,7 +13,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#![feature(globs)] + extern crate cgmath; diff --git a/tests/point.rs b/tests/point.rs index b779d67..6247eae 100644 --- a/tests/point.rs +++ b/tests/point.rs @@ -13,7 +13,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#![feature(globs)] + extern crate cgmath; diff --git a/tests/quaternion.rs b/tests/quaternion.rs index ee8c98e..1a1506f 100644 --- a/tests/quaternion.rs +++ b/tests/quaternion.rs @@ -13,7 +13,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#![feature(globs)] + extern crate cgmath; diff --git a/tests/sphere.rs b/tests/sphere.rs index 05aec67..c12e611 100644 --- a/tests/sphere.rs +++ b/tests/sphere.rs @@ -13,12 +13,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -#![feature(globs)] + extern crate cgmath; use cgmath::*; -use std::num::FloatMath; +use std::num::Float; #[test] fn test_intersection() { diff --git a/tests/transform.rs b/tests/transform.rs index c6dabd2..fb0d85c 100644 --- a/tests/transform.rs +++ b/tests/transform.rs @@ -13,7 +13,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#![feature(globs)] + extern crate cgmath; diff --git a/tests/vector.rs b/tests/vector.rs index f7f1669..b7f64a5 100644 --- a/tests/vector.rs +++ b/tests/vector.rs @@ -13,16 +13,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -#![feature(globs)] -#![feature(phase)] - -#[phase(plugin)] -extern crate cgmath; +#[macro_use] extern crate cgmath; use cgmath::*; use std::f64; -use std::num::{Float, FloatMath}; +use std::num::Float; #[test] fn test_from_value() {