Bug 1519639 - Update euclid. r=jrmuizel
authorEmilio Cobos Álvarez <emilio@crisal.io>
Sat, 12 Jan 2019 16:49:16 +0100
changeset 453671 be569ca36f5f
parent 453668 1218e374fbc7
child 453672 d884f9b54dc6
push id35367
push useraciure@mozilla.com
push dateSun, 13 Jan 2019 21:36:46 +0000
treeherdermozilla-central@63b0062fba03 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1519639
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1519639 - Update euclid. r=jrmuizel Differential Revision: https://phabricator.services.mozilla.com/D16390
Cargo.lock
third_party/rust/euclid/.cargo-checksum.json
third_party/rust/euclid/Cargo.toml
third_party/rust/euclid/src/homogen.rs
third_party/rust/euclid/src/lib.rs
third_party/rust/euclid/src/macros.rs
third_party/rust/euclid/src/point.rs
third_party/rust/euclid/src/rect.rs
third_party/rust/euclid/src/rotation.rs
third_party/rust/euclid/src/side_offsets.rs
third_party/rust/euclid/src/size.rs
third_party/rust/euclid/src/transform2d.rs
third_party/rust/euclid/src/transform3d.rs
third_party/rust/euclid/src/translation.rs
third_party/rust/euclid/src/vector.rs
third_party/rust/euclid_macros/.cargo-checksum.json
third_party/rust/euclid_macros/Cargo.toml
third_party/rust/euclid_macros/LICENSE-APACHE
third_party/rust/euclid_macros/LICENSE-MIT
third_party/rust/euclid_macros/euclid_matrix.rs
third_party/rust/euclid_macros/lib.rs
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -872,24 +872,35 @@ dependencies = [
 
 [[package]]
 name = "error-chain"
 version = "0.11.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
 name = "euclid"
-version = "0.19.4"
+version = "0.19.5"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
+ "euclid_macros 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
+name = "euclid_macros"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)",
+ "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)",
+ "syn 0.15.24 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
 name = "failure"
 version = "0.1.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
  "failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
