diff --git a/ion-proc/src/class/automatic.rs b/ion-proc/src/class/automatic.rs index 457dc9f5..38368660 100644 --- a/ion-proc/src/class/automatic.rs +++ b/ion-proc/src/class/automatic.rs @@ -27,10 +27,7 @@ pub(crate) fn from_value(ion: &TokenStream, class_ident: &Ident) -> ItemImpl { parse2(quote!( impl<'cx> #ion::conversions::FromValue<'cx> for #class_ident { type Config = (); - fn from_value<'v>(cx: &'cx #ion::Context, value: &#ion::Value<'v>, _: bool, _: ()) -> #ion::Result<#class_ident> - where - 'cx: 'v - { + fn from_value<'v>(cx: &'cx #ion::Context, value: &#ion::Value<'v>, _: bool, _: ()) -> #ion::Result<#class_ident> { #ion::class::class_from_value(cx, value) } } diff --git a/ion-proc/src/function/parameters.rs b/ion-proc/src/function/parameters.rs index 932adf8b..1daf5568 100644 --- a/ion-proc/src/function/parameters.rs +++ b/ion-proc/src/function/parameters.rs @@ -192,7 +192,7 @@ impl ThisParameter { pub(crate) fn to_statement(&self, ion: &TokenStream, is_class: bool) -> Result { let ThisParameter { pat, ty, kind } = self; let self_ = parse_quote!(self_); - let pat = if is_class && &**pat == &parse_quote!(self) { &self_ } else { pat }; + let pat = if is_class && **pat == parse_quote!(self) { &self_ } else { pat }; let mut ty = ty.clone(); visit_type_mut(&mut LifetimeRemover, &mut ty); @@ -393,13 +393,11 @@ pub(crate) fn parse_this(pat: Box, ty: Box, is_class: bool, span: Spa let lt = reference.lifetime; let mutability = reference.mutability; match *reference.elem { - Type::Path(ty) if type_ends_with(&ty, "Object") => { - return Ok(ThisParameter { - pat, - ty: Box::new(Type::Path(ty)), - kind: ThisKind::Object(lt, mutability), - }); - } + Type::Path(ty) if type_ends_with(&ty, "Object") => Ok(ThisParameter { + pat, + ty: Box::new(Type::Path(ty)), + kind: ThisKind::Object(lt, mutability), + }), ty => Ok(ThisParameter { pat, ty: Box::new(ty), diff --git a/ion-proc/src/function/wrapper.rs b/ion-proc/src/function/wrapper.rs index 133a2b66..56c30b62 100644 --- a/ion-proc/src/function/wrapper.rs +++ b/ion-proc/src/function/wrapper.rs @@ -5,7 +5,7 @@ */ use proc_macro2::{Ident, TokenStream}; -use syn::{FnArg, GenericParam, ItemFn, parse2, PathArguments, Result, ReturnType, Type, WhereClause}; +use syn::{FnArg, GenericParam, ItemFn, parse2, PathArguments, Result, ReturnType, Type}; use syn::punctuated::Punctuated; use syn::spanned::Spanned; @@ -32,7 +32,6 @@ pub(crate) fn impl_wrapper_fn( let argument_checker = argument_checker(ion, &function.sig.ident, parameters.nargs.0); let wrapper_generics: [GenericParam; 2] = [parse_quote!('cx), parse_quote!('a)]; - let wrapper_where: WhereClause = parse_quote!(where 'cx: 'a); let mut wrapper_args: Vec = vec![ parse_quote!(__cx: &'cx #ion::Context), parse_quote!(__args: &'a mut #ion::Arguments<'_, 'cx>), @@ -117,7 +116,6 @@ pub(crate) fn impl_wrapper_fn( function.sig.ident = format_ident!("wrapper", span = function.sig.ident.span()); function.sig.inputs = Punctuated::from_iter(wrapper_args); function.sig.generics.params = Punctuated::from_iter(wrapper_generics); - function.sig.generics.where_clause = Some(wrapper_where); function.sig.output = parse_quote!(-> #wrapper_output); function.sig.asyncness = None; function.sig.unsafety = Some(::default()); @@ -143,7 +141,6 @@ pub(crate) fn impl_async_wrapper_fn( let argument_checker = argument_checker(ion, &function.sig.ident, parameters.nargs.0); let wrapper_generics: [GenericParam; 2] = [parse_quote!('cx), parse_quote!('a)]; - let wrapper_where: WhereClause = parse_quote!(where 'cx: 'a); let wrapper_args: Vec = vec![ parse_quote!(__cx: &'cx #ion::Context), parse_quote!(__args: &'a mut #ion::Arguments<'_, 'cx>), @@ -228,7 +225,6 @@ pub(crate) fn impl_async_wrapper_fn( function.sig.ident = format_ident!("wrapper", span = function.sig.ident.span()); function.sig.inputs = Punctuated::from_iter(wrapper_args); function.sig.generics.params = Punctuated::from_iter(wrapper_generics); - function.sig.generics.where_clause = Some(wrapper_where); function.sig.output = parse_quote!(-> #wrapper_output); function.sig.asyncness = None; function.sig.unsafety = Some(::default()); diff --git a/ion-proc/src/value/from.rs b/ion-proc/src/value/from.rs index 02c0f1df..26dbb56b 100644 --- a/ion-proc/src/value/from.rs +++ b/ion-proc/src/value/from.rs @@ -89,9 +89,7 @@ pub(crate) fn impl_from_value(mut input: DeriveInput) -> Result { impl #impl_generics #ion::conversions::FromValue<'cx> for #name #ty_generics #where_clause { type Config = (); - fn from_value<'v>(cx: &'cx #ion::Context, value: &#ion::Value<'v>, strict: bool, _: ()) - -> #ion::Result where 'cx: 'v - { + fn from_value<'v>(cx: &'cx #ion::Context, value: &#ion::Value<'v>, strict: bool, _: ()) -> #ion::Result { #object #body } diff --git a/ion/examples/macros/from_value/structure.rs b/ion/examples/macros/from_value/structure.rs index f6cc63c5..c5801a15 100644 --- a/ion/examples/macros/from_value/structure.rs +++ b/ion/examples/macros/from_value/structure.rs @@ -21,6 +21,6 @@ pub struct Complex<'cx> { pub parsed: Arc, } -fn parse_as_atomic_arc<'cx: 'v, 'v>(cx: &'cx Context, value: Value<'v>) -> Result> { +fn parse_as_atomic_arc(cx: &Context, value: Value) -> Result> { u64::from_value(cx, &value, true, ConversionBehavior::Default).map(|num| Arc::new(AtomicU64::new(num))) } diff --git a/ion/src/class.rs b/ion/src/class.rs index 757afd1a..8c3d18fa 100644 --- a/ion/src/class.rs +++ b/ion/src/class.rs @@ -153,7 +153,7 @@ pub trait ClassDefinition { } } - fn set_private(object: *mut JSObject, native: Self) + unsafe fn set_private(object: *mut JSObject, native: Self) where Self: Sized, { @@ -172,7 +172,7 @@ pub trait ClassDefinition { } /// Converts an instance of a native class into its native value, by cloning it. -pub fn class_from_value<'cx: 'v, 'v, T: ClassDefinition + Clone>(cx: &'cx Context, value: &Value<'v>) -> Result { +pub fn class_from_value(cx: &Context, value: &Value) -> Result { let object = Object::from_value(cx, value, true, ()).unwrap(); if T::instance_of(cx, &object, None) { Ok(T::get_private(&object).clone()) diff --git a/ion/src/conversions/value/from.rs b/ion/src/conversions/value/from.rs index f3c48038..610b406d 100644 --- a/ion/src/conversions/value/from.rs +++ b/ion/src/conversions/value/from.rs @@ -26,18 +26,13 @@ pub trait FromValue<'cx>: Sized { /// Converts `value` to the desired type. /// `strict` and `config` determine the strictness of the conversion and specify additional conversion constraints respectively. /// Returns [Err] with the [error](Error) if conversion fails. - fn from_value<'v>(cx: &'cx Context, value: &Value<'v>, strict: bool, config: Self::Config) -> Result - where - 'cx: 'v; + fn from_value(cx: &'cx Context, value: &Value, strict: bool, config: Self::Config) -> Result; } impl<'cx> FromValue<'cx> for bool { type Config = (); - fn from_value<'v>(_: &'cx Context, value: &Value<'v>, strict: bool, _: ()) -> Result - where - 'cx: 'v, - { + fn from_value(_: &'cx Context, value: &Value, strict: bool, _: ()) -> Result { let value = value.handle(); if value.is_boolean() { return Ok(value.to_boolean()); @@ -56,10 +51,7 @@ macro_rules! impl_from_value_for_integer { impl<'cx> FromValue<'cx> for $ty { type Config = ConversionBehavior; - fn from_value<'v>(cx: &'cx Context, value: &Value<'v>, strict: bool, config: ConversionBehavior) -> Result<$ty> - where - 'cx: 'v, - { + fn from_value(cx: &'cx Context, value: &Value, strict: bool, config: ConversionBehavior) -> Result<$ty> { let value = value.handle(); if strict && !value.is_number() { return Err(Error::new("Expected Number in Strict Conversion", ErrorKind::Type)); @@ -88,10 +80,7 @@ impl_from_value_for_integer!(i64); impl<'cx> FromValue<'cx> for f32 { type Config = (); - fn from_value<'v>(cx: &'cx Context, value: &Value<'v>, strict: bool, _: ()) -> Result - where - 'cx: 'v, - { + fn from_value(cx: &'cx Context, value: &Value, strict: bool, _: ()) -> Result { f64::from_value(cx, value, strict, ()).map(|float| float as f32) } } @@ -99,10 +88,7 @@ impl<'cx> FromValue<'cx> for f32 { impl<'cx> FromValue<'cx> for f64 { type Config = (); - fn from_value<'v>(cx: &'cx Context, value: &Value<'v>, strict: bool, _: ()) -> Result - where - 'cx: 'v, - { + fn from_value(cx: &'cx Context, value: &Value, strict: bool, _: ()) -> Result { let value = value.handle(); if strict && !value.is_number() { return Err(Error::new("Expected Number in Strict Conversion", ErrorKind::Type)); @@ -116,10 +102,7 @@ impl<'cx> FromValue<'cx> for f64 { impl<'cx> FromValue<'cx> for *mut JSString { type Config = (); - fn from_value<'v>(cx: &'cx Context, value: &Value<'v>, strict: bool, _: ()) -> Result<*mut JSString> - where - 'cx: 'v, - { + fn from_value(cx: &'cx Context, value: &Value, strict: bool, _: ()) -> Result<*mut JSString> { let value = value.handle(); if strict && !value.is_string() { return Err(Error::new("Expected String in Strict Conversion", ErrorKind::Type)); @@ -131,10 +114,7 @@ impl<'cx> FromValue<'cx> for *mut JSString { impl<'cx> FromValue<'cx> for String<'cx> { type Config = (); - fn from_value<'v>(cx: &'cx Context, value: &Value<'v>, strict: bool, config: ()) -> Result> - where - 'cx: 'v, - { + fn from_value(cx: &'cx Context, value: &Value, strict: bool, config: ()) -> Result> { <*mut JSString>::from_value(cx, value, strict, config).map(|str| String::from(cx.root_string(str))) } } @@ -142,10 +122,7 @@ impl<'cx> FromValue<'cx> for String<'cx> { impl<'cx> FromValue<'cx> for RustString { type Config = (); - fn from_value<'v>(cx: &'cx Context, value: &Value<'v>, strict: bool, config: ()) -> Result - where - 'cx: 'v, - { + fn from_value(cx: &'cx Context, value: &Value, strict: bool, config: ()) -> Result { String::from_value(cx, value, strict, config).map(|s| s.to_owned(cx)) } } @@ -153,10 +130,7 @@ impl<'cx> FromValue<'cx> for RustString { impl<'cx> FromValue<'cx> for *mut JSObject { type Config = (); - fn from_value<'v>(cx: &'cx Context, value: &Value<'v>, _: bool, _: ()) -> Result<*mut JSObject> - where - 'cx: 'v, - { + fn from_value(cx: &'cx Context, value: &Value, _: bool, _: ()) -> Result<*mut JSObject> { let value = value.handle(); if !value.is_object() { return Err(Error::new("Expected Object", ErrorKind::Type)); @@ -173,10 +147,7 @@ impl<'cx> FromValue<'cx> for *mut JSObject { impl<'cx> FromValue<'cx> for Object<'cx> { type Config = (); - fn from_value<'v>(cx: &'cx Context, value: &Value<'v>, _: bool, _: ()) -> Result> - where - 'cx: 'v, - { + fn from_value(cx: &'cx Context, value: &Value, _: bool, _: ()) -> Result> { if !value.handle().is_object() { return Err(Error::new("Expected Object", ErrorKind::Type)); } @@ -192,10 +163,7 @@ impl<'cx> FromValue<'cx> for Object<'cx> { impl<'cx> FromValue<'cx> for Array<'cx> { type Config = (); - fn from_value<'v>(cx: &'cx Context, value: &Value<'v>, _: bool, _: ()) -> Result> - where - 'cx: 'v, - { + fn from_value(cx: &'cx Context, value: &Value, _: bool, _: ()) -> Result> { if !value.handle().is_object() { return Err(Error::new("Expected Array", ErrorKind::Type)); } @@ -215,10 +183,7 @@ impl<'cx> FromValue<'cx> for Array<'cx> { impl<'cx> FromValue<'cx> for Date<'cx> { type Config = (); - fn from_value<'v>(cx: &'cx Context, value: &Value<'v>, _: bool, _: ()) -> Result> - where - 'cx: 'v, - { + fn from_value(cx: &'cx Context, value: &Value, _: bool, _: ()) -> Result> { if !value.handle().is_object() { return Err(Error::new("Expected Date", ErrorKind::Type)); } @@ -238,10 +203,7 @@ impl<'cx> FromValue<'cx> for Date<'cx> { impl<'cx> FromValue<'cx> for Promise<'cx> { type Config = (); - fn from_value<'v>(cx: &'cx Context, value: &Value<'v>, _: bool, _: ()) -> Result> - where - 'cx: 'v, - { + fn from_value(cx: &'cx Context, value: &Value, _: bool, _: ()) -> Result> { if !value.handle().is_object() { return Err(Error::new("Expected Promise", ErrorKind::Type)); } @@ -261,10 +223,7 @@ impl<'cx> FromValue<'cx> for Promise<'cx> { impl<'cx> FromValue<'cx> for *mut JSFunction { type Config = (); - fn from_value<'v>(cx: &'cx Context, value: &Value<'v>, strict: bool, config: ()) -> Result<*mut JSFunction> - where - 'cx: 'v, - { + fn from_value(cx: &'cx Context, value: &Value, strict: bool, config: ()) -> Result<*mut JSFunction> { Function::from_value(cx, value, strict, config).map(|f| f.get()) } } @@ -272,10 +231,7 @@ impl<'cx> FromValue<'cx> for *mut JSFunction { impl<'cx> FromValue<'cx> for Function<'cx> { type Config = (); - fn from_value<'v>(cx: &'cx Context, value: &Value<'v>, _: bool, _: ()) -> Result> - where - 'cx: 'v, - { + fn from_value(cx: &'cx Context, value: &Value, _: bool, _: ()) -> Result> { if !value.handle().is_object() { return Err(Error::new("Expected Function", ErrorKind::Type)); } @@ -295,10 +251,7 @@ impl<'cx> FromValue<'cx> for Function<'cx> { impl<'cx> FromValue<'cx> for *mut JSSymbol { type Config = (); - fn from_value<'v>(_: &'cx Context, value: &Value<'v>, _: bool, _: ()) -> Result<*mut JSSymbol> - where - 'cx: 'v, - { + fn from_value(_: &'cx Context, value: &Value, _: bool, _: ()) -> Result<*mut JSSymbol> { let value = value.handle(); if value.is_symbol() { Ok(value.to_symbol()) @@ -311,10 +264,7 @@ impl<'cx> FromValue<'cx> for *mut JSSymbol { impl<'cx> FromValue<'cx> for Symbol<'cx> { type Config = (); - fn from_value<'v>(cx: &'cx Context, value: &Value<'v>, strict: bool, config: Self::Config) -> Result> - where - 'cx: 'v, - { + fn from_value(cx: &'cx Context, value: &Value, strict: bool, config: Self::Config) -> Result> { <*mut JSSymbol>::from_value(cx, value, strict, config).map(|s| cx.root_symbol(s).into()) } } @@ -322,10 +272,7 @@ impl<'cx> FromValue<'cx> for Symbol<'cx> { impl<'cx> FromValue<'cx> for JSVal { type Config = (); - fn from_value<'v>(cx: &'cx Context, value: &Value<'v>, _: bool, _: ()) -> Result - where - 'cx: 'v, - { + fn from_value(cx: &'cx Context, value: &Value, _: bool, _: ()) -> Result { let value = value.handle(); unsafe { AssertSameCompartment1(cx.as_ptr(), value.into()); @@ -337,10 +284,7 @@ impl<'cx> FromValue<'cx> for JSVal { impl<'cx> FromValue<'cx> for Value<'cx> { type Config = (); - fn from_value<'v>(cx: &'cx Context, value: &Value<'v>, _: bool, _: ()) -> Result> - where - 'cx: 'v, - { + fn from_value(cx: &'cx Context, value: &Value, _: bool, _: ()) -> Result> { let value = value.handle(); unsafe { AssertSameCompartment1(cx.as_ptr(), value.into()); @@ -352,10 +296,7 @@ impl<'cx> FromValue<'cx> for Value<'cx> { impl<'cx, T: FromValue<'cx>> FromValue<'cx> for Option { type Config = T::Config; - fn from_value<'v>(cx: &'cx Context, value: &Value<'v>, strict: bool, config: T::Config) -> Result> - where - 'cx: 'v, - { + fn from_value(cx: &'cx Context, value: &Value, strict: bool, config: T::Config) -> Result> { if value.handle().is_null_or_undefined() { Ok(None) } else { @@ -383,10 +324,7 @@ where type Config = T::Config; // Adapted from [rust-mozjs](https://github.com/servo/rust-mozjs/blob/master/src/conversions.rs#L644-L707) - fn from_value<'v>(cx: &'cx Context, value: &Value<'v>, strict: bool, config: T::Config) -> Result> - where - 'cx: 'v, - { + fn from_value(cx: &'cx Context, value: &Value, strict: bool, config: T::Config) -> Result> { if !value.handle().is_object() { return Err(Error::new("Expected Object", ErrorKind::Type)); } @@ -433,10 +371,7 @@ where impl<'cx, T: TypedArrayElement, S: JSObjectStorage> FromValue<'cx> for TypedArray { type Config = (); - fn from_value<'v>(cx: &'cx Context, value: &Value<'v>, _: bool, _: ()) -> Result> - where - 'cx: 'v, - { + fn from_value(cx: &'cx Context, value: &Value, _: bool, _: ()) -> Result> { let value = value.handle(); if value.is_object() { let object = value.to_object(); diff --git a/ion/src/format/class.rs b/ion/src/format/class.rs index 8037d760..28bfff29 100644 --- a/ion/src/format/class.rs +++ b/ion/src/format/class.rs @@ -14,7 +14,7 @@ use crate::format::Config; use crate::format::object::format_plain_object; /// Formats a [JavaScript Object](Object), along with the name of its constructor, as a string with the given [configuration](Config). -pub fn format_class_object<'cx: 'o, 'o>(cx: &'cx Context, cfg: Config, object: &Object<'o>) -> String { +pub fn format_class_object(cx: &Context, cfg: Config, object: &Object) -> String { let class = unsafe { get_object_class(object.handle().get()) }; let name = unsafe { CStr::from_ptr((*class).name) }.to_str().unwrap(); diff --git a/ion/src/format/mod.rs b/ion/src/format/mod.rs index 4f10b7c7..6d13e4dd 100644 --- a/ion/src/format/mod.rs +++ b/ion/src/format/mod.rs @@ -26,7 +26,7 @@ pub const INDENT: &str = " "; pub const NEWLINE: &str = "\n"; /// Formats a [JavaScript Value](Value) as a string with the given [configuration](Config). -pub fn format_value<'cx: 'v, 'v>(cx: &'cx Context, cfg: Config, value: &Value<'v>) -> String { +pub fn format_value(cx: &Context, cfg: Config, value: &Value) -> String { if !value.handle().is_object() { format_primitive(cx, cfg, value) } else { diff --git a/ion/src/format/object.rs b/ion/src/format/object.rs index cdf5f7eb..02759de6 100644 --- a/ion/src/format/object.rs +++ b/ion/src/format/object.rs @@ -25,7 +25,7 @@ use crate::format::promise::format_promise; /// Formats a [JavaScript Object](Object), depending on its class, as a string using the given [configuration](Config). /// The object is passed to more specific formatting functions, such as [format_array] and [format_date]. -pub fn format_object<'cx: 'o, 'o>(cx: &'cx Context, cfg: Config, object: Object<'o>) -> String { +pub fn format_object(cx: &Context, cfg: Config, object: Object) -> String { unsafe { use ESClass as ESC; let class = object.get_builtin_class(cx); @@ -57,7 +57,7 @@ pub fn format_object<'cx: 'o, 'o>(cx: &'cx Context, cfg: Config, object: Object< /// Formats a [JavaScript Object](Object) as a string using the given [configuration](Config). /// Disregards the class of the object. #[allow(clippy::unnecessary_to_owned)] -pub fn format_plain_object<'cx: 'o, 'o>(cx: &'cx Context, cfg: Config, object: &Object<'o>) -> String { +pub fn format_plain_object(cx: &Context, cfg: Config, object: &Object) -> String { let color = cfg.colours.object; if cfg.depth < 4 { let keys = object.keys(cx, Some(cfg.iteration)); diff --git a/ion/src/functions/arguments.rs b/ion/src/functions/arguments.rs index 61ce93d9..1d0c4423 100644 --- a/ion/src/functions/arguments.rs +++ b/ion/src/functions/arguments.rs @@ -67,10 +67,7 @@ impl<'c, 'cx> Arguments<'c, 'cx> { } /// Returns a vector of arguments as [Values](Value) based on the indices of the iterator. - pub fn range<'a, R: Iterator>(&'a self, range: R) -> Vec<&'a Value<'cx>> - where - 'cx: 'a, - { + pub fn range>(&self, range: R) -> Vec<&Value<'cx>> { range.filter_map(|index| self.value(index)).collect() } diff --git a/ion/src/module.rs b/ion/src/module.rs index ee98d4a1..b66e2236 100644 --- a/ion/src/module.rs +++ b/ion/src/module.rs @@ -25,7 +25,7 @@ pub struct ModuleData { impl ModuleData { /// Creates [ModuleData] based on the private data of a module - pub fn from_private<'cx: 'v, 'v>(cx: &'cx Context, private: &Value<'v>) -> Option { + pub fn from_private(cx: &Context, private: &Value) -> Option { private.handle().is_object().then(|| { let private = private.to_object(cx); let path: Option = private.get_as(cx, "path", true, ()); @@ -167,25 +167,25 @@ impl<'cx> Module<'cx> { pub trait ModuleLoader { /// Given a request and private data of a module, resolves the request into a compiled module object. /// Should return the same module object for a given request. - fn resolve<'cx: 'p + 'r, 'p, 'r>(&mut self, cx: &'cx Context, private: &Value<'p>, request: &ModuleRequest<'r>) -> *mut JSObject; + fn resolve(&mut self, cx: &Context, private: &Value, request: &ModuleRequest) -> *mut JSObject; /// Registers a new module in the module registry. Useful for native modules. - fn register<'cx: 'r, 'r>(&mut self, cx: &'cx Context, module: *mut JSObject, request: &ModuleRequest<'r>) -> *mut JSObject; + fn register(&mut self, cx: &Context, module: *mut JSObject, request: &ModuleRequest) -> *mut JSObject; /// Returns metadata of a module, used to populate `import.meta`. - fn metadata<'cx: 'p + 'm, 'p, 'm>(&self, cx: &'cx Context, private: &Value<'p>, meta: &mut Object<'m>) -> bool; + fn metadata(&self, cx: &Context, private: &Value, meta: &mut Object) -> bool; } impl ModuleLoader for () { - fn resolve<'cx: 'p + 'r, 'p, 'r>(&mut self, _: &'cx Context, _: &Value<'p>, _: &ModuleRequest<'r>) -> *mut JSObject { + fn resolve(&mut self, _: &Context, _: &Value, _: &ModuleRequest) -> *mut JSObject { ptr::null_mut() } - fn register<'cx: 'r, 'r>(&mut self, _: &'cx Context, _: *mut JSObject, _: &ModuleRequest<'r>) -> *mut JSObject { + fn register(&mut self, _: &Context, _: *mut JSObject, _: &ModuleRequest) -> *mut JSObject { ptr::null_mut() } - fn metadata<'cx: 'p + 'm, 'p, 'm>(&self, _: &'cx Context, _: &Value<'p>, _: &mut Object<'m>) -> bool { + fn metadata(&self, _: &Context, _: &Value, _: &mut Object) -> bool { true } } diff --git a/ion/src/objects/array.rs b/ion/src/objects/array.rs index 3e07d040..1637e92e 100644 --- a/ion/src/objects/array.rs +++ b/ion/src/objects/array.rs @@ -135,11 +135,11 @@ impl<'a> Array<'a> { /// Deletes the [JSVal] at the given index. /// Returns `false` if the element cannot be deleted. - pub fn delete<'cx: 'a>(&mut self, cx: &'cx Context, index: u32) -> bool { + pub fn delete(&mut self, cx: &Context, index: u32) -> bool { self.arr.delete(cx, index) } - pub fn indices<'c, 'cx: 'a>(&self, cx: &'cx Context<'c>, flags: Option) -> ArrayIndicesIter<'c, 'cx> { + pub fn indices<'c, 'cx>(&self, cx: &'cx Context<'c>, flags: Option) -> ArrayIndicesIter<'c, 'cx> { ArrayIndicesIter(self.arr.keys(cx, flags)) } @@ -213,13 +213,13 @@ impl DoubleEndedIterator for ArrayIndicesIter<'_, '_> { impl FusedIterator for ArrayIndicesIter<'_, '_> {} -pub struct ArrayIter<'c, 'cx: 'aa, 'aa, 'a> { +pub struct ArrayIter<'c, 'cx, 'aa, 'a> { cx: &'cx Context<'c>, array: &'a Array<'aa>, indices: ArrayIndicesIter<'c, 'cx>, } -impl<'c, 'cx: 'aa, 'aa, 'a> ArrayIter<'c, 'cx, 'aa, 'a> { +impl<'c, 'cx, 'aa, 'a> ArrayIter<'c, 'cx, 'aa, 'a> { fn new(cx: &'cx Context<'c>, array: &'a Array<'aa>, indices: ArrayIndicesIter<'c, 'cx>) -> ArrayIter<'c, 'cx, 'aa, 'a> { ArrayIter { cx, array, indices } } diff --git a/ion/src/objects/key.rs b/ion/src/objects/key.rs index 2d6c48de..05b1d0f1 100644 --- a/ion/src/objects/key.rs +++ b/ion/src/objects/key.rs @@ -31,7 +31,7 @@ impl<'k> PropertyKey<'k> { string.to_key(cx) } - pub fn with_symbol<'cx: 's, 's>(cx: &'cx Context, symbol: &Symbol<'s>) -> PropertyKey<'cx> { + pub fn with_symbol<'cx>(cx: &'cx Context, symbol: &Symbol) -> PropertyKey<'cx> { symbol.to_key(cx).unwrap() } diff --git a/ion/src/objects/object.rs b/ion/src/objects/object.rs index 454e489f..850a9018 100644 --- a/ion/src/objects/object.rs +++ b/ion/src/objects/object.rs @@ -181,7 +181,7 @@ impl<'o> Object<'o> { /// Deletes the [Value] at the given index. /// /// Returns `false` if the element cannot be deleted. - pub fn delete<'cx: 'o, K: ToPropertyKey<'cx>>(&self, cx: &'cx Context, key: K) -> bool { + pub fn delete<'cx, K: ToPropertyKey<'cx>>(&self, cx: &'cx Context, key: K) -> bool { let key = key.to_key(cx).unwrap(); let mut result = MaybeUninit::uninit(); unsafe { JS_DeletePropertyById(cx.as_ptr(), self.handle().into(), key.handle().into(), result.as_mut_ptr()) } @@ -329,13 +329,13 @@ impl ExactSizeIterator for ObjectKeysIter<'_, '_> { impl FusedIterator for ObjectKeysIter<'_, '_> {} -pub struct ObjectIter<'c, 'cx: 'oo, 'oo, 'o> { +pub struct ObjectIter<'c, 'cx, 'oo, 'o> { cx: &'cx Context<'c>, object: &'o Object<'oo>, keys: ObjectKeysIter<'c, 'cx>, } -impl<'c, 'cx: 'oo, 'oo, 'o> ObjectIter<'c, 'cx, 'oo, 'o> { +impl<'c, 'cx, 'oo, 'o> ObjectIter<'c, 'cx, 'oo, 'o> { fn new(cx: &'cx Context<'c>, object: &'o Object<'oo>, keys: ObjectKeysIter<'c, 'cx>) -> ObjectIter<'c, 'cx, 'oo, 'o> { ObjectIter { cx, object, keys } } diff --git a/ion/src/value.rs b/ion/src/value.rs index 624eb40b..144f640d 100644 --- a/ion/src/value.rs +++ b/ion/src/value.rs @@ -80,7 +80,7 @@ impl<'v> Value<'v> { /// /// ### Panics /// This panics if the [Value] is not an object. - pub fn to_object<'cx: 'v>(&self, cx: &'cx Context) -> Object<'cx> { + pub fn to_object<'cx>(&self, cx: &'cx Context) -> Object<'cx> { cx.root_object(self.handle().to_object()).into() } diff --git a/modules/src/lib.rs b/modules/src/lib.rs index afb0ac27..8c554964 100644 --- a/modules/src/lib.rs +++ b/modules/src/lib.rs @@ -26,14 +26,14 @@ mod url; pub struct Modules; impl StandardModules for Modules { - fn init<'cx: 'o, 'o>(self, cx: &'cx Context, global: &mut Object<'o>) -> bool { + fn init(self, cx: &Context, global: &mut Object) -> bool { init_module::(cx, global) && init_module::(cx, global) && init_module::(cx, global) && init_module::(cx, global) } - fn init_globals<'cx: 'o, 'o>(self, cx: &'cx Context, global: &mut Object<'o>) -> bool { + fn init_globals(self, cx: &Context, global: &mut Object) -> bool { init_global_module::(cx, global) && init_global_module::(cx, global) && init_global_module::(cx, global) diff --git a/runtime/src/globals/console.rs b/runtime/src/globals/console.rs index 73ac033c..3ea50362 100644 --- a/runtime/src/globals/console.rs +++ b/runtime/src/globals/console.rs @@ -52,7 +52,7 @@ fn print_indent(is_stderr: bool) { }); } -fn print_args<'cx: 'v, 'v>(cx: &'cx Context, args: &[Value<'v>], stderr: bool) { +fn print_args(cx: &Context, args: &[Value], stderr: bool) { let indents = get_indents(); for value in args.iter() { let string = format_value(cx, FormatConfig::default().indentation(indents), value); @@ -74,7 +74,7 @@ fn get_label(label: Option) -> String { } #[js_fn] -fn log<'cx: 'v, 'v>(cx: &'cx Context, #[ion(varargs)] values: Vec>) { +fn log(cx: &Context, #[ion(varargs)] values: Vec) { if Config::global().log_level >= LogLevel::Info { print_indent(false); print_args(cx, values.as_slice(), false); @@ -83,7 +83,7 @@ fn log<'cx: 'v, 'v>(cx: &'cx Context, #[ion(varargs)] values: Vec>) { } #[js_fn] -fn warn<'cx: 'v, 'v>(cx: &'cx Context, #[ion(varargs)] values: Vec>) { +fn warn(cx: &Context, #[ion(varargs)] values: Vec) { if Config::global().log_level >= LogLevel::Warn { print_indent(true); print_args(cx, values.as_slice(), true); @@ -92,7 +92,7 @@ fn warn<'cx: 'v, 'v>(cx: &'cx Context, #[ion(varargs)] values: Vec>) { } #[js_fn] -fn error<'cx: 'v, 'v>(cx: &'cx Context, #[ion(varargs)] values: Vec>) { +fn error(cx: &Context, #[ion(varargs)] values: Vec) { if Config::global().log_level >= LogLevel::Error { print_indent(true); print_args(cx, values.as_slice(), true); @@ -101,7 +101,7 @@ fn error<'cx: 'v, 'v>(cx: &'cx Context, #[ion(varargs)] values: Vec>) } #[js_fn] -fn debug<'cx: 'v, 'v>(cx: &'cx Context, #[ion(varargs)] values: Vec>) { +fn debug(cx: &Context, #[ion(varargs)] values: Vec) { if Config::global().log_level == LogLevel::Debug { print_indent(false); print_args(cx, values.as_slice(), false); @@ -110,7 +110,7 @@ fn debug<'cx: 'v, 'v>(cx: &'cx Context, #[ion(varargs)] values: Vec>) } #[js_fn] -fn assert<'cx: 'v, 'v>(cx: &'cx Context, assertion: Option, #[ion(varargs)] values: Vec>) { +fn assert(cx: &Context, assertion: Option, #[ion(varargs)] values: Vec) { if Config::global().log_level >= LogLevel::Error { if let Some(assertion) = assertion { if assertion { @@ -152,7 +152,7 @@ fn clear() { } #[js_fn] -fn trace<'cx: 'v, 'v>(cx: &'cx Context, #[ion(varargs)] values: Vec>) { +fn trace(cx: &Context, #[ion(varargs)] values: Vec) { if Config::global().log_level == LogLevel::Debug { print_indent(false); print!("Trace: "); @@ -177,7 +177,7 @@ fn trace<'cx: 'v, 'v>(cx: &'cx Context, #[ion(varargs)] values: Vec>) } #[js_fn] -fn group<'cx: 'v, 'v>(cx: &'cx Context, #[ion(varargs)] values: Vec>) { +fn group(cx: &Context, #[ion(varargs)] values: Vec) { INDENTS.with(|indents| { let mut indents = indents.borrow_mut(); *indents = (*indents).min(u16::MAX - 1) + 1; @@ -260,7 +260,7 @@ fn time(label: Option) { } #[js_fn] -fn timeLog<'cx: 'v, 'v>(cx: &'cx Context, label: Option, #[ion(varargs)] values: Vec>) { +fn timeLog(cx: &Context, label: Option, #[ion(varargs)] values: Vec) { let label = get_label(label); TIMER_MAP.with(|map| { let mut map = map.borrow_mut(); @@ -311,7 +311,7 @@ fn timeEnd(label: Option) { } #[js_fn] -fn table<'cx: 'v, 'v>(cx: &'cx Context, data: Value<'v>, columns: Option>) { +fn table(cx: &Context, data: Value, columns: Option>) { fn sort_keys<'cx, I: IntoIterator>>(cx: &'cx Context, unsorted: I) -> IndexSet> { let mut indexes = IndexSet::::new(); let mut headers = IndexSet::::new(); @@ -446,7 +446,7 @@ const METHODS: &[JSFunctionSpec] = &[ JSFunctionSpec::ZERO, ]; -pub fn define<'cx: 'o, 'o>(cx: &'cx Context, global: &mut Object<'o>) -> bool { +pub fn define(cx: &Context, global: &mut Object) -> bool { let mut console = Object::new(cx); (unsafe { console.define_methods(cx, METHODS) }) && global.define_as(cx, "console", &console, PropertyFlags::CONSTANT_ENUMERATED) } diff --git a/runtime/src/globals/fetch/body.rs b/runtime/src/globals/fetch/body.rs index 6c8e5fdc..696bb1e1 100644 --- a/runtime/src/globals/fetch/body.rs +++ b/runtime/src/globals/fetch/body.rs @@ -114,10 +114,7 @@ macro_rules! typedarray_to_bytes { impl<'cx> FromValue<'cx> for FetchBody { type Config = (); - fn from_value<'v>(cx: &'cx Context, value: &Value<'v>, _: bool, _: Self::Config) -> Result - where - 'cx: 'v, - { + fn from_value(cx: &'cx Context, value: &Value, _: bool, _: Self::Config) -> Result { if value.handle().is_string() { Ok(FetchBody { body: FetchBodyInner::Bytes(Bytes::from(String::from_value(cx, value, true, ()).unwrap())), diff --git a/runtime/src/globals/fetch/header.rs b/runtime/src/globals/fetch/header.rs index cbe8ef56..dda00109 100644 --- a/runtime/src/globals/fetch/header.rs +++ b/runtime/src/globals/fetch/header.rs @@ -4,6 +4,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#![allow(clippy::declare_interior_mutable_const)] + use std::cmp::Ordering; use std::fmt; use std::fmt::{Display, Formatter}; @@ -52,10 +54,7 @@ pub struct HeadersObject(HeaderMap); impl<'cx> FromValue<'cx> for HeadersObject { type Config = (); - fn from_value<'v>(cx: &'cx Context, value: &Value<'v>, _: bool, _: ()) -> Result - where - 'cx: 'v, - { + fn from_value(cx: &'cx Context, value: &Value, _: bool, _: ()) -> Result { let object = Object::from_value(cx, value, true, ())?; let mut headers = HeaderMap::new(); append_to_headers(cx, &mut headers, object)?; @@ -70,11 +69,8 @@ pub struct HeaderEntry { impl<'cx> FromValue<'cx> for HeaderEntry { type Config = (); - fn from_value<'v>(cx: &'cx Context, value: &Value<'v>, _: bool, _: ()) -> Result - where - 'cx: 'v, - { - let vec = Vec::::from_value(cx, value, false, ())?; + fn from_value(cx: &'cx Context, value: &Value, _: bool, _: ()) -> Result { + let vec: Vec = Vec::from_value(cx, value, false, ())?; if vec.len() != 2 { return Err(Error::new( &format!("Received Header Entry with Length {}, Expected Length 2", vec.len()), @@ -301,7 +297,7 @@ mod class { } #[ion(name = WellKnownSymbolCode::Iterator)] - pub fn iterator<'cx: 'o, 'o>(cx: &'cx Context, #[ion(this)] this: &Object<'o>) -> ion::Iterator { + pub fn iterator(cx: &Context, #[ion(this)] this: &Object) -> ion::Iterator { let thisv = this.as_value(cx); let self_ = Headers::get_private(this); @@ -410,20 +406,20 @@ fn validate_header(name: &HeaderName, value: &HeaderValue, kind: HeadersKind) -> return Err(Error::new("Headers cannot be modified", ErrorKind::Type)); } - if FORBIDDEN_REQUEST_HEADERS.contains(&name) { + if FORBIDDEN_REQUEST_HEADERS.contains(name) { return Ok(false); } if name.as_str().starts_with("proxy-") || name.as_str().starts_with("sec-") { return Ok(false); } - if FORBIDDEN_REQUEST_HEADER_METHODS.contains(&name) { - let value = split_value(&value); + if FORBIDDEN_REQUEST_HEADER_METHODS.contains(name) { + let value = split_value(value); if value.iter().any(|v| v == "CONNECT" || v == "TRACE" || v == "TRACK") { return Ok(false); } } - if FORBIDDEN_RESPONSE_HEADERS.contains(&name) { + if FORBIDDEN_RESPONSE_HEADERS.contains(name) { return Ok(false); } @@ -431,11 +427,11 @@ fn validate_header(name: &HeaderName, value: &HeaderValue, kind: HeadersKind) -> } fn validate_no_cors_safelisted_request_header(headers: &mut HeaderMap, name: &HeaderName, value: &HeaderValue) -> bool { - if !NO_CORS_SAFELISTED_REQUEST_HEADERS.contains(&name) { + if !NO_CORS_SAFELISTED_REQUEST_HEADERS.contains(name) { return false; } - let temp = get_header(headers, &name); + let temp = get_header(headers, name); let str = value.to_str().unwrap(); let temp = match temp { Some(temp) => format!("{}, {}", temp, str), @@ -471,9 +467,9 @@ fn validate_no_cors_safelisted_request_header(headers: &mut HeaderMap, name: &He let mime = Mime::from_str(str); match mime { Ok(mime) => { - if !(mime.type_() == APPLICATION && mime.subtype() == WWW_FORM_URLENCODED) - && !(mime.type_() == MULTIPART && mime.subtype() == FORM_DATA) - && !(mime.type_() == TEXT && mime.subtype() == PLAIN) + if !(mime.type_() == APPLICATION && mime.subtype() == WWW_FORM_URLENCODED + || mime.type_() == MULTIPART && mime.subtype() == FORM_DATA + || mime.type_() == TEXT && mime.subtype() == PLAIN) { return false; } @@ -485,7 +481,7 @@ fn validate_no_cors_safelisted_request_header(headers: &mut HeaderMap, name: &He return false; } let str = &str[5..]; - let digit = str.char_indices().find_map(|(i, c)| matches!(c, '0'..='9').then(|| i + 1)); + let digit = str.char_indices().find_map(|(i, c)| c.is_ascii_digit().then_some(i + 1)); let digit = digit.unwrap_or_default(); let start = str[0..digit].parse::().ok(); if str.as_bytes()[digit] != b'-' { @@ -493,7 +489,7 @@ fn validate_no_cors_safelisted_request_header(headers: &mut HeaderMap, name: &He } let str = &str[digit..]; - let digit = str.char_indices().find_map(|(i, c)| matches!(c, '0'..='9').then(|| i + 1)); + let digit = str.char_indices().find_map(|(i, c)| c.is_ascii_digit().then_some(i + 1)); let digit = digit.unwrap_or_default(); let end = str[0..digit].parse().ok(); if digit != str.len() { diff --git a/runtime/src/globals/fetch/network.rs b/runtime/src/globals/fetch/network.rs index c25eab32..6d721197 100644 --- a/runtime/src/globals/fetch/network.rs +++ b/runtime/src/globals/fetch/network.rs @@ -97,7 +97,9 @@ pub(crate) async fn send_requests<'c>(cx: &Context<'c>, req: &Request, client: C } let mut response_object = Object::from(cx.root_object(Response::new_raw_object(cx))); - Response::set_private(response_object.handle().get(), Response::new(response, url, redirections > 0)); + unsafe { + Response::set_private(response_object.handle().get(), Response::new(response, url, redirections > 0)); + } let heap = Heap::boxed(response_object.handle().get()); let response = Response::get_mut_private(&mut response_object); diff --git a/runtime/src/globals/fetch/request/mod.rs b/runtime/src/globals/fetch/request/mod.rs index e26174dc..eb5183df 100644 --- a/runtime/src/globals/fetch/request/mod.rs +++ b/runtime/src/globals/fetch/request/mod.rs @@ -127,7 +127,9 @@ pub mod class { } } }; - Request::set_private(this.handle().get(), request); + unsafe { + Request::set_private(this.handle().get(), request); + } let heap = Heap::boxed(this.handle().get()); let request = Request::get_mut_private(this); @@ -356,10 +358,7 @@ pub mod class { impl<'cx> FromValue<'cx> for Request { type Config = (); - fn from_value<'v>(cx: &'cx Context, value: &Value<'v>, _: bool, _: ()) -> Result - where - 'cx: 'v, - { + fn from_value(cx: &'cx Context, value: &Value, _: bool, _: ()) -> Result { let object = Object::from_value(cx, value, true, ())?; if Request::instance_of(cx, &object, None) { Request::get_private(&object).clone() diff --git a/runtime/src/globals/fetch/request/options.rs b/runtime/src/globals/fetch/request/options.rs index 833a6657..25a26f0d 100644 --- a/runtime/src/globals/fetch/request/options.rs +++ b/runtime/src/globals/fetch/request/options.rs @@ -118,10 +118,7 @@ impl Display for Referrer { impl<'cx> FromValue<'cx> for Referrer { type Config = (); - fn from_value<'v>(cx: &'cx Context, value: &Value<'v>, strict: bool, _: ()) -> Result - where - 'cx: 'v, - { + fn from_value(cx: &'cx Context, value: &Value, strict: bool, _: ()) -> Result { let referrer = String::from_value(cx, value, strict, ())?; Referrer::from_str(&referrer) } @@ -181,10 +178,7 @@ impl Display for ReferrerPolicy { impl<'cx> FromValue<'cx> for ReferrerPolicy { type Config = (); - fn from_value<'v>(cx: &'cx Context, value: &Value<'v>, _: bool, _: ()) -> Result - where - 'cx: 'v, - { + fn from_value(cx: &'cx Context, value: &Value, _: bool, _: ()) -> Result { let policy = String::from_value(cx, value, true, ())?; ReferrerPolicy::from_str(&policy) } @@ -232,10 +226,7 @@ impl Display for RequestMode { impl<'cx> FromValue<'cx> for RequestMode { type Config = (); - fn from_value<'v>(cx: &'cx Context, value: &Value<'v>, _: bool, _: ()) -> Result - where - 'cx: 'v, - { + fn from_value(cx: &'cx Context, value: &Value, _: bool, _: ()) -> Result { let mode = String::from_value(cx, value, true, ())?; RequestMode::from_str(&mode) } @@ -277,10 +268,7 @@ impl Display for RequestCredentials { impl<'cx> FromValue<'cx> for RequestCredentials { type Config = (); - fn from_value<'v>(cx: &'cx Context, value: &Value<'v>, _: bool, _: ()) -> Result - where - 'cx: 'v, - { + fn from_value(cx: &'cx Context, value: &Value, _: bool, _: ()) -> Result { let mode = String::from_value(cx, value, true, ())?; RequestCredentials::from_str(&mode) } @@ -331,10 +319,7 @@ impl Display for RequestCache { impl<'cx> FromValue<'cx> for RequestCache { type Config = (); - fn from_value<'v>(cx: &'cx Context, value: &Value<'v>, _: bool, _: ()) -> Result - where - 'cx: 'v, - { + fn from_value(cx: &'cx Context, value: &Value, _: bool, _: ()) -> Result { let mode = String::from_value(cx, value, true, ())?; RequestCache::from_str(&mode) } @@ -376,10 +361,7 @@ impl Display for RequestRedirect { impl<'cx> FromValue<'cx> for RequestRedirect { type Config = (); - fn from_value<'v>(cx: &'cx Context, value: &Value<'v>, _: bool, _: ()) -> Result - where - 'cx: 'v, - { + fn from_value(cx: &'cx Context, value: &Value, _: bool, _: ()) -> Result { let redirect = String::from_value(cx, value, true, ())?; RequestRedirect::from_str(&redirect) } @@ -405,10 +387,7 @@ impl FromStr for RequestDuplex { impl<'cx> FromValue<'cx> for RequestDuplex { type Config = (); - fn from_value<'v>(cx: &'cx Context, value: &Value<'v>, _: bool, _: ()) -> Result - where - 'cx: 'v, - { + fn from_value(cx: &'cx Context, value: &Value, _: bool, _: ()) -> Result { let redirect = String::from_value(cx, value, true, ())?; RequestDuplex::from_str(&redirect) } @@ -439,10 +418,7 @@ impl FromStr for RequestPriority { impl<'cx> FromValue<'cx> for RequestPriority { type Config = (); - fn from_value<'v>(cx: &'cx Context, value: &Value<'v>, _: bool, _: ()) -> Result - where - 'cx: 'v, - { + fn from_value(cx: &'cx Context, value: &Value, _: bool, _: ()) -> Result { let redirect = String::from_value(cx, value, true, ())?; RequestPriority::from_str(&redirect) } diff --git a/runtime/src/globals/fetch/response/mod.rs b/runtime/src/globals/fetch/response/mod.rs index f41555d1..512dc7a1 100644 --- a/runtime/src/globals/fetch/response/mod.rs +++ b/runtime/src/globals/fetch/response/mod.rs @@ -75,7 +75,9 @@ pub mod class { status: Some(init.status), status_text: Some(init.status_text), }; - Response::set_private(this.handle().get(), response); + unsafe { + Response::set_private(this.handle().get(), response); + } let heap = Heap::boxed(this.handle().get()); let response = Response::get_mut_private(this); diff --git a/runtime/src/globals/fetch/response/options.rs b/runtime/src/globals/fetch/response/options.rs index 2701bc5c..9cc32bc5 100644 --- a/runtime/src/globals/fetch/response/options.rs +++ b/runtime/src/globals/fetch/response/options.rs @@ -23,7 +23,7 @@ pub struct ResponseInit { pub(crate) status_text: String, } -fn parse_status<'cx: 'v, 'v>(cx: &'cx Context, status: Value<'v>) -> Result { +fn parse_status(cx: &Context, status: Value) -> Result { let code = u16::from_value(cx, &status, true, ConversionBehavior::Clamp).map(StatusCode::from_u16); match code { diff --git a/runtime/src/globals/microtasks.rs b/runtime/src/globals/microtasks.rs index db48ea7c..ce0922b5 100644 --- a/runtime/src/globals/microtasks.rs +++ b/runtime/src/globals/microtasks.rs @@ -26,7 +26,7 @@ fn queueMicrotask(cx: &Context, callback: Function) -> Result<()> { const FUNCTION: JSFunctionSpec = function_spec!(queueMicrotask, 0); -pub fn define<'cx>(cx: &'cx Context, global: &mut Object<'cx>) -> bool { +pub fn define(cx: &Context, global: &mut Object) -> bool { global.define_as( cx, "queueMicrotask", diff --git a/runtime/src/globals/mod.rs b/runtime/src/globals/mod.rs index 70084ac5..d4b0e58e 100644 --- a/runtime/src/globals/mod.rs +++ b/runtime/src/globals/mod.rs @@ -15,7 +15,7 @@ pub mod microtasks; pub mod timers; pub mod url; -pub fn init_globals<'cx: 'o, 'o>(cx: &'cx Context, global: &mut Object<'o>) -> bool { +pub fn init_globals(cx: &Context, global: &mut Object) -> bool { let result = console::define(cx, global) && encoding::define(cx, global) && url::define(cx, global) && Iterator::init_class(cx, global).0; #[cfg(feature = "fetch")] { @@ -27,10 +27,10 @@ pub fn init_globals<'cx: 'o, 'o>(cx: &'cx Context, global: &mut Object<'o>) -> b } } -pub fn init_timers<'cx: 'o, 'o>(cx: &'cx Context, global: &mut Object<'o>) -> bool { +pub fn init_timers(cx: &Context, global: &mut Object) -> bool { timers::define(cx, global) && abort::define(cx, global) } -pub fn init_microtasks<'cx: 'o, 'o>(cx: &'cx Context, global: &mut Object<'o>) -> bool { +pub fn init_microtasks(cx: &Context, global: &mut Object) -> bool { microtasks::define(cx, global) } diff --git a/runtime/src/globals/timers.rs b/runtime/src/globals/timers.rs index 618b5582..4d9f186d 100644 --- a/runtime/src/globals/timers.rs +++ b/runtime/src/globals/timers.rs @@ -87,6 +87,6 @@ const FUNCTIONS: &[JSFunctionSpec] = &[ JSFunctionSpec::ZERO, ]; -pub fn define<'cx>(cx: &'cx Context, global: &'cx mut Object) -> bool { +pub fn define(cx: &Context, global: &mut Object) -> bool { unsafe { global.define_methods(cx, FUNCTIONS) } } diff --git a/runtime/src/globals/url/search_params.rs b/runtime/src/globals/url/search_params.rs index 43757ae8..8f7ecad2 100644 --- a/runtime/src/globals/url/search_params.rs +++ b/runtime/src/globals/url/search_params.rs @@ -119,7 +119,7 @@ mod class { } #[ion(name = WellKnownSymbolCode::Iterator)] - pub fn iterator<'cx: 'o, 'o>(cx: &'cx Context, #[ion(this)] this: &Object<'o>) -> ion::Iterator { + pub fn iterator(cx: &Context, #[ion(this)] this: &Object) -> ion::Iterator { let thisv = this.as_value(cx); ion::Iterator::new(SearchParamsIterator::default(), &thisv) } diff --git a/runtime/src/modules/loader.rs b/runtime/src/modules/loader.rs index edbe97b2..1bcd59e0 100644 --- a/runtime/src/modules/loader.rs +++ b/runtime/src/modules/loader.rs @@ -28,7 +28,7 @@ pub struct Loader { } impl ModuleLoader for Loader { - fn resolve<'cx: 'p + 'r, 'p, 'r>(&mut self, cx: &'cx Context, private: &Value<'p>, request: &ModuleRequest<'r>) -> *mut JSObject { + fn resolve(&mut self, cx: &Context, private: &Value, request: &ModuleRequest) -> *mut JSObject { let specifier = request.specifier(cx).to_owned(cx); let data = ModuleData::from_private(cx, private); @@ -74,7 +74,7 @@ impl ModuleLoader for Loader { .unwrap_or_else(ptr::null_mut) } - fn register<'cx: 'r, 'r>(&mut self, cx: &'cx Context, module: *mut JSObject, request: &ModuleRequest<'r>) -> *mut JSObject { + fn register(&mut self, cx: &Context, module: *mut JSObject, request: &ModuleRequest) -> *mut JSObject { let specifier = request.specifier(cx).to_owned(cx); match self.registry.entry(specifier) { Entry::Vacant(v) => *v.insert(module), @@ -82,7 +82,7 @@ impl ModuleLoader for Loader { } } - fn metadata<'cx: 'p + 'm, 'p, 'm>(&self, cx: &'cx Context, private: &Value<'p>, meta: &mut Object<'m>) -> bool { + fn metadata(&self, cx: &Context, private: &Value, meta: &mut Object) -> bool { let data = ModuleData::from_private(cx, private); if let Some(data) = data { diff --git a/runtime/src/modules/standard.rs b/runtime/src/modules/standard.rs index f276bc04..11774af8 100644 --- a/runtime/src/modules/standard.rs +++ b/runtime/src/modules/standard.rs @@ -9,17 +9,17 @@ use ion::flags::PropertyFlags; use ion::module::{Module, ModuleRequest}; pub trait StandardModules { - fn init<'cx: 'o, 'o>(self, cx: &'cx Context, global: &mut Object<'o>) -> bool; + fn init(self, cx: &Context, global: &mut Object) -> bool; - fn init_globals<'cx: 'o, 'o>(self, cx: &'cx Context, global: &mut Object<'o>) -> bool; + fn init_globals(self, cx: &Context, global: &mut Object) -> bool; } impl StandardModules for () { - fn init<'cx: 'o, 'o>(self, _: &'cx Context, _: &mut Object<'o>) -> bool { + fn init(self, _: &Context, _: &mut Object) -> bool { true } - fn init_globals<'cx: 'o, 'o>(self, _: &'cx Context, _: &mut Object<'o>) -> bool { + fn init_globals(self, _: &Context, _: &mut Object) -> bool { true } } @@ -32,18 +32,18 @@ pub trait NativeModule { } impl StandardModules for M { - fn init<'cx: 'o, 'o>(self, cx: &'cx Context, global: &mut Object<'o>) -> bool { + fn init(self, cx: &Context, global: &mut Object) -> bool { init_module::(cx, global) } - fn init_globals<'cx: 'o, 'o>(self, cx: &'cx Context, global: &mut Object<'o>) -> bool { + fn init_globals(self, cx: &Context, global: &mut Object) -> bool { init_global_module::(cx, global) } } // TODO: Remove JS Wrapper, Stop Global Scope Pollution, Use CreateEmptyModule and AddModuleExport // TODO: Waiting on https://bugzilla.mozilla.org/show_bug.cgi?id=1722802 -pub fn init_module<'cx: 'o, 'o, M: NativeModule>(cx: &'cx Context, global: &mut Object<'o>) -> bool { +pub fn init_module(cx: &Context, global: &mut Object) -> bool { let internal = format!("______{}Internal______", M::NAME); let module = M::module(cx); @@ -61,7 +61,7 @@ pub fn init_module<'cx: 'o, 'o, M: NativeModule>(cx: &'cx Context, global: &mut false } -pub fn init_global_module<'cx: 'o, 'o, M: NativeModule>(cx: &'cx Context, global: &mut Object<'o>) -> bool { +pub fn init_global_module(cx: &Context, global: &mut Object) -> bool { let module = M::module(cx); if let Some(module) = module {