Skip to content

Commit 9c80cf5

Browse files
committed
rustc: Remove ty::arg
1 parent 191fdda commit 9c80cf5

27 files changed

+181
-302
lines changed

src/librustc/metadata/decoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ pub fn get_enum_variants(intr: @ident_interner, cdata: cmd, id: ast::node_id,
653653
item, tcx, cdata);
654654
let name = item_name(intr, item);
655655
let arg_tys = match ty::get(ctor_ty).sty {
656-
ty::ty_bare_fn(ref f) => f.sig.inputs.map(|a| a.ty),
656+
ty::ty_bare_fn(ref f) => copy f.sig.inputs,
657657
_ => ~[], // Nullary enum variant.
658658
};
659659
match variant_disr_val(item) {

src/librustc/metadata/tydecode.rs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,6 @@ pub fn parse_trait_ref_data(data: @~[u8], crate_num: int, pos: uint, tcx: ty::ct
126126
parse_trait_ref(st, conv)
127127
}
128128

129-
pub fn parse_arg_data(data: @~[u8], crate_num: int, pos: uint, tcx: ty::ctxt,
130-
conv: conv_did) -> ty::arg {
131-
let st = parse_state_from_data(data, crate_num, pos, tcx);
132-
parse_arg(st, conv)
133-
}
134-
135129
fn parse_path(st: @mut PState) -> @ast::Path {
136130
let mut idents: ~[ast::ident] = ~[];
137131
fn is_last(c: char) -> bool { return c == '(' || c == ':'; }
@@ -471,12 +465,6 @@ fn parse_onceness(c: char) -> ast::Onceness {
471465
}
472466
}
473467

474-
fn parse_arg(st: @mut PState, conv: conv_did) -> ty::arg {
475-
ty::arg {
476-
ty: parse_ty(st, conv)
477-
}
478-
}
479-
480468
fn parse_closure_ty(st: @mut PState, conv: conv_did) -> ty::ClosureTy {
481469
let sigil = parse_sigil(st);
482470
let purity = parse_purity(next(st));
@@ -505,9 +493,9 @@ fn parse_bare_fn_ty(st: @mut PState, conv: conv_did) -> ty::BareFnTy {
505493

506494
fn parse_sig(st: @mut PState, conv: conv_did) -> ty::FnSig {
507495
assert!((next(st) == '['));
508-
let mut inputs: ~[ty::arg] = ~[];
496+
let mut inputs = ~[];
509497
while peek(st) != ']' {
510-
inputs.push(ty::arg { ty: parse_ty(st, conv) });
498+
inputs.push(parse_ty(st, conv));
511499
}
512500
st.pos += 1u; // eat the ']'
513501
let ret_ty = parse_ty(st, conv);

src/librustc/metadata/tyencode.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -344,10 +344,6 @@ fn enc_sigil(w: @io::Writer, sigil: Sigil) {
344344
}
345345
}
346346

347-
pub fn enc_arg(w: @io::Writer, cx: @ctxt, arg: ty::arg) {
348-
enc_ty(w, cx, arg.ty);
349-
}
350-
351347
fn enc_purity(w: @io::Writer, p: purity) {
352348
match p {
353349
pure_fn => w.write_char('p'),
@@ -389,8 +385,8 @@ fn enc_closure_ty(w: @io::Writer, cx: @ctxt, ft: &ty::ClosureTy) {
389385

390386
fn enc_fn_sig(w: @io::Writer, cx: @ctxt, fsig: &ty::FnSig) {
391387
w.write_char('[');
392-
for fsig.inputs.each |arg| {
393-
enc_arg(w, cx, *arg);
388+
for fsig.inputs.each |ty| {
389+
enc_ty(w, cx, *ty);
394390
}
395391
w.write_char(']');
396392
enc_ty(w, cx, fsig.output);

src/librustc/middle/astencode.rs

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -526,8 +526,8 @@ fn encode_method_map_entry(ecx: @e::EncodeContext,
526526
ebml_w: &mut writer::Encoder,
527527
mme: method_map_entry) {
528528
do ebml_w.emit_struct("method_map_entry", 3) |ebml_w| {
529-
do ebml_w.emit_struct_field("self_arg", 0u) |ebml_w| {
530-
ebml_w.emit_arg(ecx, mme.self_arg);
529+
do ebml_w.emit_struct_field("self_ty", 0u) |ebml_w| {
530+
ebml_w.emit_ty(ecx, mme.self_ty);
531531
}
532532
do ebml_w.emit_struct_field("explicit_self", 2u) |ebml_w| {
533533
mme.explicit_self.encode(ebml_w);
@@ -546,8 +546,8 @@ impl read_method_map_entry_helper for reader::Decoder {
546546
-> method_map_entry {
547547
do self.read_struct("method_map_entry", 3) |this| {
548548
method_map_entry {
549-
self_arg: this.read_struct_field("self_arg", 0, |this| {
550-
this.read_arg(xcx)
549+
self_ty: this.read_struct_field("self_ty", 0u, |this| {
550+
this.read_ty(xcx)
551551
}),
552552
explicit_self: this.read_struct_field("explicit_self",
553553
2,
@@ -712,7 +712,6 @@ impl get_ty_str_ctxt for e::EncodeContext {
712712
}
713713

714714
trait ebml_writer_helpers {
715-
fn emit_arg(&mut self, ecx: @e::EncodeContext, arg: ty::arg);
716715
fn emit_ty(&mut self, ecx: @e::EncodeContext, ty: ty::t);
717716
fn emit_vstore(&mut self, ecx: @e::EncodeContext, vstore: ty::vstore);
718717
fn emit_tys(&mut self, ecx: @e::EncodeContext, tys: &[ty::t]);
@@ -737,12 +736,6 @@ impl ebml_writer_helpers for writer::Encoder {
737736
}
738737
}
739738

740-
fn emit_arg(&mut self, ecx: @e::EncodeContext, arg: ty::arg) {
741-
do self.emit_opaque |this| {
742-
tyencode::enc_arg(this.writer, ecx.ty_str_ctxt(), arg);
743-
}
744-
}
745-
746739
fn emit_tys(&mut self, ecx: @e::EncodeContext, tys: &[ty::t]) {
747740
do self.emit_from_vec(tys) |this, ty| {
748741
this.emit_ty(ecx, *ty)
@@ -943,7 +936,6 @@ impl doc_decoder_helpers for ebml::Doc {
943936
}
944937

945938
trait ebml_decoder_decoder_helpers {
946-
fn read_arg(&mut self, xcx: @ExtendedDecodeContext) -> ty::arg;
947939
fn read_ty(&mut self, xcx: @ExtendedDecodeContext) -> ty::t;
948940
fn read_tys(&mut self, xcx: @ExtendedDecodeContext) -> ~[ty::t];
949941
fn read_type_param_def(&mut self, xcx: @ExtendedDecodeContext)
@@ -958,17 +950,6 @@ trait ebml_decoder_decoder_helpers {
958950
}
959951

960952
impl ebml_decoder_decoder_helpers for reader::Decoder {
961-
fn read_arg(&mut self, xcx: @ExtendedDecodeContext) -> ty::arg {
962-
do self.read_opaque |this, doc| {
963-
tydecode::parse_arg_data(
964-
doc.data,
965-
xcx.dcx.cdata.cnum,
966-
doc.start,
967-
xcx.dcx.tcx,
968-
|s, a| this.convert_def_id(xcx, s, a))
969-
}
970-
}
971-
972953
fn read_ty(&mut self, xcx: @ExtendedDecodeContext) -> ty::t {
973954
// Note: regions types embed local node ids. In principle, we
974955
// should translate these node ids into the new decode

src/librustc/middle/trans/asm.rs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,9 @@ pub fn trans_inline_asm(bcx: block, ia: &ast::inline_asm) -> block {
3232
let outputs = do ia.outputs.map |&(c, out)| {
3333
constraints.push(copy *c);
3434

35-
let aoutty = ty::arg {
36-
ty: expr_ty(bcx, out)
37-
};
3835
aoutputs.push(unpack_result!(bcx, {
3936
callee::trans_arg_expr(bcx,
40-
aoutty,
37+
expr_ty(bcx, out),
4138
ty::ByCopy,
4239
out,
4340
&mut cleanups,
@@ -50,13 +47,9 @@ pub fn trans_inline_asm(bcx: block, ia: &ast::inline_asm) -> block {
5047
_ => fail!("Expression must be addr of")
5148
};
5249

53-
let outty = ty::arg {
54-
ty: expr_ty(bcx, e)
55-
};
56-
5750
unpack_result!(bcx, {
5851
callee::trans_arg_expr(bcx,
59-
outty,
52+
expr_ty(bcx, e),
6053
ty::ByCopy,
6154
e,
6255
&mut cleanups,
@@ -75,13 +68,9 @@ pub fn trans_inline_asm(bcx: block, ia: &ast::inline_asm) -> block {
7568
let inputs = do ia.inputs.map |&(c, in)| {
7669
constraints.push(copy *c);
7770

78-
let inty = ty::arg {
79-
ty: expr_ty(bcx, in)
80-
};
81-
8271
unpack_result!(bcx, {
8372
callee::trans_arg_expr(bcx,
84-
inty,
73+
expr_ty(bcx, in),
8574
ty::ByCopy,
8675
in,
8776
&mut cleanups,

src/librustc/middle/trans/base.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1701,7 +1701,7 @@ pub fn copy_args_to_allocas(fcx: fn_ctxt,
17011701
bcx: block,
17021702
args: &[ast::arg],
17031703
raw_llargs: &[ValueRef],
1704-
arg_tys: &[ty::arg]) -> block {
1704+
arg_tys: &[ty::t]) -> block {
17051705
let _icx = fcx.insn_ctxt("copy_args_to_allocas");
17061706
let mut bcx = bcx;
17071707

@@ -1720,7 +1720,7 @@ pub fn copy_args_to_allocas(fcx: fn_ctxt,
17201720
}
17211721

17221722
for uint::range(0, arg_tys.len()) |arg_n| {
1723-
let arg_ty = &arg_tys[arg_n];
1723+
let arg_ty = arg_tys[arg_n];
17241724
let raw_llarg = raw_llargs[arg_n];
17251725
let arg_id = args[arg_n].id;
17261726

@@ -1732,15 +1732,15 @@ pub fn copy_args_to_allocas(fcx: fn_ctxt,
17321732
// This alloca should be optimized away by LLVM's mem-to-reg pass in
17331733
// the event it's not truly needed.
17341734
// only by value if immediate:
1735-
let llarg = if datum::appropriate_mode(arg_ty.ty).is_by_value() {
1736-
let alloc = alloc_ty(bcx, arg_ty.ty);
1735+
let llarg = if datum::appropriate_mode(arg_ty).is_by_value() {
1736+
let alloc = alloc_ty(bcx, arg_ty);
17371737
Store(bcx, raw_llarg, alloc);
17381738
alloc
17391739
} else {
17401740
raw_llarg
17411741
};
17421742

1743-
add_clean(bcx, llarg, arg_ty.ty);
1743+
add_clean(bcx, llarg, arg_ty);
17441744

17451745
bcx = _match::bind_irrefutable_pat(bcx,
17461746
args[arg_n].pat,
@@ -1987,7 +1987,7 @@ pub fn trans_enum_variant(ccx: @CrateContext,
19871987
Some(&local_mem(x)) => x,
19881988
_ => fail!("trans_enum_variant: how do we know this works?"),
19891989
};
1990-
let arg_ty = arg_tys[i].ty;
1990+
let arg_ty = arg_tys[i];
19911991
memcpy_ty(bcx, lldestptr, llarg, arg_ty);
19921992
}
19931993
build_return(bcx);
@@ -2061,7 +2061,7 @@ pub fn trans_tuple_struct(ccx: @CrateContext,
20612061
local_mem")
20622062
}
20632063
};
2064-
let arg_ty = arg_tys[i].ty;
2064+
let arg_ty = arg_tys[i];
20652065
memcpy_ty(bcx, lldestptr, llarg, arg_ty);
20662066
}
20672067

src/librustc/middle/trans/callee.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ pub enum AutorefArg {
674674
// temp_cleanups: cleanups that should run only if failure occurs before the
675675
// call takes place:
676676
pub fn trans_arg_expr(bcx: block,
677-
formal_ty: ty::arg,
677+
formal_arg_ty: ty::t,
678678
self_mode: ty::SelfMode,
679679
arg_expr: @ast::expr,
680680
temp_cleanups: &mut ~[ValueRef],
@@ -683,9 +683,9 @@ pub fn trans_arg_expr(bcx: block,
683683
let _icx = bcx.insn_ctxt("trans_arg_expr");
684684
let ccx = bcx.ccx();
685685

686-
debug!("trans_arg_expr(formal_ty=(%s), self_mode=%?, arg_expr=%s, \
686+
debug!("trans_arg_expr(formal_arg_ty=(%s), self_mode=%?, arg_expr=%s, \
687687
ret_flag=%?)",
688-
formal_ty.ty.repr(bcx.tcx()),
688+
formal_arg_ty.repr(bcx.tcx()),
689689
self_mode,
690690
arg_expr.repr(bcx.tcx()),
691691
ret_flag.map(|v| bcx.val_str(*v)));
@@ -734,9 +734,9 @@ pub fn trans_arg_expr(bcx: block,
734734
// "undef" value, as such a value should never
735735
// be inspected. It's important for the value
736736
// to have type lldestty (the callee's expected type).
737-
let llformal_ty = type_of::type_of(ccx, formal_ty.ty);
737+
let llformal_arg_ty = type_of::type_of(ccx, formal_arg_ty);
738738
unsafe {
739-
val = llvm::LLVMGetUndef(llformal_ty);
739+
val = llvm::LLVMGetUndef(llformal_arg_ty);
740740
}
741741
} else {
742742
// FIXME(#3548) use the adjustments table
@@ -784,16 +784,16 @@ pub fn trans_arg_expr(bcx: block,
784784
}
785785
}
786786

787-
if formal_ty.ty != arg_datum.ty {
787+
if formal_arg_ty != arg_datum.ty {
788788
// this could happen due to e.g. subtyping
789-
let llformal_ty = type_of::type_of_explicit_arg(ccx, &formal_ty);
790-
let llformal_ty = match self_mode {
791-
ty::ByRef => T_ptr(llformal_ty),
792-
ty::ByCopy => llformal_ty,
789+
let llformal_arg_ty = type_of::type_of_explicit_arg(ccx, &formal_arg_ty);
790+
let llformal_arg_ty = match self_mode {
791+
ty::ByRef => T_ptr(llformal_arg_ty),
792+
ty::ByCopy => llformal_arg_ty,
793793
};
794794
debug!("casting actual type (%s) to match formal (%s)",
795-
bcx.val_str(val), bcx.llty_str(llformal_ty));
796-
val = PointerCast(bcx, val, llformal_ty);
795+
bcx.val_str(val), bcx.llty_str(llformal_arg_ty));
796+
val = PointerCast(bcx, val, llformal_arg_ty);
797797
}
798798
}
799799

src/librustc/middle/trans/debuginfo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ fn create_ty(cx: @CrateContext, t: ty::t, span: span)
785785
cx.sess.span_bug(span, "debuginfo for rptr NYI")
786786
},
787787
ty::ty_bare_fn(ref barefnty) => {
788-
let inputs = do barefnty.sig.inputs.map |a| { a.ty };
788+
let inputs = barefnty.sig.inputs.map(|a| *a);
789789
let output = barefnty.sig.output;
790790
create_fn_ty(cx, t, inputs, output, span)
791791
},

src/librustc/middle/trans/foreign.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use middle::trans::machine;
2929
use middle::trans::type_of::*;
3030
use middle::trans::type_of;
3131
use middle::ty;
32-
use middle::ty::{FnSig, arg};
32+
use middle::ty::FnSig;
3333
use util::ppaux::ty_to_str;
3434

3535
use syntax::codemap::span;
@@ -94,7 +94,7 @@ fn foreign_signature(ccx: @CrateContext, fn_sig: &ty::FnSig)
9494
* values by pointer like we do.
9595
*/
9696

97-
let llarg_tys = fn_sig.inputs.map(|arg| type_of(ccx, arg.ty));
97+
let llarg_tys = fn_sig.inputs.map(|arg_ty| type_of(ccx, *arg_ty));
9898
let llret_ty = type_of::type_of(ccx, fn_sig.output);
9999
LlvmSignature {
100100
llarg_tys: llarg_tys,
@@ -820,7 +820,7 @@ pub fn trans_intrinsic(ccx: @CrateContext,
820820
region: ty::re_bound(ty::br_anon(0)),
821821
sig: FnSig {
822822
bound_lifetime_names: opt_vec::Empty,
823-
inputs: ~[ arg { ty: star_u8 } ],
823+
inputs: ~[ star_u8 ],
824824
output: ty::mk_nil()
825825
}
826826
});

src/librustc/middle/trans/meth.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ use middle::trans::inline;
2525
use middle::trans::monomorphize;
2626
use middle::trans::type_of::*;
2727
use middle::ty;
28-
use middle::ty::arg;
2928
use middle::typeck;
3029
use util::common::indenter;
3130
use util::ppaux::Repr;
@@ -155,12 +154,10 @@ pub fn trans_self_arg(bcx: block,
155154
let mut temp_cleanups = ~[];
156155

157156
// Compute the type of self.
158-
let self_arg = arg {
159-
ty: monomorphize_type(bcx, mentry.self_arg.ty)
160-
};
157+
let self_ty = monomorphize_type(bcx, mentry.self_ty);
161158

162159
let result = trans_arg_expr(bcx,
163-
self_arg,
160+
self_ty,
164161
mentry.self_mode,
165162
base,
166163
&mut temp_cleanups,

src/librustc/middle/trans/reflect.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -284,13 +284,8 @@ pub impl Reflector {
284284
let sym = mangle_internal_name_by_path_and_seq(ccx,
285285
sub_path,
286286
"get_disr");
287-
let args = [
288-
ty::arg {
289-
ty: opaqueptrty
290-
}
291-
];
292287

293-
let llfty = type_of_fn(ccx, args, ty::mk_int());
288+
let llfty = type_of_fn(ccx, [opaqueptrty], ty::mk_int());
294289
let llfdecl = decl_internal_cdecl_fn(ccx.llmod, sym, llfty);
295290
let arg = unsafe {
296291
llvm::LLVMGetParam(llfdecl, first_real_arg as c_uint)
@@ -357,7 +352,7 @@ pub impl Reflector {
357352
let modeval = 5u; // "by copy"
358353
let extra = ~[self.c_uint(i),
359354
self.c_uint(modeval),
360-
self.c_tydesc(arg.ty)];
355+
self.c_tydesc(*arg)];
361356
self.visit(~"fn_input", extra);
362357
}
363358
let extra = ~[self.c_uint(retval),

0 commit comments

Comments
 (0)