Skip to content

Commit 47eca21

Browse files
author
James Miller
committed
De-share ast::Ty
1 parent 46a1f54 commit 47eca21

26 files changed

+256
-255
lines changed

src/librustc/front/config.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,10 @@ fn fold_foreign_mod(
9898
fn fold_item_underscore(cx: @Context, item: &ast::item_,
9999
fld: @fold::ast_fold) -> ast::item_ {
100100
let item = match *item {
101-
ast::item_impl(ref a, ref b, c, ref methods) => {
101+
ast::item_impl(ref a, ref b, ref c, ref methods) => {
102102
let methods = methods.iter().filter(|m| method_in_cfg(cx, **m))
103103
.transform(|x| *x).collect();
104-
ast::item_impl(/*bad*/ copy *a, /*bad*/ copy *b, c, methods)
104+
ast::item_impl(/*bad*/ copy *a, /*bad*/ copy *b, /*bad*/ copy *c, methods)
105105
}
106106
ast::item_trait(ref a, ref b, ref methods) => {
107107
let methods = methods.iter().filter(|m| trait_method_in_cfg(cx, *m) )

src/librustc/metadata/encoder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1003,7 +1003,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
10031003
index);
10041004
}
10051005
}
1006-
item_impl(ref generics, ref opt_trait, ty, ref methods) => {
1006+
item_impl(ref generics, ref opt_trait, ref ty, ref methods) => {
10071007
add_to_index();
10081008
ebml_w.start_tag(tag_items_data_item);
10091009
encode_def_id(ebml_w, local_def(item.id));

src/librustc/middle/kind.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ fn check_item(item: @item, (cx, visitor): (Context, visit::vt<Context>)) {
117117
// If this is a destructor, check kinds.
118118
if !attrs_contains_name(item.attrs, "unsafe_destructor") {
119119
match item.node {
120-
item_impl(_, Some(ref trait_ref), self_type, _) => {
120+
item_impl(_, Some(ref trait_ref), ref self_type, _) => {
121121
match cx.tcx.def_map.find(&trait_ref.ref_id) {
122122
None => cx.tcx.sess.bug("trait ref not in def map!"),
123123
Some(&trait_def) => {
@@ -321,7 +321,7 @@ pub fn check_expr(e: @expr, (cx, v): (Context, visit::vt<Context>)) {
321321
visit::visit_expr(e, (cx, v));
322322
}
323323

324-
fn check_ty(aty: @Ty, (cx, v): (Context, visit::vt<Context>)) {
324+
fn check_ty(aty: &Ty, (cx, v): (Context, visit::vt<Context>)) {
325325
match aty.node {
326326
ty_path(_, _, id) => {
327327
let r = cx.tcx.node_type_substs.find(&id);

src/librustc/middle/lint.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -747,9 +747,9 @@ fn check_item_ctypes(cx: &Context, it: &ast::item) {
747747

748748
fn check_foreign_fn(cx: &Context, decl: &ast::fn_decl) {
749749
for decl.inputs.iter().advance |in| {
750-
check_ty(cx, in.ty);
750+
check_ty(cx, &in.ty);
751751
}
752-
check_ty(cx, decl.output)
752+
check_ty(cx, &decl.output)
753753
}
754754

755755
match it.node {
@@ -759,7 +759,7 @@ fn check_item_ctypes(cx: &Context, it: &ast::item) {
759759
ast::foreign_item_fn(ref decl, _, _) => {
760760
check_foreign_fn(cx, decl);
761761
}
762-
ast::foreign_item_static(t, _) => { check_ty(cx, t); }
762+
ast::foreign_item_static(ref t, _) => { check_ty(cx, t); }
763763
}
764764
}
765765
}

src/librustc/middle/region.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -713,10 +713,10 @@ fn determine_rp_in_fn(fk: &visit::fn_kind,
713713
do cx.with(cx.item_id, false) {
714714
do cx.with_ambient_variance(rv_contravariant) {
715715
for decl.inputs.iter().advance |a| {
716-
(visitor.visit_ty)(a.ty, (cx, visitor));
716+
(visitor.visit_ty)(&a.ty, (cx, visitor));
717717
}
718718
}
719-
(visitor.visit_ty)(decl.output, (cx, visitor));
719+
(visitor.visit_ty)(&decl.output, (cx, visitor));
720720
let generics = visit::generics_of_fn(fk);
721721
(visitor.visit_generics)(&generics, (cx, visitor));
722722
(visitor.visit_block)(body, (cx, visitor));
@@ -731,7 +731,7 @@ fn determine_rp_in_ty_method(ty_m: &ast::ty_method,
731731
}
732732
}
733733

734-
fn determine_rp_in_ty(ty: @ast::Ty,
734+
fn determine_rp_in_ty(ty: &ast::Ty,
735735
(cx, visitor): (@mut DetermineRpCtxt,
736736
visit::vt<@mut DetermineRpCtxt>)) {
737737
// we are only interested in types that will require an item to
@@ -815,16 +815,16 @@ fn determine_rp_in_ty(ty: @ast::Ty,
815815
}
816816

817817
match ty.node {
818-
ast::ty_box(mt) | ast::ty_uniq(mt) | ast::ty_vec(mt) |
819-
ast::ty_rptr(_, mt) | ast::ty_ptr(mt) => {
818+
ast::ty_box(ref mt) | ast::ty_uniq(ref mt) | ast::ty_vec(ref mt) |
819+
ast::ty_rptr(_, ref mt) | ast::ty_ptr(ref mt) => {
820820
visit_mt(mt, (cx, visitor));
821821
}
822822

823823
ast::ty_path(ref path, _, _) => {
824824
// type parameters are---for now, anyway---always invariant
825825
do cx.with_ambient_variance(rv_invariant) {
826826
for path.types.iter().advance |tp| {
827-
(visitor.visit_ty)(*tp, (cx, visitor));
827+
(visitor.visit_ty)(tp, (cx, visitor));
828828
}
829829
}
830830
}
@@ -837,10 +837,10 @@ fn determine_rp_in_ty(ty: @ast::Ty,
837837
// parameters are contravariant
838838
do cx.with_ambient_variance(rv_contravariant) {
839839
for decl.inputs.iter().advance |a| {
840-
(visitor.visit_ty)(a.ty, (cx, visitor));
840+
(visitor.visit_ty)(&a.ty, (cx, visitor));
841841
}
842842
}
843-
(visitor.visit_ty)(decl.output, (cx, visitor));
843+
(visitor.visit_ty)(&decl.output, (cx, visitor));
844844
}
845845
}
846846

@@ -849,7 +849,7 @@ fn determine_rp_in_ty(ty: @ast::Ty,
849849
}
850850
}
851851

852-
fn visit_mt(mt: ast::mt,
852+
fn visit_mt(mt: &ast::mt,
853853
(cx, visitor): (@mut DetermineRpCtxt,
854854
visit::vt<@mut DetermineRpCtxt>)) {
855855
// mutability is invariant

src/librustc/middle/resolve.rs

+17-17
Original file line numberDiff line numberDiff line change
@@ -1233,7 +1233,7 @@ impl Resolver {
12331233
visit_item(item, (new_parent, visitor));
12341234
}
12351235

1236-
item_impl(_, None, ty, ref methods) => {
1236+
item_impl(_, None, ref ty, ref methods) => {
12371237
// If this implements an anonymous trait, then add all the
12381238
// methods within to a new module, if the type was defined
12391239
// within this module.
@@ -1243,8 +1243,8 @@ impl Resolver {
12431243
// the same module that declared the type.
12441244

12451245
// Create the module and add all methods.
1246-
match *ty {
1247-
Ty {
1246+
match ty {
1247+
&Ty {
12481248
node: ty_path(ref path, _, _),
12491249
_
12501250
} if path.idents.len() == 1 => {
@@ -1313,7 +1313,7 @@ impl Resolver {
13131313
visit_item(item, (parent, visitor));
13141314
}
13151315

1316-
item_impl(_, Some(_), _ty, ref _methods) => {
1316+
item_impl(_, Some(_), _, _) => {
13171317
visit_item(item, (parent, visitor));
13181318
}
13191319

@@ -3534,7 +3534,7 @@ impl Resolver {
35343534

35353535
item_impl(ref generics,
35363536
ref implemented_traits,
3537-
self_type,
3537+
ref self_type,
35383538
ref methods) => {
35393539
self.resolve_implementation(item.id,
35403540
generics,
@@ -3585,10 +3585,10 @@ impl Resolver {
35853585
visitor);
35863586

35873587
for ty_m.decl.inputs.iter().advance |argument| {
3588-
self.resolve_type(argument.ty, visitor);
3588+
self.resolve_type(&argument.ty, visitor);
35893589
}
35903590

3591-
self.resolve_type(ty_m.decl.output, visitor);
3591+
self.resolve_type(&ty_m.decl.output, visitor);
35923592
}
35933593
}
35943594
provided(m) => {
@@ -3778,12 +3778,12 @@ impl Resolver {
37783778
None,
37793779
visitor);
37803780

3781-
self.resolve_type(argument.ty, visitor);
3781+
self.resolve_type(&argument.ty, visitor);
37823782

37833783
debug!("(resolving function) recorded argument");
37843784
}
37853785

3786-
self.resolve_type(declaration.output, visitor);
3786+
self.resolve_type(&declaration.output, visitor);
37873787
}
37883788
}
37893789

@@ -3878,7 +3878,7 @@ impl Resolver {
38783878

38793879
// Resolve fields.
38803880
for fields.iter().advance |field| {
3881-
self.resolve_type(field.node.ty, visitor);
3881+
self.resolve_type(&field.node.ty, visitor);
38823882
}
38833883
}
38843884
}
@@ -3914,7 +3914,7 @@ impl Resolver {
39143914
id: node_id,
39153915
generics: &Generics,
39163916
opt_trait_reference: &Option<trait_ref>,
3917-
self_type: @Ty,
3917+
self_type: &Ty,
39183918
methods: &[@method],
39193919
visitor: ResolveVisitor) {
39203920
// If applicable, create a rib for the type parameters.
@@ -4001,7 +4001,7 @@ impl Resolver {
40014001
let mutability = if local.node.is_mutbl {Mutable} else {Immutable};
40024002

40034003
// Resolve the type.
4004-
self.resolve_type(local.node.ty, visitor);
4004+
self.resolve_type(&local.node.ty, visitor);
40054005

40064006
// Resolve the initializer, if necessary.
40074007
match local.node.init {
@@ -4112,7 +4112,7 @@ impl Resolver {
41124112
debug!("(resolving block) leaving block");
41134113
}
41144114

4115-
pub fn resolve_type(@mut self, ty: @Ty, visitor: ResolveVisitor) {
4115+
pub fn resolve_type(@mut self, ty: &Ty, visitor: ResolveVisitor) {
41164116
match ty.node {
41174117
// Like path expressions, the interpretation of path types depends
41184118
// on whether the path has multiple elements in it or not.
@@ -4334,7 +4334,7 @@ impl Resolver {
43344334

43354335
// Check the types in the path pattern.
43364336
for path.types.iter().advance |ty| {
4337-
self.resolve_type(*ty, visitor);
4337+
self.resolve_type(ty, visitor);
43384338
}
43394339
}
43404340

@@ -4367,7 +4367,7 @@ impl Resolver {
43674367

43684368
// Check the types in the path pattern.
43694369
for path.types.iter().advance |ty| {
4370-
self.resolve_type(*ty, visitor);
4370+
self.resolve_type(ty, visitor);
43714371
}
43724372
}
43734373

@@ -4396,7 +4396,7 @@ impl Resolver {
43964396

43974397
// Check the types in the path pattern.
43984398
for path.types.iter().advance |ty| {
4399-
self.resolve_type(*ty, visitor);
4399+
self.resolve_type(ty, visitor);
44004400
}
44014401
}
44024402

@@ -4491,7 +4491,7 @@ impl Resolver {
44914491
-> Option<def> {
44924492
// First, resolve the types.
44934493
for path.types.iter().advance |ty| {
4494-
self.resolve_type(*ty, visitor);
4494+
self.resolve_type(ty, visitor);
44954495
}
44964496

44974497
if path.global {

src/librustc/middle/trans/base.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1737,7 +1737,7 @@ pub fn copy_args_to_allocas(fcx: fn_ctxt,
17371737
fcx.llargs.insert(arg_id, llarg);
17381738

17391739
if fcx.ccx.sess.opts.extra_debuginfo && fcx_has_nonzero_span(fcx) {
1740-
debuginfo::create_arg(bcx, args[arg_n], args[arg_n].ty.span);
1740+
debuginfo::create_arg(bcx, &args[arg_n], args[arg_n].ty.span);
17411741
}
17421742
}
17431743

@@ -1911,7 +1911,7 @@ pub fn trans_enum_variant(ccx: @mut CrateContext,
19111911
let fn_args = do args.map |varg| {
19121912
ast::arg {
19131913
is_mutbl: false,
1914-
ty: varg.ty,
1914+
ty: copy varg.ty,
19151915
pat: ast_util::ident_to_pat(
19161916
ccx.tcx.sess.next_node_id(),
19171917
codemap::dummy_sp(),
@@ -1985,7 +1985,7 @@ pub fn trans_tuple_struct(ccx: @mut CrateContext,
19851985
let fn_args = do fields.map |field| {
19861986
ast::arg {
19871987
is_mutbl: false,
1988-
ty: field.node.ty,
1988+
ty: copy field.node.ty,
19891989
pat: ast_util::ident_to_pat(ccx.tcx.sess.next_node_id(),
19901990
codemap::dummy_sp(),
19911991
special_idents::arg),

src/librustc/middle/trans/debuginfo.rs

+11-9
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ pub fn create_local_var(bcx: block, local: @ast::local) -> DIVariable {
182182
///
183183
/// Adds the created metadata nodes directly to the crate's IR.
184184
/// The return value should be ignored if called from outside of the debuginfo module.
185-
pub fn create_arg(bcx: block, arg: ast::arg, span: span) -> Option<DIVariable> {
185+
pub fn create_arg(bcx: block, arg: &ast::arg, span: span) -> Option<DIVariable> {
186186
debug!("create_arg");
187187
if true {
188188
// XXX create_arg disabled for now because "node_id_type(bcx, arg.id)" below blows
@@ -259,23 +259,25 @@ pub fn create_function(fcx: fn_ctxt) -> DISubprogram {
259259
let fcx = &mut *fcx;
260260
let span = fcx.span.get();
261261

262-
let (ident, ret_ty, id) = match cx.tcx.items.get_copy(&fcx.id) {
263-
ast_map::node_item(item, _) => {
262+
let fnitem = cx.tcx.items.get_copy(&fcx.id);
263+
let (ident, ret_ty, id) = match fnitem {
264+
ast_map::node_item(ref item, _) => {
264265
match item.node {
265-
ast::item_fn(ref decl, _, _, _, _) => {
266-
(item.ident, decl.output, item.id)
266+
ast::item_fn(ast::fn_decl { output: ref ty, _}, _, _, _, _) => {
267+
(item.ident, ty, item.id)
267268
}
268269
_ => fcx.ccx.sess.span_bug(item.span, "create_function: item bound to non-function")
269270
}
270271
}
271-
ast_map::node_method(method, _, _) => {
272-
(method.ident, method.decl.output, method.id)
272+
ast_map::node_method(@ast::method { decl: ast::fn_decl { output: ref ty, _ },
273+
id: id, ident: ident, _}, _, _) => {
274+
(ident, ty, id)
273275
}
274-
ast_map::node_expr(expr) => {
276+
ast_map::node_expr(ref expr) => {
275277
match expr.node {
276278
ast::expr_fn_block(ref decl, _) => {
277279
let name = gensym_name("fn");
278-
(name, decl.output, expr.id)
280+
(name, &decl.output, expr.id)
279281
}
280282
_ => fcx.ccx.sess.span_bug(expr.span,
281283
"create_function: expected an expr_fn_block here")

src/librustc/middle/typeck/astconv.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ fn ast_path_substs<AC:AstConv,RS:region_scope + Copy + 'static>(
179179
fmt!("wrong number of type arguments: expected %u but found %u",
180180
decl_generics.type_param_defs.len(), path.types.len()));
181181
}
182-
let tps = path.types.map(|a_t| ast_ty_to_ty(this, rscope, *a_t));
182+
let tps = path.types.map(|a_t| ast_ty_to_ty(this, rscope, a_t));
183183

184184
substs {self_r:self_r, self_ty:self_ty, tps:tps}
185185
}
@@ -377,7 +377,7 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:region_scope + Copy + 'static>(
377377
|tmt| ty::mk_rptr(tcx, r, tmt))
378378
}
379379
ast::ty_tup(ref fields) => {
380-
let flds = fields.map(|t| ast_ty_to_ty(this, rscope, *t));
380+
let flds = fields.map(|t| ast_ty_to_ty(this, rscope, t));
381381
ty::mk_tup(tcx, flds)
382382
}
383383
ast::ty_bare_fn(ref bf) => {
@@ -525,13 +525,13 @@ pub fn ty_of_arg<AC:AstConv,
525525
RS:region_scope + Copy + 'static>(
526526
this: &AC,
527527
rscope: &RS,
528-
a: ast::arg,
528+
a: &ast::arg,
529529
expected_ty: Option<ty::t>)
530530
-> ty::t {
531531
match a.ty.node {
532532
ast::ty_infer if expected_ty.is_some() => expected_ty.get(),
533533
ast::ty_infer => this.ty_infer(a.ty.span),
534-
_ => ast_ty_to_ty(this, rscope, a.ty),
534+
_ => ast_ty_to_ty(this, rscope, &a.ty),
535535
}
536536
}
537537

@@ -621,11 +621,11 @@ fn ty_of_method_or_bare_fn<AC:AstConv,RS:region_scope + Copy + 'static>(
621621
transform_self_ty(this, &rb, self_info)
622622
});
623623

624-
let input_tys = decl.inputs.map(|a| ty_of_arg(this, &rb, *a, None));
624+
let input_tys = decl.inputs.map(|a| ty_of_arg(this, &rb, a, None));
625625

626626
let output_ty = match decl.output.node {
627627
ast::ty_infer => this.ty_infer(decl.output.span),
628-
_ => ast_ty_to_ty(this, &rb, decl.output)
628+
_ => ast_ty_to_ty(this, &rb, &decl.output)
629629
};
630630

631631
return (opt_transformed_self_ty,
@@ -724,14 +724,14 @@ pub fn ty_of_closure<AC:AstConv,RS:region_scope + Copy + 'static>(
724724
// were supplied
725725
if i < e.inputs.len() {Some(e.inputs[i])} else {None}
726726
};
727-
ty_of_arg(this, &rb, *a, expected_arg_ty)
727+
ty_of_arg(this, &rb, a, expected_arg_ty)
728728
}.collect();
729729

730730
let expected_ret_ty = expected_sig.map(|e| e.output);
731731
let output_ty = match decl.output.node {
732732
ast::ty_infer if expected_ret_ty.is_some() => expected_ret_ty.get(),
733733
ast::ty_infer => this.ty_infer(decl.output.span),
734-
_ => ast_ty_to_ty(this, &rb, decl.output)
734+
_ => ast_ty_to_ty(this, &rb, &decl.output)
735735
};
736736

737737
ty::ClosureTy {

0 commit comments

Comments
 (0)