diff --git a/src/libcollections/bit.rs b/src/libcollections/bit.rs index a0c4f6e7ee8c7..6113e2323c1f7 100644 --- a/src/libcollections/bit.rs +++ b/src/libcollections/bit.rs @@ -154,7 +154,7 @@ struct MaskWords<'a> { impl<'a> Iterator<(uint, u32)> for MaskWords<'a> { /// Returns (offset, word) #[inline] - fn next<'a>(&'a mut self) -> Option<(uint, u32)> { + fn next(&mut self) -> Option<(uint, u32)> { let ret = self.next_word; match ret { Some(&w) => { diff --git a/src/libcollections/btree/map.rs b/src/libcollections/btree/map.rs index e49a8ddbe5ab8..00f4eac2858e2 100644 --- a/src/libcollections/btree/map.rs +++ b/src/libcollections/btree/map.rs @@ -561,7 +561,7 @@ mod stack { impl<'a, K, V> PartialSearchStack<'a, K, V> { /// Creates a new PartialSearchStack from a BTreeMap by initializing the stack with the /// root of the tree. - pub fn new<'a>(map: &'a mut BTreeMap) -> PartialSearchStack<'a, K, V> { + pub fn new(map: &'a mut BTreeMap) -> PartialSearchStack<'a, K, V> { let depth = map.depth; PartialSearchStack { diff --git a/src/libcollections/dlist.rs b/src/libcollections/dlist.rs index df86ac96424b5..3ae66954e9c97 100644 --- a/src/libcollections/dlist.rs +++ b/src/libcollections/dlist.rs @@ -692,7 +692,7 @@ impl<'a, A> ListInsertion for MutItems<'a, A> { } #[inline] - fn peek_next<'a>(&'a mut self) -> Option<&'a mut A> { + fn peek_next(&mut self) -> Option<&mut A> { if self.nelem == 0 { return None } diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs index 37a1d4d564d84..1dac70383515e 100644 --- a/src/libcore/fmt/mod.rs +++ b/src/libcore/fmt/mod.rs @@ -115,7 +115,7 @@ impl<'a> Argument<'a> { Show::fmt(x, f) } - fn new<'a, T>(x: &'a T, f: fn(&T, &mut Formatter) -> Result) -> Argument<'a> { + fn new<'b, T>(x: &'b T, f: fn(&T, &mut Formatter) -> Result) -> Argument<'b> { unsafe { Argument { formatter: mem::transmute(f), @@ -124,7 +124,7 @@ impl<'a> Argument<'a> { } } - fn from_uint<'a>(x: &'a uint) -> Argument<'a> { + fn from_uint(x: &uint) -> Argument { Argument::new(x, Argument::show_uint) } @@ -144,8 +144,8 @@ impl<'a> Arguments<'a> { /// Arguments structure. #[doc(hidden)] #[inline] #[experimental = "implementation detail of the `format_args!` macro"] - pub fn new<'a>(pieces: &'a [&'a str], - args: &'a [Argument<'a>]) -> Arguments<'a> { + pub fn new(pieces: &'a [&'a str], + args: &'a [Argument<'a>]) -> Arguments<'a> { Arguments { pieces: pieces, fmt: None, @@ -161,9 +161,9 @@ impl<'a> Arguments<'a> { /// unsafety, but will ignore invalid . #[doc(hidden)] #[inline] #[experimental = "implementation detail of the `format_args!` macro"] - pub fn with_placeholders<'a>(pieces: &'a [&'a str], - fmt: &'a [rt::Argument<'a>], - args: &'a [Argument<'a>]) -> Arguments<'a> { + pub fn with_placeholders(pieces: &'a [&'a str], + fmt: &'a [rt::Argument<'a>], + args: &'a [Argument<'a>]) -> Arguments<'a> { Arguments { pieces: pieces, fmt: Some(fmt), diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs index 27a4328ba8017..209edf9043955 100644 --- a/src/libcore/slice.rs +++ b/src/libcore/slice.rs @@ -1036,12 +1036,12 @@ impl AsSlice for [T] { impl<'a, T, Sized? U: AsSlice> AsSlice for &'a U { #[inline(always)] - fn as_slice<'a>(&'a self) -> &'a [T] { AsSlice::as_slice(*self) } + fn as_slice(&self) -> &[T] { AsSlice::as_slice(*self) } } impl<'a, T, Sized? U: AsSlice> AsSlice for &'a mut U { #[inline(always)] - fn as_slice<'a>(&'a self) -> &'a [T] { AsSlice::as_slice(*self) } + fn as_slice(&self) -> &[T] { AsSlice::as_slice(*self) } } #[unstable = "waiting for DST"] diff --git a/src/libfmt_macros/lib.rs b/src/libfmt_macros/lib.rs index db389457a1e47..444806e78c129 100644 --- a/src/libfmt_macros/lib.rs +++ b/src/libfmt_macros/lib.rs @@ -185,7 +185,7 @@ impl<'a> Iterator> for Parser<'a> { impl<'a> Parser<'a> { /// Creates a new parser for the given format string - pub fn new<'a>(s: &'a str) -> Parser<'a> { + pub fn new(s: &'a str) -> Parser<'a> { Parser { input: s, cur: s.char_indices(), diff --git a/src/libgraphviz/lib.rs b/src/libgraphviz/lib.rs index fa048346e99b5..8ce761580b762 100644 --- a/src/libgraphviz/lib.rs +++ b/src/libgraphviz/lib.rs @@ -165,10 +165,10 @@ //! fn node_id(&'a self, n: &Nd) -> dot::Id<'a> { //! dot::Id::new(format!("N{}", n)).unwrap() //! } -//! fn node_label<'a>(&'a self, n: &Nd) -> dot::LabelText<'a> { +//! fn node_label<'b>(&'b self, n: &Nd) -> dot::LabelText<'b> { //! dot::LabelStr(self.nodes[*n].as_slice().into_cow()) //! } -//! fn edge_label<'a>(&'a self, _: &Ed) -> dot::LabelText<'a> { +//! fn edge_label<'b>(&'b self, _: &Ed) -> dot::LabelText<'b> { //! dot::LabelStr("⊆".into_cow()) //! } //! } @@ -220,11 +220,11 @@ //! fn node_id(&'a self, n: &Nd<'a>) -> dot::Id<'a> { //! dot::Id::new(format!("N{}", n.0)).unwrap() //! } -//! fn node_label<'a>(&'a self, n: &Nd<'a>) -> dot::LabelText<'a> { +//! fn node_label<'b>(&'b self, n: &Nd<'b>) -> dot::LabelText<'b> { //! let &(i, _) = n; //! dot::LabelStr(self.nodes[i].as_slice().into_cow()) //! } -//! fn edge_label<'a>(&'a self, _: &Ed<'a>) -> dot::LabelText<'a> { +//! fn edge_label<'b>(&'b self, _: &Ed<'b>) -> dot::LabelText<'b> { //! dot::LabelStr("⊆".into_cow()) //! } //! } diff --git a/src/libgraphviz/maybe_owned_vec.rs b/src/libgraphviz/maybe_owned_vec.rs index 7ebf9b6335208..f017bed737ac3 100644 --- a/src/libgraphviz/maybe_owned_vec.rs +++ b/src/libgraphviz/maybe_owned_vec.rs @@ -169,7 +169,7 @@ impl<'a, T> Default for MaybeOwnedVector<'a, T> { } impl<'a> BytesContainer for MaybeOwnedVector<'a, u8> { - fn container_as_bytes<'a>(&'a self) -> &'a [u8] { + fn container_as_bytes(&self) -> &[u8] { self.as_slice() } } diff --git a/src/librand/distributions/mod.rs b/src/librand/distributions/mod.rs index a44197c98590c..58125c67fdae9 100644 --- a/src/librand/distributions/mod.rs +++ b/src/librand/distributions/mod.rs @@ -114,7 +114,7 @@ impl<'a, T: Clone> WeightedChoice<'a, T> { /// - `v` is empty /// - the total weight is 0 /// - the total weight is larger than a `uint` can contain. - pub fn new<'a>(items: &'a mut [Weighted]) -> WeightedChoice<'a, T> { + pub fn new(items: &'a mut [Weighted]) -> WeightedChoice<'a, T> { // strictly speaking, this is subsumed by the total weight == 0 case assert!(!items.is_empty(), "WeightedChoice::new called with no items"); diff --git a/src/librustc/middle/astencode.rs b/src/librustc/middle/astencode.rs index 26d70502a5b16..8fad90adc9db0 100644 --- a/src/librustc/middle/astencode.rs +++ b/src/librustc/middle/astencode.rs @@ -601,7 +601,7 @@ fn encode_method_callee<'a, 'tcx>(ecx: &e::EncodeContext<'a, 'tcx>, } impl<'a, 'tcx> read_method_callee_helper<'tcx> for reader::Decoder<'a> { - fn read_method_callee<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>) + fn read_method_callee<'b, 'c>(&mut self, dcx: &DecodeContext<'b, 'c, 'tcx>) -> (ty::ExprAdjustment, MethodCallee<'tcx>) { self.read_struct("MethodCallee", 4, |this| { @@ -810,7 +810,7 @@ trait get_ty_str_ctxt<'tcx> { } impl<'a, 'tcx> get_ty_str_ctxt<'tcx> for e::EncodeContext<'a, 'tcx> { - fn ty_str_ctxt<'a>(&'a self) -> tyencode::ctxt<'a, 'tcx> { + fn ty_str_ctxt<'b>(&'b self) -> tyencode::ctxt<'b, 'tcx> { tyencode::ctxt { diag: self.tcx.sess.diagnostic(), ds: e::def_to_string, @@ -851,16 +851,16 @@ trait rbml_writer_helpers<'tcx> { } impl<'a, 'tcx> rbml_writer_helpers<'tcx> for Encoder<'a> { - fn emit_closure_type<'a>(&mut self, - ecx: &e::EncodeContext<'a, 'tcx>, + fn emit_closure_type<'b>(&mut self, + ecx: &e::EncodeContext<'b, 'tcx>, closure_type: &ty::ClosureTy<'tcx>) { self.emit_opaque(|this| { Ok(e::write_closure_type(ecx, this, closure_type)) }); } - fn emit_method_origin<'a>(&mut self, - ecx: &e::EncodeContext<'a, 'tcx>, + fn emit_method_origin<'b>(&mut self, + ecx: &e::EncodeContext<'b, 'tcx>, method_origin: &ty::MethodOrigin<'tcx>) { use serialize::Encoder; @@ -916,20 +916,20 @@ impl<'a, 'tcx> rbml_writer_helpers<'tcx> for Encoder<'a> { }); } - fn emit_ty<'a>(&mut self, ecx: &e::EncodeContext<'a, 'tcx>, ty: Ty<'tcx>) { + fn emit_ty<'b>(&mut self, ecx: &e::EncodeContext<'b, 'tcx>, ty: Ty<'tcx>) { self.emit_opaque(|this| Ok(e::write_type(ecx, this, ty))); } - fn emit_tys<'a>(&mut self, ecx: &e::EncodeContext<'a, 'tcx>, tys: &[Ty<'tcx>]) { + fn emit_tys<'b>(&mut self, ecx: &e::EncodeContext<'b, 'tcx>, tys: &[Ty<'tcx>]) { self.emit_from_vec(tys, |this, ty| Ok(this.emit_ty(ecx, *ty))); } - fn emit_trait_ref<'a>(&mut self, ecx: &e::EncodeContext<'a, 'tcx>, + fn emit_trait_ref<'b>(&mut self, ecx: &e::EncodeContext<'b, 'tcx>, trait_ref: &ty::TraitRef<'tcx>) { self.emit_opaque(|this| Ok(e::write_trait_ref(ecx, this, trait_ref))); } - fn emit_type_param_def<'a>(&mut self, ecx: &e::EncodeContext<'a, 'tcx>, + fn emit_type_param_def<'b>(&mut self, ecx: &e::EncodeContext<'b, 'tcx>, type_param_def: &ty::TypeParameterDef<'tcx>) { self.emit_opaque(|this| { Ok(tyencode::enc_type_param_def(this.writer, @@ -938,7 +938,7 @@ impl<'a, 'tcx> rbml_writer_helpers<'tcx> for Encoder<'a> { }); } - fn emit_predicate<'a>(&mut self, ecx: &e::EncodeContext<'a, 'tcx>, + fn emit_predicate<'b>(&mut self, ecx: &e::EncodeContext<'b, 'tcx>, predicate: &ty::Predicate<'tcx>) { self.emit_opaque(|this| { Ok(tyencode::enc_predicate(this.writer, @@ -947,8 +947,8 @@ impl<'a, 'tcx> rbml_writer_helpers<'tcx> for Encoder<'a> { }); } - fn emit_polytype<'a>(&mut self, - ecx: &e::EncodeContext<'a, 'tcx>, + fn emit_polytype<'b>(&mut self, + ecx: &e::EncodeContext<'b, 'tcx>, pty: ty::Polytype<'tcx>) { use serialize::Encoder; @@ -990,14 +990,14 @@ impl<'a, 'tcx> rbml_writer_helpers<'tcx> for Encoder<'a> { bounds))); } - fn emit_substs<'a>(&mut self, ecx: &e::EncodeContext<'a, 'tcx>, + fn emit_substs<'b>(&mut self, ecx: &e::EncodeContext<'b, 'tcx>, substs: &subst::Substs<'tcx>) { self.emit_opaque(|this| Ok(tyencode::enc_substs(this.writer, &ecx.ty_str_ctxt(), substs))); } - fn emit_auto_adjustment<'a>(&mut self, ecx: &e::EncodeContext<'a, 'tcx>, + fn emit_auto_adjustment<'b>(&mut self, ecx: &e::EncodeContext<'b, 'tcx>, adj: &ty::AutoAdjustment<'tcx>) { use serialize::Encoder; @@ -1019,7 +1019,7 @@ impl<'a, 'tcx> rbml_writer_helpers<'tcx> for Encoder<'a> { }); } - fn emit_autoref<'a>(&mut self, ecx: &e::EncodeContext<'a, 'tcx>, + fn emit_autoref<'b>(&mut self, ecx: &e::EncodeContext<'b, 'tcx>, autoref: &ty::AutoRef<'tcx>) { use serialize::Encoder; @@ -1069,7 +1069,7 @@ impl<'a, 'tcx> rbml_writer_helpers<'tcx> for Encoder<'a> { }); } - fn emit_auto_deref_ref<'a>(&mut self, ecx: &e::EncodeContext<'a, 'tcx>, + fn emit_auto_deref_ref<'b>(&mut self, ecx: &e::EncodeContext<'b, 'tcx>, auto_deref_ref: &ty::AutoDerefRef<'tcx>) { use serialize::Encoder; @@ -1086,7 +1086,7 @@ impl<'a, 'tcx> rbml_writer_helpers<'tcx> for Encoder<'a> { }); } - fn emit_unsize_kind<'a>(&mut self, ecx: &e::EncodeContext<'a, 'tcx>, + fn emit_unsize_kind<'b>(&mut self, ecx: &e::EncodeContext<'b, 'tcx>, uk: &ty::UnsizeKind<'tcx>) { use serialize::Encoder; @@ -1427,7 +1427,7 @@ impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> { }).unwrap() } - fn read_method_origin<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>) + fn read_method_origin<'b, 'c>(&mut self, dcx: &DecodeContext<'b, 'c, 'tcx>) -> ty::MethodOrigin<'tcx> { self.read_enum("MethodOrigin", |this| { @@ -1498,7 +1498,7 @@ impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> { } - fn read_ty<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>) -> Ty<'tcx> { + fn read_ty<'b, 'c>(&mut self, dcx: &DecodeContext<'b, 'c, 'tcx>) -> Ty<'tcx> { // Note: regions types embed local node ids. In principle, we // should translate these node ids into the new decode // context. However, we do not bother, because region types @@ -1526,12 +1526,12 @@ impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> { } } - fn read_tys<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>) + fn read_tys<'b, 'c>(&mut self, dcx: &DecodeContext<'b, 'c, 'tcx>) -> Vec> { self.read_to_vec(|this| Ok(this.read_ty(dcx))).unwrap().into_iter().collect() } - fn read_trait_ref<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>) + fn read_trait_ref<'b, 'c>(&mut self, dcx: &DecodeContext<'b, 'c, 'tcx>) -> Rc> { Rc::new(self.read_opaque(|this, doc| { let ty = tydecode::parse_trait_ref_data( @@ -1544,7 +1544,7 @@ impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> { }).unwrap()) } - fn read_type_param_def<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>) + fn read_type_param_def<'b, 'c>(&mut self, dcx: &DecodeContext<'b, 'c, 'tcx>) -> ty::TypeParameterDef<'tcx> { self.read_opaque(|this, doc| { Ok(tydecode::parse_type_param_def_data( @@ -1556,7 +1556,7 @@ impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> { }).unwrap() } - fn read_predicate<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>) + fn read_predicate<'b, 'c>(&mut self, dcx: &DecodeContext<'b, 'c, 'tcx>) -> ty::Predicate<'tcx> { self.read_opaque(|this, doc| { @@ -1565,7 +1565,7 @@ impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> { }).unwrap() } - fn read_polytype<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>) + fn read_polytype<'b, 'c>(&mut self, dcx: &DecodeContext<'b, 'c, 'tcx>) -> ty::Polytype<'tcx> { self.read_struct("Polytype", 2, |this| { Ok(ty::Polytype { @@ -1599,7 +1599,7 @@ impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> { }).unwrap() } - fn read_existential_bounds<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>) + fn read_existential_bounds<'b, 'c>(&mut self, dcx: &DecodeContext<'b, 'c, 'tcx>) -> ty::ExistentialBounds { self.read_opaque(|this, doc| { @@ -1611,7 +1611,7 @@ impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> { }).unwrap() } - fn read_substs<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>) + fn read_substs<'b, 'c>(&mut self, dcx: &DecodeContext<'b, 'c, 'tcx>) -> subst::Substs<'tcx> { self.read_opaque(|this, doc| { Ok(tydecode::parse_substs_data(doc.data, @@ -1622,7 +1622,7 @@ impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> { }).unwrap() } - fn read_auto_adjustment<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>) + fn read_auto_adjustment<'b, 'c>(&mut self, dcx: &DecodeContext<'b, 'c, 'tcx>) -> ty::AutoAdjustment<'tcx> { self.read_enum("AutoAdjustment", |this| { let variants = ["AutoAddEnv", "AutoDerefRef"]; @@ -1647,7 +1647,7 @@ impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> { }).unwrap() } - fn read_auto_deref_ref<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>) + fn read_auto_deref_ref<'b, 'c>(&mut self, dcx: &DecodeContext<'b, 'c, 'tcx>) -> ty::AutoDerefRef<'tcx> { self.read_struct("AutoDerefRef", 2, |this| { Ok(ty::AutoDerefRef { @@ -1667,7 +1667,7 @@ impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> { }).unwrap() } - fn read_autoref<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>) -> ty::AutoRef<'tcx> { + fn read_autoref<'b, 'c>(&mut self, dcx: &DecodeContext<'b, 'c, 'tcx>) -> ty::AutoRef<'tcx> { self.read_enum("AutoRef", |this| { let variants = ["AutoPtr", "AutoUnsize", @@ -1725,7 +1725,7 @@ impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> { }).unwrap() } - fn read_unsize_kind<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>) + fn read_unsize_kind<'b, 'c>(&mut self, dcx: &DecodeContext<'b, 'c, 'tcx>) -> ty::UnsizeKind<'tcx> { self.read_enum("UnsizeKind", |this| { let variants = &["UnsizeLength", "UnsizeStruct", "UnsizeVtable"]; @@ -1768,7 +1768,7 @@ impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> { }).unwrap() } - fn read_unboxed_closure<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>) + fn read_unboxed_closure<'b, 'c>(&mut self, dcx: &DecodeContext<'b, 'c, 'tcx>) -> ty::UnboxedClosure<'tcx> { let closure_type = self.read_opaque(|this, doc| { Ok(tydecode::parse_ty_closure_data( diff --git a/src/librustc/middle/cfg/construct.rs b/src/librustc/middle/cfg/construct.rs index b6347278bffda..5c39c9fa74d0a 100644 --- a/src/librustc/middle/cfg/construct.rs +++ b/src/librustc/middle/cfg/construct.rs @@ -151,7 +151,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> { } } - fn pats_all<'a, I: Iterator<&'a P>>(&mut self, + fn pats_all<'b, I: Iterator<&'b P>>(&mut self, pats: I, pred: CFGIndex) -> CFGIndex { //! Handles case where all of the patterns must match. @@ -505,7 +505,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> { } } - fn call<'a, I: Iterator<&'a ast::Expr>>(&mut self, + fn call<'b, I: Iterator<&'b ast::Expr>>(&mut self, call_expr: &ast::Expr, pred: CFGIndex, func_or_rcvr: &ast::Expr, @@ -525,7 +525,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> { } } - fn exprs<'a, I: Iterator<&'a ast::Expr>>(&mut self, + fn exprs<'b, I: Iterator<&'b ast::Expr>>(&mut self, exprs: I, pred: CFGIndex) -> CFGIndex { //! Constructs graph for `exprs` evaluated in order @@ -539,7 +539,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> { opt_expr.iter().fold(pred, |p, e| self.expr(&**e, p)) } - fn straightline<'a, I: Iterator<&'a ast::Expr>>(&mut self, + fn straightline<'b, I: Iterator<&'b ast::Expr>>(&mut self, expr: &ast::Expr, pred: CFGIndex, subexprs: I) -> CFGIndex { diff --git a/src/librustc/middle/check_match.rs b/src/librustc/middle/check_match.rs index 669f4ee6ec81c..034bf3e840a89 100644 --- a/src/librustc/middle/check_match.rs +++ b/src/librustc/middle/check_match.rs @@ -392,7 +392,7 @@ pub struct StaticInliner<'a, 'tcx: 'a> { } impl<'a, 'tcx> StaticInliner<'a, 'tcx> { - pub fn new<'a>(tcx: &'a ty::ctxt<'tcx>) -> StaticInliner<'a, 'tcx> { + pub fn new<'b>(tcx: &'b ty::ctxt<'tcx>) -> StaticInliner<'b, 'tcx> { StaticInliner { tcx: tcx, failed: false diff --git a/src/librustc/middle/infer/mod.rs b/src/librustc/middle/infer/mod.rs index 2b1d8776365ec..3cd981b57844c 100644 --- a/src/librustc/middle/infer/mod.rs +++ b/src/librustc/middle/infer/mod.rs @@ -539,29 +539,29 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { } } - pub fn skolemizer<'a>(&'a self) -> TypeSkolemizer<'a, 'tcx> { + pub fn skolemizer<'b>(&'b self) -> TypeSkolemizer<'b, 'tcx> { skolemize::TypeSkolemizer::new(self) } - pub fn combine_fields<'a>(&'a self, a_is_expected: bool, trace: TypeTrace<'tcx>) - -> CombineFields<'a, 'tcx> { + pub fn combine_fields<'b>(&'b self, a_is_expected: bool, trace: TypeTrace<'tcx>) + -> CombineFields<'b, 'tcx> { CombineFields {infcx: self, a_is_expected: a_is_expected, trace: trace} } - pub fn equate<'a>(&'a self, a_is_expected: bool, trace: TypeTrace<'tcx>) - -> Equate<'a, 'tcx> { + pub fn equate<'b>(&'b self, a_is_expected: bool, trace: TypeTrace<'tcx>) + -> Equate<'b, 'tcx> { Equate(self.combine_fields(a_is_expected, trace)) } - pub fn sub<'a>(&'a self, a_is_expected: bool, trace: TypeTrace<'tcx>) - -> Sub<'a, 'tcx> { + pub fn sub<'b>(&'b self, a_is_expected: bool, trace: TypeTrace<'tcx>) + -> Sub<'b, 'tcx> { Sub(self.combine_fields(a_is_expected, trace)) } - pub fn lub<'a>(&'a self, a_is_expected: bool, trace: TypeTrace<'tcx>) - -> Lub<'a, 'tcx> { + pub fn lub<'b>(&'b self, a_is_expected: bool, trace: TypeTrace<'tcx>) + -> Lub<'b, 'tcx> { Lub(self.combine_fields(a_is_expected, trace)) } diff --git a/src/librustc/middle/infer/region_inference/mod.rs b/src/librustc/middle/infer/region_inference/mod.rs index 98f69f66b27fc..e855511e26f80 100644 --- a/src/librustc/middle/infer/region_inference/mod.rs +++ b/src/librustc/middle/infer/region_inference/mod.rs @@ -561,8 +561,8 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { } } - fn combine_map<'a>(&'a self, t: CombineMapType) - -> &'a RefCell { + fn combine_map(&self, t: CombineMapType) + -> &RefCell { match t { Glb => &self.glbs, Lub => &self.lubs, diff --git a/src/librustc/middle/infer/skolemize.rs b/src/librustc/middle/infer/skolemize.rs index 705b0ae730d49..8336131c54acc 100644 --- a/src/librustc/middle/infer/skolemize.rs +++ b/src/librustc/middle/infer/skolemize.rs @@ -46,7 +46,7 @@ pub struct TypeSkolemizer<'a, 'tcx:'a> { } impl<'a, 'tcx> TypeSkolemizer<'a, 'tcx> { - pub fn new<'tcx>(infcx: &'a InferCtxt<'a, 'tcx>) -> TypeSkolemizer<'a, 'tcx> { + pub fn new(infcx: &'a InferCtxt<'a, 'tcx>) -> TypeSkolemizer<'a, 'tcx> { TypeSkolemizer { infcx: infcx, skolemization_count: 0, diff --git a/src/librustc/middle/resolve_lifetime.rs b/src/librustc/middle/resolve_lifetime.rs index 48d6ac847d8d0..1923142be9e3f 100644 --- a/src/librustc/middle/resolve_lifetime.rs +++ b/src/librustc/middle/resolve_lifetime.rs @@ -90,38 +90,41 @@ pub fn krate(sess: &Session, krate: &ast::Crate, def_map: &DefMap) -> NamedRegio impl<'a, 'v> Visitor<'v> for LifetimeContext<'a> { fn visit_item(&mut self, item: &ast::Item) { - match item.node { - ast::ItemFn(..) => { - // Fn lifetimes get added in visit_fn below: - self.with(RootScope, |this| visit::walk_item(this, item)); - } - ast::ItemMod(..) | - ast::ItemMac(..) | - ast::ItemForeignMod(..) | - ast::ItemStatic(..) | - ast::ItemConst(..) => { - // These sorts of items have no lifetime parameters at all. - self.with(RootScope, |this| visit::walk_item(this, item)); - } - ast::ItemTy(_, ref generics) | - ast::ItemEnum(_, ref generics) | - ast::ItemStruct(_, ref generics) | - ast::ItemTrait(_, ref generics, _, _, _) => { - // These kinds of items have only early bound lifetime parameters. - let lifetimes = &generics.lifetimes; - self.with(EarlyScope(subst::TypeSpace, lifetimes, &ROOT_SCOPE), |this| { - this.check_lifetime_defs(lifetimes); + // Items always introduce a new root scope + self.with(RootScope, |_, this| { + match item.node { + ast::ItemFn(..) => { + // Fn lifetimes get added in visit_fn below: visit::walk_item(this, item); - }); - } - ast::ItemImpl(_, ref generics, _, _, _) => { - // Impls have both early- and late-bound lifetimes. - self.visit_early_late(subst::TypeSpace, generics, |this| { - this.check_lifetime_defs(&generics.lifetimes); + } + ast::ItemMod(..) | + ast::ItemMac(..) | + ast::ItemForeignMod(..) | + ast::ItemStatic(..) | + ast::ItemConst(..) => { + // These sorts of items have no lifetime parameters at all. visit::walk_item(this, item); - }) + } + ast::ItemTy(_, ref generics) | + ast::ItemEnum(_, ref generics) | + ast::ItemStruct(_, ref generics) | + ast::ItemTrait(_, ref generics, _, _, _) => { + // These kinds of items have only early bound lifetime parameters. + let lifetimes = &generics.lifetimes; + let early_scope = EarlyScope(subst::TypeSpace, lifetimes, &ROOT_SCOPE); + this.with(early_scope, |old_scope, this| { + this.check_lifetime_defs(old_scope, lifetimes); + visit::walk_item(this, item); + }); + } + ast::ItemImpl(_, ref generics, _, _, _) => { + // Impls have both early- and late-bound lifetimes. + this.visit_early_late(subst::TypeSpace, generics, |this| { + visit::walk_item(this, item); + }) + } } - } + }); } fn visit_fn(&mut self, fk: visit::FnKind<'v>, fd: &'v ast::FnDecl, @@ -129,9 +132,9 @@ impl<'a, 'v> Visitor<'v> for LifetimeContext<'a> { match fk { visit::FkItemFn(_, generics, _, _) | visit::FkMethod(_, generics, _) => { - self.visit_early_late( - subst::FnSpace, generics, - |this| visit::walk_fn(this, fk, fd, b, s)) + self.visit_early_late(subst::FnSpace, generics, |this| { + visit::walk_fn(this, fk, fd, b, s) + }) } visit::FkFnBlock(..) => { visit::walk_fn(self, fk, fd, b, s) @@ -145,8 +148,8 @@ impl<'a, 'v> Visitor<'v> for LifetimeContext<'a> { // Careful, the bounds on a closure/proc are *not* within its binder. visit::walk_ty_param_bounds_helper(self, &c.bounds); visit::walk_lifetime_decls_helper(self, &c.lifetimes); - self.with(LateScope(&c.lifetimes, self.scope), |this| { - this.check_lifetime_defs(&c.lifetimes); + self.with(LateScope(&c.lifetimes, self.scope), |old_scope, this| { + this.check_lifetime_defs(old_scope, &c.lifetimes); for argument in c.decl.inputs.iter() { this.visit_ty(&*argument.ty) } @@ -155,10 +158,10 @@ impl<'a, 'v> Visitor<'v> for LifetimeContext<'a> { } ast::TyBareFn(ref c) => { visit::walk_lifetime_decls_helper(self, &c.lifetimes); - self.with(LateScope(&c.lifetimes, self.scope), |this| { + self.with(LateScope(&c.lifetimes, self.scope), |old_scope, this| { // a bare fn has no bounds, so everything // contained within is scoped within its binder. - this.check_lifetime_defs(&c.lifetimes); + this.check_lifetime_defs(old_scope, &c.lifetimes); visit::walk_ty(this, ty); }); } @@ -167,7 +170,7 @@ impl<'a, 'v> Visitor<'v> for LifetimeContext<'a> { // a trait ref, which introduces a binding scope. match self.def_map.borrow().get(&id) { Some(&def::DefTrait(..)) => { - self.with(LateScope(&Vec::new(), self.scope), |this| { + self.with(LateScope(&Vec::new(), self.scope), |_, this| { this.visit_path(path, id); }); } @@ -190,7 +193,7 @@ impl<'a, 'v> Visitor<'v> for LifetimeContext<'a> { fn visit_block(&mut self, b: &ast::Block) { self.with(BlockScope(region::CodeExtent::from_node_id(b.id), self.scope), - |this| visit::walk_block(this, b)); + |_, this| visit::walk_block(this, b)); } fn visit_lifetime_ref(&mut self, lifetime_ref: &ast::Lifetime) { @@ -232,8 +235,8 @@ impl<'a, 'v> Visitor<'v> for LifetimeContext<'a> { fn visit_poly_trait_ref(&mut self, trait_ref: &ast::PolyTraitRef) { debug!("visit_poly_trait_ref trait_ref={}", trait_ref); - self.with(LateScope(&trait_ref.bound_lifetimes, self.scope), |this| { - this.check_lifetime_defs(&trait_ref.bound_lifetimes); + self.with(LateScope(&trait_ref.bound_lifetimes, self.scope), |old_scope, this| { + this.check_lifetime_defs(old_scope, &trait_ref.bound_lifetimes); for lifetime in trait_ref.bound_lifetimes.iter() { this.visit_lifetime_def(lifetime); } @@ -248,7 +251,7 @@ impl<'a, 'v> Visitor<'v> for LifetimeContext<'a> { impl<'a> LifetimeContext<'a> { fn with(&mut self, wrap_scope: ScopeChain, f: F) where - F: FnOnce(&mut LifetimeContext), + F: FnOnce(Scope, &mut LifetimeContext), { let LifetimeContext {sess, ref mut named_region_map, ..} = *self; let mut this = LifetimeContext { @@ -258,7 +261,7 @@ impl<'a> LifetimeContext<'a> { def_map: self.def_map, }; debug!("entering scope {}", this.scope); - f(&mut this); + f(self.scope, &mut this); debug!("exiting scope {}", this.scope); } @@ -294,9 +297,9 @@ impl<'a> LifetimeContext<'a> { let (early, late) = generics.lifetimes.clone().partition( |l| referenced_idents.iter().any(|&i| i == l.lifetime.name)); - self.with(EarlyScope(early_space, &early, self.scope), move |this| { - this.with(LateScope(&late, this.scope), move |this| { - this.check_lifetime_defs(&generics.lifetimes); + self.with(EarlyScope(early_space, &early, self.scope), move |old_scope, this| { + this.with(LateScope(&late, this.scope), move |_, this| { + this.check_lifetime_defs(old_scope, &generics.lifetimes); walk(this); }); }); @@ -323,7 +326,8 @@ impl<'a> LifetimeContext<'a> { EarlyScope(space, lifetimes, s) => { match search_lifetimes(lifetimes, lifetime_ref) { - Some((index, decl_id)) => { + Some((index, lifetime_def)) => { + let decl_id = lifetime_def.id; let def = DefEarlyBoundRegion(space, index, decl_id); self.insert_lifetime(lifetime_ref, def); return; @@ -336,7 +340,8 @@ impl<'a> LifetimeContext<'a> { LateScope(lifetimes, s) => { match search_lifetimes(lifetimes, lifetime_ref) { - Some((_index, decl_id)) => { + Some((_index, lifetime_def)) => { + let decl_id = lifetime_def.id; let debruijn = ty::DebruijnIndex::new(late_depth + 1); let def = DefLateBoundRegion(debruijn, decl_id); self.insert_lifetime(lifetime_ref, def); @@ -388,8 +393,8 @@ impl<'a> LifetimeContext<'a> { } match search_result { - Some((_depth, decl_id)) => { - let def = DefFreeRegion(scope_data, decl_id); + Some((_depth, lifetime)) => { + let def = DefFreeRegion(scope_data, lifetime.id); self.insert_lifetime(lifetime_ref, def); } @@ -407,7 +412,7 @@ impl<'a> LifetimeContext<'a> { token::get_name(lifetime_ref.name)).as_slice()); } - fn check_lifetime_defs(&mut self, lifetimes: &Vec) { + fn check_lifetime_defs(&mut self, old_scope: Scope, lifetimes: &Vec) { for i in range(0, lifetimes.len()) { let lifetime_i = &lifetimes[i]; @@ -422,6 +427,7 @@ impl<'a> LifetimeContext<'a> { } } + // It is a hard error to shadow a lifetime within the same scope. for j in range(i + 1, lifetimes.len()) { let lifetime_j = &lifetimes[j]; @@ -435,12 +441,54 @@ impl<'a> LifetimeContext<'a> { } } + // It is a soft error to shadow a lifetime within a parent scope. + self.check_lifetime_def_for_shadowing(old_scope, &lifetime_i.lifetime); + for bound in lifetime_i.bounds.iter() { self.resolve_lifetime_ref(bound); } } } + fn check_lifetime_def_for_shadowing(&self, + mut old_scope: Scope, + lifetime: &ast::Lifetime) + { + loop { + match *old_scope { + BlockScope(_, s) => { + old_scope = s; + } + + RootScope => { + return; + } + + EarlyScope(_, lifetimes, s) | + LateScope(lifetimes, s) => { + if let Some((_, lifetime_def)) = search_lifetimes(lifetimes, lifetime) { + self.sess.span_warn( + lifetime.span, + format!("lifetime name `{}` shadows another \ + lifetime name that is already in scope", + token::get_name(lifetime.name)).as_slice()); + self.sess.span_help( + lifetime_def.span, + format!("shadowed lifetime `{}` declared here", + token::get_name(lifetime.name)).as_slice()); + self.sess.span_help( + lifetime.span, + "shadowed lifetimes are deprecated \ + and will become a hard error before 1.0"); + return; + } + + old_scope = s; + } + } + } + } + fn insert_lifetime(&mut self, lifetime_ref: &ast::Lifetime, def: DefRegion) { @@ -458,12 +506,12 @@ impl<'a> LifetimeContext<'a> { } } -fn search_lifetimes(lifetimes: &Vec, +fn search_lifetimes<'a>(lifetimes: &'a Vec, lifetime_ref: &ast::Lifetime) - -> Option<(uint, ast::NodeId)> { + -> Option<(uint, &'a ast::Lifetime)> { for (i, lifetime_decl) in lifetimes.iter().enumerate() { if lifetime_decl.lifetime.name == lifetime_ref.name { - return Some((i, lifetime_decl.lifetime.id)); + return Some((i, &lifetime_decl.lifetime)); } } return None; diff --git a/src/librustc/middle/subst.rs b/src/librustc/middle/subst.rs index 2098aa3db533a..1cf25cd1dc866 100644 --- a/src/librustc/middle/subst.rs +++ b/src/librustc/middle/subst.rs @@ -588,7 +588,7 @@ struct SubstFolder<'a, 'tcx: 'a> { } impl<'a, 'tcx> TypeFolder<'tcx> for SubstFolder<'a, 'tcx> { - fn tcx<'a>(&'a self) -> &'a ty::ctxt<'tcx> { self.tcx } + fn tcx(&self) -> &ty::ctxt<'tcx> { self.tcx } fn enter_region_binder(&mut self) { self.region_binders_passed += 1; diff --git a/src/librustc/middle/ty_fold.rs b/src/librustc/middle/ty_fold.rs index 5d0c584864dbc..4877512ce5816 100644 --- a/src/librustc/middle/ty_fold.rs +++ b/src/librustc/middle/ty_fold.rs @@ -834,7 +834,7 @@ pub fn erase_regions<'tcx, T: TypeFoldable<'tcx>>(tcx: &ty::ctxt<'tcx>, t: T) -> } impl<'a, 'tcx> TypeFolder<'tcx> for RegionEraser<'a, 'tcx> { - fn tcx<'a>(&'a self) -> &'a ty::ctxt<'tcx> { self.tcx } + fn tcx(&self) -> &ty::ctxt<'tcx> { self.tcx } fn fold_region(&mut self, r: ty::Region) -> ty::Region { match r { diff --git a/src/librustc_trans/trans/cleanup.rs b/src/librustc_trans/trans/cleanup.rs index 2fd6551409e90..e8857de7b73bc 100644 --- a/src/librustc_trans/trans/cleanup.rs +++ b/src/librustc_trans/trans/cleanup.rs @@ -979,10 +979,10 @@ impl<'tcx> Cleanup<'tcx> for FreeSlice { false } - fn trans<'blk, 'tcx>(&self, - bcx: Block<'blk, 'tcx>, - debug_loc: Option) - -> Block<'blk, 'tcx> { + fn trans<'blk>(&self, + bcx: Block<'blk, 'tcx>, + debug_loc: Option) + -> Block<'blk, 'tcx> { apply_debug_loc(bcx.fcx, debug_loc); match self.heap { @@ -1012,10 +1012,10 @@ impl<'tcx> Cleanup<'tcx> for LifetimeEnd { true } - fn trans<'blk, 'tcx>(&self, - bcx: Block<'blk, 'tcx>, - debug_loc: Option) - -> Block<'blk, 'tcx> { + fn trans<'blk>(&self, + bcx: Block<'blk, 'tcx>, + debug_loc: Option) + -> Block<'blk, 'tcx> { apply_debug_loc(bcx.fcx, debug_loc); base::call_lifetime_end(bcx, self.ptr); bcx diff --git a/src/librustc_typeck/check/method/probe.rs b/src/librustc_typeck/check/method/probe.rs index d3879e49034b1..80e0de8e001a0 100644 --- a/src/librustc_typeck/check/method/probe.rs +++ b/src/librustc_typeck/check/method/probe.rs @@ -394,7 +394,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> { &mut self, bounds: &[Rc>], num_includes_types: bool, - mk_cand: for<'a> |this: &mut ProbeContext<'a, 'tcx>, + mk_cand: for<'b> |this: &mut ProbeContext<'b, 'tcx>, tr: Rc>, m: Rc>, method_num: uint|) diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index e0df94745d6a9..ed743ad9b6aff 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -246,7 +246,7 @@ pub struct FnCtxt<'a, 'tcx: 'a> { } impl<'a, 'tcx> mem_categorization::Typer<'tcx> for FnCtxt<'a, 'tcx> { - fn tcx<'a>(&'a self) -> &'a ty::ctxt<'tcx> { + fn tcx(&self) -> &ty::ctxt<'tcx> { self.ccx.tcx } fn node_ty(&self, id: ast::NodeId) -> McResult> { @@ -256,7 +256,7 @@ impl<'a, 'tcx> mem_categorization::Typer<'tcx> for FnCtxt<'a, 'tcx> { -> Option> { self.inh.method_map.borrow().get(&method_call).map(|m| m.ty) } - fn adjustments<'a>(&'a self) -> &'a RefCell>> { + fn adjustments(&self) -> &RefCell>> { &self.inh.adjustments } fn is_method_call(&self, id: ast::NodeId) -> bool { @@ -272,8 +272,7 @@ impl<'a, 'tcx> mem_categorization::Typer<'tcx> for FnCtxt<'a, 'tcx> { -> ast::CaptureClause { self.ccx.tcx.capture_mode(closure_expr_id) } - fn unboxed_closures<'a>(&'a self) - -> &'a RefCell>> { + fn unboxed_closures(&self) -> &RefCell>> { &self.inh.unboxed_closures } } @@ -1526,7 +1525,7 @@ fn check_cast(fcx: &FnCtxt, } impl<'a, 'tcx> AstConv<'tcx> for FnCtxt<'a, 'tcx> { - fn tcx<'a>(&'a self) -> &'a ty::ctxt<'tcx> { self.ccx.tcx } + fn tcx(&self) -> &ty::ctxt<'tcx> { self.ccx.tcx } fn get_item_ty(&self, id: ast::DefId) -> ty::Polytype<'tcx> { ty::lookup_item_type(self.tcx(), id) @@ -1557,7 +1556,7 @@ impl<'a, 'tcx> AstConv<'tcx> for FnCtxt<'a, 'tcx> { } impl<'a, 'tcx> FnCtxt<'a, 'tcx> { - fn tcx<'a>(&'a self) -> &'a ty::ctxt<'tcx> { self.ccx.tcx } + fn tcx(&self) -> &ty::ctxt<'tcx> { self.ccx.tcx } pub fn infcx<'b>(&'b self) -> &'b infer::InferCtxt<'a, 'tcx> { &self.inh.infcx @@ -1879,7 +1878,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } - pub fn item_substs<'a>(&'a self) -> Ref<'a, NodeMap>> { + pub fn item_substs(&self) -> Ref>> { self.inh.item_substs.borrow() } diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 61b8e6c956cab..08b465dfa80f7 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -153,7 +153,7 @@ impl<'a,'tcx> ToTy<'tcx> for CrateCtxt<'a,'tcx> { } impl<'a, 'tcx> AstConv<'tcx> for CrateCtxt<'a, 'tcx> { - fn tcx<'a>(&'a self) -> &'a ty::ctxt<'tcx> { self.tcx } + fn tcx(&self) -> &ty::ctxt<'tcx> { self.tcx } fn get_item_ty(&self, id: ast::DefId) -> ty::Polytype<'tcx> { if id.krate != ast::LOCAL_CRATE { @@ -719,7 +719,7 @@ struct ImplCtxt<'a,'tcx:'a> { } impl<'a,'tcx> AstConv<'tcx> for ImplCtxt<'a,'tcx> { - fn tcx<'a>(&'a self) -> &'a ty::ctxt<'tcx> { + fn tcx(&self) -> &ty::ctxt<'tcx> { self.ccx.tcx } @@ -808,7 +808,7 @@ struct FnCtxt<'a,'tcx:'a> { } impl<'a,'tcx> AstConv<'tcx> for FnCtxt<'a,'tcx> { - fn tcx<'a>(&'a self) -> &'a ty::ctxt<'tcx> { + fn tcx(&self) -> &ty::ctxt<'tcx> { self.ccx.tcx } @@ -857,7 +857,7 @@ struct ImplMethodCtxt<'a,'tcx:'a> { } impl<'a,'tcx> AstConv<'tcx> for ImplMethodCtxt<'a,'tcx> { - fn tcx<'a>(&'a self) -> &'a ty::ctxt<'tcx> { + fn tcx(&self) -> &ty::ctxt<'tcx> { self.ccx.tcx } @@ -906,7 +906,7 @@ struct TraitMethodCtxt<'a,'tcx:'a> { } impl<'a,'tcx> AstConv<'tcx> for TraitMethodCtxt<'a,'tcx> { - fn tcx<'a>(&'a self) -> &'a ty::ctxt<'tcx> { + fn tcx(&self) -> &ty::ctxt<'tcx> { self.ccx.tcx } @@ -986,7 +986,7 @@ struct GenericsCtxt<'a,'tcx:'a,AC:'a> { } impl<'a,'tcx,AC:AstConv<'tcx>> AstConv<'tcx> for GenericsCtxt<'a,'tcx,AC> { - fn tcx<'a>(&'a self) -> &'a ty::ctxt<'tcx> { + fn tcx(&self) -> &ty::ctxt<'tcx> { self.chain.tcx() } diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 92184ce93deec..6f40a93bcf540 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -459,7 +459,7 @@ impl attr::AttrMetaMethods for Attribute { impl<'a> attr::AttrMetaMethods for &'a Attribute { fn name(&self) -> InternedString { (**self).name() } fn value_str(&self) -> Option { (**self).value_str() } - fn meta_item_list<'a>(&'a self) -> Option<&'a [P]> { None } + fn meta_item_list(&self) -> Option<&[P]> { None } } #[deriving(Clone, Encodable, Decodable, PartialEq)] diff --git a/src/librustrt/exclusive.rs b/src/librustrt/exclusive.rs index 9adcc0a844dff..1d8ea2202bf0d 100644 --- a/src/librustrt/exclusive.rs +++ b/src/librustrt/exclusive.rs @@ -71,10 +71,10 @@ impl<'a, T: Send> ExclusiveGuard<'a, T> { } impl<'a, T: Send> Deref for ExclusiveGuard<'a, T> { - fn deref<'a>(&'a self) -> &'a T { &*self._data } + fn deref(&self) -> &T { &*self._data } } impl<'a, T: Send> DerefMut for ExclusiveGuard<'a, T> { - fn deref_mut<'a>(&'a mut self) -> &'a mut T { &mut *self._data } + fn deref_mut(&mut self) -> &mut T { &mut *self._data } } #[cfg(test)] diff --git a/src/libserialize/json.rs b/src/libserialize/json.rs index d34828ccee328..d17f293b4432b 100644 --- a/src/libserialize/json.rs +++ b/src/libserialize/json.rs @@ -627,13 +627,13 @@ pub struct PrettyEncoder<'a> { impl<'a> PrettyEncoder<'a> { /// Creates a new encoder whose output will be written to the specified writer - pub fn new<'a>(writer: &'a mut io::Writer) -> PrettyEncoder<'a> { + pub fn new(writer: &'a mut io::Writer) -> PrettyEncoder<'a> { PrettyEncoder { writer: writer, curr_indent: 0, indent: 2, } } /// Set the number of spaces to indent for each level. /// This is safe to set during encoding. - pub fn set_indent<'a>(&mut self, indent: uint) { + pub fn set_indent(&mut self, indent: uint) { // self.indent very well could be 0 so we need to use checked division. let level = self.curr_indent.checked_div(self.indent).unwrap_or(0); self.indent = indent; @@ -1103,7 +1103,7 @@ impl Json { } impl<'a> ops::Index<&'a str, Json> for Json { - fn index<'a>(&'a self, idx: & &str) -> &'a Json { + fn index(&self, idx: & &str) -> &Json { self.find(*idx).unwrap() } } diff --git a/src/libstd/io/mem.rs b/src/libstd/io/mem.rs index 4dc87278e2bbc..8eb66dec40cec 100644 --- a/src/libstd/io/mem.rs +++ b/src/libstd/io/mem.rs @@ -226,7 +226,7 @@ impl<'a> Reader for &'a [u8] { impl<'a> Buffer for &'a [u8] { #[inline] - fn fill_buf<'a>(&'a mut self) -> IoResult<&'a [u8]> { + fn fill_buf(&mut self) -> IoResult<&[u8]> { if self.is_empty() { Err(io::standard_error(io::EndOfFile)) } else { @@ -268,7 +268,7 @@ impl<'a> BufWriter<'a> { /// Creates a new `BufWriter` which will wrap the specified buffer. The /// writer initially starts at position 0. #[inline] - pub fn new<'a>(buf: &'a mut [u8]) -> BufWriter<'a> { + pub fn new(buf: &'a mut [u8]) -> BufWriter<'a> { BufWriter { buf: buf, pos: 0 @@ -337,7 +337,7 @@ pub struct BufReader<'a> { impl<'a> BufReader<'a> { /// Creates a new buffered reader which will read the specified buffer #[inline] - pub fn new<'a>(buf: &'a [u8]) -> BufReader<'a> { + pub fn new(buf: &'a [u8]) -> BufReader<'a> { BufReader { buf: buf, pos: 0 @@ -384,7 +384,7 @@ impl<'a> Seek for BufReader<'a> { impl<'a> Buffer for BufReader<'a> { #[inline] - fn fill_buf<'a>(&'a mut self) -> IoResult<&'a [u8]> { + fn fill_buf(&mut self) -> IoResult<&[u8]> { if self.pos < self.buf.len() { Ok(self.buf[self.pos..]) } else { diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index 4baeaabc6c6a5..a384610e504c9 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -981,7 +981,7 @@ impl<'a, R: Reader> Reader for RefReader<'a, R> { } impl<'a, R: Buffer> Buffer for RefReader<'a, R> { - fn fill_buf<'a>(&'a mut self) -> IoResult<&'a [u8]> { self.inner.fill_buf() } + fn fill_buf(&mut self) -> IoResult<&[u8]> { self.inner.fill_buf() } fn consume(&mut self, amt: uint) { self.inner.consume(amt) } } diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 3c7a4a81d208f..354b53bfc01d0 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -468,8 +468,8 @@ pub struct ExtCtxt<'a> { } impl<'a> ExtCtxt<'a> { - pub fn new<'a>(parse_sess: &'a parse::ParseSess, cfg: ast::CrateConfig, - ecfg: expand::ExpansionConfig) -> ExtCtxt<'a> { + pub fn new(parse_sess: &'a parse::ParseSess, cfg: ast::CrateConfig, + ecfg: expand::ExpansionConfig) -> ExtCtxt<'a> { let env = initial_syntax_expander_table(&ecfg); ExtCtxt { parse_sess: parse_sess, diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index 50c7258fe1c7b..da908f46ff61f 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -275,8 +275,8 @@ impl<'a> StringReader<'a> { } /// Converts CRLF to LF in the given string, raising an error on bare CR. - fn translate_crlf<'a>(&self, start: BytePos, - s: &'a str, errmsg: &'a str) -> str::CowString<'a> { + fn translate_crlf<'b>(&self, start: BytePos, + s: &'b str, errmsg: &'b str) -> str::CowString<'b> { let mut i = 0u; while i < s.len() { let str::CharRange { ch, next } = s.char_range_at(i); diff --git a/src/test/compile-fail/generic-lifetime-trait-impl.rs b/src/test/compile-fail/generic-lifetime-trait-impl.rs index 651072d2118e5..fc54002820e01 100644 --- a/src/test/compile-fail/generic-lifetime-trait-impl.rs +++ b/src/test/compile-fail/generic-lifetime-trait-impl.rs @@ -19,7 +19,7 @@ trait Bar<'a> {} trait Foo<'a> { - fn bar<'a, T: Bar<'a>>(self) -> &'a str; + fn bar<'b, T: Bar<'b>>(self) -> &'b str; } impl<'a> Foo<'a> for &'a str { diff --git a/src/test/compile-fail/shadowed-lifetime.rs b/src/test/compile-fail/shadowed-lifetime.rs new file mode 100644 index 0000000000000..ff8ce7769d77e --- /dev/null +++ b/src/test/compile-fail/shadowed-lifetime.rs @@ -0,0 +1,43 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that shadowed lifetimes generate an error. + +struct Foo<'a>(&'a int); + +impl<'a> Foo<'a> { + //~^ HELP shadowed lifetime `'a` declared here + fn shadow_in_method<'a>(&'a self) -> &'a int { + //~^ WARNING lifetime name `'a` shadows another lifetime name that is already in scope + //~| HELP deprecated + self.0 + } + + fn shadow_in_type<'b>(&'b self) -> &'b int { + //~^ HELP shadowed lifetime `'b` declared here + let x: for<'b> fn(&'b int) = panic!(); + //~^ WARNING lifetime name `'b` shadows another lifetime name that is already in scope + //~| HELP deprecated + self.0 + } + + fn not_shadow_in_item<'b>(&'b self) { + struct Bar<'a, 'b>(&'a int, &'b int); // not a shadow, separate item + fn foo<'a, 'b>(x: &'a int, y: &'b int) { } // same + } +} + +fn main() { + // intentional error that occurs after `resolve_lifetime` runs, + // just to ensure that this test fails to compile; when shadowed + // lifetimes become either an error or a proper lint, this will + // not be needed. + let x: int = 3u; //~ ERROR mismatched types +} diff --git a/src/test/compile-fail/unboxed-closure-sugar-equiv.rs b/src/test/compile-fail/unboxed-closure-sugar-equiv.rs index 308b33f9b4db1..16d6b217872ae 100644 --- a/src/test/compile-fail/unboxed-closure-sugar-equiv.rs +++ b/src/test/compile-fail/unboxed-closure-sugar-equiv.rs @@ -35,17 +35,17 @@ fn test<'a,'b>() { // Test that anonymous regions in `()` form are equivalent // to fresh bound regions, and that we can intermingle // named and anonymous as we choose: - eq::< for<'a,'b> Foo<(&'a int,&'b uint),uint>, - for<'a,'b> Foo(&'a int,&'b uint) -> uint >(); - eq::< for<'a,'b> Foo<(&'a int,&'b uint),uint>, - for<'a> Foo(&'a int,&uint) -> uint >(); - eq::< for<'a,'b> Foo<(&'a int,&'b uint),uint>, - for<'b> Foo(&int,&'b uint) -> uint >(); - eq::< for<'a,'b> Foo<(&'a int,&'b uint),uint>, + eq::< for<'x,'y> Foo<(&'x int,&'y uint),uint>, + for<'x,'y> Foo(&'x int,&'y uint) -> uint >(); + eq::< for<'x,'y> Foo<(&'x int,&'y uint),uint>, + for<'x> Foo(&'x int,&uint) -> uint >(); + eq::< for<'x,'y> Foo<(&'x int,&'y uint),uint>, + for<'y> Foo(&int,&'y uint) -> uint >(); + eq::< for<'x,'y> Foo<(&'x int,&'y uint),uint>, Foo(&int,&uint) -> uint >(); // lifetime elision - eq::< for<'a,'b> Foo<(&'a int,), &'a int>, + eq::< for<'x> Foo<(&'x int,), &'x int>, Foo(&int) -> &int >(); // Errors expected: diff --git a/src/test/pretty/issue-4264.pp b/src/test/pretty/issue-4264.pp index 8a2c2d35ef5ba..b5ea9bd4b89c6 100644 --- a/src/test/pretty/issue-4264.pp +++ b/src/test/pretty/issue-4264.pp @@ -52,14 +52,14 @@ ((::std::fmt::format as fn(&core::fmt::Arguments<'_>) -> collections::string::String)((&((::std::fmt::Arguments::new as - fn(&'a [&'a str], &'a [core::fmt::Argument<'a>]) -> core::fmt::Arguments<'a>)((__STATIC_FMTSTR - as - &'static [&'static str]), - (&([] - as - [core::fmt::Argument<'_>, ..0]) - as - &[core::fmt::Argument<'_>, ..0])) + fn(&[&str], &[core::fmt::Argument<'_>]) -> core::fmt::Arguments<'_>)((__STATIC_FMTSTR + as + &'static [&'static str]), + (&([] + as + [core::fmt::Argument<'_>, ..0]) + as + &[core::fmt::Argument<'_>, ..0])) as core::fmt::Arguments<'_>) as diff --git a/src/test/run-pass/issue-6157.rs b/src/test/run-pass/issue-6157.rs index 4144c8227dcd7..23e700855040c 100644 --- a/src/test/run-pass/issue-6157.rs +++ b/src/test/run-pass/issue-6157.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -pub trait OpInt<'a> { fn call<'a>(&'a mut self, int, int) -> int; } +pub trait OpInt<'a> { fn call(&mut self, int, int) -> int; } impl<'a> OpInt<'a> for |int, int|: 'a -> int { fn call(&mut self, a:int, b:int) -> int {