diff --git a/src/librustc/metadata/decoder.rs b/src/librustc/metadata/decoder.rs index 69faf519bc280..b08186349319d 100644 --- a/src/librustc/metadata/decoder.rs +++ b/src/librustc/metadata/decoder.rs @@ -786,7 +786,7 @@ fn get_explicit_self(item: ebml::Doc) -> ast::explicit_self_ { 's' => { return ast::sty_static; } 'v' => { return ast::sty_value; } '@' => { return ast::sty_box(get_mutability(string[1])); } - '~' => { return ast::sty_uniq(get_mutability(string[1])); } + '~' => { return ast::sty_uniq; } '&' => { // FIXME(#4846) expl. region return ast::sty_region(None, get_mutability(string[1])); diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index e394c8dcf92f9..7735a7e39561f 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -630,9 +630,8 @@ fn encode_explicit_self(ebml_w: &mut writer::Encoder, explicit_self: ast::explic ebml_w.writer.write(&[ '@' as u8 ]); encode_mutability(ebml_w, m); } - sty_uniq(m) => { + sty_uniq => { ebml_w.writer.write(&[ '~' as u8 ]); - encode_mutability(ebml_w, m); } } diff --git a/src/librustc/middle/check_const.rs b/src/librustc/middle/check_const.rs index 2c6ba79e96e45..8ad61fe1f61cd 100644 --- a/src/librustc/middle/check_const.rs +++ b/src/librustc/middle/check_const.rs @@ -92,7 +92,7 @@ pub fn check_expr(sess: Session, if is_const { match e.node { expr_unary(_, deref, _) => { } - expr_unary(_, box(_), _) | expr_unary(_, uniq(_), _) => { + expr_unary(_, box(_), _) | expr_unary(_, uniq, _) => { sess.span_err(e.span, "disallowed operator in constant expression"); return; diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs index 86b8b2943198e..e431784f1e63a 100644 --- a/src/librustc/middle/liveness.rs +++ b/src/librustc/middle/liveness.rs @@ -368,7 +368,7 @@ fn visit_fn(fk: &visit::fn_kind, match *fk { 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_)); } diff --git a/src/librustc/middle/trans/consts.rs b/src/librustc/middle/trans/consts.rs index d7b6e9cf5a372..6780c51e5062a 100644 --- a/src/librustc/middle/trans/consts.rs +++ b/src/librustc/middle/trans/consts.rs @@ -340,7 +340,7 @@ fn const_expr_unadjusted(cx: @mut CrateContext, e: &ast::expr) -> ValueRef { let is_float = ty::type_is_fp(ty); return match u { ast::box(_) | - ast::uniq(_) | + ast::uniq | ast::deref => { let (dv, _dt) = const_deref(cx, te, ty, true); dv diff --git a/src/librustc/middle/trans/expr.rs b/src/librustc/middle/trans/expr.rs index 3532273075602..297a466c7cb0a 100644 --- a/src/librustc/middle/trans/expr.rs +++ b/src/librustc/middle/trans/expr.rs @@ -1314,7 +1314,7 @@ fn trans_unary_datum(bcx: block, trans_boxed_expr(bcx, un_ty, sub_expr, sub_ty, heap_managed) } - ast::uniq(_) => { + ast::uniq => { let heap = heap_for_unique(bcx, un_ty); trans_boxed_expr(bcx, un_ty, sub_expr, sub_ty, heap) } diff --git a/src/librustc/middle/trans/meth.rs b/src/librustc/middle/trans/meth.rs index 0b051662781e0..75e9dbe48619d 100644 --- a/src/librustc/middle/trans/meth.rs +++ b/src/librustc/middle/trans/meth.rs @@ -532,7 +532,7 @@ pub fn trans_trait_callee(bcx: block, let llpair = match explicit_self { ast::sty_region(*) => Load(bcx, llpair), ast::sty_static | ast::sty_value | - ast::sty_box(_) | ast::sty_uniq(_) => llpair + ast::sty_box(_) | ast::sty_uniq => llpair }; let callee_ty = node_id_type(bcx, callee_id); @@ -622,7 +622,7 @@ pub fn trans_trait_callee_from_llval(bcx: block, self_mode = ty::ByRef; } - ast::sty_uniq(_) => { + ast::sty_uniq => { // Pass the unique pointer. match store { ty::UniqTraitStore => llself = llbox, diff --git a/src/librustc/middle/trans/type_use.rs b/src/librustc/middle/trans/type_use.rs index c636b7f48761f..d8d5397646203 100644 --- a/src/librustc/middle/trans/type_use.rs +++ b/src/librustc/middle/trans/type_use.rs @@ -278,7 +278,7 @@ pub fn mark_for_method_call(cx: &Context, e_id: node_id, callee_id: node_id) { pub fn mark_for_expr(cx: &Context, e: &expr) { match e.node { expr_vstore(_, _) | expr_vec(_, _) | expr_struct(*) | expr_tup(_) | - expr_unary(_, box(_), _) | expr_unary(_, uniq(_), _) | + expr_unary(_, box(_), _) | expr_unary(_, uniq, _) | expr_binary(_, add, _, _) | expr_copy(_) | expr_repeat(*) => { node_type_needs(cx, use_repr, e.id); } diff --git a/src/librustc/middle/typeck/astconv.rs b/src/librustc/middle/typeck/astconv.rs index 07fb23fea48a3..1e236c620a0e5 100644 --- a/src/librustc/middle/typeck/astconv.rs +++ b/src/librustc/middle/typeck/astconv.rs @@ -662,10 +662,10 @@ fn ty_of_method_or_bare_fn( ty::mt {ty: self_info.untransformed_self_ty, mutbl: mutability})) } - ast::sty_uniq(mutability) => { + ast::sty_uniq => { Some(ty::mk_uniq(this.tcx(), ty::mt {ty: self_info.untransformed_self_ty, - mutbl: mutability})) + mutbl: ast::m_imm})) } } } diff --git a/src/librustc/middle/typeck/check/method.rs b/src/librustc/middle/typeck/check/method.rs index 4bebca3c9a8b3..7489882ab768c 100644 --- a/src/librustc/middle/typeck/check/method.rs +++ b/src/librustc/middle/typeck/check/method.rs @@ -1123,11 +1123,11 @@ impl<'self> LookupContext<'self> { } } - sty_uniq(m) => { + sty_uniq => { debug!("(is relevant?) explicit self is a unique pointer"); match ty::get(rcvr_ty).sty { ty::ty_uniq(mt) => { - mutability_matches(mt.mutbl, m) && + mutability_matches(mt.mutbl, ast::m_imm) && self.fcx.can_mk_subty(mt.ty, candidate.rcvr_ty).is_ok() } diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index 23266767124c8..0cd9aac379892 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -2301,7 +2301,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, ast::expr_unary(callee_id, unop, oprnd) => { let exp_inner = do unpack_expected(fcx, expected) |sty| { match unop { - ast::box(_) | ast::uniq(_) => match *sty { + ast::box(_) | ast::uniq => match *sty { ty::ty_box(ref mt) | ty::ty_uniq(ref mt) => Some(mt.ty), _ => None }, @@ -2318,9 +2318,10 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, oprnd_t = ty::mk_box(tcx, ty::mt {ty: oprnd_t, mutbl: mutbl}); } - ast::uniq(mutbl) => { + ast::uniq => { oprnd_t = ty::mk_uniq(tcx, - ty::mt {ty: oprnd_t, mutbl: mutbl}); + ty::mt {ty: oprnd_t, + mutbl: ast::m_imm}); } ast::deref => { let sty = structure_of(fcx, expr.span, oprnd_t); diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index bc432c4c7b0b6..2603cbb2dd7c5 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -333,7 +333,7 @@ pub enum binop { #[deriving(Eq, Encodable, Decodable,IterBytes)] pub enum unop { box(mutability), - uniq(mutability), + uniq, deref, not, neg @@ -805,7 +805,7 @@ pub enum explicit_self_ { sty_value, // `self` sty_region(Option<@Lifetime>, mutability), // `&'lt self` sty_box(mutability), // `@self` - sty_uniq(mutability) // `~self` + sty_uniq // `~self` } pub type explicit_self = spanned; diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 9439f45be21bf..ee7c7180f8db2 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -135,7 +135,7 @@ pub fn is_shift_binop(b: binop) -> bool { pub fn unop_to_str(op: unop) -> ~str { match op { box(mt) => if mt == m_mutbl { ~"@mut " } else { ~"@" }, - uniq(mt) => if mt == m_mutbl { ~"~mut " } else { ~"~" }, + uniq => ~"~", deref => ~"*", not => ~"!", neg => ~"-" diff --git a/src/libsyntax/ext/deriving/ty.rs b/src/libsyntax/ext/deriving/ty.rs index a2f9aa58d99ad..e210853bfb4dc 100644 --- a/src/libsyntax/ext/deriving/ty.rs +++ b/src/libsyntax/ext/deriving/ty.rs @@ -248,7 +248,7 @@ pub fn get_explicit_self(cx: @ExtCtxt, span: span, self_ptr: &Option) let self_ty = respan( span, match *ptr { - Send => ast::sty_uniq(ast::m_imm), + Send => ast::sty_uniq, Managed(mutbl) => ast::sty_box(mutbl), Borrowed(ref lt, mutbl) => { let lt = lt.map(|s| @cx.lifetime(span, diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index f1b5c4d16be97..cc0baa28e20d7 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -2071,9 +2071,8 @@ impl Parser { ex = match e.node { expr_vec(*) | expr_lit(@codemap::spanned { node: lit_str(_), span: _}) | - expr_repeat(*) - if m == m_imm => expr_vstore(e, expr_vstore_uniq), - _ => self.mk_unary(uniq(m), e) + expr_repeat(*) => expr_vstore(e, expr_vstore_uniq), + _ => self.mk_unary(uniq, e) }; } _ => return self.parse_dot_or_call_expr() @@ -3366,7 +3365,12 @@ impl Parser { maybe_parse_explicit_self(sty_box, self) } token::TILDE => { - maybe_parse_explicit_self(sty_uniq, self) + maybe_parse_explicit_self(|mutability| { + if mutability != m_imm { + self.obsolete(*self.last_span, ObsoleteMutOwnedPointer); + } + sty_uniq + }, self) } token::IDENT(*) if self.is_self_ident() => { self.bump(); diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 9a1682bf063d7..978561eaa67c6 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -1653,6 +1653,7 @@ pub fn print_explicit_self(s: @ps, explicit_self: ast::explicit_self_) -> bool { match explicit_self { ast::sty_static => { return false; } ast::sty_value => { word(s.s, "self"); } + ast::sty_uniq => { word(s.s, "~self"); } ast::sty_region(lt, m) => { word(s.s, "&"); print_opt_lifetime(s, lt); @@ -1662,9 +1663,6 @@ pub fn print_explicit_self(s: @ps, explicit_self: ast::explicit_self_) -> bool { ast::sty_box(m) => { word(s.s, "@"); print_mutability(s, m); word(s.s, "self"); } - ast::sty_uniq(m) => { - word(s.s, "~"); print_mutability(s, m); word(s.s, "self"); - } } return true; }