Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "De-share ast::Ty" #7644

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/librustc/front/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ fn fold_foreign_mod(
fn fold_item_underscore(cx: @Context, item: &ast::item_,
fld: @fold::ast_fold) -> ast::item_ {
let item = match *item {
ast::item_impl(ref a, ref b, ref c, ref methods) => {
ast::item_impl(ref a, ref b, c, ref methods) => {
let methods = methods.iter().filter(|m| method_in_cfg(cx, **m))
.transform(|x| *x).collect();
ast::item_impl(/*bad*/ copy *a, /*bad*/ copy *b, /*bad*/ copy *c, methods)
ast::item_impl(/*bad*/ copy *a, /*bad*/ copy *b, c, methods)
}
ast::item_trait(ref a, ref b, ref methods) => {
let methods = methods.iter().filter(|m| trait_method_in_cfg(cx, *m) )
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/metadata/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1003,7 +1003,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
index);
}
}
item_impl(ref generics, ref opt_trait, ref ty, ref methods) => {
item_impl(ref generics, ref opt_trait, ty, ref methods) => {
add_to_index();
ebml_w.start_tag(tag_items_data_item);
encode_def_id(ebml_w, local_def(item.id));
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ fn check_item(item: @item, (cx, visitor): (Context, visit::vt<Context>)) {
// If this is a destructor, check kinds.
if !attrs_contains_name(item.attrs, "unsafe_destructor") {
match item.node {
item_impl(_, Some(ref trait_ref), ref self_type, _) => {
item_impl(_, Some(ref trait_ref), self_type, _) => {
match cx.tcx.def_map.find(&trait_ref.ref_id) {
None => cx.tcx.sess.bug("trait ref not in def map!"),
Some(&trait_def) => {
Expand Down Expand Up @@ -321,7 +321,7 @@ pub fn check_expr(e: @expr, (cx, v): (Context, visit::vt<Context>)) {
visit::visit_expr(e, (cx, v));
}

fn check_ty(aty: &Ty, (cx, v): (Context, visit::vt<Context>)) {
fn check_ty(aty: @Ty, (cx, v): (Context, visit::vt<Context>)) {
match aty.node {
ty_path(_, _, id) => {
let r = cx.tcx.node_type_substs.find(&id);
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/middle/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -747,9 +747,9 @@ fn check_item_ctypes(cx: &Context, it: &ast::item) {

fn check_foreign_fn(cx: &Context, decl: &ast::fn_decl) {
for decl.inputs.iter().advance |in| {
check_ty(cx, &in.ty);
check_ty(cx, in.ty);
}
check_ty(cx, &decl.output)
check_ty(cx, decl.output)
}

match it.node {
Expand All @@ -759,7 +759,7 @@ fn check_item_ctypes(cx: &Context, it: &ast::item) {
ast::foreign_item_fn(ref decl, _, _) => {
check_foreign_fn(cx, decl);
}
ast::foreign_item_static(ref t, _) => { check_ty(cx, t); }
ast::foreign_item_static(t, _) => { check_ty(cx, t); }
}
}
}
Expand Down
18 changes: 9 additions & 9 deletions src/librustc/middle/region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -713,10 +713,10 @@ fn determine_rp_in_fn(fk: &visit::fn_kind,
do cx.with(cx.item_id, false) {
do cx.with_ambient_variance(rv_contravariant) {
for decl.inputs.iter().advance |a| {
(visitor.visit_ty)(&a.ty, (cx, visitor));
(visitor.visit_ty)(a.ty, (cx, visitor));
}
}
(visitor.visit_ty)(&decl.output, (cx, visitor));
(visitor.visit_ty)(decl.output, (cx, visitor));
let generics = visit::generics_of_fn(fk);
(visitor.visit_generics)(&generics, (cx, visitor));
(visitor.visit_block)(body, (cx, visitor));
Expand All @@ -731,7 +731,7 @@ fn determine_rp_in_ty_method(ty_m: &ast::ty_method,
}
}

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

match ty.node {
ast::ty_box(ref mt) | ast::ty_uniq(ref mt) | ast::ty_vec(ref mt) |
ast::ty_rptr(_, ref mt) | ast::ty_ptr(ref mt) => {
ast::ty_box(mt) | ast::ty_uniq(mt) | ast::ty_vec(mt) |
ast::ty_rptr(_, mt) | ast::ty_ptr(mt) => {
visit_mt(mt, (cx, visitor));
}

ast::ty_path(ref path, _, _) => {
// type parameters are---for now, anyway---always invariant
do cx.with_ambient_variance(rv_invariant) {
for path.types.iter().advance |tp| {
(visitor.visit_ty)(tp, (cx, visitor));
(visitor.visit_ty)(*tp, (cx, visitor));
}
}
}
Expand All @@ -837,10 +837,10 @@ fn determine_rp_in_ty(ty: &ast::Ty,
// parameters are contravariant
do cx.with_ambient_variance(rv_contravariant) {
for decl.inputs.iter().advance |a| {
(visitor.visit_ty)(&a.ty, (cx, visitor));
(visitor.visit_ty)(a.ty, (cx, visitor));
}
}
(visitor.visit_ty)(&decl.output, (cx, visitor));
(visitor.visit_ty)(decl.output, (cx, visitor));
}
}

Expand All @@ -849,7 +849,7 @@ fn determine_rp_in_ty(ty: &ast::Ty,
}
}

fn visit_mt(mt: &ast::mt,
fn visit_mt(mt: ast::mt,
(cx, visitor): (@mut DetermineRpCtxt,
visit::vt<@mut DetermineRpCtxt>)) {
// mutability is invariant
Expand Down
34 changes: 17 additions & 17 deletions src/librustc/middle/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1233,7 +1233,7 @@ impl Resolver {
visit_item(item, (new_parent, visitor));
}

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

// Create the module and add all methods.
match ty {
&Ty {
match *ty {
Ty {
node: ty_path(ref path, _, _),
_
} if path.idents.len() == 1 => {
Expand Down Expand Up @@ -1313,7 +1313,7 @@ impl Resolver {
visit_item(item, (parent, visitor));
}

item_impl(_, Some(_), _, _) => {
item_impl(_, Some(_), _ty, ref _methods) => {
visit_item(item, (parent, visitor));
}

Expand Down Expand Up @@ -3534,7 +3534,7 @@ impl Resolver {

item_impl(ref generics,
ref implemented_traits,
ref self_type,
self_type,
ref methods) => {
self.resolve_implementation(item.id,
generics,
Expand Down Expand Up @@ -3585,10 +3585,10 @@ impl Resolver {
visitor);

for ty_m.decl.inputs.iter().advance |argument| {
self.resolve_type(&argument.ty, visitor);
self.resolve_type(argument.ty, visitor);
}

self.resolve_type(&ty_m.decl.output, visitor);
self.resolve_type(ty_m.decl.output, visitor);
}
}
provided(m) => {
Expand Down Expand Up @@ -3778,12 +3778,12 @@ impl Resolver {
None,
visitor);

self.resolve_type(&argument.ty, visitor);
self.resolve_type(argument.ty, visitor);

debug!("(resolving function) recorded argument");
}

self.resolve_type(&declaration.output, visitor);
self.resolve_type(declaration.output, visitor);
}
}

Expand Down Expand Up @@ -3878,7 +3878,7 @@ impl Resolver {

// Resolve fields.
for fields.iter().advance |field| {
self.resolve_type(&field.node.ty, visitor);
self.resolve_type(field.node.ty, visitor);
}
}
}
Expand Down Expand Up @@ -3914,7 +3914,7 @@ impl Resolver {
id: node_id,
generics: &Generics,
opt_trait_reference: &Option<trait_ref>,
self_type: &Ty,
self_type: @Ty,
methods: &[@method],
visitor: ResolveVisitor) {
// If applicable, create a rib for the type parameters.
Expand Down Expand Up @@ -4001,7 +4001,7 @@ impl Resolver {
let mutability = if local.node.is_mutbl {Mutable} else {Immutable};

// Resolve the type.
self.resolve_type(&local.node.ty, visitor);
self.resolve_type(local.node.ty, visitor);

// Resolve the initializer, if necessary.
match local.node.init {
Expand Down Expand Up @@ -4112,7 +4112,7 @@ impl Resolver {
debug!("(resolving block) leaving block");
}

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

// Check the types in the path pattern.
for path.types.iter().advance |ty| {
self.resolve_type(ty, visitor);
self.resolve_type(*ty, visitor);
}
}

Expand Down Expand Up @@ -4367,7 +4367,7 @@ impl Resolver {

// Check the types in the path pattern.
for path.types.iter().advance |ty| {
self.resolve_type(ty, visitor);
self.resolve_type(*ty, visitor);
}
}

Expand Down Expand Up @@ -4396,7 +4396,7 @@ impl Resolver {

// Check the types in the path pattern.
for path.types.iter().advance |ty| {
self.resolve_type(ty, visitor);
self.resolve_type(*ty, visitor);
}
}

Expand Down Expand Up @@ -4491,7 +4491,7 @@ impl Resolver {
-> Option<def> {
// First, resolve the types.
for path.types.iter().advance |ty| {
self.resolve_type(ty, visitor);
self.resolve_type(*ty, visitor);
}

if path.global {
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/middle/trans/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1811,7 +1811,7 @@ pub fn copy_args_to_allocas(fcx: fn_ctxt,
fcx.llargs.insert(arg_id, llarg);

if fcx.ccx.sess.opts.extra_debuginfo && fcx_has_nonzero_span(fcx) {
debuginfo::create_arg(bcx, &args[arg_n], args[arg_n].ty.span);
debuginfo::create_arg(bcx, args[arg_n], args[arg_n].ty.span);
}
}

Expand Down Expand Up @@ -1979,7 +1979,7 @@ pub fn trans_enum_variant(ccx: @mut CrateContext,
let fn_args = do args.map |varg| {
ast::arg {
is_mutbl: false,
ty: copy varg.ty,
ty: varg.ty,
pat: ast_util::ident_to_pat(
ccx.tcx.sess.next_node_id(),
codemap::dummy_sp(),
Expand Down Expand Up @@ -2053,7 +2053,7 @@ pub fn trans_tuple_struct(ccx: @mut CrateContext,
let fn_args = do fields.map |field| {
ast::arg {
is_mutbl: false,
ty: copy field.node.ty,
ty: field.node.ty,
pat: ast_util::ident_to_pat(ccx.tcx.sess.next_node_id(),
codemap::dummy_sp(),
special_idents::arg),
Expand Down
20 changes: 9 additions & 11 deletions src/librustc/middle/trans/debuginfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ pub fn create_local_var(bcx: block, local: @ast::local) -> DIVariable {
///
/// Adds the created metadata nodes directly to the crate's IR.
/// The return value should be ignored if called from outside of the debuginfo module.
pub fn create_arg(bcx: block, arg: &ast::arg, span: span) -> Option<DIVariable> {
pub fn create_arg(bcx: block, arg: ast::arg, span: span) -> Option<DIVariable> {
debug!("create_arg");
if true {
// XXX create_arg disabled for now because "node_id_type(bcx, arg.id)" below blows
Expand Down Expand Up @@ -259,25 +259,23 @@ pub fn create_function(fcx: fn_ctxt) -> DISubprogram {
let fcx = &mut *fcx;
let span = fcx.span.get();

let fnitem = cx.tcx.items.get_copy(&fcx.id);
let (ident, ret_ty, id) = match fnitem {
ast_map::node_item(ref item, _) => {
let (ident, ret_ty, id) = match cx.tcx.items.get_copy(&fcx.id) {
ast_map::node_item(item, _) => {
match item.node {
ast::item_fn(ast::fn_decl { output: ref ty, _}, _, _, _, _) => {
(item.ident, ty, item.id)
ast::item_fn(ref decl, _, _, _, _) => {
(item.ident, decl.output, item.id)
}
_ => fcx.ccx.sess.span_bug(item.span, "create_function: item bound to non-function")
}
}
ast_map::node_method(@ast::method { decl: ast::fn_decl { output: ref ty, _ },
id: id, ident: ident, _}, _, _) => {
(ident, ty, id)
ast_map::node_method(method, _, _) => {
(method.ident, method.decl.output, method.id)
}
ast_map::node_expr(ref expr) => {
ast_map::node_expr(expr) => {
match expr.node {
ast::expr_fn_block(ref decl, _) => {
let name = gensym_name("fn");
(name, &decl.output, expr.id)
(name, decl.output, expr.id)
}
_ => fcx.ccx.sess.span_bug(expr.span,
"create_function: expected an expr_fn_block here")
Expand Down
16 changes: 8 additions & 8 deletions src/librustc/middle/typeck/astconv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ fn ast_path_substs<AC:AstConv,RS:region_scope + Copy + 'static>(
fmt!("wrong number of type arguments: expected %u but found %u",
decl_generics.type_param_defs.len(), path.types.len()));
}
let tps = path.types.map(|a_t| ast_ty_to_ty(this, rscope, a_t));
let tps = path.types.map(|a_t| ast_ty_to_ty(this, rscope, *a_t));

substs {self_r:self_r, self_ty:self_ty, tps:tps}
}
Expand Down Expand Up @@ -377,7 +377,7 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:region_scope + Copy + 'static>(
|tmt| ty::mk_rptr(tcx, r, tmt))
}
ast::ty_tup(ref fields) => {
let flds = fields.map(|t| ast_ty_to_ty(this, rscope, t));
let flds = fields.map(|t| ast_ty_to_ty(this, rscope, *t));
ty::mk_tup(tcx, flds)
}
ast::ty_bare_fn(ref bf) => {
Expand Down Expand Up @@ -525,13 +525,13 @@ pub fn ty_of_arg<AC:AstConv,
RS:region_scope + Copy + 'static>(
this: &AC,
rscope: &RS,
a: &ast::arg,
a: ast::arg,
expected_ty: Option<ty::t>)
-> ty::t {
match a.ty.node {
ast::ty_infer if expected_ty.is_some() => expected_ty.get(),
ast::ty_infer => this.ty_infer(a.ty.span),
_ => ast_ty_to_ty(this, rscope, &a.ty),
_ => ast_ty_to_ty(this, rscope, a.ty),
}
}

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

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

let output_ty = match decl.output.node {
ast::ty_infer => this.ty_infer(decl.output.span),
_ => ast_ty_to_ty(this, &rb, &decl.output)
_ => ast_ty_to_ty(this, &rb, decl.output)
};

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

let expected_ret_ty = expected_sig.map(|e| e.output);
let output_ty = match decl.output.node {
ast::ty_infer if expected_ret_ty.is_some() => expected_ret_ty.get(),
ast::ty_infer => this.ty_infer(decl.output.span),
_ => ast_ty_to_ty(this, &rb, &decl.output)
_ => ast_ty_to_ty(this, &rb, decl.output)
};

ty::ClosureTy {
Expand Down
Loading