Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

alloc, arena, test, url, uuid: Elide lifetimes. #16137

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/liballoc/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ impl<T: Clone> Rc<T> {
/// data is cloned if the reference count is greater than one.
#[inline]
#[experimental]
pub fn make_unique<'a>(&'a mut self) -> &'a mut T {
pub fn make_unique(&mut self) -> &mut T {
// Note that we hold a strong reference, which also counts as
// a weak reference, so we only clone if there is an
// additional reference of either kind.
Expand All @@ -247,7 +247,7 @@ impl<T: Clone> Rc<T> {
impl<T> Deref<T> for Rc<T> {
/// Borrow the value contained in the reference-counted box
#[inline(always)]
fn deref<'a>(&'a self) -> &'a T {
fn deref(&self) -> &T {
&self.inner().value
}
}
Expand Down Expand Up @@ -390,7 +390,7 @@ impl<T> Clone for Weak<T> {

#[doc(hidden)]
trait RcBoxPtr<T> {
fn inner<'a>(&'a self) -> &'a RcBox<T>;
fn inner(&self) -> &RcBox<T>;

#[inline]
fn strong(&self) -> uint { self.inner().strong.get() }
Expand All @@ -413,12 +413,12 @@ trait RcBoxPtr<T> {

impl<T> RcBoxPtr<T> for Rc<T> {
#[inline(always)]
fn inner<'a>(&'a self) -> &'a RcBox<T> { unsafe { &(*self._ptr) } }
fn inner(&self) -> &RcBox<T> { unsafe { &(*self._ptr) } }
}

impl<T> RcBoxPtr<T> for Weak<T> {
#[inline(always)]
fn inner<'a>(&'a self) -> &'a RcBox<T> { unsafe { &(*self._ptr) } }
fn inner(&self) -> &RcBox<T> { unsafe { &(*self._ptr) } }
}

#[cfg(test)]
Expand Down
12 changes: 6 additions & 6 deletions src/libarena/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ impl Arena {
}

#[inline]
fn alloc_copy<'a, T>(&'a self, op: || -> T) -> &'a T {
fn alloc_copy<T>(&self, op: || -> T) -> &T {
unsafe {
let ptr = self.alloc_copy_inner(mem::size_of::<T>(),
mem::min_align_of::<T>());
Expand Down Expand Up @@ -261,7 +261,7 @@ impl Arena {
}

#[inline]
fn alloc_noncopy<'a, T>(&'a self, op: || -> T) -> &'a T {
fn alloc_noncopy<T>(&self, op: || -> T) -> &T {
unsafe {
let tydesc = get_tydesc::<T>();
let (ty_ptr, ptr) =
Expand All @@ -285,7 +285,7 @@ impl Arena {
/// Allocate a new item in the arena, using `op` to initialize the value
/// and returning a reference to it.
#[inline]
pub fn alloc<'a, T>(&'a self, op: || -> T) -> &'a T {
pub fn alloc<T>(&self, op: || -> T) -> &T {
unsafe {
if intrinsics::needs_drop::<T>() {
self.alloc_noncopy(op)
Expand Down Expand Up @@ -458,13 +458,13 @@ impl<T> TypedArena<T> {

/// Allocates an object in the TypedArena, returning a reference to it.
#[inline]
pub fn alloc<'a>(&'a self, object: T) -> &'a T {
pub fn alloc(&self, object: T) -> &T {
if self.ptr == self.end {
self.grow()
}

let ptr: &'a T = unsafe {
let ptr: &'a mut T = mem::transmute(self.ptr);
let ptr: &T = unsafe {
let ptr: &mut T = mem::transmute(self.ptr);
ptr::write(ptr, object);
self.ptr.set(self.ptr.get().offset(1));
ptr
Expand Down
2 changes: 1 addition & 1 deletion src/libtest/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ impl<T: FloatMath + FromPrimitive> Summary<T> {
}
}

impl<'a,T: FloatMath + FromPrimitive> Stats<T> for &'a [T] {
impl<'a, T: FloatMath + FromPrimitive> Stats<T> for &'a [T] {

// FIXME #11059 handle NaN, inf and overflow
fn sum(self) -> T {
Expand Down
11 changes: 5 additions & 6 deletions src/liburl/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ pub fn decode_form_urlencoded(s: &[u8])
}
}

fn split_char_first<'a>(s: &'a str, c: char) -> (&'a str, &'a str) {
fn split_char_first(s: &str, c: char) -> (&str, &str) {
let mut iter = s.splitn(c, 1);

match (iter.next(), iter.next()) {
Expand Down Expand Up @@ -461,7 +461,7 @@ pub fn query_to_str(query: &Query) -> String {
/// };
/// println!("Scheme in use: {}.", scheme); // Scheme in use: https.
/// ```
pub fn get_scheme<'a>(rawurl: &'a str) -> DecodeResult<(&'a str, &'a str)> {
pub fn get_scheme(rawurl: &str) -> DecodeResult<(&str, &str)> {
for (i,c) in rawurl.chars().enumerate() {
let result = match c {
'A' .. 'Z'
Expand All @@ -488,8 +488,8 @@ pub fn get_scheme<'a>(rawurl: &'a str) -> DecodeResult<(&'a str, &'a str)> {
}

// returns userinfo, host, port, and unparsed part, or an error
fn get_authority<'a>(rawurl: &'a str) ->
DecodeResult<(Option<UserInfo>, &'a str, Option<u16>, &'a str)> {
fn get_authority(rawurl: &str) ->
DecodeResult<(Option<UserInfo>, &str, Option<u16>, &str)> {
enum State {
Start, // starting state
PassHostPort, // could be in user or port
Expand Down Expand Up @@ -657,8 +657,7 @@ fn get_authority<'a>(rawurl: &'a str) ->


// returns the path and unparsed part of url, or an error
fn get_path<'a>(rawurl: &'a str, is_authority: bool)
-> DecodeResult<(String, &'a str)> {
fn get_path(rawurl: &str, is_authority: bool) -> DecodeResult<(String, &str)> {
let len = rawurl.len();
let mut end = len;
for (i,c) in rawurl.chars().enumerate() {
Expand Down
2 changes: 1 addition & 1 deletion src/libuuid/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ impl Uuid {
}

/// Return an array of 16 octets containing the UUID data
pub fn as_bytes<'a>(&'a self) -> &'a [u8] {
pub fn as_bytes(&self) -> &[u8] {
self.bytes.as_slice()
}

Expand Down