From 49de82cdca2064a909d3104f4e5eccacb0425fd0 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Wed, 10 Apr 2013 13:11:27 -0700 Subject: Issue #5656: Make &self not mean "&'self self" Fixes #5656. Fixes #5541. --- src/libsyntax/ast.rs | 9 --------- src/libsyntax/ext/base.rs | 13 +++++++++++++ src/libsyntax/opt_vec.rs | 11 +++++++++++ src/libsyntax/print/pprust.rs | 4 ++++ 4 files changed, 28 insertions(+), 9 deletions(-) (limited to 'src/libsyntax') diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index ec77b54a853..3b2df24e7d9 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -1002,15 +1002,6 @@ pub enum self_ty_ { sty_uniq(mutability) // `~self` } -impl self_ty_ { - fn is_borrowed(&self) -> bool { - match *self { - sty_region(*) => true, - _ => false - } - } -} - pub type self_ty = spanned; #[auto_encode] diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 92f0c7c7679..886af694920 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -454,6 +454,7 @@ impl MapChain{ // ugh: can't get this to compile with mut because of the // lack of flow sensitivity. + #[cfg(stage0)] fn get_map(&self) -> &'self HashMap { match *self { BaseMapChain (~ref map) => map, @@ -461,6 +462,18 @@ impl MapChain{ } } + // ugh: can't get this to compile with mut because of the + // lack of flow sensitivity. + #[cfg(stage1)] + #[cfg(stage2)] + #[cfg(stage3)] + fn get_map<'a>(&'a self) -> &'a HashMap { + match *self { + BaseMapChain (~ref map) => map, + ConsMapChain (~ref map,_) => map + } + } + // traits just don't work anywhere...? //pub impl Map for MapChain { diff --git a/src/libsyntax/opt_vec.rs b/src/libsyntax/opt_vec.rs index fd54746f3dc..1604c40f917 100644 --- a/src/libsyntax/opt_vec.rs +++ b/src/libsyntax/opt_vec.rs @@ -61,6 +61,7 @@ impl OptVec { } } + #[cfg(stage0)] fn get(&self, i: uint) -> &'self T { match *self { Empty => fail!(fmt!("Invalid index %u", i)), @@ -68,6 +69,16 @@ impl OptVec { } } + #[cfg(stage1)] + #[cfg(stage2)] + #[cfg(stage3)] + fn get<'a>(&'a self, i: uint) -> &'a T { + match *self { + Empty => fail!(fmt!("Invalid index %u", i)), + Vec(ref v) => &v[i] + } + } + fn is_empty(&self) -> bool { self.len() == 0 } diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 20fc99baf21..36cd7c06842 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -1633,6 +1633,10 @@ pub fn print_pat(s: @ps, &&pat: @ast::pat, refutable: bool) { (s.ann.post)(ann_node); } +pub fn self_ty_to_str(self_ty: ast::self_ty_, intr: @ident_interner) -> ~str { + to_str(self_ty, |a, b| { print_self_ty(a, b); () }, intr) +} + // Returns whether it printed anything pub fn print_self_ty(s: @ps, self_ty: ast::self_ty_) -> bool { match self_ty { -- cgit 1.4.1-3-g733a5