Skip to content

Commit 22f3492

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 c178ef5 commit 22f3492

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
-1087
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
@@ -247,8 +247,8 @@ fn doc_transformed_self_ty(doc: ebml::Doc,
247247
}
248248
}
249249
250-
pub fn item_type(_item_id: ast::def_id, item: ebml::Doc,
251-
tcx: ty::ctxt, cdata: cmd) -> ty::t {
250+
pub fn item_type(_: ast::def_id, item: ebml::Doc, tcx: ty::ctxt, cdata: cmd)
251+
-> ty::t {
252252
doc_type(item, tcx, cdata)
253253
}
254254

src/librustc/metadata/tydecode.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -474,16 +474,9 @@ fn parse_onceness(c: char) -> ast::Onceness {
474474
}
475475
476476
fn parse_arg(st: @mut PState, conv: conv_did) -> ty::arg {
477-
ty::arg { mode: parse_mode(st), ty: parse_ty(st, conv) }
478-
}
479-
480-
fn parse_mode(st: @mut PState) -> ast::mode {
481-
let m = ast::expl(match next(st) {
482-
'+' => ast::by_copy,
483-
'=' => ast::by_ref,
484-
_ => fail!(~"bad mode")
485-
});
486-
return m;
477+
ty::arg {
478+
ty: parse_ty(st, conv)
479+
}
487480
}
488481
489482
fn parse_closure_ty(st: @mut PState, conv: conv_did) -> ty::ClosureTy {
@@ -516,8 +509,7 @@ fn parse_sig(st: @mut PState, conv: conv_did) -> ty::FnSig {
516509
assert!((next(st) == '['));
517510
let mut inputs: ~[ty::arg] = ~[];
518511
while peek(st) != ']' {
519-
let mode = parse_mode(st);
520-
inputs.push(ty::arg { mode: mode, ty: parse_ty(st, conv) });
512+
inputs.push(ty::arg { ty: parse_ty(st, conv) });
521513
}
522514
st.pos += 1u; // eat the ']'
523515
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
@@ -347,17 +347,9 @@ fn enc_sigil(w: @io::Writer, sigil: Sigil) {
347347
}
348348

349349
pub fn enc_arg(w: @io::Writer, cx: @ctxt, arg: ty::arg) {
350-
enc_mode(w, cx, arg.mode);
351350
enc_ty(w, cx, arg.ty);
352351
}
353352

354-
pub fn enc_mode(w: @io::Writer, cx: @ctxt, m: mode) {
355-
match ty::resolved_mode(cx.tcx, m) {
356-
by_copy => w.write_char('+'),
357-
by_ref => w.write_char('='),
358-
}
359-
}
360-
361353
fn enc_purity(w: @io::Writer, p: purity) {
362354
match p {
363355
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
@@ -412,7 +412,7 @@ impl tr for ast::def {
412412
ast::def_mod(did) => { ast::def_mod(did.tr(xcx)) }
413413
ast::def_foreign_mod(did) => { ast::def_foreign_mod(did.tr(xcx)) }
414414
ast::def_const(did) => { ast::def_const(did.tr(xcx)) }
415-
ast::def_arg(nid, m, b) => { ast::def_arg(xcx.tr_id(nid), m, b) }
415+
ast::def_arg(nid, b) => { ast::def_arg(xcx.tr_id(nid), b) }
416416
ast::def_local(nid, b) => { ast::def_local(xcx.tr_id(nid), b) }
417417
ast::def_variant(e_did, v_did) => {
418418
ast::def_variant(e_did.tr(xcx), v_did.tr(xcx))
@@ -573,6 +573,9 @@ fn encode_method_map_entry(ecx: @e::EncodeContext,
573573
do ebml_w.emit_field(~"origin", 1u) {
574574
mme.origin.encode(ebml_w);
575575
}
576+
do ebml_w.emit_field(~"self_mode", 3) {
577+
mme.self_mode.encode(ebml_w);
578+
}
576579
}
577580
}
578581
@@ -592,6 +595,9 @@ fn encode_method_map_entry(ecx: @e::EncodeContext,
592595
do ebml_w.emit_struct_field("origin", 1u) {
593596
mme.origin.encode(ebml_w);
594597
}
598+
do ebml_w.emit_struct_field("self_mode", 3) {
599+
mme.self_mode.encode(ebml_w);
600+
}
595601
}
596602
}
597603
@@ -613,6 +619,10 @@ impl read_method_map_entry_helper for reader::Decoder {
613619
Decodable::decode(self);
614620
method_origin.tr(xcx)
615621
}),
622+
self_mode: self.read_field(~"self_mode", 3, || {
623+
let self_mode: ty::SelfMode = Decodable::decode(self);
624+
self_mode
625+
}),
616626
}
617627
}
618628
}
@@ -627,7 +637,7 @@ impl read_method_map_entry_helper for reader::Decoder {
627637
self_arg: self.read_struct_field("self_arg", 0u, || {
628638
self.read_arg(xcx)
629639
}),
630-
explicit_self: self.read_struct_field("explicit_self", 2u, || {
640+
explicit_self: self.read_struct_field("explicit_self", 2, || {
631641
let self_type: ast::self_ty_ = Decodable::decode(self);
632642
self_type
633643
}),
@@ -636,6 +646,10 @@ impl read_method_map_entry_helper for reader::Decoder {
636646
Decodable::decode(self);
637647
method_origin.tr(xcx)
638648
}),
649+
self_mode: self.read_struct_field("self_mode", 3, || {
650+
let self_mode: ty::SelfMode = Decodable::decode(self);
651+
self_mode
652+
}),
639653
}
640654
}
641655
}
@@ -980,20 +994,6 @@ fn encode_side_tables_for_id(ecx: @e::EncodeContext,
980994
}
981995
}
982996
983-
// I believe it is not necessary to encode this information. The
984-
// ids will appear in the AST but in the *type* information, which
985-
// is what we actually use in trans, all modes will have been
986-
// resolved.
987-
//
988-
//for tcx.inferred_modes.find(&id).each |m| {
989-
// ebml_w.tag(c::tag_table_inferred_modes) {||
990-
// ebml_w.id(id);
991-
// ebml_w.tag(c::tag_table_val) {||
992-
// tyencode::enc_mode(ebml_w.writer, ty_str_ctxt(), m);
993-
// }
994-
// }
995-
//}
996-
997997
if maps.mutbl_map.contains(&id) {
998998
do ebml_w.tag(c::tag_table_mutbl) {
999999
ebml_w.id(id);

src/librustc/middle/borrowck/gather_loans.rs

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ use util::common::indenter;
3232
use util::ppaux::{Repr, region_to_str};
3333

3434
use core::hashmap::{HashSet, HashMap};
35-
use core::vec;
3635
use syntax::ast::{m_const, m_imm, m_mutbl};
3736
use syntax::ast;
3837
use syntax::codemap::span;
@@ -150,38 +149,6 @@ fn req_loans_in_expr(ex: @ast::expr,
150149
visit::visit_expr(ex, self, vt);
151150
}
152151

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

0 commit comments

Comments
 (0)