's' => { return ast::sty_static; }
'v' => { return ast::sty_value(get_mutability(string[1])); }
'@' => { return ast::sty_box(get_mutability(string[1])); }
- '~' => { return ast::sty_uniq; }
+ '~' => { return ast::sty_uniq(get_mutability(string[1])); }
'&' => {
// FIXME(#4846) expl. region
return ast::sty_region(None, get_mutability(string[1]));
ebml_w.writer.write(&[ '@' as u8 ]);
encode_mutability(ebml_w, m);
}
- sty_uniq => {
+ sty_uniq(m) => {
ebml_w.writer.write(&[ '~' as u8 ]);
+ encode_mutability(ebml_w, m);
}
}
match *fk {
visit::fk_method(_, _, method) => {
match method.explicit_self.node {
- sty_value(_) | sty_region(*) | sty_box(_) | sty_uniq => {
+ sty_value(_) | sty_region(*) | sty_box(_) | sty_uniq(_) => {
fn_maps.add_variable(Arg(method.self_id,
special_idents::self_));
}
}
HasSelfBinding(self_node_id, explicit_self) => {
let mutable = match explicit_self.node {
- sty_value(m) if m == MutMutable => true,
+ sty_uniq(m) | sty_value(m) if m == MutMutable => true,
_ => false
};
let def_like = DlDef(DefSelf(self_node_id, mutable));
ty::mt {ty: self_info.untransformed_self_ty,
mutbl: mutability}))
}
- ast::sty_uniq => {
+ ast::sty_uniq(_) => {
Some(ty::mk_uniq(this.tcx(),
ty::mt {ty: self_info.untransformed_self_ty,
mutbl: ast::MutImmutable}))
}
}
- sty_uniq => {
+ sty_uniq(_) => {
debug!("(is relevant?) explicit self is a unique pointer");
match ty::get(rcvr_ty).sty {
ty::ty_uniq(mt) => {
match self.node {
ast::sty_static => SelfStatic,
ast::sty_value(_) => SelfValue,
- ast::sty_uniq => SelfOwned,
+ ast::sty_uniq(_) => SelfOwned,
ast::sty_region(lt, mt) => SelfBorrowed(lt.clean(), mt.clean()),
ast::sty_box(mt) => SelfManaged(mt.clean()),
}
sty_value(Mutability), // `self`
sty_region(Option<Lifetime>, Mutability), // `&'lt self`
sty_box(Mutability), // `@self`
- sty_uniq // `~self`
+ sty_uniq(Mutability) // `~self`
}
pub type explicit_self = Spanned<explicit_self_>;
let self_ty = respan(
span,
match *ptr {
- Send => ast::sty_uniq,
+ Send => ast::sty_uniq(ast::MutImmutable),
Managed(mutbl) => ast::sty_box(mutbl),
Borrowed(ref lt, mutbl) => {
let lt = lt.map(|s| cx.lifetime(span, cx.ident_of(s)));
self.span_err(*self.last_span,
"mutability declaration not allowed here");
}
- sty_uniq
+ sty_uniq(MutImmutable)
}, self)
}
token::IDENT(*) if self.is_self_ident() => {
self.expect_self_ident();
sty_value(mutability)
}
+ _ if self.token_is_mutability(self.token) &&
+ self.look_ahead(1, |t| *t == token::TILDE) &&
+ self.look_ahead(2, |t| token::is_keyword(keywords::Self, t)) => {
+ let mutability = self.parse_mutability();
+ self.bump();
+ self.expect_self_ident();
+ sty_uniq(mutability)
+ }
_ => {
sty_static
}
print_mutability(s, m);
word(s.s, "self");
}
- ast::sty_uniq => { word(s.s, "~self"); }
+ ast::sty_uniq(m) => {
+ print_mutability(s, m);
+ word(s.s, "~self");
+ }
ast::sty_region(ref lt, m) => {
word(s.s, "&");
print_opt_lifetime(s, lt);