Skip to content

Commit f861848

Browse files
omasanorialexcrichton
authored andcommitted
alloc, arena, test, url, uuid: Elide lifetimes.
Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
1 parent 2467c6e commit f861848

File tree

5 files changed

+18
-19
lines changed

5 files changed

+18
-19
lines changed

src/liballoc/rc.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ impl<T: Clone> Rc<T> {
226226
/// data is cloned if the reference count is greater than one.
227227
#[inline]
228228
#[experimental]
229-
pub fn make_unique<'a>(&'a mut self) -> &'a mut T {
229+
pub fn make_unique(&mut self) -> &mut T {
230230
// Note that we hold a strong reference, which also counts as
231231
// a weak reference, so we only clone if there is an
232232
// additional reference of either kind.
@@ -247,7 +247,7 @@ impl<T: Clone> Rc<T> {
247247
impl<T> Deref<T> for Rc<T> {
248248
/// Borrow the value contained in the reference-counted box
249249
#[inline(always)]
250-
fn deref<'a>(&'a self) -> &'a T {
250+
fn deref(&self) -> &T {
251251
&self.inner().value
252252
}
253253
}
@@ -390,7 +390,7 @@ impl<T> Clone for Weak<T> {
390390

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

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

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

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

424424
#[cfg(test)]

src/libarena/lib.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ impl Arena {
207207
}
208208

209209
#[inline]
210-
fn alloc_copy<'a, T>(&'a self, op: || -> T) -> &'a T {
210+
fn alloc_copy<T>(&self, op: || -> T) -> &T {
211211
unsafe {
212212
let ptr = self.alloc_copy_inner(mem::size_of::<T>(),
213213
mem::min_align_of::<T>());
@@ -261,7 +261,7 @@ impl Arena {
261261
}
262262

263263
#[inline]
264-
fn alloc_noncopy<'a, T>(&'a self, op: || -> T) -> &'a T {
264+
fn alloc_noncopy<T>(&self, op: || -> T) -> &T {
265265
unsafe {
266266
let tydesc = get_tydesc::<T>();
267267
let (ty_ptr, ptr) =
@@ -285,7 +285,7 @@ impl Arena {
285285
/// Allocate a new item in the arena, using `op` to initialize the value
286286
/// and returning a reference to it.
287287
#[inline]
288-
pub fn alloc<'a, T>(&'a self, op: || -> T) -> &'a T {
288+
pub fn alloc<T>(&self, op: || -> T) -> &T {
289289
unsafe {
290290
if intrinsics::needs_drop::<T>() {
291291
self.alloc_noncopy(op)
@@ -458,13 +458,13 @@ impl<T> TypedArena<T> {
458458

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

466-
let ptr: &'a T = unsafe {
467-
let ptr: &'a mut T = mem::transmute(self.ptr);
466+
let ptr: &T = unsafe {
467+
let ptr: &mut T = mem::transmute(self.ptr);
468468
ptr::write(ptr, object);
469469
self.ptr.set(self.ptr.get().offset(1));
470470
ptr

src/libtest/stats.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ impl<T: FloatMath + FromPrimitive> Summary<T> {
164164
}
165165
}
166166

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

169169
// FIXME #11059 handle NaN, inf and overflow
170170
fn sum(self) -> T {

src/liburl/lib.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ pub fn decode_form_urlencoded(s: &[u8])
394394
}
395395
}
396396

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

400400
match (iter.next(), iter.next()) {
@@ -466,7 +466,7 @@ pub fn query_to_str(query: &Query) -> String {
466466
/// };
467467
/// println!("Scheme in use: {}.", scheme); // Scheme in use: https.
468468
/// ```
469-
pub fn get_scheme<'a>(rawurl: &'a str) -> DecodeResult<(&'a str, &'a str)> {
469+
pub fn get_scheme(rawurl: &str) -> DecodeResult<(&str, &str)> {
470470
for (i,c) in rawurl.chars().enumerate() {
471471
let result = match c {
472472
'A' .. 'Z'
@@ -493,8 +493,8 @@ pub fn get_scheme<'a>(rawurl: &'a str) -> DecodeResult<(&'a str, &'a str)> {
493493
}
494494

495495
// returns userinfo, host, port, and unparsed part, or an error
496-
fn get_authority<'a>(rawurl: &'a str) ->
497-
DecodeResult<(Option<UserInfo>, &'a str, Option<u16>, &'a str)> {
496+
fn get_authority(rawurl: &str) ->
497+
DecodeResult<(Option<UserInfo>, &str, Option<u16>, &str)> {
498498
enum State {
499499
Start, // starting state
500500
PassHostPort, // could be in user or port
@@ -662,8 +662,7 @@ fn get_authority<'a>(rawurl: &'a str) ->
662662

663663

664664
// returns the path and unparsed part of url, or an error
665-
fn get_path<'a>(rawurl: &'a str, is_authority: bool)
666-
-> DecodeResult<(String, &'a str)> {
665+
fn get_path(rawurl: &str, is_authority: bool) -> DecodeResult<(String, &str)> {
667666
let len = rawurl.len();
668667
let mut end = len;
669668
for (i,c) in rawurl.chars().enumerate() {

src/libuuid/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ impl Uuid {
313313
}
314314

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

0 commit comments

Comments
 (0)