@@ -1459,17 +1470,17 @@ dependencies = [
 ]
 
 [[package]]
 name = "malloc_size_of"
 version = "0.0.1"
 dependencies = [
  "app_units 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "cssparser 0.25.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "euclid 0.19.4 (registry+https://github.com/rust-lang/crates.io-index)",
+ "euclid 0.19.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "hashglobe 0.1.0",
  "selectors 0.21.0",
  "servo_arc 0.1.1",
  "smallbitvec 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "smallvec 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "thin-slice 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
@@ -1921,17 +1932,17 @@ version = "0.2.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
 name = "plane-split"
 version = "0.13.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "binary-space-partition 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "euclid 0.19.4 (registry+https://github.com/rust-lang/crates.io-index)",
+ "euclid 0.19.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "podio"
 version = "0.1.5"
 source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2417,17 +2428,17 @@ version = "0.0.1"
 dependencies = [
  "app_units 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "arrayvec 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "atomic_refcell 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "bindgen 0.43.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
  "cssparser 0.25.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "euclid 0.19.4 (registry+https://github.com/rust-lang/crates.io-index)",
+ "euclid 0.19.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "fallible 0.0.1",
  "fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "hashglobe 0.1.0",
  "indexmap 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "itertools 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "itoa 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "lazy_static 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2475,17 +2486,17 @@ dependencies = [
 
 [[package]]
 name = "style_traits"
 version = "0.0.1"
 dependencies = [
  "app_units 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "cssparser 0.25.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "euclid 0.19.4 (registry+https://github.com/rust-lang/crates.io-index)",
+ "euclid 0.19.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "malloc_size_of 0.0.1",
  "malloc_size_of_derive 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "selectors 0.21.0",
  "servo_arc 0.1.1",
 ]
 
 [[package]]
 name = "stylo_tests"
@@ -3017,17 +3028,17 @@ version = "0.58.0"
 dependencies = [
  "app_units 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "bincode 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
  "core-foundation 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "core-graphics 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "dwrote 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "euclid 0.19.4 (registry+https://github.com/rust-lang/crates.io-index)",
+ "euclid 0.19.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "malloc_size_of_derive 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde_bytes 0.10.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde_derive 1.0.80 (git+https://github.com/servo/serde?branch=deserialize_from_enums9)",
  "time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
  "wr_malloc_size_of 0.0.1",
 ]
 
@@ -3035,17 +3046,17 @@ dependencies = [
 name = "webrender_bindings"
 version = "0.1.0"
 dependencies = [
  "app_units 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "bincode 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "core-foundation 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "core-graphics 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "dwrote 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "euclid 0.19.4 (registry+https://github.com/rust-lang/crates.io-index)",
+ "euclid 0.19.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "foreign-types 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "gleam 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "nsstring 0.1.0",
  "rayon 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "thread_profiler 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "uuid 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3113,17 +3124,17 @@ dependencies = [
  "winapi 0.3.6 (git+https://github.com/froydnj/winapi-rs?branch=aarch64)",
 ]
 
 [[package]]
 name = "wr_malloc_size_of"
 version = "0.0.1"
 dependencies = [
  "app_units 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "euclid 0.19.4 (registry+https://github.com/rust-lang/crates.io-index)",
+ "euclid 0.19.5 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "ws2_32-sys"
 version = "0.2.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3268,17 +3279,18 @@ dependencies = [
 "checksum dtoa-short 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "068d4026697c1a18f0b0bb8cfcad1b0c151b90d8edb9bf4c235ad68128920d1d"
 "checksum dwrote 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2d2ea0fd88d96838ce5ed30326338cc04a0eb4cff10e3e15d188d74112777103"
 "checksum either 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "18785c1ba806c258137c937e44ada9ee7e69a37e3c72077542cd2f069d78562a"
 "checksum ena 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "88dc8393b3c7352f94092497f6b52019643e493b6b890eb417cdb7c46117e621"
 "checksum encoding_c 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "769ecb8b33323998e482b218c0d13cd64c267609023b4b7ec3ee740714c318ee"
 "checksum encoding_rs 0.8.14 (registry+https://github.com/rust-lang/crates.io-index)" = "a69d152eaa438a291636c1971b0a370212165ca8a75759eb66818c5ce9b538f7"
 "checksum env_logger 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0561146661ae44c579e993456bc76d11ce1e0c7d745e57b2fa7146b6e49fa2ad"
 "checksum error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ff511d5dc435d703f4971bc399647c9bc38e20cb41452e3b9feb4765419ed3f3"
-"checksum euclid 0.19.4 (registry+https://github.com/rust-lang/crates.io-index)" = "dbbf962bb6f877239a34491f2e0a12c6b824f389bc789eb90f1d70d4780b0727"
+"checksum euclid 0.19.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d1a7698bdda3d7444a79d33bdc96e8b518d44ea3ff101d8492a6ca1207b886ea"
+"checksum euclid_macros 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fdcb84c18ea5037a1c5a23039b4ff29403abce2e0d6b1daa11cf0bde2b30be15"
 "checksum failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6dd377bcc1b1b7ce911967e3ec24fa19c3224394ec05b54aa7b083d498341ac7"
 "checksum failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "64c2d913fe8ed3b6c6518eedf4538255b989945c14c2a7d5cbff62a5e2120596"
 "checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed"
 "checksum fixedbitset 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "85cb8fec437468d86dc7c83ca7cfc933341d561873275f22dd5eedefa63a6478"
 "checksum flate2 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9fac2277e84e5e858483756647a9d0aa8d9a2b7cba517fd84325a0aaa69a0909"
 "checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3"
 "checksum foreign-types 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5ebc04f19019fff1f2d627b5581574ead502f80c48c88900575a46e0840fe5d0"
 "checksum freetype 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b659e75b7a7338fe75afd7f909fc2b71937845cffb6ebe54ba2e50f13d8e903d"
--- a/third_party/rust/euclid/.cargo-checksum.json
+++ b/third_party/rust/euclid/.cargo-checksum.json
@@ -1,1 +1,1 @@
-{"files":{"COPYRIGHT":"ec82b96487e9e778ee610c7ab245162464782cfa1f555c2299333f8dbe5c036a","Cargo.toml":"67de143fd7f5aa450d230b26c25cabccce0fc3c3512c47ff5d485f0329baeac1","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"62065228e42caebca7e7d7db1204cbb867033de5982ca4009928915e4095f3a3","README.md":"625bec69c76ce5423fdd05cfe46922b2680ec517f97c5854ce34798d1d8a9541","src/approxeq.rs":"6594377e8f6c20f88f628520d8de9b9a59c5892a0ee9a6ccd13c8400c1499911","src/homogen.rs":"cb26346ad1ea2797bdc1cac7f532872becabf28a1f9c60792f86ad4a655582f9","src/length.rs":"3171315822707728b1bfbdd04a4190ffb7206b4bfc59e9dd072bb2caa05ff292","src/lib.rs":"f89c2b86cabae4431a956b88c630c5cbdf51f7329dfeb677ab4fd4ff02e7d53b","src/macros.rs":"d2b7b391f58fe9cedb426780cfa1d2771f9ac786a6237b0f89d3e5788f5ec1b7","src/num.rs":"4439479fad5729073e0bfe0b96b547672a237430d48e564519759b9550baa033","src/point.rs":"2c399e282c2e81528775a1fc6ee1a0f2f6f71ed4a14bbe426115ae78b4cf2149","src/rect.rs":"43aad88856645bb9601e076b9ddc3376ee71f59bb8fdb7839a17f0198121824a","src/rotation.rs":"982aaca640215bacc5d2dc60a8949bb2510d5b6d492975b8b6946a7c8f69b496","src/scale.rs":"fc07bcf47f3a1215023c830059f0d270e570cbd37fe8c367ef4a47b191f4ae3e","src/side_offsets.rs":"f114cb881256bbeff2ee2aa305d363e2dea65aa8535140f104f6fa9364bd02f5","src/size.rs":"1fe99377bee13835ca416adbccdb0d163091a3dcf2977c3222da2d6b22d70621","src/transform2d.rs":"2f9bafe40b9a6dd9c41747aabfdefbfc9ee48daf4f4297d2320ccbdac185a30d","src/transform3d.rs":"90decfc535c4b24199cab9614037f27f0cdefad82580fcd6d132f49dfa88f77d","src/translation.rs":"c835abaf167234b288e95323f9e693099be9fd992fc137cd6e692edbe4456f19","src/trig.rs":"97a263c4f178b0332501659ca8143f9f637a0755aca189dd31ac551bcd4cb73c","src/vector.rs":"b0b41eac9c823e05bf6357e69c71dac977db2d8ab27b25f80f1f44b056d15f6d"},"package":"dbbf962bb6f877239a34491f2e0a12c6b824f389bc789eb90f1d70d4780b0727"}
\ No newline at end of file
+{"files":{"COPYRIGHT":"ec82b96487e9e778ee610c7ab245162464782cfa1f555c2299333f8dbe5c036a","Cargo.toml":"4c50cb6cf03b2ab58cf9c017fdeee3f3d918b6143adeb529910f329bb07e7fd3","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"62065228e42caebca7e7d7db1204cbb867033de5982ca4009928915e4095f3a3","README.md":"625bec69c76ce5423fdd05cfe46922b2680ec517f97c5854ce34798d1d8a9541","src/approxeq.rs":"6594377e8f6c20f88f628520d8de9b9a59c5892a0ee9a6ccd13c8400c1499911","src/homogen.rs":"7b02aa671fffcb554557ad790f598bd5d7440dc1aa4a6d1c5a97d8bc3c8f64d6","src/length.rs":"3171315822707728b1bfbdd04a4190ffb7206b4bfc59e9dd072bb2caa05ff292","src/lib.rs":"e8b1317127ec281fd42318f2c470558c2ecbb2e1459cebd4f9c63a2af807eb3d","src/macros.rs":"3b475e84d00cceee6c7e96e9f2c97ba15d8dc7f4094efb82c5ed10bd60d86a64","src/num.rs":"4439479fad5729073e0bfe0b96b547672a237430d48e564519759b9550baa033","src/point.rs":"689a8348428d12f6c5262965c505395bde37b4b1776369d93e93d73406d5344b","src/rect.rs":"ae16bb9ccb95cf329439d0ea4eb4c3821c4cd769cce4a544904b65d7e4af04b7","src/rotation.rs":"3d765a8e8e8c7181cc10d39be617779a8676d2611b408c69c841c3a10ce78a47","src/scale.rs":"fc07bcf47f3a1215023c830059f0d270e570cbd37fe8c367ef4a47b191f4ae3e","src/side_offsets.rs":"b79d43cca4c2e9fac7482a95661f72cb3ed51008f1d3e0c3f4fe608c68ef3658","src/size.rs":"49088bf3bf0e1ce740c1fe92761c18a43a6287d1d81a945bc92b21af63ef3416","src/transform2d.rs":"641acc1c9de9368bdbe0bb64b5ba4c1069ebeda6d6ad31463c81bdf85d678043","src/transform3d.rs":"c47dda0759629c1a836861fabf65e889001cf2d5ab59258544c1c04167cd7a67","src/translation.rs":"9787de1bccdd402774ba9a5bc55ec6d4b2ee36e0a146baecee417ee9cc753db5","src/trig.rs":"97a263c4f178b0332501659ca8143f9f637a0755aca189dd31ac551bcd4cb73c","src/vector.rs":"d57493649da9d8a728dcba49bb80c579a4d2bf6f3557dd4b4c770cfcef6ee395"},"package":"d1a7698bdda3d7444a79d33bdc96e8b518d44ea3ff101d8492a6ca1207b886ea"}
\ No newline at end of file
--- a/third_party/rust/euclid/Cargo.toml
+++ b/third_party/rust/euclid/Cargo.toml
@@ -7,24 +7,27 @@
 #
 # If you believe there's an error in this file please file an
 # issue against the rust-lang/cargo repository. If you're
 # editing this file be aware that the upstream Cargo.toml
 # will likely look very different (and much more reasonable)
 
 [package]
 name = "euclid"
-version = "0.19.4"
+version = "0.19.5"
 authors = ["The Servo Project Developers"]
 description = "Geometry primitives"
 documentation = "https://docs.rs/euclid/"
 keywords = ["matrix", "vector", "linear-algebra", "geometry"]
 categories = ["science"]
 license = "MIT / Apache-2.0"
 repository = "https://github.com/servo/euclid"
+[dependencies.euclid_macros]
+version = "0.1"
+
 [dependencies.mint]
 version = "0.5.1"
 optional = true
 
 [dependencies.num-traits]
 version = "0.2"
 
 [dependencies.serde]
--- a/third_party/rust/euclid/src/homogen.rs
+++ b/third_party/rust/euclid/src/homogen.rs
@@ -12,24 +12,26 @@ use vector::{TypedVector2D, TypedVector3
 
 use num::{One, Zero};
 
 use core::fmt;
 use core::marker::PhantomData;
 use core::ops::Div;
 
 
-define_matrix! {
-    /// Homogeneous vector in 3D space.
-    pub struct HomogeneousVector<T, U> {
-        pub x: T,
-        pub y: T,
-        pub z: T,
-        pub w: T,
-    }
+/// Homogeneous vector in 3D space.
+#[derive(EuclidMatrix)]
+#[repr(C)]
+pub struct HomogeneousVector<T, U> {
+    pub x: T,
+    pub y: T,
+    pub z: T,
+    pub w: T,
+    #[doc(hidden)]
+    pub _unit: PhantomData<U>,
 }
 
 
 impl<T, U> HomogeneousVector<T, U> {
     /// Constructor taking scalar values directly.
     #[inline]
     pub fn new(x: T, y: T, z: T, w: T) -> Self {
         HomogeneousVector { x, y, z, w, _unit: PhantomData }
--- a/third_party/rust/euclid/src/lib.rs
+++ b/third_party/rust/euclid/src/lib.rs
@@ -57,16 +57,18 @@
 //! ```
 
 #[cfg(feature = "serde")]
 #[macro_use]
 extern crate serde;
 
 #[cfg(feature = "mint")]
 pub extern crate mint;
+#[macro_use]
+extern crate euclid_macros;
 extern crate num_traits;
 #[cfg(test)]
 extern crate rand;
 #[cfg(test)]
 use std as core;
 
 pub use length::Length;
 pub use scale::TypedScale;
--- a/third_party/rust/euclid/src/macros.rs
+++ b/third_party/rust/euclid/src/macros.rs
@@ -2,94 +2,16 @@
 // file at the top-level directory of this distribution.
 //
 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-macro_rules! define_matrix {
-    (
-        $(#[$attr:meta])*
-        pub struct $name:ident<T, $($phantom:ident),+> {
-            $(pub $field:ident: T,)+
-        }
-    ) => (
-        #[repr(C)]
-        $(#[$attr])*
-        pub struct $name<T, $($phantom),+> {
-            $(pub $field: T,)+
-
-            // Keep this (secretly) public for the few cases where we would like to
-            // create static constants which currently can't be initialized with a
-            // function.
-            #[doc(hidden)]
-            pub _unit: PhantomData<($($phantom),+)>
-        }
-
-        impl<T: Clone, $($phantom),+> Clone for $name<T, $($phantom),+> {
-            fn clone(&self) -> Self {
-                $name {
-                    $($field: self.$field.clone(),)+
-                    _unit: PhantomData,
-                }
-            }
-        }
-
-        impl<T: Copy, $($phantom),+> Copy for $name<T, $($phantom),+> {}
-
-        #[cfg(feature = "serde")]
-        impl<'de, T, $($phantom),+> ::serde::Deserialize<'de> for $name<T, $($phantom),+>
-            where T: ::serde::Deserialize<'de>
-        {
-            fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
-                where D: ::serde::Deserializer<'de>
-            {
-                let ($($field,)+) =
-                    try!(::serde::Deserialize::deserialize(deserializer));
-                Ok($name {
-                    $($field: $field,)+
-                    _unit: PhantomData,
-                })
-            }
-        }
-
-        #[cfg(feature = "serde")]
-        impl<T, $($phantom),+> ::serde::Serialize for $name<T, $($phantom),+>
-            where T: ::serde::Serialize
-        {
-            fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
-                where S: ::serde::Serializer
-            {
-                ($(&self.$field,)+).serialize(serializer)
-            }
-        }
-
-        impl<T, $($phantom),+> ::core::cmp::Eq for $name<T, $($phantom),+>
-            where T: ::core::cmp::Eq {}
-
-        impl<T, $($phantom),+> ::core::cmp::PartialEq for $name<T, $($phantom),+>
-            where T: ::core::cmp::PartialEq
-        {
-            fn eq(&self, other: &Self) -> bool {
-                true $(&& self.$field == other.$field)+
-            }
-        }
-
-        impl<T, $($phantom),+> ::core::hash::Hash for $name<T, $($phantom),+>
-            where T: ::core::hash::Hash
-        {
-            fn hash<H: ::core::hash::Hasher>(&self, h: &mut H) {
-                $(self.$field.hash(h);)+
-            }
-        }
-    )
-}
-
 macro_rules! mint_vec {
     ($name:ident [ $($field:ident),* ] = $std_name:ident) => {
         #[cfg(feature = "mint")]
         impl<T, U> From<mint::$std_name<T>> for $name<T, U> {
             fn from(v: mint::$std_name<T>) -> Self {
                 $name {
                     $( $field: v.$field, )*
                     _unit: PhantomData,
--- a/third_party/rust/euclid/src/point.rs
+++ b/third_party/rust/euclid/src/point.rs
@@ -16,23 +16,26 @@ use size::TypedSize2D;
 use mint;
 use num::*;
 use num_traits::{Float, NumCast};
 use vector::{TypedVector2D, TypedVector3D, vec2, vec3};
 use core::fmt;
 use core::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Sub, SubAssign};
 use core::marker::PhantomData;
 
-define_matrix! {
-    /// A 2d Point tagged with a unit.
-    pub struct TypedPoint2D<T, U> {
-        pub x: T,
-        pub y: T,
-    }
+/// A 2d Point tagged with a unit.
+#[derive(EuclidMatrix)]
+#[repr(C)]
+pub struct TypedPoint2D<T, U> {
+    pub x: T,
+    pub y: T,
+    #[doc(hidden)]
+    pub _unit: PhantomData<U>,
 }
+
 mint_vec!(TypedPoint2D[x, y] = Point2);
 
 /// Default 2d point type with no unit.
 ///
 /// `Point2D` provides the same methods as `TypedPoint2D`.
 pub type Point2D<T> = TypedPoint2D<T, UnknownUnit>;
 
 impl<T: Copy + Zero, U> TypedPoint2D<T, U> {
@@ -403,24 +406,27 @@ impl<T: Copy, U> Into<[T; 2]> for TypedP
 }
 
 impl<T: Copy, U> From<[T; 2]> for TypedPoint2D<T, U> {
     fn from(array: [T; 2]) -> Self {
         point2(array[0], array[1])
     }
 }
 
-define_matrix! {
-    /// A 3d Point tagged with a unit.
-    pub struct TypedPoint3D<T, U> {
-        pub x: T,
-        pub y: T,
-        pub z: T,
-    }
+/// A 3d Point tagged with a unit.
+#[derive(EuclidMatrix)]
+#[repr(C)]
+pub struct TypedPoint3D<T, U> {
+    pub x: T,
+    pub y: T,
+    pub z: T,
+    #[doc(hidden)]
+    pub _unit: PhantomData<U>,
 }
+
 mint_vec!(TypedPoint3D[x, y, z] = Point3);
 
 /// Default 3d point type with no unit.
 ///
 /// `Point3D` provides the same methods as `TypedPoint3D`.
 pub type Point3D<T> = TypedPoint3D<T, UnknownUnit>;
 
 impl<T: Copy + Zero, U> TypedPoint3D<T, U> {
--- a/third_party/rust/euclid/src/rect.rs
+++ b/third_party/rust/euclid/src/rect.rs
@@ -19,17 +19,17 @@ use size::TypedSize2D;
 use num_traits::NumCast;
 #[cfg(feature = "serde")]
 use serde::{Deserialize, Deserializer, Serialize, Serializer};
 
 use core::borrow::Borrow;
 use core::cmp::PartialOrd;
 use core::fmt;
 use core::hash::{Hash, Hasher};
-use core::ops::{Add, Div, Mul, Sub};
+use core::ops::{Add, Div, Mul, Sub, Range};
 
 
 /// A 2d Rectangle optionally tagged with a unit.
 #[repr(C)]
 pub struct TypedRect<T, U = UnknownUnit> {
     pub origin: TypedPoint2D<T, U>,
     pub size: TypedSize2D<T, U>,
 }
@@ -164,16 +164,26 @@ where
     }
 
     #[inline]
     pub fn min_y_typed(&self) -> Length<T, U> {
         Length::new(self.min_y())
     }
 
     #[inline]
+    pub fn x_range(&self) -> Range<T> {
+        self.min_x()..self.max_x()
+    }
+
+    #[inline]
+    pub fn y_range(&self) -> Range<T> {
+        self.min_y()..self.max_y()
+    }
+
+    #[inline]
     pub fn intersection(&self, other: &Self) -> Option<Self> {
         if !self.intersects(other) {
             return None;
         }
 
         let upper_left = TypedPoint2D::new(
             max(self.min_x(), other.min_x()),
             max(self.min_y(), other.min_y()),
--- a/third_party/rust/euclid/src/rotation.rs
+++ b/third_party/rust/euclid/src/rotation.rs
@@ -180,21 +180,23 @@ impl<T: Clone + MulAssign<T>> MulAssign<
 
 impl<T: Neg<Output = T>> Neg for Angle<T> {
     type Output = Self;
     fn neg(self) -> Self {
         Angle::radians(-self.radians)
     }
 }
 
-define_matrix! {
-    /// A transform that can represent rotations in 2d, represented as an angle in radians.
-    pub struct TypedRotation2D<T, Src, Dst> {
-        pub angle : T,
-    }
+/// A transform that can represent rotations in 2d, represented as an angle in radians.
+#[derive(EuclidMatrix)]
+#[repr(C)]
+pub struct TypedRotation2D<T, Src, Dst> {
+    pub angle : T,
+    #[doc(hidden)]
+    pub _unit: PhantomData<(Src, Dst)>,
 }
 
 /// The default 2d rotation type with no units.
 pub type Rotation2D<T> = TypedRotation2D<T, UnknownUnit, UnknownUnit>;
 
 impl<T, Src, Dst> TypedRotation2D<T, Src, Dst> {
     #[inline]
     /// Creates a rotation from an angle in radians.
@@ -306,36 +308,38 @@ where
 {
     /// Returns the matrix representation of this rotation.
     #[inline]
     pub fn to_transform(&self) -> TypedTransform2D<T, Src, Dst> {
         TypedTransform2D::create_rotation(self.get_angle())
     }
 }
 
-define_matrix! {
-    /// A transform that can represent rotations in 3d, represented as a quaternion.
-    ///
-    /// Most methods expect the quaternion to be normalized.
-    /// When in doubt, use `unit_quaternion` instead of `quaternion` to create
-    /// a rotation as the former will ensure that its result is normalized.
-    ///
-    /// Some people use the `x, y, z, w` (or `w, x, y, z`) notations. The equivalence is
-    /// as follows: `x -> i`, `y -> j`, `z -> k`, `w -> r`.
-    /// The memory layout of this type corresponds to the `x, y, z, w` notation
-    pub struct TypedRotation3D<T, Src, Dst> {
-        // Component multiplied by the imaginary number `i`.
-        pub i: T,
-        // Component multiplied by the imaginary number `j`.
-        pub j: T,
-        // Component multiplied by the imaginary number `k`.
-        pub k: T,
-        // The real part.
-        pub r: T,
-    }
+/// A transform that can represent rotations in 3d, represented as a quaternion.
+///
+/// Most methods expect the quaternion to be normalized.
+/// When in doubt, use `unit_quaternion` instead of `quaternion` to create
+/// a rotation as the former will ensure that its result is normalized.
+///
+/// Some people use the `x, y, z, w` (or `w, x, y, z`) notations. The equivalence is
+/// as follows: `x -> i`, `y -> j`, `z -> k`, `w -> r`.
+/// The memory layout of this type corresponds to the `x, y, z, w` notation
+#[derive(EuclidMatrix)]
+#[repr(C)]
+pub struct TypedRotation3D<T, Src, Dst> {
+    /// Component multiplied by the imaginary number `i`.
+    pub i: T,
+    /// Component multiplied by the imaginary number `j`.
+    pub j: T,
+    /// Component multiplied by the imaginary number `k`.
+    pub k: T,
+    /// The real part.
+    pub r: T,
+    #[doc(hidden)]
+    pub _unit: PhantomData<(Src, Dst)>,
 }
 
 /// The default 3d rotation type with no units.
 pub type Rotation3D<T> = TypedRotation3D<T, UnknownUnit, UnknownUnit>;
 
 impl<T, Src, Dst> TypedRotation3D<T, Src, Dst> {
     /// Creates a rotation around from a quaternion representation.
     ///
--- a/third_party/rust/euclid/src/side_offsets.rs
+++ b/third_party/rust/euclid/src/side_offsets.rs
@@ -14,23 +14,25 @@ use super::UnknownUnit;
 use length::Length;
 use num::Zero;
 use core::fmt;
 use core::ops::Add;
 use core::marker::PhantomData;
 
 /// A group of side offsets, which correspond to top/left/bottom/right for borders, padding,
 /// and margins in CSS, optionally tagged with a unit.
-define_matrix! {
-    pub struct TypedSideOffsets2D<T, U> {
-        pub top: T,
-        pub right: T,
-        pub bottom: T,
-        pub left: T,
-    }
+#[derive(EuclidMatrix)]
+#[repr(C)]
+pub struct TypedSideOffsets2D<T, U> {
+    pub top: T,
+    pub right: T,
+    pub bottom: T,
+    pub left: T,
+    #[doc(hidden)]
+    pub _unit: PhantomData<U>,
 }
 
 impl<T: fmt::Debug, U> fmt::Debug for TypedSideOffsets2D<T, U> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         write!(
             f,
             "({:?},{:?},{:?},{:?})",
             self.top, self.right, self.bottom, self.left
--- a/third_party/rust/euclid/src/size.rs
+++ b/third_party/rust/euclid/src/size.rs
@@ -16,21 +16,23 @@ use vector::{TypedVector2D, vec2, BoolVe
 use num::*;
 
 use num_traits::{Float, NumCast, Signed};
 use core::fmt;
 use core::ops::{Add, Div, Mul, Sub};
 use core::marker::PhantomData;
 
 /// A 2d size tagged with a unit.
-define_matrix! {
-    pub struct TypedSize2D<T, U> {
-        pub width: T,
-        pub height: T,
-    }
+#[derive(EuclidMatrix)]
+#[repr(C)]
+pub struct TypedSize2D<T, U> {
+    pub width: T,
+    pub height: T,
+    #[doc(hidden)]
+    pub _unit: PhantomData<U>,
 }
 
 /// Default 2d size type with no unit.
 ///
 /// `Size2D` provides the same methods as `TypedSize2D`.
 pub type Size2D<T> = TypedSize2D<T, UnknownUnit>;
 
 impl<T: fmt::Debug, U> fmt::Debug for TypedSize2D<T, U> {
--- a/third_party/rust/euclid/src/transform2d.rs
+++ b/third_party/rust/euclid/src/transform2d.rs
@@ -19,33 +19,35 @@ use rect::TypedRect;
 use transform3d::TypedTransform3D;
 use core::ops::{Add, Mul, Div, Sub, Neg};
 use core::marker::PhantomData;
 use approxeq::ApproxEq;
 use trig::Trig;
 use core::fmt;
 use num_traits::NumCast;
 
-define_matrix! {
-    /// A 2d transform stored as a 3 by 2 matrix in row-major order in memory.
-    ///
-    /// Transforms can be parametrized over the source and destination units, to describe a
-    /// transformation from a space to another.
-    /// For example, `TypedTransform2D<f32, WorldSpace, ScreenSpace>::transform_point4d`
-    /// takes a `TypedPoint2D<f32, WorldSpace>` and returns a `TypedPoint2D<f32, ScreenSpace>`.
-    ///
-    /// Transforms expose a set of convenience methods for pre- and post-transformations.
-    /// A pre-transformation corresponds to adding an operation that is applied before
-    /// the rest of the transformation, while a post-transformation adds an operation
-    /// that is applied after.
-    pub struct TypedTransform2D<T, Src, Dst> {
-        pub m11: T, pub m12: T,
-        pub m21: T, pub m22: T,
-        pub m31: T, pub m32: T,
-    }
+/// A 2d transform stored as a 3 by 2 matrix in row-major order in memory.
+///
+/// Transforms can be parametrized over the source and destination units, to describe a
+/// transformation from a space to another.
+/// For example, `TypedTransform2D<f32, WorldSpace, ScreenSpace>::transform_point4d`
+/// takes a `TypedPoint2D<f32, WorldSpace>` and returns a `TypedPoint2D<f32, ScreenSpace>`.
+///
+/// Transforms expose a set of convenience methods for pre- and post-transformations.
+/// A pre-transformation corresponds to adding an operation that is applied before
+/// the rest of the transformation, while a post-transformation adds an operation
+/// that is applied after.
+#[repr(C)]
+#[derive(EuclidMatrix)]
+pub struct TypedTransform2D<T, Src, Dst> {
+    pub m11: T, pub m12: T,
+    pub m21: T, pub m22: T,
+    pub m31: T, pub m32: T,
+    #[doc(hidden)]
+    pub _unit: PhantomData<(Src, Dst)>,
 }
 
 /// The default 2d transform type with no units.
 pub type Transform2D<T> = TypedTransform2D<T, UnknownUnit, UnknownUnit>;
 
 impl<T: Copy, Src, Dst> TypedTransform2D<T, Src, Dst> {
     /// Create a transform specifying its matrix elements in row-major order.
     pub fn row_major(m11: T, m12: T, m21: T, m22: T, m31: T, m32: T) -> Self {
--- a/third_party/rust/euclid/src/transform3d.rs
+++ b/third_party/rust/euclid/src/transform3d.rs
@@ -21,34 +21,36 @@ use rect::TypedRect;
 use transform2d::TypedTransform2D;
 use scale::TypedScale;
 use num::{One, Zero};
 use core::ops::{Add, Mul, Sub, Div, Neg};
 use core::marker::PhantomData;
 use core::fmt;
 use num_traits::NumCast;
 
-define_matrix! {
-    /// A 3d transform stored as a 4 by 4 matrix in row-major order in memory.
-    ///
-    /// Transforms can be parametrized over the source and destination units, to describe a
-    /// transformation from a space to another.
-    /// For example, `TypedTransform3D<f32, WorldSpace, ScreenSpace>::transform_point3d`
-    /// takes a `TypedPoint3D<f32, WorldSpace>` and returns a `TypedPoint3D<f32, ScreenSpace>`.
-    ///
-    /// Transforms expose a set of convenience methods for pre- and post-transformations.
-    /// A pre-transformation corresponds to adding an operation that is applied before
-    /// the rest of the transformation, while a post-transformation adds an operation
-    /// that is applied after.
-    pub struct TypedTransform3D<T, Src, Dst> {
-        pub m11: T, pub m12: T, pub m13: T, pub m14: T,
-        pub m21: T, pub m22: T, pub m23: T, pub m24: T,
-        pub m31: T, pub m32: T, pub m33: T, pub m34: T,
-        pub m41: T, pub m42: T, pub m43: T, pub m44: T,
-    }
+/// A 3d transform stored as a 4 by 4 matrix in row-major order in memory.
+///
+/// Transforms can be parametrized over the source and destination units, to describe a
+/// transformation from a space to another.
+/// For example, `TypedTransform3D<f32, WorldSpace, ScreenSpace>::transform_point3d`
+/// takes a `TypedPoint3D<f32, WorldSpace>` and returns a `TypedPoint3D<f32, ScreenSpace>`.
+///
+/// Transforms expose a set of convenience methods for pre- and post-transformations.
+/// A pre-transformation corresponds to adding an operation that is applied before
+/// the rest of the transformation, while a post-transformation adds an operation
+/// that is applied after.
+#[derive(EuclidMatrix)]
+#[repr(C)]
+pub struct TypedTransform3D<T, Src, Dst> {
+    pub m11: T, pub m12: T, pub m13: T, pub m14: T,
+    pub m21: T, pub m22: T, pub m23: T, pub m24: T,
+    pub m31: T, pub m32: T, pub m33: T, pub m34: T,
+    pub m41: T, pub m42: T, pub m43: T, pub m44: T,
+    #[doc(hidden)]
+    pub _unit: PhantomData<(Src, Dst)>,
 }
 
 /// The default 3d transform type with no units.
 pub type Transform3D<T> = TypedTransform3D<T, UnknownUnit, UnknownUnit>;
 
 impl<T, Src, Dst> TypedTransform3D<T, Src, Dst> {
     /// Create a transform specifying its components in row-major order.
     ///
--- a/third_party/rust/euclid/src/translation.rs
+++ b/third_party/rust/euclid/src/translation.rs
@@ -10,41 +10,43 @@
 use {TypedVector2D, TypedPoint2D, TypedVector3D, TypedPoint3D, TypedTransform2D, TypedTransform3D};
 use {TypedSize2D, TypedRect, vec2, point2, vec3, point3};
 use num::*;
 use trig::Trig;
 use core::ops::{Add, Sub, Neg, Mul, Div};
 use core::marker::PhantomData;
 use core::fmt;
 
-define_matrix! {
-    /// A 2d transformation from a space to another that can only express translations.
-    ///
-    /// The main benefit of this type over a TypedVector2D is the ability to cast
-    /// between a source and a destination spaces.
-    ///
-    /// Example:
-    ///
-    /// ```
-    /// use euclid::{TypedTranslation2D, TypedPoint2D, point2};
-    /// struct ParentSpace;
-    /// struct ChildSpace;
-    /// type ScrollOffset = TypedTranslation2D<i32, ParentSpace, ChildSpace>;
-    /// type ParentPoint = TypedPoint2D<i32, ParentSpace>;
-    /// type ChildPoint = TypedPoint2D<i32, ChildSpace>;
-    ///
-    /// let scrolling = ScrollOffset::new(0, 100);
-    /// let p1: ParentPoint = point2(0, 0);
-    /// let p2: ChildPoint = scrolling.transform_point(&p1);
-    /// ```
-    ///
-    pub struct TypedTranslation2D<T, Src, Dst> {
-        pub x: T,
-        pub y: T,
-    }
+/// A 2d transformation from a space to another that can only express translations.
+///
+/// The main benefit of this type over a TypedVector2D is the ability to cast
+/// between a source and a destination spaces.
+///
+/// Example:
+///
+/// ```
+/// use euclid::{TypedTranslation2D, TypedPoint2D, point2};
+/// struct ParentSpace;
+/// struct ChildSpace;
+/// type ScrollOffset = TypedTranslation2D<i32, ParentSpace, ChildSpace>;
+/// type ParentPoint = TypedPoint2D<i32, ParentSpace>;
+/// type ChildPoint = TypedPoint2D<i32, ChildSpace>;
+///
+/// let scrolling = ScrollOffset::new(0, 100);
+/// let p1: ParentPoint = point2(0, 0);
+/// let p2: ChildPoint = scrolling.transform_point(&p1);
+/// ```
+///
+#[derive(EuclidMatrix)]
+#[repr(C)]
+pub struct TypedTranslation2D<T, Src, Dst> {
+    pub x: T,
+    pub y: T,
+    #[doc(hidden)]
+    pub _unit: PhantomData<(Src, Dst)>,
 }
 
 impl<T, Src, Dst> TypedTranslation2D<T, Src, Dst> {
     #[inline]
     pub fn new(x: T, y: T) -> Self {
         TypedTranslation2D {
             x,
             y,
@@ -223,26 +225,28 @@ impl<T, Src, Dst> fmt::Debug for TypedTr
 where T: Copy + fmt::Debug {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         self.to_array().fmt(f)
     }
 }
 
 
 
-define_matrix! {
-    /// A 3d transformation from a space to another that can only express translations.
-    ///
-    /// The main benefit of this type over a TypedVector3D is the ability to cast
-    /// between a source and a destination spaces.
-    pub struct TypedTranslation3D<T, Src, Dst> {
-        pub x: T,
-        pub y: T,
-        pub z: T,
-    }
+/// A 3d transformation from a space to another that can only express translations.
+///
+/// The main benefit of this type over a TypedVector3D is the ability to cast
+/// between a source and a destination spaces.
+#[derive(EuclidMatrix)]
+#[repr(C)]
+pub struct TypedTranslation3D<T, Src, Dst> {
+    pub x: T,
+    pub y: T,
+    pub z: T,
+    #[doc(hidden)]
+    pub _unit: PhantomData<(Src, Dst)>,
 }
 
 impl<T, Src, Dst> TypedTranslation3D<T, Src, Dst> {
     #[inline]
     pub fn new(x: T, y: T, z: T) -> Self {
         TypedTranslation3D {
             x,
             y,
--- a/third_party/rust/euclid/src/vector.rs
+++ b/third_party/rust/euclid/src/vector.rs
@@ -18,23 +18,26 @@ use scale::TypedScale;
 use trig::Trig;
 use Angle;
 use num::*;
 use num_traits::{Float, NumCast, Signed};
 use core::fmt;
 use core::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
 use core::marker::PhantomData;
 
-define_matrix! {
-    /// A 2d Vector tagged with a unit.
-    pub struct TypedVector2D<T, U> {
-        pub x: T,
-        pub y: T,
-    }
+/// A 2d Vector tagged with a unit.
+#[derive(EuclidMatrix)]
+#[repr(C)]
+pub struct TypedVector2D<T, U> {
+    pub x: T,
+    pub y: T,
+    #[doc(hidden)]
+    pub _unit: PhantomData<U>,
 }
+
 mint_vec!(TypedVector2D[x, y] = Vector2);
 
 /// Default 2d vector type with no unit.
 ///
 /// `Vector2D` provides the same methods as `TypedVector2D`.
 pub type Vector2D<T> = TypedVector2D<T, UnknownUnit>;
 
 impl<T: Copy + Zero, U> TypedVector2D<T, U> {
@@ -463,24 +466,27 @@ impl<T, U> TypedVector2D<T, U>
 where
     T: Signed,
 {
     pub fn abs(&self) -> Self {
         vec2(self.x.abs(), self.y.abs())
     }
 }
 
-define_matrix! {
-    /// A 3d Vector tagged with a unit.
-    pub struct TypedVector3D<T, U> {
-        pub x: T,
-        pub y: T,
-        pub z: T,
-    }
+/// A 3d Vector tagged with a unit.
+#[derive(EuclidMatrix)]
+#[repr(C)]
+pub struct TypedVector3D<T, U> {
+    pub x: T,
+    pub y: T,
+    pub z: T,
+    #[doc(hidden)]
+    pub _unit: PhantomData<U>,
 }
+
 mint_vec!(TypedVector3D[x, y, z] = Vector3);
 
 /// Default 3d vector type with no unit.
 ///
 /// `Vector3D` provides the same methods as `TypedVector3D`.
 pub type Vector3D<T> = TypedVector3D<T, UnknownUnit>;
 
 impl<T: Copy + Zero, U> TypedVector3D<T, U> {
new file mode 100644
--- /dev/null
+++ b/third_party/rust/euclid_macros/.cargo-checksum.json
@@ -0,0 +1,1 @@
+{"files":{"Cargo.toml":"12f4357876f09242153fbbd912c70861b03d5a8f983fce3de0d3696389452be6","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"62065228e42caebca7e7d7db1204cbb867033de5982ca4009928915e4095f3a3","euclid_matrix.rs":"0643b38d8284278c3d54a3791aa0eae7edd5f73a54e1edec38e1bcdb4af66e0b","lib.rs":"845b9a82365e06d51edce03560a5abe617f955c9c640e90140c87fb594c65fbd"},"package":"fdcb84c18ea5037a1c5a23039b4ff29403abce2e0d6b1daa11cf0bde2b30be15"}
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/third_party/rust/euclid_macros/Cargo.toml
@@ -0,0 +1,31 @@
+# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
+#
+# When uploading crates to the registry Cargo will automatically
+# "normalize" Cargo.toml files for maximal compatibility
+# with all versions of Cargo and also rewrite `path` dependencies
+# to registry (e.g. crates.io) dependencies
+#
+# If you believe there's an error in this file please file an
+# issue against the rust-lang/cargo repository. If you're
+# editing this file be aware that the upstream Cargo.toml
+# will likely look very different (and much more reasonable)
+
+[package]
+name = "euclid_macros"
+version = "0.1.0"
+authors = ["Emilio Cobos Álvarez <emilio@crisal.io>", "The Servo project developers"]
+description = "Euclid implementation detail"
+license = "MIT / Apache-2.0"
+
+[lib]
+path = "lib.rs"
+proc-macro = true
+[dependencies.proc-macro2]
+version = "0.4"
+
+[dependencies.quote]
+version = "0.6"
+
+[dependencies.syn]
+version = "0.15"
+features = ["visit"]
new file mode 100644
--- /dev/null
+++ b/third_party/rust/euclid_macros/LICENSE-APACHE
@@ -0,0 +1,201 @@
+                              Apache License
+                        Version 2.0, January 2004
+                     http://www.apache.org/licenses/
+
+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+1. Definitions.
+
+   "License" shall mean the terms and conditions for use, reproduction,
+   and distribution as defined by Sections 1 through 9 of this document.
+
+   "Licensor" shall mean the copyright owner or entity authorized by
+   the copyright owner that is granting the License.
+
+   "Legal Entity" shall mean the union of the acting entity and all
+   other entities that control, are controlled by, or are under common
+   control with that entity. For the purposes of this definition,
+   "control" means (i) the power, direct or indirect, to cause the
+   direction or management of such entity, whether by contract or
+   otherwise, or (ii) ownership of fifty percent (50%) or more of the
+   outstanding shares, or (iii) beneficial ownership of such entity.
+
+   "You" (or "Your") shall mean an individual or Legal Entity
+   exercising permissions granted by this License.
+
+   "Source" form shall mean the preferred form for making modifications,
+   including but not limited to software source code, documentation
+   source, and configuration files.
+
+   "Object" form shall mean any form resulting from mechanical
+   transformation or translation of a Source form, including but
+   not limited to compiled object code, generated documentation,
+   and conversions to other media types.
+
+   "Work" shall mean the work of authorship, whether in Source or
+   Object form, made available under the License, as indicated by a
+   copyright notice that is included in or attached to the work
+   (an example is provided in the Appendix below).
+
+   "Derivative Works" shall mean any work, whether in Source or Object
+   form, that is based on (or derived from) the Work and for which the
+   editorial revisions, annotations, elaborations, or other modifications
+   represent, as a whole, an original work of authorship. For the purposes
+   of this License, Derivative Works shall not include works that remain
+   separable from, or merely link (or bind by name) to the interfaces of,
+   the Work and Derivative Works thereof.
+
+   "Contribution" shall mean any work of authorship, including
+   the original version of the Work and any modifications or additions
+   to that Work or Derivative Works thereof, that is intentionally
+   submitted to Licensor for inclusion in the Work by the copyright owner
+   or by an individual or Legal Entity authorized to submit on behalf of
+   the copyright owner. For the purposes of this definition, "submitted"
+   means any form of electronic, verbal, or written communication sent
+   to the Licensor or its representatives, including but not limited to
+   communication on electronic mailing lists, source code control systems,
+   and issue tracking systems that are managed by, or on behalf of, the
+   Licensor for the purpose of discussing and improving the Work, but
+   excluding communication that is conspicuously marked or otherwise
+   designated in writing by the copyright owner as "Not a Contribution."
+
+   "Contributor" shall mean Licensor and any individual or Legal Entity
+   on behalf of whom a Contribution has been received by Licensor and
+   subsequently incorporated within the Work.
+
+2. Grant of Copyright License. Subject to the terms and conditions of
+   this License, each Contributor hereby grants to You a perpetual,
+   worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+   copyright license to reproduce, prepare Derivative Works of,
+   publicly display, publicly perform, sublicense, and distribute the
+   Work and such Derivative Works in Source or Object form.
+
+3. Grant of Patent License. Subject to the terms and conditions of
+   this License, each Contributor hereby grants to You a perpetual,
+   worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+   (except as stated in this section) patent license to make, have made,
+   use, offer to sell, sell, import, and otherwise transfer the Work,
+   where such license applies only to those patent claims licensable
+   by such Contributor that are necessarily infringed by their
+   Contribution(s) alone or by combination of their Contribution(s)
+   with the Work to which such Contribution(s) was submitted. If You
+   institute patent litigation against any entity (including a
+   cross-claim or counterclaim in a lawsuit) alleging that the Work
+   or a Contribution incorporated within the Work constitutes direct
+   or contributory patent infringement, then any patent licenses
+   granted to You under this License for that Work shall terminate
+   as of the date such litigation is filed.
+
+4. Redistribution. You may reproduce and distribute copies of the
+   Work or Derivative Works thereof in any medium, with or without
+   modifications, and in Source or Object form, provided that You
+   meet the following conditions:
+
+   (a) You must give any other recipients of the Work or
+       Derivative Works a copy of this License; and
+
+   (b) You must cause any modified files to carry prominent notices
+       stating that You changed the files; and
+
+   (c) You must retain, in the Source form of any Derivative Works
+       that You distribute, all copyright, patent, trademark, and
+       attribution notices from the Source form of the Work,
+       excluding those notices that do not pertain to any part of
+       the Derivative Works; and
+
+   (d) If the Work includes a "NOTICE" text file as part of its
+       distribution, then any Derivative Works that You distribute must
+       include a readable copy of the attribution notices contained
+       within such NOTICE file, excluding those notices that do not
+       pertain to any part of the Derivative Works, in at least one
+       of the following places: within a NOTICE text file distributed
+       as part of the Derivative Works; within the Source form or
+       documentation, if provided along with the Derivative Works; or,
+       within a display generated by the Derivative Works, if and
+       wherever such third-party notices normally appear. The contents
+       of the NOTICE file are for informational purposes only and
+       do not modify the License. You may add Your own attribution
+       notices within Derivative Works that You distribute, alongside
+       or as an addendum to the NOTICE text from the Work, provided
+       that such additional attribution notices cannot be construed
+       as modifying the License.
+
+   You may add Your own copyright statement to Your modifications and
+   may provide additional or different license terms and conditions
+   for use, reproduction, or distribution of Your modifications, or
+   for any such Derivative Works as a whole, provided Your use,
+   reproduction, and distribution of the Work otherwise complies with
+   the conditions stated in this License.
+
+5. Submission of Contributions. Unless You explicitly state otherwise,
+   any Contribution intentionally submitted for inclusion in the Work
+   by You to the Licensor shall be under the terms and conditions of
+   this License, without any additional terms or conditions.
+   Notwithstanding the above, nothing herein shall supersede or modify
+   the terms of any separate license agreement you may have executed
+   with Licensor regarding such Contributions.
+
+6. Trademarks. This License does not grant permission to use the trade
+   names, trademarks, service marks, or product names of the Licensor,
+   except as required for reasonable and customary use in describing the
+   origin of the Work and reproducing the content of the NOTICE file.
+
+7. Disclaimer of Warranty. Unless required by applicable law or
+   agreed to in writing, Licensor provides the Work (and each
+   Contributor provides its Contributions) on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+   implied, including, without limitation, any warranties or conditions
+   of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+   PARTICULAR PURPOSE. You are solely responsible for determining the
+   appropriateness of using or redistributing the Work and assume any
+   risks associated with Your exercise of permissions under this License.
+
+8. Limitation of Liability. In no event and under no legal theory,
+   whether in tort (including negligence), contract, or otherwise,
+   unless required by applicable law (such as deliberate and grossly
+   negligent acts) or agreed to in writing, shall any Contributor be
+   liable to You for damages, including any direct, indirect, special,
+   incidental, or consequential damages of any character arising as a
+   result of this License or out of the use or inability to use the
+   Work (including but not limited to damages for loss of goodwill,
+   work stoppage, computer failure or malfunction, or any and all
+   other commercial damages or losses), even if such Contributor
+   has been advised of the possibility of such damages.
+
+9. Accepting Warranty or Additional Liability. While redistributing
+   the Work or Derivative Works thereof, You may choose to offer,
+   and charge a fee for, acceptance of support, warranty, indemnity,
+   or other liability obligations and/or rights consistent with this
+   License. However, in accepting such obligations, You may act only
+   on Your own behalf and on Your sole responsibility, not on behalf
+   of any other Contributor, and only if You agree to indemnify,
+   defend, and hold each Contributor harmless for any liability
+   incurred by, or claims asserted against, such Contributor by reason
+   of your accepting any such warranty or additional liability.
+
+END OF TERMS AND CONDITIONS
+
+APPENDIX: How to apply the Apache License to your work.
+
+   To apply the Apache License to your work, attach the following
+   boilerplate notice, with the fields enclosed by brackets "[]"
+   replaced with your own identifying information. (Don't include
+   the brackets!)  The text should be enclosed in the appropriate
+   comment syntax for the file format. We also recommend that a
+   file or class name and description of purpose be included on the
+   same "printed page" as the copyright notice for easier
+   identification within third-party archives.
+
+Copyright [yyyy] [name of copyright owner]
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+	http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
new file mode 100644
--- /dev/null
+++ b/third_party/rust/euclid_macros/LICENSE-MIT
@@ -0,0 +1,25 @@
+Copyright (c) 2012-2013 Mozilla Foundation
+
+Permission is hereby granted, free of charge, to any
+person obtaining a copy of this software and associated
+documentation files (the "Software"), to deal in the
+Software without restriction, including without
+limitation the rights to use, copy, modify, merge,
+publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software
+is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice
+shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
+ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
+TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
+SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
new file mode 100644
--- /dev/null
+++ b/third_party/rust/euclid_macros/euclid_matrix.rs
@@ -0,0 +1,247 @@
+use proc_macro2::TokenStream;
+use syn::{self, DeriveInput};
+
+type Fields = syn::punctuated::Punctuated<syn::Field, syn::token::Comma>;
+
+fn derive_trait<F>(
+    input: &DeriveInput,
+    trait_name: TokenStream,
+    generics: &syn::Generics,
+    body: F
+) -> TokenStream
+where
+    F: FnOnce() -> TokenStream,
+{
+    let struct_name = &input.ident;
+
+    let (impl_generics, _, where_clause) = generics.split_for_impl();
+    let (_, ty_generics, _) = input.generics.split_for_impl();
+
+    let body = body();
+    quote! {
+        impl #impl_generics #trait_name for #struct_name #ty_generics #where_clause {
+            #body
+        }
+    }
+}
+
+fn derive_simple_trait<F>(
+    input: &DeriveInput,
+    trait_name: TokenStream,
+    t: &syn::TypeParam,
+    body: F,
+) -> TokenStream
+where
+    F: FnOnce() -> TokenStream,
+{
+    let mut generics = input.generics.clone();
+    generics
+        .make_where_clause()
+        .predicates
+        .push(parse_quote!(#t: #trait_name));
+    derive_trait(input, trait_name, &generics, body)
+}
+
+fn each_field_except_unit<F>(
+    fields: &Fields,
+    unit: &syn::Field,
+    mut field_expr: F,
+) -> TokenStream
+where
+    F: FnMut(&syn::Ident) -> TokenStream,
+{
+    fields.iter().filter(|f| f.ident != unit.ident).fold(quote! {}, |body, field| {
+        let name = field.ident.as_ref().unwrap();
+        let expr = field_expr(name);
+        quote! {
+            #body
+            #expr
+        }
+    })
+}
+
+
+fn derive_struct_body<F>(
+    fields: &Fields,
+    unit: &syn::Field,
+    mut field_expr: F,
+) -> TokenStream
+where
+    F: FnMut(&syn::Ident) -> TokenStream,
+{
+    let body = each_field_except_unit(fields, unit, |name| {
+        let expr = field_expr(name);
+        quote! {
+            #name: #expr,
+        }
+    });
+
+    let unit_name = unit.ident.as_ref().unwrap();
+    quote! {
+        Self {
+            #body
+            #unit_name: PhantomData,
+        }
+    }
+}
+
+fn clone_impl(input: &DeriveInput, fields: &Fields, unit: &syn::Field, t: &syn::TypeParam) -> TokenStream {
+    derive_simple_trait(input, quote! { Clone }, t, || {
+        let body = derive_struct_body(fields, unit, |name| {
+            quote! { self.#name.clone() }
+        });
+        quote! {
+            fn clone(&self) -> Self {
+                #body
+            }
+        }
+    })
+}
+
+fn copy_impl(input: &DeriveInput, t: &syn::TypeParam) -> TokenStream {
+    derive_simple_trait(input, quote!{ Copy }, t, || quote! {})
+}
+
+fn eq_impl(input: &DeriveInput, t: &syn::TypeParam) -> TokenStream {
+    derive_simple_trait(input, quote!{ ::core::cmp::Eq }, t, || quote! {})
+}
+
+fn partialeq_impl(input: &DeriveInput, fields: &Fields, unit: &syn::Field, t: &syn::TypeParam) -> TokenStream {
+    derive_simple_trait(input, quote!{ ::core::cmp::PartialEq }, t, || {
+        let body = each_field_except_unit(fields, unit, |name| {
+            quote! { && self.#name == other.#name }
+        });
+
+        quote! {
+            fn eq(&self, other: &Self) -> bool {
+                true #body
+            }
+        }
+    })
+}
+
+fn hash_impl(input: &DeriveInput, fields: &Fields, unit: &syn::Field, t: &syn::TypeParam) -> TokenStream {
+    derive_simple_trait(input, quote!{ ::core::hash::Hash }, t, || {
+        let body = each_field_except_unit(fields, unit, |name| {
+            quote! { self.#name.hash(h); }
+        });
+
+        quote! {
+            fn hash<H: ::core::hash::Hasher>(&self, h: &mut H) {
+                #body
+            }
+        }
+    })
+}
+
+fn serde_impl(
+    input: &DeriveInput,
+    fields: &Fields,
+    unit: &syn::Field,
+    t: &syn::TypeParam,
+) -> TokenStream {
+    let deserialize_impl = {
+        let mut generics = input.generics.clone();
+        generics.params.insert(0, parse_quote!('de));
+        generics
+            .make_where_clause()
+            .predicates
+            .push(parse_quote!(#t: ::serde::Deserialize<'de>));
+        derive_trait(input, quote!{ ::serde::Deserialize<'de> }, &generics, || {
+            let tuple = each_field_except_unit(fields, unit, |name| {
+                quote! { #name, }
+            });
+            let body = derive_struct_body(fields, unit, |name| quote! { #name });
+            quote! {
+                fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
+                where
+                    D: ::serde::Deserializer<'de>,
+                {
+                    let (#tuple) = ::serde::Deserialize::deserialize(deserializer)?;
+                    Ok(#body)
+                }
+            }
+        })
+    };
+
+    let serialize_impl = derive_simple_trait(input, quote! { ::serde::Serialize }, t, || {
+        let tuple = each_field_except_unit(fields, unit, |name| {
+            quote! { &self.#name, }
+        });
+        quote! {
+            fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+            where
+                S: ::serde::Serializer,
+            {
+                (#tuple).serialize(serializer)
+            }
+        }
+    });
+
+    quote! {
+        #[cfg(feature = "serde")]
+        #serialize_impl
+        #[cfg(feature = "serde")]
+        #deserialize_impl
+    }
+}
+
+pub fn derive(input: DeriveInput) -> TokenStream {
+    let s = match input.data {
+        syn::Data::Struct(ref s) => s,
+        _ => panic!("Need to derive this on a struct"),
+    };
+
+    let fields = match s.fields {
+        syn::Fields::Named(ref named) => &named.named,
+        _ => panic!("Need to use named fields"),
+    };
+
+    assert!(!fields.is_empty());
+
+    let unit_field = fields.last().unwrap();
+    assert_eq!(
+        unit_field.value().ident.as_ref().unwrap().to_string(),
+        "_unit",
+        "You need to have a _unit field to derive this trait",
+    );
+
+    assert!(match unit_field.value().vis {
+        syn::Visibility::Public(..) => true,
+        _ => false,
+    }, "Unit field should be public");
+
+    assert!(input.attrs.iter().filter_map(|attr| attr.interpret_meta()).any(|attr| {
+        match attr {
+            syn::Meta::Word(..) |
+            syn::Meta::NameValue(..) => false,
+            syn::Meta::List(ref list) => {
+                list.ident == "repr" && list.nested.iter().any(|meta| {
+                    match *meta {
+                        syn::NestedMeta::Meta(syn::Meta::Word(ref w)) => w == "C",
+                        _ => false,
+                    }
+                })
+            }
+        }
+    }), "struct should be #[repr(C)]");
+
+    let type_param =
+        input.generics.type_params().next().cloned().expect("Need a T");
+
+    let clone = clone_impl(&input, fields, unit_field.value(), &type_param);
+    let copy = copy_impl(&input, &type_param);
+    let serde = serde_impl(&input, fields, unit_field.value(), &type_param);
+    let eq = eq_impl(&input, &type_param);
+    let partialeq = partialeq_impl(&input, fields, unit_field.value(), &type_param);
+    let hash = hash_impl(&input, fields, unit_field.value(), &type_param);
+
+    quote! {
+        #clone
+        #copy
+        #serde
+        #eq
+        #partialeq
+        #hash
+    }
+}
new file mode 100644
--- /dev/null
+++ b/third_party/rust/euclid_macros/lib.rs
@@ -0,0 +1,16 @@
+extern crate proc_macro;
+extern crate proc_macro2;
+#[macro_use]
+extern crate quote;
+#[macro_use]
+extern crate syn;
+
+use proc_macro::TokenStream;
+
+mod euclid_matrix;
+
+#[proc_macro_derive(EuclidMatrix)]
+pub fn derive_euclid_matrix(input: TokenStream) -> TokenStream {
+    let input = syn::parse(input).unwrap();
+    euclid_matrix::derive(input).into()
+}