Issue #5656: Make &self not mean "&'self self"

Fixes #5656.
Fixes #5541.
This commit is contained in:
Niko Matsakis 2013-04-10 13:11:27 -07:00
parent 3322595e89
commit 49de82cdca
16 changed files with 337 additions and 296 deletions

View file

@ -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<self_ty_>;
#[auto_encode]

View file

@ -454,6 +454,7 @@ impl <K: Eq + Hash + IterBytes ,V: Copy> MapChain<K,V>{
// ugh: can't get this to compile with mut because of the
// lack of flow sensitivity.
#[cfg(stage0)]
fn get_map(&self) -> &'self HashMap<K,@V> {
match *self {
BaseMapChain (~ref map) => map,
@ -461,6 +462,18 @@ impl <K: Eq + Hash + IterBytes ,V: Copy> MapChain<K,V>{
}
}
// 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<K,@V> {
match *self {
BaseMapChain (~ref map) => map,
ConsMapChain (~ref map,_) => map
}
}
// traits just don't work anywhere...?
//pub impl Map<Name,SyntaxExtension> for MapChain {

View file

@ -61,6 +61,7 @@ impl<T> OptVec<T> {
}
}
#[cfg(stage0)]
fn get(&self, i: uint) -> &'self T {
match *self {
Empty => fail!(fmt!("Invalid index %u", i)),
@ -68,6 +69,16 @@ impl<T> OptVec<T> {
}
}
#[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
}

View file

@ -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 {