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" #8072

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 @@ -96,10 +96,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((*a).clone(), (*b).clone(), (*c).clone(), methods)
ast::item_impl((*a).clone(), (*b).clone(), 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/tydecode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ fn parse_substs(st: &mut PState, conv: conv_did) -> ty::substs {
};
}

fn parse_region_substs(st: &mut PState, conv: conv_did) -> ty::RegionSubsts {
fn parse_region_substs(st: &mut PState, _conv: conv_did) -> ty::RegionSubsts {
match next(st) {
'e' => ty::ErasedRegions,
'n' => {
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 @@ -116,7 +116,7 @@ fn check_item(item: @item, (cx, visitor): (Context, visit::vt<Context>)) {
// If this is a destructor, check kinds.
if !attr::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 @@ -313,7 +313,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 @@ -707,9 +707,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 @@ -719,7 +719,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 @@ -714,10 +714,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 @@ -732,7 +732,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 @@ -816,16 +816,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 @@ -838,10 +838,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 @@ -850,7 +850,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 @@ -1216,7 +1216,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 @@ -1226,8 +1226,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 @@ -1296,7 +1296,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 @@ -3517,7 +3517,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 @@ -3568,10 +3568,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 @@ -3761,12 +3761,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 @@ -3863,7 +3863,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 @@ -3899,7 +3899,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 @@ -3987,7 +3987,7 @@ impl Resolver {
let mutability = if local.is_mutbl {Mutable} else {Immutable};

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

// Resolve the initializer, if necessary.
match local.init {
Expand Down Expand Up @@ -4098,7 +4098,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 @@ -4320,7 +4320,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 @@ -4353,7 +4353,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 @@ -4382,7 +4382,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 @@ -4478,7 +4478,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
10 changes: 5 additions & 5 deletions src/librustc/middle/trans/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1791,7 +1791,7 @@ pub fn copy_args_to_allocas(fcx: @mut FunctionContext,
bcx = _match::store_arg(bcx, args[arg_n].pat, llarg);

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

Expand Down Expand Up @@ -2011,17 +2011,17 @@ pub fn trans_tuple_struct(ccx: @mut CrateContext,

trait IdAndTy {
fn id(&self) -> ast::node_id;
fn ty<'a>(&'a self) -> &'a ast::Ty;
fn ty(&self) -> @ast::Ty;
}

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

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

pub fn trans_enum_variant_or_tuple_like_struct<A:IdAndTy>(
Expand All @@ -2036,7 +2036,7 @@ pub fn trans_enum_variant_or_tuple_like_struct<A:IdAndTy>(
let fn_args = do args.map |varg| {
ast::arg {
is_mutbl: false,
ty: (*varg.ty()).clone(),
ty: varg.ty(),
pat: ast_util::ident_to_pat(
ccx.tcx.sess.next_node_id(),
codemap::dummy_sp(),
Expand Down
12 changes: 6 additions & 6 deletions src/librustc/middle/trans/debuginfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ pub fn create_local_var_metadata(bcx: @mut Block, local: @ast::Local) -> DIVaria
///
/// 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_argument_metadata(bcx: @mut Block, arg: &ast::arg, span: span) -> Option<DIVariable> {
pub fn create_argument_metadata(bcx: @mut Block, arg: ast::arg, span: span) -> Option<DIVariable> {
debug!("create_argument_metadata");
if true {
// XXX create_argument_metadata disabled for now because "node_id_type(bcx, arg.id)" below
Expand Down Expand Up @@ -278,9 +278,9 @@ pub fn create_function_metadata(fcx: &FunctionContext) -> DISubprogram {

let fnitem = cx.tcx.items.get_copy(&fcx.id);
let (ident, ret_ty, id) = match fnitem {
ast_map::node_item(ref item, _) => {
ast_map::node_item(item, _) => {
match item.node {
ast::item_fn(ast::fn_decl { output: ref ty, _}, _, _, _, _) => {
ast::item_fn(ast::fn_decl { output: ty, _}, _, _, _, _) => {
(item.ident, ty, item.id)
}
_ => fcx.ccx.sess.span_bug(item.span,
Expand All @@ -289,7 +289,7 @@ pub fn create_function_metadata(fcx: &FunctionContext) -> DISubprogram {
}
ast_map::node_method(
@ast::method {
decl: ast::fn_decl { output: ref ty, _ },
decl: ast::fn_decl { output: ty, _ },
id: id,
ident: ident,
_
Expand All @@ -302,7 +302,7 @@ pub fn create_function_metadata(fcx: &FunctionContext) -> DISubprogram {
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_metadata: expected an expr_fn_block here")
Expand All @@ -311,7 +311,7 @@ pub fn create_function_metadata(fcx: &FunctionContext) -> DISubprogram {
ast_map::node_trait_method(
@ast::provided(
@ast::method {
decl: ast::fn_decl { output: ref ty, _ },
decl: ast::fn_decl { output: ty, _ },
id: id,
ident: ident,
_
Expand Down
Loading