Skip to content

Commit 3bad712

Browse files
committed
Remove mutability from unique boxes in the AST
1 parent b29c368 commit 3bad712

File tree

16 files changed

+30
-28
lines changed

16 files changed

+30
-28
lines changed

src/librustc/metadata/decoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,7 @@ fn get_explicit_self(item: ebml::Doc) -> ast::explicit_self_ {
786786
's' => { return ast::sty_static; }
787787
'v' => { return ast::sty_value; }
788788
'@' => { return ast::sty_box(get_mutability(string[1])); }
789-
'~' => { return ast::sty_uniq(get_mutability(string[1])); }
789+
'~' => { return ast::sty_uniq; }
790790
'&' => {
791791
// FIXME(#4846) expl. region
792792
return ast::sty_region(None, get_mutability(string[1]));

src/librustc/metadata/encoder.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -630,9 +630,8 @@ fn encode_explicit_self(ebml_w: &mut writer::Encoder, explicit_self: ast::explic
630630
ebml_w.writer.write(&[ '@' as u8 ]);
631631
encode_mutability(ebml_w, m);
632632
}
633-
sty_uniq(m) => {
633+
sty_uniq => {
634634
ebml_w.writer.write(&[ '~' as u8 ]);
635-
encode_mutability(ebml_w, m);
636635
}
637636
}
638637

src/librustc/middle/check_const.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ pub fn check_expr(sess: Session,
9292
if is_const {
9393
match e.node {
9494
expr_unary(_, deref, _) => { }
95-
expr_unary(_, box(_), _) | expr_unary(_, uniq(_), _) => {
95+
expr_unary(_, box(_), _) | expr_unary(_, uniq, _) => {
9696
sess.span_err(e.span,
9797
"disallowed operator in constant expression");
9898
return;

src/librustc/middle/liveness.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ fn visit_fn(fk: &visit::fn_kind,
368368
match *fk {
369369
fk_method(_, _, method) => {
370370
match method.explicit_self.node {
371-
sty_value | sty_region(*) | sty_box(_) | sty_uniq(_) => {
371+
sty_value | sty_region(*) | sty_box(_) | sty_uniq => {
372372
fn_maps.add_variable(Arg(method.self_id,
373373
special_idents::self_));
374374
}

src/librustc/middle/trans/consts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ fn const_expr_unadjusted(cx: @mut CrateContext, e: &ast::expr) -> ValueRef {
340340
let is_float = ty::type_is_fp(ty);
341341
return match u {
342342
ast::box(_) |
343-
ast::uniq(_) |
343+
ast::uniq |
344344
ast::deref => {
345345
let (dv, _dt) = const_deref(cx, te, ty, true);
346346
dv

src/librustc/middle/trans/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1314,7 +1314,7 @@ fn trans_unary_datum(bcx: block,
13141314
trans_boxed_expr(bcx, un_ty, sub_expr, sub_ty,
13151315
heap_managed)
13161316
}
1317-
ast::uniq(_) => {
1317+
ast::uniq => {
13181318
let heap = heap_for_unique(bcx, un_ty);
13191319
trans_boxed_expr(bcx, un_ty, sub_expr, sub_ty, heap)
13201320
}

src/librustc/middle/trans/meth.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ pub fn trans_trait_callee(bcx: block,
532532
let llpair = match explicit_self {
533533
ast::sty_region(*) => Load(bcx, llpair),
534534
ast::sty_static | ast::sty_value |
535-
ast::sty_box(_) | ast::sty_uniq(_) => llpair
535+
ast::sty_box(_) | ast::sty_uniq => llpair
536536
};
537537

538538
let callee_ty = node_id_type(bcx, callee_id);
@@ -622,7 +622,7 @@ pub fn trans_trait_callee_from_llval(bcx: block,
622622

623623
self_mode = ty::ByRef;
624624
}
625-
ast::sty_uniq(_) => {
625+
ast::sty_uniq => {
626626
// Pass the unique pointer.
627627
match store {
628628
ty::UniqTraitStore => llself = llbox,

src/librustc/middle/trans/type_use.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ pub fn mark_for_method_call(cx: &Context, e_id: node_id, callee_id: node_id) {
278278
pub fn mark_for_expr(cx: &Context, e: &expr) {
279279
match e.node {
280280
expr_vstore(_, _) | expr_vec(_, _) | expr_struct(*) | expr_tup(_) |
281-
expr_unary(_, box(_), _) | expr_unary(_, uniq(_), _) |
281+
expr_unary(_, box(_), _) | expr_unary(_, uniq, _) |
282282
expr_binary(_, add, _, _) | expr_copy(_) | expr_repeat(*) => {
283283
node_type_needs(cx, use_repr, e.id);
284284
}

src/librustc/middle/typeck/astconv.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -662,10 +662,10 @@ fn ty_of_method_or_bare_fn<AC:AstConv,RS:region_scope + Copy + 'static>(
662662
ty::mt {ty: self_info.untransformed_self_ty,
663663
mutbl: mutability}))
664664
}
665-
ast::sty_uniq(mutability) => {
665+
ast::sty_uniq => {
666666
Some(ty::mk_uniq(this.tcx(),
667667
ty::mt {ty: self_info.untransformed_self_ty,
668-
mutbl: mutability}))
668+
mutbl: ast::m_imm}))
669669
}
670670
}
671671
}

src/librustc/middle/typeck/check/method.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,11 +1123,11 @@ impl<'self> LookupContext<'self> {
11231123
}
11241124
}
11251125

1126-
sty_uniq(m) => {
1126+
sty_uniq => {
11271127
debug!("(is relevant?) explicit self is a unique pointer");
11281128
match ty::get(rcvr_ty).sty {
11291129
ty::ty_uniq(mt) => {
1130-
mutability_matches(mt.mutbl, m) &&
1130+
mutability_matches(mt.mutbl, ast::m_imm) &&
11311131
self.fcx.can_mk_subty(mt.ty, candidate.rcvr_ty).is_ok()
11321132
}
11331133

src/librustc/middle/typeck/check/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2301,7 +2301,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
23012301
ast::expr_unary(callee_id, unop, oprnd) => {
23022302
let exp_inner = do unpack_expected(fcx, expected) |sty| {
23032303
match unop {
2304-
ast::box(_) | ast::uniq(_) => match *sty {
2304+
ast::box(_) | ast::uniq => match *sty {
23052305
ty::ty_box(ref mt) | ty::ty_uniq(ref mt) => Some(mt.ty),
23062306
_ => None
23072307
},
@@ -2318,9 +2318,10 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
23182318
oprnd_t = ty::mk_box(tcx,
23192319
ty::mt {ty: oprnd_t, mutbl: mutbl});
23202320
}
2321-
ast::uniq(mutbl) => {
2321+
ast::uniq => {
23222322
oprnd_t = ty::mk_uniq(tcx,
2323-
ty::mt {ty: oprnd_t, mutbl: mutbl});
2323+
ty::mt {ty: oprnd_t,
2324+
mutbl: ast::m_imm});
23242325
}
23252326
ast::deref => {
23262327
let sty = structure_of(fcx, expr.span, oprnd_t);

src/libsyntax/ast.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ pub enum binop {
333333
#[deriving(Eq, Encodable, Decodable,IterBytes)]
334334
pub enum unop {
335335
box(mutability),
336-
uniq(mutability),
336+
uniq,
337337
deref,
338338
not,
339339
neg
@@ -805,7 +805,7 @@ pub enum explicit_self_ {
805805
sty_value, // `self`
806806
sty_region(Option<@Lifetime>, mutability), // `&'lt self`
807807
sty_box(mutability), // `@self`
808-
sty_uniq(mutability) // `~self`
808+
sty_uniq // `~self`
809809
}
810810
811811
pub type explicit_self = spanned<explicit_self_>;

src/libsyntax/ast_util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ pub fn is_shift_binop(b: binop) -> bool {
135135
pub fn unop_to_str(op: unop) -> ~str {
136136
match op {
137137
box(mt) => if mt == m_mutbl { ~"@mut " } else { ~"@" },
138-
uniq(mt) => if mt == m_mutbl { ~"~mut " } else { ~"~" },
138+
uniq => ~"~",
139139
deref => ~"*",
140140
not => ~"!",
141141
neg => ~"-"

src/libsyntax/ext/deriving/ty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ pub fn get_explicit_self(cx: @ExtCtxt, span: span, self_ptr: &Option<PtrTy>)
248248
let self_ty = respan(
249249
span,
250250
match *ptr {
251-
Send => ast::sty_uniq(ast::m_imm),
251+
Send => ast::sty_uniq,
252252
Managed(mutbl) => ast::sty_box(mutbl),
253253
Borrowed(ref lt, mutbl) => {
254254
let lt = lt.map(|s| @cx.lifetime(span,

src/libsyntax/parse/parser.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2071,9 +2071,8 @@ impl Parser {
20712071
ex = match e.node {
20722072
expr_vec(*) |
20732073
expr_lit(@codemap::spanned { node: lit_str(_), span: _}) |
2074-
expr_repeat(*)
2075-
if m == m_imm => expr_vstore(e, expr_vstore_uniq),
2076-
_ => self.mk_unary(uniq(m), e)
2074+
expr_repeat(*) => expr_vstore(e, expr_vstore_uniq),
2075+
_ => self.mk_unary(uniq, e)
20772076
};
20782077
}
20792078
_ => return self.parse_dot_or_call_expr()
@@ -3366,7 +3365,12 @@ impl Parser {
33663365
maybe_parse_explicit_self(sty_box, self)
33673366
}
33683367
token::TILDE => {
3369-
maybe_parse_explicit_self(sty_uniq, self)
3368+
maybe_parse_explicit_self(|mutability| {
3369+
if mutability != m_imm {
3370+
self.obsolete(*self.last_span, ObsoleteMutOwnedPointer);
3371+
}
3372+
sty_uniq
3373+
}, self)
33703374
}
33713375
token::IDENT(*) if self.is_self_ident() => {
33723376
self.bump();

src/libsyntax/print/pprust.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1653,6 +1653,7 @@ pub fn print_explicit_self(s: @ps, explicit_self: ast::explicit_self_) -> bool {
16531653
match explicit_self {
16541654
ast::sty_static => { return false; }
16551655
ast::sty_value => { word(s.s, "self"); }
1656+
ast::sty_uniq => { word(s.s, "~self"); }
16561657
ast::sty_region(lt, m) => {
16571658
word(s.s, "&");
16581659
print_opt_lifetime(s, lt);
@@ -1662,9 +1663,6 @@ pub fn print_explicit_self(s: @ps, explicit_self: ast::explicit_self_) -> bool {
16621663
ast::sty_box(m) => {
16631664
word(s.s, "@"); print_mutability(s, m); word(s.s, "self");
16641665
}
1665-
ast::sty_uniq(m) => {
1666-
word(s.s, "~"); print_mutability(s, m); word(s.s, "self");
1667-
}
16681666
}
16691667
return true;
16701668
}

0 commit comments

Comments
 (0)