diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index 795204466df..6fa1b75fcd4 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -3016,7 +3016,7 @@ class CGUnionConversionStruct(CGThing): post="\n}") return CGWrapper( CGIndenter(method), - pre="impl FromJSValConvertible<()> for %s {\n" % self.type, + pre="impl FromJSValConvertible for %s {\ntype Config = ();\n" % self.type, post="\n}") def try_method(self, t): diff --git a/components/script/dom/bindings/conversions.rs b/components/script/dom/bindings/conversions.rs index bf805a35fbf..d7182f8993f 100644 --- a/components/script/dom/bindings/conversions.rs +++ b/components/script/dom/bindings/conversions.rs @@ -49,12 +49,13 @@ pub trait ToJSValConvertible { } /// A trait to convert `JSVal`s to Rust types. -pub trait FromJSValConvertible { +pub trait FromJSValConvertible { + type Config; /// Convert `val` to type `Self`. /// Optional configuration of type `T` can be passed as the `option` /// argument. /// If it returns `Err(())`, a JSAPI exception is pending. - fn from_jsval(cx: *mut JSContext, val: JSVal, option: T) -> Result; + fn from_jsval(cx: *mut JSContext, val: JSVal, option: Self::Config) -> Result; } @@ -92,7 +93,8 @@ impl ToJSValConvertible for bool { } } -impl FromJSValConvertible<()> for bool { +impl FromJSValConvertible for bool { + type Config = (); fn from_jsval(cx: *mut JSContext, val: JSVal, _option: ()) -> Result { let result = unsafe { convert_from_jsval(cx, val, JS_ValueToBoolean) }; result.map(|b| b != 0) @@ -105,7 +107,8 @@ impl ToJSValConvertible for i8 { } } -impl FromJSValConvertible<()> for i8 { +impl FromJSValConvertible for i8 { + type Config = (); fn from_jsval(cx: *mut JSContext, val: JSVal, _option: ()) -> Result { let result = unsafe { convert_from_jsval(cx, val, JS_ValueToECMAInt32) }; result.map(|v| v as i8) @@ -118,7 +121,8 @@ impl ToJSValConvertible for u8 { } } -impl FromJSValConvertible<()> for u8 { +impl FromJSValConvertible for u8 { + type Config = (); fn from_jsval(cx: *mut JSContext, val: JSVal, _option: ()) -> Result { let result = unsafe { convert_from_jsval(cx, val, JS_ValueToECMAInt32) }; result.map(|v| v as u8) @@ -131,7 +135,8 @@ impl ToJSValConvertible for i16 { } } -impl FromJSValConvertible<()> for i16 { +impl FromJSValConvertible for i16 { + type Config = (); fn from_jsval(cx: *mut JSContext, val: JSVal, _option: ()) -> Result { let result = unsafe { convert_from_jsval(cx, val, JS_ValueToECMAInt32) }; result.map(|v| v as i16) @@ -144,7 +149,8 @@ impl ToJSValConvertible for u16 { } } -impl FromJSValConvertible<()> for u16 { +impl FromJSValConvertible for u16 { + type Config = (); fn from_jsval(cx: *mut JSContext, val: JSVal, _option: ()) -> Result { unsafe { convert_from_jsval(cx, val, JS_ValueToUint16) } } @@ -156,7 +162,8 @@ impl ToJSValConvertible for i32 { } } -impl FromJSValConvertible<()> for i32 { +impl FromJSValConvertible for i32 { + type Config = (); fn from_jsval(cx: *mut JSContext, val: JSVal, _option: ()) -> Result { unsafe { convert_from_jsval(cx, val, JS_ValueToECMAInt32) } } @@ -168,7 +175,8 @@ impl ToJSValConvertible for u32 { } } -impl FromJSValConvertible<()> for u32 { +impl FromJSValConvertible for u32 { + type Config = (); fn from_jsval(cx: *mut JSContext, val: JSVal, _option: ()) -> Result { unsafe { convert_from_jsval(cx, val, JS_ValueToECMAUint32) } } @@ -182,7 +190,8 @@ impl ToJSValConvertible for i64 { } } -impl FromJSValConvertible<()> for i64 { +impl FromJSValConvertible for i64 { + type Config = (); fn from_jsval(cx: *mut JSContext, val: JSVal, _option: ()) -> Result { unsafe { convert_from_jsval(cx, val, JS_ValueToInt64) } } @@ -196,7 +205,8 @@ impl ToJSValConvertible for u64 { } } -impl FromJSValConvertible<()> for u64 { +impl FromJSValConvertible for u64 { + type Config = (); fn from_jsval(cx: *mut JSContext, val: JSVal, _option: ()) -> Result { unsafe { convert_from_jsval(cx, val, JS_ValueToUint64) } } @@ -210,7 +220,8 @@ impl ToJSValConvertible for f32 { } } -impl FromJSValConvertible<()> for f32 { +impl FromJSValConvertible for f32 { + type Config = (); fn from_jsval(cx: *mut JSContext, val: JSVal, _option: ()) -> Result { let result = unsafe { convert_from_jsval(cx, val, JS_ValueToNumber) }; result.map(|f| f as f32) @@ -225,7 +236,8 @@ impl ToJSValConvertible for f64 { } } -impl FromJSValConvertible<()> for f64 { +impl FromJSValConvertible for f64 { + type Config = (); fn from_jsval(cx: *mut JSContext, val: JSVal, _option: ()) -> Result { unsafe { convert_from_jsval(cx, val, JS_ValueToNumber) } } @@ -285,7 +297,8 @@ pub fn jsid_to_str(cx: *mut JSContext, id: jsid) -> DOMString { } } -impl FromJSValConvertible for DOMString { +impl FromJSValConvertible for DOMString { + type Config = StringificationBehavior; fn from_jsval(cx: *mut JSContext, value: JSVal, null_behavior: StringificationBehavior) -> Result { @@ -317,7 +330,8 @@ impl ToJSValConvertible for ByteString { } } -impl FromJSValConvertible<()> for ByteString { +impl FromJSValConvertible for ByteString { + type Config = (); fn from_jsval(cx: *mut JSContext, value: JSVal, _option: ()) -> Result { unsafe { let string = JS_ValueToString(cx, value); @@ -462,7 +476,8 @@ pub fn unwrap_jsmanaged(mut obj: *mut JSObject) -> Result, ()> } } -impl FromJSValConvertible<()> for JS { +impl FromJSValConvertible for JS { + type Config = (); fn from_jsval(_cx: *mut JSContext, value: JSVal, _option: ()) -> Result, ()> { if !value.is_object() { return Err(()); @@ -498,8 +513,8 @@ impl ToJSValConvertible for Option { } } -#[old_impl_check] -impl> FromJSValConvertible<()> for Option { +impl> FromJSValConvertible for Option { + type Config = (); fn from_jsval(cx: *mut JSContext, value: JSVal, _: ()) -> Result, ()> { if value.is_null_or_undefined() { Ok(None) diff --git a/components/script/lib.rs b/components/script/lib.rs index 5ffaa96b657..fdc69fd73f9 100644 --- a/components/script/lib.rs +++ b/components/script/lib.rs @@ -3,7 +3,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #![feature(unsafe_destructor, plugin, box_syntax, int_uint)] -#![feature(old_impl_check)] #![deny(unsafe_blocks)] #![deny(unused_imports)] diff --git a/components/util/lib.rs b/components/util/lib.rs index bceab7a3014..3736b6a5a09 100644 --- a/components/util/lib.rs +++ b/components/util/lib.rs @@ -5,7 +5,6 @@ #![feature(unsafe_destructor)] #![feature(plugin)] #![feature(int_uint)] -#![feature(old_impl_check)] #![feature(box_syntax)] #![deny(unused_imports)] diff --git a/components/util/range.rs b/components/util/range.rs index fbf14f38400..8c217beb218 100644 --- a/components/util/range.rs +++ b/components/util/range.rs @@ -9,12 +9,14 @@ use std::num; use std::num::Int; /// An index type to be used by a `Range` -pub trait RangeIndex: Int + fmt::Show { - fn new(x: T) -> Self; - fn get(self) -> T; +pub trait RangeIndex: Int + fmt::Show { + type Index; + fn new(x: Self::Index) -> Self; + fn get(self) -> Self::Index; } -impl RangeIndex for int { +impl RangeIndex for int { + type Index = int; #[inline] fn new(x: int) -> int { x } @@ -37,7 +39,8 @@ macro_rules! int_range_index { } } - impl RangeIndex<$T> for $Self { + impl RangeIndex for $Self { + type Index = $T; #[inline] fn new(x: $T) -> $Self { $Self(x) @@ -191,8 +194,7 @@ pub struct Range { length: I, } -#[old_impl_check] -impl, T> fmt::Show for Range { +impl fmt::Show for Range { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "[{:?} .. {:?})", self.begin(), self.end()) } @@ -203,11 +205,11 @@ pub struct EachIndex { it: iter::Range, } -pub fn each_index>(start: I, stop: I) -> EachIndex { +pub fn each_index>(start: I, stop: I) -> EachIndex { EachIndex { it: iter::range(start.get(), stop.get()) } } -impl> Iterator for EachIndex { +impl> Iterator for EachIndex { type Item = I; #[inline] @@ -221,8 +223,7 @@ impl> Iterator for EachIndex { } } -#[old_impl_check] -impl, T> Range { +impl Range { /// Create a new range from beginning and length offsets. This could be /// denoted as `[begin, begin + length)`. /// @@ -359,8 +360,7 @@ impl, T> Range { } /// Methods for `Range`s with indices based on integer values -#[old_impl_check] -impl> Range { +impl> Range { /// Returns an iterater that increments over `[begin, end)`. #[inline] pub fn each_index(&self) -> EachIndex {