Skip to content

Commit 47b9294

Browse files
Aatchbrson
authored andcommitted
Revert "De-share ast::Ty"
This reverts commit 47eca21.
1 parent e388a80 commit 47b9294

28 files changed

+264
-265
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, ref c, ref methods) => {
101+
ast::item_impl(ref a, ref b, 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, /*bad*/ copy *c, methods)
104+
ast::item_impl(/*bad*/ copy *a, /*bad*/ copy *b, 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, ref ty, ref methods) => {
1006+
item_impl(ref generics, ref opt_trait, 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), ref self_type, _) => {
120+
item_impl(_, Some(ref trait_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(ref t, _) => { check_ty(cx, t); }
762+
ast::foreign_item_static(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(ref mt) | ast::ty_uniq(ref mt) | ast::ty_vec(ref mt) |
819-
ast::ty_rptr(_, ref mt) | ast::ty_ptr(ref mt) => {
818+
ast::ty_box(mt) | ast::ty_uniq(mt) | ast::ty_vec(mt) |
819+
ast::ty_rptr(_, mt) | ast::ty_ptr(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, ref ty, ref methods) => {
1236+
item_impl(_, None, 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(_), _, _) => {
1316+
item_impl(_, Some(_), _ty, ref _methods) => {
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-
ref self_type,
3537+
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

+5-5
Original file line numberDiff line numberDiff line change
@@ -1750,7 +1750,7 @@ pub fn copy_args_to_allocas(fcx: fn_ctxt,
17501750
bcx = _match::store_arg(bcx, args[arg_n].pat, llarg);
17511751

17521752
if fcx.ccx.sess.opts.extra_debuginfo && fcx_has_nonzero_span(fcx) {
1753-
debuginfo::create_arg(bcx, &args[arg_n], args[arg_n].ty.span);
1753+
debuginfo::create_arg(bcx, args[arg_n], args[arg_n].ty.span);
17541754
}
17551755
}
17561756

@@ -1969,17 +1969,17 @@ pub fn trans_tuple_struct(ccx: @mut CrateContext,
19691969

19701970
trait IdAndTy {
19711971
fn id(&self) -> ast::node_id;
1972-
fn ty<'a>(&'a self) -> &'a ast::Ty;
1972+
fn ty<'a>(&'a self) -> @ast::Ty;
19731973
}
19741974

19751975
impl IdAndTy for ast::variant_arg {
19761976
fn id(&self) -> ast::node_id { self.id }
1977-
fn ty<'a>(&'a self) -> &'a ast::Ty { &self.ty }
1977+
fn ty<'a>(&'a self) -> @ast::Ty { self.ty }
19781978
}
19791979

19801980
impl IdAndTy for @ast::struct_field {
19811981
fn id(&self) -> ast::node_id { self.node.id }
1982-
fn ty<'a>(&'a self) -> &'a ast::Ty { &self.node.ty }
1982+
fn ty<'a>(&'a self) -> @ast::Ty { self.node.ty }
19831983
}
19841984

19851985
pub fn trans_enum_variant_or_tuple_like_struct<A:IdAndTy>(
@@ -1994,7 +1994,7 @@ pub fn trans_enum_variant_or_tuple_like_struct<A:IdAndTy>(
19941994
let fn_args = do args.map |varg| {
19951995
ast::arg {
19961996
is_mutbl: false,
1997-
ty: copy *varg.ty(),
1997+
ty: varg.ty(),
19981998
pat: ast_util::ident_to_pat(
19991999
ccx.tcx.sess.next_node_id(),
20002000
codemap::dummy_sp(),

src/librustc/middle/trans/debuginfo.rs

+9-11
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,25 +259,23 @@ pub fn create_function(fcx: fn_ctxt) -> DISubprogram {
259259
let fcx = &mut *fcx;
260260
let span = fcx.span.get();
261261

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, _) => {
262+
let (ident, ret_ty, id) = match cx.tcx.items.get_copy(&fcx.id) {
263+
ast_map::node_item(item, _) => {
265264
match item.node {
266-
ast::item_fn(ast::fn_decl { output: ref ty, _}, _, _, _, _) => {
267-
(item.ident, ty, item.id)
265+
ast::item_fn(ref decl, _, _, _, _) => {
266+
(item.ident, decl.output, item.id)
268267
}
269268
_ => fcx.ccx.sess.span_bug(item.span, "create_function: item bound to non-function")
270269
}
271270
}
272-
ast_map::node_method(@ast::method { decl: ast::fn_decl { output: ref ty, _ },
273-
id: id, ident: ident, _}, _, _) => {
274-
(ident, ty, id)
271+
ast_map::node_method(method, _, _) => {
272+
(method.ident, method.decl.output, method.id)
275273
}
276-
ast_map::node_expr(ref expr) => {
274+
ast_map::node_expr(expr) => {
277275
match expr.node {
278276
ast::expr_fn_block(ref decl, _) => {
279277
let name = gensym_name("fn");
280-
(name, &decl.output, expr.id)
278+
(name, decl.output, expr.id)
281279
}
282280
_ => fcx.ccx.sess.span_bug(expr.span,
283281
"create_function: expected an expr_fn_block here")

0 commit comments

Comments
 (0)