Skip to content

Commit f30f54e

Browse files
committed
librustc: Remove the concept of modes from the compiler.
This commit does not remove `ty::arg`, although that should be possible to do now.
1 parent a12a3db commit f30f54e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+557
-1083
lines changed

src/librustc/metadata/common.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ pub enum astencode_tag { // Reserves 0x50 -- 0x6f
128128
tag_table_freevars = 0x59,
129129
tag_table_tcache = 0x5a,
130130
tag_table_param_defs = 0x5b,
131-
tag_table_inferred_modes = 0x5c,
132131
tag_table_mutbl = 0x5d,
133132
tag_table_last_use = 0x5e,
134133
tag_table_spill = 0x5f,

src/librustc/metadata/decoder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,8 @@ fn doc_transformed_self_ty(doc: ebml::Doc,
244244
}
245245
}
246246
247-
pub fn item_type(_item_id: ast::def_id, item: ebml::Doc,
248-
tcx: ty::ctxt, cdata: cmd) -> ty::t {
247+
pub fn item_type(_: ast::def_id, item: ebml::Doc, tcx: ty::ctxt, cdata: cmd)
248+
-> ty::t {
249249
doc_type(item, tcx, cdata)
250250
}
251251

src/librustc/metadata/tydecode.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -469,16 +469,9 @@ fn parse_onceness(c: char) -> ast::Onceness {
469469
}
470470
471471
fn parse_arg(st: @mut PState, conv: conv_did) -> ty::arg {
472-
ty::arg { mode: parse_mode(st), ty: parse_ty(st, conv) }
473-
}
474-
475-
fn parse_mode(st: @mut PState) -> ast::mode {
476-
let m = ast::expl(match next(st) {
477-
'+' => ast::by_copy,
478-
'=' => ast::by_ref,
479-
_ => fail!(~"bad mode")
480-
});
481-
return m;
472+
ty::arg {
473+
ty: parse_ty(st, conv)
474+
}
482475
}
483476
484477
fn parse_closure_ty(st: @mut PState, conv: conv_did) -> ty::ClosureTy {
@@ -511,8 +504,7 @@ fn parse_sig(st: @mut PState, conv: conv_did) -> ty::FnSig {
511504
assert!((next(st) == '['));
512505
let mut inputs: ~[ty::arg] = ~[];
513506
while peek(st) != ']' {
514-
let mode = parse_mode(st);
515-
inputs.push(ty::arg { mode: mode, ty: parse_ty(st, conv) });
507+
inputs.push(ty::arg { ty: parse_ty(st, conv) });
516508
}
517509
st.pos += 1u; // eat the ']'
518510
let ret_ty = parse_ty(st, conv);

src/librustc/metadata/tyencode.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -344,17 +344,9 @@ fn enc_sigil(w: @io::Writer, sigil: Sigil) {
344344
}
345345

346346
pub fn enc_arg(w: @io::Writer, cx: @ctxt, arg: ty::arg) {
347-
enc_mode(w, cx, arg.mode);
348347
enc_ty(w, cx, arg.ty);
349348
}
350349

351-
pub fn enc_mode(w: @io::Writer, cx: @ctxt, m: mode) {
352-
match ty::resolved_mode(cx.tcx, m) {
353-
by_copy => w.write_char('+'),
354-
by_ref => w.write_char('='),
355-
}
356-
}
357-
358350
fn enc_purity(w: @io::Writer, p: purity) {
359351
match p {
360352
pure_fn => w.write_char('p'),

src/librustc/middle/astencode.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ impl tr for ast::def {
410410
ast::def_mod(did) => { ast::def_mod(did.tr(xcx)) }
411411
ast::def_foreign_mod(did) => { ast::def_foreign_mod(did.tr(xcx)) }
412412
ast::def_const(did) => { ast::def_const(did.tr(xcx)) }
413-
ast::def_arg(nid, m, b) => { ast::def_arg(xcx.tr_id(nid), m, b) }
413+
ast::def_arg(nid, b) => { ast::def_arg(xcx.tr_id(nid), b) }
414414
ast::def_local(nid, b) => { ast::def_local(xcx.tr_id(nid), b) }
415415
ast::def_variant(e_did, v_did) => {
416416
ast::def_variant(e_did.tr(xcx), v_did.tr(xcx))
@@ -571,6 +571,9 @@ fn encode_method_map_entry(ecx: @e::EncodeContext,
571571
do ebml_w.emit_field(~"origin", 1u) {
572572
mme.origin.encode(ebml_w);
573573
}
574+
do ebml_w.emit_field(~"self_mode", 3) {
575+
mme.self_mode.encode(ebml_w);
576+
}
574577
}
575578
}
576579
@@ -590,6 +593,9 @@ fn encode_method_map_entry(ecx: @e::EncodeContext,
590593
do ebml_w.emit_struct_field("origin", 1u) {
591594
mme.origin.encode(ebml_w);
592595
}
596+
do ebml_w.emit_struct_field("self_mode", 3) {
597+
mme.self_mode.encode(ebml_w);
598+
}
593599
}
594600
}
595601
@@ -611,6 +617,10 @@ impl read_method_map_entry_helper for reader::Decoder {
611617
Decodable::decode(self);
612618
method_origin.tr(xcx)
613619
}),
620+
self_mode: self.read_field(~"self_mode", 3, || {
621+
let self_mode: ty::SelfMode = Decodable::decode(self);
622+
self_mode
623+
}),
614624
}
615625
}
616626
}
@@ -625,7 +635,7 @@ impl read_method_map_entry_helper for reader::Decoder {
625635
self_arg: self.read_struct_field("self_arg", 0u, || {
626636
self.read_arg(xcx)
627637
}),
628-
explicit_self: self.read_struct_field("explicit_self", 2u, || {
638+
explicit_self: self.read_struct_field("explicit_self", 2, || {
629639
let self_type: ast::self_ty_ = Decodable::decode(self);
630640
self_type
631641
}),
@@ -634,6 +644,10 @@ impl read_method_map_entry_helper for reader::Decoder {
634644
Decodable::decode(self);
635645
method_origin.tr(xcx)
636646
}),
647+
self_mode: self.read_struct_field("self_mode", 3, || {
648+
let self_mode: ty::SelfMode = Decodable::decode(self);
649+
self_mode
650+
}),
637651
}
638652
}
639653
}
@@ -978,20 +992,6 @@ fn encode_side_tables_for_id(ecx: @e::EncodeContext,
978992
}
979993
}
980994
981-
// I believe it is not necessary to encode this information. The
982-
// ids will appear in the AST but in the *type* information, which
983-
// is what we actually use in trans, all modes will have been
984-
// resolved.
985-
//
986-
//for tcx.inferred_modes.find(&id).each |m| {
987-
// ebml_w.tag(c::tag_table_inferred_modes) {||
988-
// ebml_w.id(id);
989-
// ebml_w.tag(c::tag_table_val) {||
990-
// tyencode::enc_mode(ebml_w.writer, ty_str_ctxt(), m);
991-
// }
992-
// }
993-
//}
994-
995995
if maps.mutbl_map.contains(&id) {
996996
do ebml_w.tag(c::tag_table_mutbl) {
997997
ebml_w.id(id);

src/librustc/middle/borrowck/gather_loans.rs

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -147,38 +147,6 @@ fn req_loans_in_expr(ex: @ast::expr,
147147
visit::visit_expr(ex, self, vt);
148148
}
149149

150-
ast::expr_call(f, ref args, _) => {
151-
let arg_tys = ty::ty_fn_args(ty::expr_ty(self.tcx(), f));
152-
let scope_r = ty::re_scope(ex.id);
153-
for vec::each2(*args, arg_tys) |arg, arg_ty| {
154-
match ty::resolved_mode(self.tcx(), arg_ty.mode) {
155-
ast::by_ref => {
156-
let arg_cmt = self.bccx.cat_expr(*arg);
157-
self.guarantee_valid(arg_cmt, m_imm, scope_r);
158-
}
159-
ast::by_copy => {}
160-
}
161-
}
162-
visit::visit_expr(ex, self, vt);
163-
}
164-
165-
ast::expr_method_call(_, _, _, ref args, _) => {
166-
let arg_tys = ty::ty_fn_args(ty::node_id_to_type(self.tcx(),
167-
ex.callee_id));
168-
let scope_r = ty::re_scope(ex.id);
169-
for vec::each2(*args, arg_tys) |arg, arg_ty| {
170-
match ty::resolved_mode(self.tcx(), arg_ty.mode) {
171-
ast::by_ref => {
172-
let arg_cmt = self.bccx.cat_expr(*arg);
173-
self.guarantee_valid(arg_cmt, m_imm, scope_r);
174-
}
175-
ast::by_copy => {}
176-
}
177-
}
178-
179-
visit::visit_expr(ex, self, vt);
180-
}
181-
182150
ast::expr_match(ex_v, ref arms) => {
183151
let cmt = self.bccx.cat_expr(ex_v);
184152
for (*arms).each |arm| {

0 commit comments

Comments
 (0)