Elide most 'a lifetimes

This commit is contained in:
Manish Goregaokar 2015-09-04 08:55:51 +05:30
parent 35dd1816a9
commit 54c036cd66
33 changed files with 126 additions and 126 deletions

View file

@ -29,7 +29,7 @@ impl<T> DOMRefCell<T> {
///
/// For use in the layout task only.
#[allow(unsafe_code)]
pub unsafe fn borrow_for_layout<'a>(&'a self) -> &'a T {
pub unsafe fn borrow_for_layout(&self) -> &T {
debug_assert!(task_state::get().is_layout());
&*self.value.as_unsafe_cell().get()
}
@ -39,7 +39,7 @@ impl<T> DOMRefCell<T> {
/// This succeeds even if the object is mutably borrowed,
/// so you have to be careful in trace code!
#[allow(unsafe_code)]
pub unsafe fn borrow_for_gc_trace<'a>(&'a self) -> &'a T {
pub unsafe fn borrow_for_gc_trace(&self) -> &T {
// FIXME: IN_GC isn't reliable enough - doesn't catch minor GCs
// https://github.com/servo/servo/issues/6389
//debug_assert!(task_state::get().contains(SCRIPT | IN_GC));
@ -49,7 +49,7 @@ impl<T> DOMRefCell<T> {
/// Borrow the contents for the purpose of script deallocation.
///
#[allow(unsafe_code)]
pub unsafe fn borrow_for_script_deallocation<'a>(&'a self) -> &'a mut T {
pub unsafe fn borrow_for_script_deallocation(&self) -> &mut T {
debug_assert!(task_state::get().contains(SCRIPT));
&mut *self.value.as_unsafe_cell().get()
}
@ -71,7 +71,7 @@ impl<T> DOMRefCell<T> {
/// # Panics
///
/// Panics if this is called off the script thread.
pub fn try_borrow<'a>(&'a self) -> Option<Ref<'a, T>> {
pub fn try_borrow(&self) -> Option<Ref<T>> {
debug_assert!(task_state::get().is_script());
match self.value.borrow_state() {
BorrowState::Writing => None,
@ -89,7 +89,7 @@ impl<T> DOMRefCell<T> {
/// # Panics
///
/// Panics if this is called off the script thread.
pub fn try_borrow_mut<'a>(&'a self) -> Option<RefMut<'a, T>> {
pub fn try_borrow_mut(&self) -> Option<RefMut<T>> {
debug_assert!(task_state::get().is_script());
match self.value.borrow_state() {
BorrowState::Unused => Some(self.value.borrow_mut()),
@ -127,7 +127,7 @@ impl<T> DOMRefCell<T> {
/// Panics if this is called off the script thread.
///
/// Panics if the value is currently mutably borrowed.
pub fn borrow<'a>(&'a self) -> Ref<'a, T> {
pub fn borrow(&self) -> Ref<T> {
self.try_borrow().expect("DOMRefCell<T> already mutably borrowed")
}
@ -141,7 +141,7 @@ impl<T> DOMRefCell<T> {
/// Panics if this is called off the script thread.
///
/// Panics if the value is currently borrowed.
pub fn borrow_mut<'a>(&'a self) -> RefMut<'a, T> {
pub fn borrow_mut(&self) -> RefMut<T> {
self.try_borrow_mut().expect("DOMRefCell<T> already borrowed")
}
}

View file

@ -149,7 +149,7 @@ impl LayoutJS<Node> {
}
impl<T: Reflectable> Reflectable for JS<T> {
fn reflector<'a>(&'a self) -> &'a Reflector {
fn reflector(&self) -> &Reflector {
unsafe {
(**self.ptr).reflector()
}
@ -310,11 +310,11 @@ impl<T: Reflectable> LayoutJS<T> {
pub trait RootedReference<T> {
/// Obtain a safe optional reference to the wrapped JS owned-value that
/// cannot outlive the lifetime of this root.
fn r<'a>(&'a self) -> Option<&'a T>;
fn r(&self) -> Option<&T>;
}
impl<T: Reflectable> RootedReference<T> for Option<Root<T>> {
fn r<'a>(&'a self) -> Option<&'a T> {
fn r(&self) -> Option<&T> {
self.as_ref().map(|root| root.r())
}
}
@ -323,11 +323,11 @@ impl<T: Reflectable> RootedReference<T> for Option<Root<T>> {
pub trait OptionalRootedReference<T> {
/// Obtain a safe optional optional reference to the wrapped JS owned-value
/// that cannot outlive the lifetime of this root.
fn r<'a>(&'a self) -> Option<Option<&'a T>>;
fn r(&self) -> Option<Option<&T>>;
}
impl<T: Reflectable> OptionalRootedReference<T> for Option<Option<Root<T>>> {
fn r<'a>(&'a self) -> Option<Option<&'a T>> {
fn r(&self) -> Option<Option<&T>> {
self.as_ref().map(|inner| inner.r())
}
}
@ -430,7 +430,7 @@ impl<T: Reflectable> Root<T> {
/// Obtain a safe reference to the wrapped JS owned-value that cannot
/// outlive the lifetime of this root.
pub fn r<'a>(&'a self) -> &'a T {
pub fn r(&self) -> &T {
&**self
}
@ -443,7 +443,7 @@ impl<T: Reflectable> Root<T> {
impl<T: Reflectable> Deref for Root<T> {
type Target = T;
fn deref<'a>(&'a self) -> &'a T {
fn deref(&self) -> &T {
unsafe { &**self.ptr.deref() }
}
}

View file

@ -25,7 +25,7 @@ impl ByteString {
/// Returns `self` as a string, if it encodes valid UTF-8, and `None`
/// otherwise.
pub fn as_str<'a>(&'a self) -> Option<&'a str> {
pub fn as_str(&self) -> Option<&str> {
let ByteString(ref vec) = *self;
str::from_utf8(&vec).ok()
}

View file

@ -404,7 +404,7 @@ pub fn initialize_global(global: *mut JSObject) {
/// A trait to provide access to the `Reflector` for a DOM object.
pub trait Reflectable {
/// Returns the receiver's reflector.
fn reflector<'a>(&'a self) -> &'a Reflector;
fn reflector(&self) -> &Reflector;
/// Initializes the Reflector
fn init_reflector(&mut self, _obj: *mut JSObject) {
panic!("Cannot call init on this Reflectable");