import util::filesearch;
enum output_type {
- output_type_none;
- output_type_bitcode;
- output_type_assembly;
- output_type_llvm_assembly;
- output_type_object;
- output_type_exe;
+ output_type_none,
+ output_type_bitcode,
+ output_type_assembly,
+ output_type_llvm_assembly,
+ output_type_object,
+ output_type_exe,
}
fn llvm_err(sess: session, msg: str) unsafe {
}
enum level {
- fatal;
- error;
- warning;
- note;
+ fatal,
+ error,
+ warning,
+ note,
}
fn diagnosticstr(lvl: level) -> str {
import getopts::{optopt, optmulti, optflag, optflagopt, opt_present};
import back::{x86, x86_64};
-enum pp_mode { ppm_normal; ppm_expanded; ppm_typed; ppm_identified; }
+enum pp_mode { ppm_normal, ppm_expanded, ppm_typed, ppm_identified, }
fn default_configuration(sess: session, argv0: str, input: str) ->
ast::crate_cfg {
}
enum compile_upto {
- cu_parse;
- cu_expand;
- cu_typeck;
- cu_no_trans;
- cu_everything;
+ cu_parse,
+ cu_expand,
+ cu_typeck,
+ cu_no_trans,
+ cu_everything,
}
fn compile_upto(sess: session, cfg: ast::crate_cfg,
*/
fn monitor(f: fn~(diagnostic::emitter)) {
enum monitor_msg {
- fatal;
- done;
+ fatal,
+ done,
};
let p = comm::port();
import back::target_strs;
import middle::lint;
-enum os { os_win32; os_macos; os_linux; os_freebsd; }
+enum os { os_win32, os_macos, os_linux, os_freebsd, }
-enum arch { arch_x86; arch_x86_64; arch_arm; }
+enum arch { arch_x86, arch_x86_64, arch_arm, }
-enum crate_type { bin_crate; lib_crate; unknown_crate; }
+enum crate_type { bin_crate, lib_crate, unknown_crate, }
type config =
{os: os,
// other modules to access the cstore's private data. This could also be
// achieved with an obj, but at the expense of a vtable. Not sure if this is a
// good pattern or not.
-enum cstore { private(cstore_private); }
+enum cstore { private(cstore_private), }
type cstore_private =
@{metas: map::hashmap<ast::crate_num, crate_metadata>,
// Whatever format you choose should not contain pipe characters.
type ty_abbrev = {pos: uint, len: uint, s: @str};
-enum abbrev_ctxt { ac_no_abbrevs; ac_use_abbrevs(hashmap<ty::t, ty_abbrev>); }
+enum abbrev_ctxt { ac_no_abbrevs, ac_use_abbrevs(hashmap<ty::t, ty_abbrev>), }
fn cx_uses_abbrevs(cx: @ctxt) -> bool {
alt cx.abbrevs {
// getting input from one, to be more precise). It is a pass that checks
// whether aliases are used in a safe way.
-enum copied { not_allowed; copied; not_copied; }
-enum invalid_reason { overwritten; val_taken; }
+enum copied { not_allowed, copied, not_copied, }
+enum invalid_reason { overwritten, val_taken, }
type invalid = {reason: invalid_reason,
node_id: node_id,
sp: span, path: @ast::path};
-enum unsafe_ty { contains(ty::t); mut_contains(ty::t); }
+enum unsafe_ty { contains(ty::t), mut_contains(ty::t), }
type binding = @{node_id: node_id,
span: span,
mutable copied: not_copied};
}
-enum local_info { local(uint); }
+enum local_info { local(uint), }
type copy_map = std::map::hashmap<node_id, ()>;
type ref_map = std::map::hashmap<node_id, node_id>;
import syntax::{visit, codemap};
enum ast_node {
- node_item(@item);
- node_native_item(@native_item);
- node_method(@method);
- node_expr(@expr);
+ node_item(@item),
+ node_native_item(@native_item),
+ node_method(@method),
+ node_expr(@expr),
// Locals are numbered, because the alias analysis needs to know in which
// order they are introduced.
- node_arg(arg, uint);
- node_local(uint);
- node_res_ctor(@item);
+ node_arg(arg, uint),
+ node_local(uint),
+ node_res_ctor(@item),
}
type map = std::map::map<node_id, ast_node>;
export cap_ref;
enum capture_mode {
- cap_copy; //< Copy the value into the closure.
- cap_move; //< Move the value into the closure.
- cap_drop; //< Drop value after creating closure.
- cap_ref; //< Reference directly from parent stack frame (block fn).
+ cap_copy, //< Copy the value into the closure.
+ cap_move, //< Move the value into the closure.
+ cap_drop, //< Drop value after creating closure.
+ cap_ref, //< Reference directly from parent stack frame (block fn).
}
type capture_var = {
type metadata_cache = hashmap<int, [debug_metadata]>;
enum debug_metadata {
- file_metadata(@metadata<file_md>);
- compile_unit_metadata(@metadata<compile_unit_md>);
- subprogram_metadata(@metadata<subprogram_md>);
- local_var_metadata(@metadata<local_var_md>);
- tydesc_metadata(@metadata<tydesc_md>);
- block_metadata(@metadata<block_md>);
- argument_metadata(@metadata<argument_md>);
- retval_metadata(@metadata<retval_md>);
+ file_metadata(@metadata<file_md>),
+ compile_unit_metadata(@metadata<compile_unit_md>),
+ subprogram_metadata(@metadata<subprogram_md>),
+ local_var_metadata(@metadata<local_var_md>),
+ tydesc_metadata(@metadata<tydesc_md>),
+ block_metadata(@metadata<block_md>),
+ argument_metadata(@metadata<argument_md>),
+ retval_metadata(@metadata<retval_md>),
}
fn cast_safely<T: copy, U>(val: T) -> U unsafe {
// Marks expr_paths that are last uses.
type last_uses = std::map::hashmap<node_id, ()>;
-enum seen { unset; seen(node_id); }
-enum block_type { func; loop; }
+enum seen { unset, seen(node_id), }
+enum block_type { func, loop, }
type set = [{def: node_id, exprs: list<node_id>}];
type bl = @{type: block_type, mutable second: bool, mutable exits: [set]};
type crate_ctxt = {tcx: ty::ctxt};
enum option {
- ctypes;
+ ctypes,
}
fn check_ctypes(tcx: ty::ctxt, crate: @ast::crate) {
import syntax::ast_util;
import driver::session::session;
-enum deref_t { unbox; field; index; }
+enum deref_t { unbox, field, index, }
type deref = @{mut: bool, kind: deref_t, outer_t: ty::t};
ret cx.mut_map;
}
-enum msg { msg_assign; msg_move_out; msg_mut_ref; }
+enum msg { msg_assign, msg_move_out, msg_mut_ref, }
fn mk_err(cx: @ctx, span: syntax::codemap::span, msg: msg, name: str) {
cx.tcx.sess.span_err(span, alt msg {
// them, storing the resulting def in the AST nodes.
enum scope {
- scope_crate;
- scope_item(@ast::item);
- scope_bare_fn(ast::fn_decl, node_id, [ast::ty_param]);
- scope_fn_expr(ast::fn_decl, node_id, [ast::ty_param]);
- scope_native_item(@ast::native_item);
- scope_loop(@ast::local); // there's only 1 decl per loop.
- scope_block(ast::blk, @mutable uint, @mutable uint);
- scope_arm(ast::arm);
- scope_method(ast::node_id, [ast::ty_param]);
+ scope_crate,
+ scope_item(@ast::item),
+ scope_bare_fn(ast::fn_decl, node_id, [ast::ty_param]),
+ scope_fn_expr(ast::fn_decl, node_id, [ast::ty_param]),
+ scope_native_item(@ast::native_item),
+ scope_loop(@ast::local), // there's only 1 decl per loop.
+ scope_block(ast::blk, @mutable uint, @mutable uint),
+ scope_arm(ast::arm),
+ scope_method(ast::node_id, [ast::ty_param]),
}
type scopes = list<scope>;
enum import_state {
- todo(ast::node_id, ast::ident, @[ast::ident], codemap::span, scopes);
- is_glob(@[ast::ident], scopes, codemap::span);
- resolving(span);
+ todo(ast::node_id, ast::ident, @[ast::ident], codemap::span, scopes),
+ is_glob(@[ast::ident], scopes, codemap::span),
+ resolving(span),
resolved(option::t<def>, /* value */
option::t<def>, /* type */
option::t<def>, /* module */
@[@_impl], /* impls */
/* used for reporting unused import warning */
- ast::ident, codemap::span);
+ ast::ident, codemap::span),
}
enum glob_import_state {
- glob_resolving(span);
+ glob_resolving(span),
glob_resolved(option::t<def>, /* value */
option::t<def>, /* type */
- option::t<def>); /* module */
+ option::t<def>), /* module */
}
type ext_hash = hashmap<{did: def_id, ident: str, ns: namespace}, def>;
}
enum mod_index_entry {
- mie_view_item(@ast::view_item);
- mie_import_ident(node_id, codemap::span);
- mie_item(@ast::item);
- mie_native_item(@ast::native_item);
- mie_tag_variant(/* enum item */@ast::item, /* variant index */uint);
+ mie_view_item(@ast::view_item),
+ mie_import_ident(node_id, codemap::span),
+ mie_item(@ast::item),
+ mie_native_item(@ast::native_item),
+ mie_tag_variant(/* enum item */@ast::item, /* variant index */uint),
}
type mod_index = hashmap<ident, list<mod_index_entry>>;
// Used to distinguish between lookups from outside and from inside modules,
// since export restrictions should only be applied for the former.
-enum dir { inside; outside; }
+enum dir { inside, outside, }
// There are two types of ns_value enum: "definitely a enum";
// and "any value". This is so that lookup can behave differently
// when looking up a variable name that's not yet in scope to check
// if it's already bound to a enum.
-enum namespace { ns_val(ns_value_type); ns_type; ns_module; }
-enum ns_value_type { ns_a_tag; ns_any_value; }
+enum namespace { ns_val(ns_value_type), ns_type, ns_module, }
+enum ns_value_type { ns_a_tag, ns_any_value, }
fn resolve_crate(sess: session, amap: ast_map::map, crate: @ast::crate) ->
{def_map: def_map, exp_map: exp_map, impl_map: impl_map} {
}
}
-enum ctxt { in_mod(def); in_scope(scopes); }
+enum ctxt { in_mod(def), in_scope(scopes), }
fn unresolved_err(e: env, cx: ctxt, sp: span, name: ident, kind: str) {
fn find_fn_or_mod_scope(sc: scopes) -> option::t<scope> {
ret {size: max_size, align: max_align};
}
-enum tag_kind { tk_unit; tk_enum; tk_complex; }
+enum tag_kind { tk_unit, tk_enum, tk_complex, }
fn tag_kind(ccx: @crate_ctxt, did: ast::def_id) -> tag_kind {
let variants = ty::tag_variants(ccx.tcx, did);
// Used only for creating scalar comparison glue.
-enum scalar_type { nil_type; signed_int; unsigned_int; floating_point; }
+enum scalar_type { nil_type, signed_int, unsigned_int, floating_point, }
fn compare_scalar_types(cx: @block_ctxt, lhs: ValueRef, rhs: ValueRef,
ret call_memmove(bcx, dst, src, llsz).bcx;
}
-enum copy_action { INIT; DROP_EXISTING; }
+enum copy_action { INIT, DROP_EXISTING, }
// These are the types that are passed by pointer.
fn type_is_structural_or_param(tcx: ty::ctxt, t: ty::t) -> bool {
}
enum dest {
- by_val(@mutable ValueRef);
- save_in(ValueRef);
- ignore;
+ by_val(@mutable ValueRef),
+ save_in(ValueRef),
+ ignore,
}
fn empty_dest_cell() -> @mutable ValueRef {
};
enum lval_kind {
- temporary; //< Temporary value passed by value if of immediate type
- owned; //< Non-temporary value passed by pointer
- owned_imm; //< Non-temporary value passed by value
+ temporary, //< Temporary value passed by value if of immediate type
+ owned, //< Non-temporary value passed by pointer
+ owned_imm, //< Non-temporary value passed by value
}
type local_var_result = {val: ValueRef, kind: lval_kind};
type lval_result = {bcx: @block_ctxt, val: ValueRef, kind: lval_kind};
enum callee_env {
- null_env;
- is_closure;
- self_env(ValueRef);
- dict_env(ValueRef, ValueRef);
+ null_env,
+ is_closure,
+ self_env(ValueRef),
+ dict_env(ValueRef, ValueRef),
}
type lval_maybe_callee = {bcx: @block_ctxt,
val: ValueRef,
check (type_has_static_size(ccx, t_out));
let ll_t_out = type_of(ccx, e.span, t_out);
- enum kind { pointer; integral; float; tag_; other; }
+ enum kind { pointer, integral, float, tag_, other, }
fn t_kind(tcx: ty::ctxt, t: ty::t) -> kind {
ret if ty::type_is_fp(tcx, t) {
float
RetVoid(ret_cx);
}
-enum self_arg { impl_self(ty::t); no_self; }
+enum self_arg { impl_self(ty::t), no_self, }
// trans_closure: Builds an LLVM function out of a source function.
// If the function closes over its environment a closure will be
// An option identifying a branch (either a literal, a enum variant or a
// range)
enum opt {
- lit(@ast::expr);
+ lit(@ast::expr),
var(/* disr val */int, /* variant dids */{tg: def_id, var: def_id});
range(@ast::expr, @ast::expr);
}
}
enum opt_result {
- single_result(result);
- range_result(result, result);
+ single_result(result),
+ range_result(result, result),
}
fn trans_opt(bcx: @block_ctxt, o: opt) -> opt_result {
let ccx = bcx_ccx(bcx), bcx = bcx;
// Decide what kind of branch we need
let opts = get_options(ccx, m, col);
- enum branch_kind { no_branch; single; switch; compare; }
+ enum branch_kind { no_branch, single, switch, compare, }
let kind = no_branch;
let test_val = val;
if vec::len(opts) > 0u {
enum environment_value {
// Evaluate expr and store result in env (used for bind).
- env_expr(@ast::expr);
+ env_expr(@ast::expr),
// Copy the value from this llvm ValueRef into the environment.
- env_copy(ValueRef, ty::t, lval_kind);
+ env_copy(ValueRef, ty::t, lval_kind),
// Move the value from this llvm ValueRef into the environment.
- env_move(ValueRef, ty::t, lval_kind);
+ env_move(ValueRef, ty::t, lval_kind),
// Access by reference (used for blocks).
- env_ref(ValueRef, ty::t, lval_kind);
+ env_ref(ValueRef, ty::t, lval_kind),
}
fn ev_to_str(ccx: @crate_ctxt, ev: environment_value) -> str {
type derived_tydesc_info = {lltydesc: ValueRef, escapes: bool};
enum tydesc_kind {
- tk_static; // Static (monomorphic) type descriptor
- tk_param; // Type parameter.
- tk_derived; // Derived from a typaram or another derived tydesc.
+ tk_static, // Static (monomorphic) type descriptor
+ tk_param, // Type parameter.
+ tk_derived, // Derived from a typaram or another derived tydesc.
}
type tydesc_info =
// Types used for llself.
type val_self_pair = {v: ValueRef, t: ty::t};
-enum local_val { local_mem(ValueRef); local_imm(ValueRef); }
+enum local_val { local_mem(ValueRef), local_imm(ValueRef), }
type fn_ty_param = {desc: ValueRef, dicts: option::t<[ValueRef]>};
lcx: @local_ctxt};
enum cleanup {
- clean(fn@(@block_ctxt) -> @block_ctxt);
- clean_temp(ValueRef, fn@(@block_ctxt) -> @block_ctxt);
+ clean(fn@(@block_ctxt) -> @block_ctxt),
+ clean_temp(ValueRef, fn@(@block_ctxt) -> @block_ctxt),
}
fn add_clean(cx: @block_ctxt, val: ValueRef, ty: ty::t) {
// FIXME: we should be able to use option::t<@block_parent> here but
// the infinite-enum check in rustboot gets upset.
-enum block_parent { parent_none; parent_some(@block_ctxt); }
+enum block_parent { parent_none, parent_some(@block_ctxt), }
type result = {bcx: @block_ctxt, val: ValueRef};
type result_t = {bcx: @block_ctxt, val: ValueRef, ty: ty::t};
// Used to identify cached dictionaries
enum dict_param {
- dict_param_dict(dict_id);
- dict_param_ty(ty::t);
+ dict_param_dict(dict_id),
+ dict_param_ty(ty::t),
}
type dict_id = @{def: ast::def_id, params: [dict_param]};
fn hash_dict_id(&&dp: dict_id) -> uint {
// Used to communicate which operands should be invalidated
// to helper functions
enum oper_type {
- oper_move;
- oper_swap;
- oper_assign;
- oper_assign_op;
- oper_pure;
+ oper_move,
+ oper_swap,
+ oper_assign,
+ oper_assign_op,
+ oper_pure,
}
/* logging funs */
type constr_arg_use = spanned<constr_arg_general_<inst>>;
enum constraint {
- cinit(uint, span, ident);
+ cinit(uint, span, ident),
// FIXME: really only want it to be mutable during collect_locals.
// freeze it after that.
- cpred(@path, @mutable [pred_args]);
+ cpred(@path, @mutable [pred_args]),
}
// An ninit variant has a node_id because it refers to a local var.
// FIXME: would be nice to give both a def_id field,
// and give ninit a constraint saying it's local.
enum tsconstr {
- ninit(node_id, ident);
- npred(@path, def_id, [@constr_arg_use]);
+ ninit(node_id, ident),
+ npred(@path, def_id, [@constr_arg_use]),
}
type sp_constr = spanned<tsconstr>;
ret rslt;
}
-enum if_ty { if_check; plain_if; }
+enum if_ty { if_check, plain_if, }
fn local_node_id_to_def_id_strict(fcx: fn_ctxt, sp: span, i: node_id) ->
def_id {
*/
type t = {uncertain: bitv::t, val: bitv::t, nbits: uint};
-enum trit { ttrue; tfalse; dont_care; }
+enum trit { ttrue, tfalse, dont_care, }
fn create_tritv(len: uint) -> t {
ret {uncertain: bitv::create(len, true),
type t = uint;
enum closure_kind {
- ck_any;
- ck_block;
- ck_box;
- ck_uniq;
+ ck_any,
+ ck_block,
+ ck_box,
+ ck_uniq,
}
type fn_ty = {proto: ast::proto,
// NB: If you change this, you'll probably want to change the corresponding
// AST structure in front/ast::rs as well.
enum sty {
- ty_nil;
- ty_bot;
- ty_bool;
- ty_int(ast::int_ty);
- ty_uint(ast::uint_ty);
- ty_float(ast::float_ty);
- ty_str;
- ty_tag(def_id, [t]);
- ty_box(mt);
- ty_uniq(mt);
- ty_vec(mt);
- ty_ptr(mt);
- ty_rec([field]);
- ty_fn(fn_ty);
- ty_native_fn([arg], t);
- ty_iface(def_id, [t]);
- ty_res(def_id, t, [t]);
- ty_tup([t]);
- ty_var(int); // type variable
-
- ty_param(uint, def_id); // fn/enum type param
-
- ty_type; // type_desc*
- ty_send_type; // type_desc* that has been cloned into exchange heap
- ty_native(def_id);
- ty_constr(t, [@type_constr]);
- ty_opaque_closure_ptr(closure_kind); // ptr to env for fn, fn@, fn~
- ty_named(t, @str);
+ ty_nil,
+ ty_bot,
+ ty_bool,
+ ty_int(ast::int_ty),
+ ty_uint(ast::uint_ty),
+ ty_float(ast::float_ty),
+ ty_str,
+ ty_tag(def_id, [t]),
+ ty_box(mt),
+ ty_uniq(mt),
+ ty_vec(mt),
+ ty_ptr(mt),
+ ty_rec([field]),
+ ty_fn(fn_ty),
+ ty_native_fn([arg], t),
+ ty_iface(def_id, [t]),
+ ty_res(def_id, t, [t]),
+ ty_tup([t]),
+ ty_var(int), // type variable
+
+ ty_param(uint, def_id), // fn/enum type param
+
+ ty_type, // type_desc*
+ ty_send_type, // type_desc* that has been cloned into exchange heap
+ ty_native(def_id),
+ ty_constr(t, [@type_constr]),
+ ty_opaque_closure_ptr(closure_kind), // ptr to env for fn, fn@, fn~
+ ty_named(t, @str),
}
// In the middle end, constraints have a def_id attached, referring
// Data structures used in type unification
enum type_err {
- terr_mismatch;
- terr_ret_style_mismatch(ast::ret_style, ast::ret_style);
- terr_box_mutability;
- terr_vec_mutability;
- terr_tuple_size(uint, uint);
- terr_record_size(uint, uint);
- terr_record_mutability;
- terr_record_fields(ast::ident, ast::ident);
- terr_arg_count;
- terr_mode_mismatch(mode, mode);
- terr_constr_len(uint, uint);
- terr_constr_mismatch(@type_constr, @type_constr);
+ terr_mismatch,
+ terr_ret_style_mismatch(ast::ret_style, ast::ret_style),
+ terr_box_mutability,
+ terr_vec_mutability,
+ terr_tuple_size(uint, uint),
+ terr_record_size(uint, uint),
+ terr_record_mutability,
+ terr_record_fields(ast::ident, ast::ident),
+ terr_arg_count,
+ terr_mode_mismatch(mode, mode),
+ terr_constr_len(uint, uint),
+ terr_constr_mismatch(@type_constr, @type_constr),
}
enum param_bound {
- bound_copy;
- bound_send;
- bound_iface(t);
+ bound_copy,
+ bound_send,
+ bound_iface(t),
}
fn param_bounds_to_kind(bounds: param_bounds) -> kind {
}
enum fold_mode {
- fm_var(fn@(int) -> t);
- fm_param(fn@(uint, def_id) -> t);
- fm_general(fn@(t) -> t);
+ fm_var(fn@(int) -> t),
+ fm_param(fn@(uint, def_id) -> t),
+ fm_general(fn@(t) -> t),
}
fn fold_ty(cx: ctxt, fld: fold_mode, ty_0: t) -> t {
ret result;
}
-enum kind { kind_sendable; kind_copyable; kind_noncopyable; }
+enum kind { kind_sendable, kind_copyable, kind_noncopyable, }
// Using these query functons is preferable to direct comparison or matching
// against the kind constants, as we may modify the kind hierarchy in the
export var_bindings;
export precise, in_bindings;
- enum result { ures_ok(t); ures_err(type_err); }
- enum union_result { unres_ok; unres_err(type_err); }
+ enum result { ures_ok(t), ures_err(type_err), }
+ enum union_result { unres_ok, unres_err(type_err), }
enum fixup_result {
- fix_ok(t); // fixup succeeded
- fix_err(int); // fixup failed because a type variable was unresolved
+ fix_ok(t), // fixup succeeded
+ fix_err(int), // fixup failed because a type variable was unresolved
}
type var_bindings =
{sets: ufind::ufind, types: smallintmap::smallintmap<t>};
enum unify_style {
- precise;
- in_bindings(@var_bindings);
+ precise,
+ in_bindings(@var_bindings),
}
type ctxt = {st: unify_style, tcx: ty_ctxt};
// Specifies the allowable subtyping between expected and actual types
enum variance {
// Actual may be a subtype of expected
- covariant;
+ covariant,
// Actual may be a supertype of expected
- contravariant;
+ contravariant,
// Actual must be the same type as expected
- invariant;
+ invariant,
}
// The calculation for recursive variance
export dict_map, dict_res, dict_origin, dict_static, dict_param, dict_iface;
enum method_origin {
- method_static(ast::def_id);
+ method_static(ast::def_id),
// iface id, method num, param num, bound num
- method_param(ast::def_id, uint, uint, uint);
- method_iface(uint);
+ method_param(ast::def_id, uint, uint, uint),
+ method_iface(uint),
}
type method_map = hashmap<ast::node_id, method_origin>;
// Resolutions for bounds of all parameters, left to right, for a given path.
type dict_res = @[dict_origin];
enum dict_origin {
- dict_static(ast::def_id, [ty::t], dict_res);
+ dict_static(ast::def_id, [ty::t], dict_res),
// Param number, bound number
- dict_param(uint, uint);
- dict_iface(ast::def_id);
+ dict_param(uint, uint),
+ dict_iface(ast::def_id),
}
type dict_map = hashmap<ast::node_id, dict_res>;
// Used for typechecking the methods of an impl
enum self_info {
- self_impl(ty::t);
+ self_impl(ty::t),
}
type crate_ctxt = {mutable self_infos: [self_info],
}
}
-enum mode { m_collect; m_check; m_check_tyvar(@fn_ctxt); }
+enum mode { m_collect, m_check, m_check_tyvar(@fn_ctxt), }
fn ast_ty_to_ty(tcx: ty::ctxt, mode: mode, &&ast_ty: @ast::ty) -> ty::t {
fn getter(tcx: ty::ctxt, mode: mode, id: ast::def_id)
const crate_node_id: node_id = 0;
enum ty_param_bound {
- bound_copy;
- bound_send;
- bound_iface(@ty);
+ bound_copy,
+ bound_send,
+ bound_iface(@ty),
}
type ty_param = {ident: ident, id: node_id, bounds: @[ty_param_bound]};
enum def {
- def_fn(def_id, purity);
- def_self(def_id);
- def_mod(def_id);
- def_native_mod(def_id);
- def_const(def_id);
- def_arg(def_id, mode);
- def_local(def_id, let_style);
- def_variant(def_id /* enum */, def_id /* variant */);
- def_ty(def_id);
- def_ty_param(def_id, uint);
- def_binding(def_id);
- def_use(def_id);
- def_native_ty(def_id);
- def_native_fn(def_id, purity);
- def_upvar(def_id, @def, node_id); // node_id == expr_fn or expr_fn_block
+ def_fn(def_id, purity),
+ def_self(def_id),
+ def_mod(def_id),
+ def_native_mod(def_id),
+ def_const(def_id),
+ def_arg(def_id, mode),
+ def_local(def_id, let_style),
+ def_variant(def_id /* enum */, def_id /* variant */),
+ def_ty(def_id),
+ def_ty_param(def_id, uint),
+ def_binding(def_id),
+ def_use(def_id),
+ def_native_ty(def_id),
+ def_native_fn(def_id, purity),
+ def_upvar(def_id, @def, node_id), // node_id == expr_fn or expr_fn_block
}
// The set of meta_items that define the compilation environment of the crate,
config: crate_cfg};
enum crate_directive_ {
- cdir_src_mod(ident, [attribute]);
- cdir_dir_mod(ident, [@crate_directive], [attribute]);
+ cdir_src_mod(ident, [attribute]),
+ cdir_dir_mod(ident, [@crate_directive], [attribute]),
- // NB: cdir_view_item is *not* processed by the rest of the compiler; the
+ // NB: cdir_view_item is *not* processed by the rest of the compiler, the
// attached view_items are sunk into the crate's module during parsing,
// and processed (resolved, imported, etc.) there. This enum-variant
// exists only to preserve the view items in order in case we decide to
// pretty-print crates in the future.
- cdir_view_item(@view_item);
+ cdir_view_item(@view_item),
- cdir_syntax(@path);
+ cdir_syntax(@path),
}
type crate_directive = spanned<crate_directive_>;
type meta_item = spanned<meta_item_>;
enum meta_item_ {
- meta_word(ident);
- meta_list(ident, [@meta_item]);
- meta_name_value(ident, lit);
+ meta_word(ident),
+ meta_list(ident, [@meta_item]),
+ meta_name_value(ident, lit),
}
type blk = spanned<blk_>;
type field_pat = {ident: ident, pat: @pat};
enum pat_ {
- pat_wild;
+ pat_wild,
// A pat_ident may either be a new bound variable,
// or a nullary enum (in which case the second field
// is none).
// After the resolution phase, code should never pattern-
// match on a pat directly! Always call pat_util::normalize_pat --
// it turns any pat_idents that refer to nullary tags into pat_tags.
- pat_ident(@path, option::t<@pat>);
- pat_tag(@path, [@pat]);
- pat_rec([field_pat], bool);
- pat_tup([@pat]);
- pat_box(@pat);
- pat_uniq(@pat);
- pat_lit(@expr);
- pat_range(@expr, @expr);
+ pat_ident(@path, option::t<@pat>),
+ pat_tag(@path, [@pat]),
+ pat_rec([field_pat], bool),
+ pat_tup([@pat]),
+ pat_box(@pat),
+ pat_uniq(@pat),
+ pat_lit(@expr),
+ pat_range(@expr, @expr),
}
-enum mutability { mut; imm; maybe_mut; }
+enum mutability { mut, imm, maybe_mut, }
enum proto {
- proto_bare; // native fn
- proto_any; // fn
- proto_uniq; // fn~
- proto_box; // fn@
- proto_block; // fn&
+ proto_bare, // native fn
+ proto_any, // fn
+ proto_uniq, // fn~
+ proto_box, // fn@
+ proto_block, // fn&
}
pure fn is_blockish(p: ast::proto) -> bool {
}
enum binop {
- add;
- subtract;
- mul;
- div;
- rem;
- and;
- or;
- bitxor;
- bitand;
- bitor;
- lsl;
- lsr;
- asr;
- eq;
- lt;
- le;
- ne;
- ge;
- gt;
+ add,
+ subtract,
+ mul,
+ div,
+ rem,
+ and,
+ or,
+ bitxor,
+ bitand,
+ bitor,
+ lsl,
+ lsr,
+ asr,
+ eq,
+ lt,
+ le,
+ ne,
+ ge,
+ gt,
}
enum unop {
- box(mutability);
- uniq(mutability);
- deref; not; neg;
+ box(mutability),
+ uniq(mutability),
+ deref, not, neg,
}
-enum mode { by_ref; by_val; by_mut_ref; by_move; by_copy; mode_infer; }
+enum mode { by_ref, by_val, by_mut_ref, by_move, by_copy, mode_infer, }
type stmt = spanned<stmt_>;
enum stmt_ {
- stmt_decl(@decl, node_id);
+ stmt_decl(@decl, node_id),
// expr without trailing semi-colon (must have unit type):
- stmt_expr(@expr, node_id);
+ stmt_expr(@expr, node_id),
// expr with trailing semi-colon (may have any type):
- stmt_semi(@expr, node_id);
+ stmt_semi(@expr, node_id),
}
-enum init_op { init_assign; init_move; }
+enum init_op { init_assign, init_move, }
type initializer = {op: init_op, expr: @expr};
type decl = spanned<decl_>;
-enum let_style { let_copy; let_ref; }
+enum let_style { let_copy, let_ref, }
-enum decl_ { decl_local([(let_style, @local)]); decl_item(@item); }
+enum decl_ { decl_local([(let_style, @local)]), decl_item(@item), }
type arm = {pats: [@pat], guard: option::t<@expr>, body: blk};
type field = spanned<field_>;
-enum blk_check_mode { default_blk; unchecked_blk; unsafe_blk; }
+enum blk_check_mode { default_blk, unchecked_blk, unsafe_blk, }
-enum expr_check_mode { claimed_expr; checked_expr; }
+enum expr_check_mode { claimed_expr, checked_expr, }
type expr = {id: node_id, node: expr_, span: span};
enum expr_ {
- expr_vec([@expr], mutability);
- expr_rec([field], option::t<@expr>);
- expr_call(@expr, [@expr], bool);
- expr_tup([@expr]);
- expr_bind(@expr, [option::t<@expr>]);
- expr_binary(binop, @expr, @expr);
- expr_unary(unop, @expr);
- expr_lit(@lit);
- expr_cast(@expr, @ty);
- expr_if(@expr, blk, option::t<@expr>);
- expr_ternary(@expr, @expr, @expr);
- expr_while(@expr, blk);
- expr_for(@local, @expr, blk);
- expr_do_while(blk, @expr);
- expr_alt(@expr, [arm]);
- expr_fn(proto, fn_decl, blk, @capture_clause);
- expr_fn_block(fn_decl, blk);
- expr_block(blk);
+ expr_vec([@expr], mutability),
+ expr_rec([field], option::t<@expr>),
+ expr_call(@expr, [@expr], bool),
+ expr_tup([@expr]),
+ expr_bind(@expr, [option::t<@expr>]),
+ expr_binary(binop, @expr, @expr),
+ expr_unary(unop, @expr),
+ expr_lit(@lit),
+ expr_cast(@expr, @ty),
+ expr_if(@expr, blk, option::t<@expr>),
+ expr_ternary(@expr, @expr, @expr),
+ expr_while(@expr, blk),
+ expr_for(@local, @expr, blk),
+ expr_do_while(blk, @expr),
+ expr_alt(@expr, [arm]),
+ expr_fn(proto, fn_decl, blk, @capture_clause),
+ expr_fn_block(fn_decl, blk),
+ expr_block(blk),
/*
* FIXME: many of these @exprs should be constrained with
* is_lval once we have constrained types working.
*/
- expr_copy(@expr);
- expr_move(@expr, @expr);
- expr_assign(@expr, @expr);
- expr_swap(@expr, @expr);
- expr_assign_op(binop, @expr, @expr);
- expr_field(@expr, ident, [@ty]);
- expr_index(@expr, @expr);
- expr_path(@path);
- expr_fail(option::t<@expr>);
- expr_break;
- expr_cont;
- expr_ret(option::t<@expr>);
- expr_be(@expr);
- expr_log(int, @expr, @expr);
+ expr_copy(@expr),
+ expr_move(@expr, @expr),
+ expr_assign(@expr, @expr),
+ expr_swap(@expr, @expr),
+ expr_assign_op(binop, @expr, @expr),
+ expr_field(@expr, ident, [@ty]),
+ expr_index(@expr, @expr),
+ expr_path(@path),
+ expr_fail(option::t<@expr>),
+ expr_break,
+ expr_cont,
+ expr_ret(option::t<@expr>),
+ expr_be(@expr),
+ expr_log(int, @expr, @expr),
/* just an assert, no significance to typestate */
- expr_assert(@expr);
+ expr_assert(@expr),
/* preds that typestate is aware of */
- expr_check(expr_check_mode, @expr);
+ expr_check(expr_check_mode, @expr),
/* FIXME Would be nice if expr_check desugared
to expr_if_check. */
- expr_if_check(@expr, blk, option::t<@expr>);
- expr_mac(mac);
+ expr_if_check(@expr, blk, option::t<@expr>),
+ expr_mac(mac),
}
type capture_item = {
// Says whether this is a block the user marked as
// "unchecked"
enum blk_sort {
- blk_unchecked; // declared as "exception to effect-checking rules"
- blk_checked; // all typing rules apply
+ blk_unchecked, // declared as "exception to effect-checking rules"
+ blk_checked, // all typing rules apply
}
*/
type mac = spanned<mac_>;
enum mac_ {
- mac_invoc(@path, @expr, option::t<str>);
- mac_embed_type(@ty);
- mac_embed_block(blk);
- mac_ellipsis;
+ mac_invoc(@path, @expr, option::t<str>),
+ mac_embed_type(@ty),
+ mac_embed_block(blk),
+ mac_ellipsis,
}
type lit = spanned<lit_>;
enum lit_ {
- lit_str(str);
- lit_int(i64, int_ty);
- lit_uint(u64, uint_ty);
- lit_float(str, float_ty);
- lit_nil;
- lit_bool(bool);
+ lit_str(str),
+ lit_int(i64, int_ty),
+ lit_uint(u64, uint_ty),
+ lit_float(str, float_ty),
+ lit_nil,
+ lit_bool(bool),
}
// NB: If you change this, you'll probably want to change the corresponding
type ty_method = {ident: ident, decl: fn_decl, tps: [ty_param], span: span};
-enum int_ty { ty_i; ty_char; ty_i8; ty_i16; ty_i32; ty_i64; }
+enum int_ty { ty_i, ty_char, ty_i8, ty_i16, ty_i32, ty_i64, }
-enum uint_ty { ty_u; ty_u8; ty_u16; ty_u32; ty_u64; }
+enum uint_ty { ty_u, ty_u8, ty_u16, ty_u32, ty_u64, }
-enum float_ty { ty_f; ty_f32; ty_f64; }
+enum float_ty { ty_f, ty_f32, ty_f64, }
type ty = spanned<ty_>;
enum ty_ {
- ty_nil;
- ty_bot; /* return type of ! functions and type of
+ ty_nil,
+ ty_bot, /* return type of ! functions and type of
ret/fail/break/cont. there is no syntax
for this type. */
/* bot represents the value of functions that don't return a value
locally to their context. in contrast, things like log that do
return, but don't return a meaningful value, have result type nil. */
- ty_bool;
- ty_int(int_ty);
- ty_uint(uint_ty);
- ty_float(float_ty);
- ty_str;
- ty_box(mt);
- ty_uniq(mt);
- ty_vec(mt);
- ty_ptr(mt);
- ty_task;
- ty_port(@ty);
- ty_chan(@ty);
- ty_rec([ty_field]);
- ty_fn(proto, fn_decl);
- ty_tup([@ty]);
- ty_path(@path, node_id);
- ty_type;
- ty_constr(@ty, [@ty_constr]);
- ty_mac(mac);
+ ty_bool,
+ ty_int(int_ty),
+ ty_uint(uint_ty),
+ ty_float(float_ty),
+ ty_str,
+ ty_box(mt),
+ ty_uniq(mt),
+ ty_vec(mt),
+ ty_ptr(mt),
+ ty_task,
+ ty_port(@ty),
+ ty_chan(@ty),
+ ty_rec([ty_field]),
+ ty_fn(proto, fn_decl),
+ ty_tup([@ty]),
+ ty_path(@path, node_id),
+ ty_type,
+ ty_constr(@ty, [@ty_constr]),
+ ty_mac(mac),
// ty_infer means the type should be inferred instead of it having been
// specified. This should only appear at the "top level" of a type and not
// nested in one.
- ty_infer;
+ ty_infer,
}
So, the constr_arg type is parameterized: it's instantiated with uint for
declarations, and ident for uses.
*/
-enum constr_arg_general_<T> { carg_base; carg_ident(T); carg_lit(@lit); }
+enum constr_arg_general_<T> { carg_base, carg_ident(T), carg_lit(@lit), }
type fn_constr_arg = constr_arg_general_<uint>;
type sp_constr_arg<T> = spanned<constr_arg_general_<T>>;
constraints: [@constr]};
enum purity {
- pure_fn; // declared with "pure fn"
- unsafe_fn; // declared with "unsafe fn"
- impure_fn; // declared with "fn"
+ pure_fn, // declared with "pure fn"
+ unsafe_fn, // declared with "unsafe fn"
+ impure_fn, // declared with "fn"
}
enum ret_style {
- noreturn; // functions with return type _|_ that always
+ noreturn, // functions with return type _|_ that always
// raise an error or exit (i.e. never return to the caller)
- return_val; // everything else
+ return_val, // everything else
}
type method = {ident: ident, tps: [ty_param], decl: fn_decl, body: blk,
type _mod = {view_items: [@view_item], items: [@item]};
enum native_abi {
- native_abi_rust_intrinsic;
- native_abi_cdecl;
- native_abi_stdcall;
+ native_abi_rust_intrinsic,
+ native_abi_cdecl,
+ native_abi_stdcall,
}
type native_mod =
type import_ident = spanned<import_ident_>;
enum view_item_ {
- view_item_use(ident, [@meta_item], node_id);
- view_item_import(ident, @simple_path, node_id);
- view_item_import_glob(@simple_path, node_id);
- view_item_import_from(@simple_path, [import_ident], node_id);
- view_item_export([ident], node_id);
+ view_item_use(ident, [@meta_item], node_id),
+ view_item_import(ident, @simple_path, node_id),
+ view_item_import_glob(@simple_path, node_id),
+ view_item_import_from(@simple_path, [import_ident], node_id),
+ view_item_export([ident], node_id),
}
// Meta-data associated with an item
// Distinguishes between attributes that decorate items and attributes that
// are contained as statements within items. These two cases need to be
// distinguished for pretty-printing.
-enum attr_style { attr_outer; attr_inner; }
+enum attr_style { attr_outer, attr_inner, }
type attribute_ = {style: attr_style, value: meta_item};
id: node_id, node: item_, span: span};
enum item_ {
- item_const(@ty, @expr);
- item_fn(fn_decl, [ty_param], blk);
- item_mod(_mod);
- item_native_mod(native_mod);
- item_ty(@ty, [ty_param]);
- item_tag([variant], [ty_param]);
+ item_const(@ty, @expr),
+ item_fn(fn_decl, [ty_param], blk),
+ item_mod(_mod),
+ item_native_mod(native_mod),
+ item_ty(@ty, [ty_param]),
+ item_tag([variant], [ty_param]),
item_res(fn_decl /* dtor */, [ty_param], blk,
- node_id /* dtor id */, node_id /* ctor id */);
- item_iface([ty_param], [ty_method]);
+ node_id /* dtor id */, node_id /* ctor id */),
+ item_iface([ty_param], [ty_method]),
item_impl([ty_param], option::t<@ty> /* iface */,
- @ty /* self */, [@method]);
+ @ty /* self */, [@method]),
}
type native_item =
span: span};
enum native_item_ {
- native_item_ty;
- native_item_fn(fn_decl, [ty_param]);
+ native_item_ty,
+ native_item_fn(fn_decl, [ty_param]),
}
//
// FIXME this doesn't handle big integer/float literals correctly (nor does
// the rest of our literal handling)
enum const_val {
- const_float(float);
- const_int(i64);
- const_uint(u64);
- const_str(str);
+ const_float(float),
+ const_int(i64),
+ const_uint(u64),
+ const_str(str),
}
// FIXME: issue #1417
enum opt_span {
//hack (as opposed to option::t), to make `span` compile
- os_none;
- os_some(@span);
+ os_none,
+ os_some(@span),
}
type span = {lo: uint, hi: uint, expanded_from: opt_span};
fn@(ext_ctxt, span, @ast::expr, option::t<str>) -> macro_def;
enum syntax_extension {
- normal(syntax_expander);
- macro_defining(macro_definer);
+ normal(syntax_expander),
+ macro_defining(macro_definer),
}
// A temporary hard-coded map of methods for expanding syntax extension
type clause = {params: binders, body: @expr};
/* logically, an arb_depth should contain only one kind of matchable */
-enum arb_depth<T> { leaf(T); seq(@[arb_depth<T>], span); }
+enum arb_depth<T> { leaf(T), seq(@[arb_depth<T>], span), }
enum matchable {
- match_expr(@expr);
- match_path(@path);
- match_ident(ast::spanned<ident>);
- match_ty(@ty);
- match_block(ast::blk);
- match_exact; /* don't bind anything, just verify the AST traversal */
+ match_expr(@expr),
+ match_path(@path),
+ match_ident(ast::spanned<ident>),
+ match_ty(@ty),
+ match_block(ast::blk),
+ match_exact, /* don't bind anything, just verify the AST traversal */
}
/* for when given an incompatible bit of AST */
}
enum cmnt_style {
- isolated; // No code on either side of each line of the comment
- trailing; // Code exists to the left of the comment
- mixed; // Code before /* foo */ and after the comment
- blank_line; // Just a manual blank line "\n\n", for layout
+ isolated, // No code on either side of each line of the comment
+ trailing, // Code exists to the left of the comment
+ mixed, // Code before /* foo */ and after the comment
+ blank_line, // Just a manual blank line "\n\n", for layout
}
type cmnt = {style: cmnt_style, lines: [str], pos: uint};
import driver::diagnostic;
enum restriction {
- UNRESTRICTED;
- RESTRICT_STMT_EXPR;
- RESTRICT_NO_CALL_EXPRS;
- RESTRICT_NO_BAR_OP;
+ UNRESTRICTED,
+ RESTRICT_STMT_EXPR,
+ RESTRICT_NO_CALL_EXPRS,
+ RESTRICT_NO_BAR_OP,
}
-enum file_type { CRATE_FILE; SOURCE_FILE; }
+enum file_type { CRATE_FILE, SOURCE_FILE, }
type parse_sess = @{
cm: codemap::codemap,
// part of the AST, we wrap such expressions in the pexpr enum. They
// can then be converted to true expressions by a call to `to_expr()`.
enum pexpr {
- pexpr(@ast::expr);
+ pexpr(@ast::expr),
}
fn mk_pexpr(p: parser, lo: uint, hi: uint, node: ast::expr_) -> pexpr {
type str_num = uint;
enum binop {
- PLUS;
- MINUS;
- STAR;
- SLASH;
- PERCENT;
- CARET;
- AND;
- OR;
- LSL;
- LSR;
- ASR;
+ PLUS,
+ MINUS,
+ STAR,
+ SLASH,
+ PERCENT,
+ CARET,
+ AND,
+ OR,
+ LSL,
+ LSR,
+ ASR,
}
enum token {
/* Expression-operator symbols. */
- EQ;
- LT;
- LE;
- EQEQ;
- NE;
- GE;
- GT;
- ANDAND;
- OROR;
- NOT;
- TILDE;
- BINOP(binop);
- BINOPEQ(binop);
+ EQ,
+ LT,
+ LE,
+ EQEQ,
+ NE,
+ GE,
+ GT,
+ ANDAND,
+ OROR,
+ NOT,
+ TILDE,
+ BINOP(binop),
+ BINOPEQ(binop),
/* Structural symbols */
- AT;
- DOT;
- ELLIPSIS;
- COMMA;
- SEMI;
- COLON;
- MOD_SEP;
- QUES;
- RARROW;
- LARROW;
- DARROW;
- LPAREN;
- RPAREN;
- LBRACKET;
- RBRACKET;
- LBRACE;
- RBRACE;
- POUND;
- POUND_LBRACE;
- POUND_LT;
+ AT,
+ DOT,
+ ELLIPSIS,
+ COMMA,
+ SEMI,
+ COLON,
+ MOD_SEP,
+ QUES,
+ RARROW,
+ LARROW,
+ DARROW,
+ LPAREN,
+ RPAREN,
+ LBRACKET,
+ RBRACKET,
+ LBRACE,
+ RBRACE,
+ POUND,
+ POUND_LBRACE,
+ POUND_LT,
/* Literals */
- LIT_INT(i64, ast::int_ty);
- LIT_UINT(u64, ast::uint_ty);
- LIT_FLOAT(str_num, ast::float_ty);
- LIT_STR(str_num);
- LIT_BOOL(bool);
+ LIT_INT(i64, ast::int_ty),
+ LIT_UINT(u64, ast::uint_ty),
+ LIT_FLOAT(str_num, ast::float_ty),
+ LIT_STR(str_num),
+ LIT_BOOL(bool),
/* Name components */
- IDENT(str_num, bool);
- IDX(int);
- UNDERSCORE;
- BRACEQUOTE(str_num);
- EOF;
+ IDENT(str_num, bool),
+ IDX(int),
+ UNDERSCORE,
+ BRACEQUOTE(str_num),
+ EOF,
}
fn binop_to_str(o: binop) -> str {
* line (which it can't) and so naturally place the content on its own line to
* avoid combining it with other lines and making matters even worse.
*/
-enum breaks { consistent; inconsistent; }
+enum breaks { consistent, inconsistent, }
type break_t = {offset: int, blank_space: int};
type begin_t = {offset: int, breaks: breaks};
-enum token { STRING(str, int); BREAK(break_t); BEGIN(begin_t); END; EOF; }
+enum token { STRING(str, int), BREAK(break_t), BEGIN(begin_t), END, EOF, }
fn tok_str(t: token) -> str {
alt t {
ret s;
}
-enum print_stack_break { fits; broken(breaks); }
+enum print_stack_break { fits, broken(breaks), }
type print_stack_elt = {offset: int, pbreak: print_stack_break};
// The ps is stored here to prevent recursive type.
// FIXME use a nominal enum instead
enum ann_node {
- node_block(ps, ast::blk);
- node_item(ps, @ast::item);
- node_expr(ps, @ast::expr);
- node_pat(ps, @ast::pat);
+ node_block(ps, ast::blk),
+ node_item(ps, @ast::item),
+ node_expr(ps, @ast::expr),
+ node_pat(ps, @ast::pat),
}
type pp_ann = {pre: fn@(ann_node), post: fn@(ann_node)};
print_possibly_embedded_block_(s, blk, block_normal, indent_unit, attrs);
}
-enum embed_type { block_macro; block_block_fn; block_normal; }
+enum embed_type { block_macro, block_block_fn, block_normal, }
fn print_possibly_embedded_block(s: ps, blk: ast::blk, embedded: embed_type,
indented: uint) {
// Our typesystem doesn't do circular types, so the visitor record can not
// hold functions that take visitors. A vt enum is used to break the cycle.
-enum vt<E> { mk_vt(visitor<E>); }
+enum vt<E> { mk_vt(visitor<E>), }
enum fn_kind {
- fk_item_fn(ident, [ty_param]); //< an item declared with fn()
- fk_method(ident, [ty_param]);
- fk_res(ident, [ty_param]);
- fk_anon(proto); //< an anonymous function like fn@(...)
- fk_fn_block; //< a block {||...}
+ fk_item_fn(ident, [ty_param]), //< an item declared with fn()
+ fk_method(ident, [ty_param]),
+ fk_res(ident, [ty_param]),
+ fk_anon(proto), //< an anonymous function like fn@(...)
+ fk_fn_block, //< a block {||...}
}
fn name_of_fn(fk: fn_kind) -> ident {