Convert alt to match. Stop parsing alt
This commit is contained in:
parent
d3a9bb1bd4
commit
ecaf9e39c9
359 changed files with 2938 additions and 2915 deletions
|
|
@ -111,7 +111,7 @@ fn decode_inlined_item(cdata: cstore::crate_metadata,
|
|||
path: ast_map::path,
|
||||
par_doc: ebml::doc) -> option<ast::inlined_item> {
|
||||
let dcx = @{cdata: cdata, tcx: tcx, maps: maps};
|
||||
alt par_doc.opt_child(c::tag_ast) {
|
||||
match par_doc.opt_child(c::tag_ast) {
|
||||
none => none,
|
||||
some(ast_doc) => {
|
||||
debug!{"> Decoding inlined fn: %s::?", ast_map::path_to_str(path)};
|
||||
|
|
@ -129,7 +129,7 @@ fn decode_inlined_item(cdata: cstore::crate_metadata,
|
|||
decode_side_tables(xcx, ast_doc);
|
||||
debug!{"< Decoded inlined fn: %s::%s",
|
||||
ast_map::path_to_str(path), *ii.ident()};
|
||||
alt ii {
|
||||
match ii {
|
||||
ast::ii_item(i) => {
|
||||
debug!{">>> DECODED ITEM >>>\n%s\n<<< DECODED ITEM <<<",
|
||||
syntax::print::pprust::item_to_str(i)};
|
||||
|
|
@ -245,7 +245,7 @@ fn encode_ast(ebml_w: ebml::writer, item: ast::inlined_item) {
|
|||
fn simplify_ast(ii: ast::inlined_item) -> ast::inlined_item {
|
||||
fn drop_nested_items(blk: ast::blk_, fld: fold::ast_fold) -> ast::blk_ {
|
||||
let stmts_sans_items = do vec::filter(blk.stmts) |stmt| {
|
||||
alt stmt.node {
|
||||
match stmt.node {
|
||||
ast::stmt_expr(_, _) | ast::stmt_semi(_, _) |
|
||||
ast::stmt_decl(@{node: ast::decl_local(_), span: _}, _) => true,
|
||||
ast::stmt_decl(@{node: ast::decl_item(_), span: _}, _) => false
|
||||
|
|
@ -260,7 +260,7 @@ fn simplify_ast(ii: ast::inlined_item) -> ast::inlined_item {
|
|||
with *fold::default_ast_fold()
|
||||
});
|
||||
|
||||
alt ii {
|
||||
match ii {
|
||||
ast::ii_item(i) => {
|
||||
ast::ii_item(fld.fold_item(i).get()) //hack: we're not dropping items
|
||||
}
|
||||
|
|
@ -300,7 +300,7 @@ fn renumber_ast(xcx: extended_decode_ctxt, ii: ast::inlined_item)
|
|||
with *fold::default_ast_fold()
|
||||
});
|
||||
|
||||
alt ii {
|
||||
match ii {
|
||||
ast::ii_item(i) => {
|
||||
ast::ii_item(fld.fold_item(i).get())
|
||||
}
|
||||
|
|
@ -352,7 +352,7 @@ fn decode_def(xcx: extended_decode_ctxt, doc: ebml::doc) -> ast::def {
|
|||
|
||||
impl of tr for ast::def {
|
||||
fn tr(xcx: extended_decode_ctxt) -> ast::def {
|
||||
alt self {
|
||||
match self {
|
||||
ast::def_fn(did, p) => ast::def_fn(did.tr(xcx), p),
|
||||
ast::def_self(nid) => ast::def_self(xcx.tr_id(nid)),
|
||||
ast::def_mod(did) => ast::def_mod(did.tr(xcx)),
|
||||
|
|
@ -422,7 +422,7 @@ impl helper of read_method_map_entry_helper for ebml::ebml_deserializer {
|
|||
|
||||
impl of tr for method_origin {
|
||||
fn tr(xcx: extended_decode_ctxt) -> method_origin {
|
||||
alt self {
|
||||
match self {
|
||||
typeck::method_static(did) => {
|
||||
typeck::method_static(did.tr(xcx))
|
||||
}
|
||||
|
|
@ -455,7 +455,7 @@ fn encode_vtable_origin(ecx: @e::encode_ctxt,
|
|||
ebml_w: ebml::writer,
|
||||
vtable_origin: typeck::vtable_origin) {
|
||||
do ebml_w.emit_enum(~"vtable_origin") {
|
||||
alt vtable_origin {
|
||||
match vtable_origin {
|
||||
typeck::vtable_static(def_id, tys, vtable_res) => {
|
||||
do ebml_w.emit_enum_variant(~"vtable_static", 0u, 3u) {
|
||||
do ebml_w.emit_enum_variant_arg(0u) {
|
||||
|
|
@ -508,7 +508,7 @@ impl helpers of vtable_deserialization_helpers for ebml::ebml_deserializer {
|
|||
-> typeck::vtable_origin {
|
||||
do self.read_enum(~"vtable_origin") {
|
||||
do self.read_enum_variant |i| {
|
||||
alt check i {
|
||||
match check i {
|
||||
0u => {
|
||||
typeck::vtable_static(
|
||||
do self.read_enum_variant_arg(0u) {
|
||||
|
|
@ -992,7 +992,7 @@ fn test_simplification() {
|
|||
return {eq_fn: eq_int, mut data: ~[]};
|
||||
}
|
||||
});
|
||||
alt (item_out, item_exp) {
|
||||
match (item_out, item_exp) {
|
||||
(ast::ii_item(item_out), ast::ii_item(item_exp)) => {
|
||||
assert pprust::item_to_str(item_out) == pprust::item_to_str(item_exp);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ fn check_crate(tcx: ty::ctxt, crate: @crate) {
|
|||
|
||||
fn visit_expr(ex: @expr, cx: ctx, v: visit::vt<ctx>) {
|
||||
if !cx.allow_block {
|
||||
alt ty::get(ty::expr_ty(cx.tcx, ex)).struct {
|
||||
match ty::get(ty::expr_ty(cx.tcx, ex)).struct {
|
||||
ty::ty_fn({proto: p, _}) if is_blockish(p) => {
|
||||
cx.tcx.sess.span_err(ex.span,
|
||||
~"expressions with stack closure type \
|
||||
|
|
@ -23,7 +23,7 @@ fn visit_expr(ex: @expr, cx: ctx, v: visit::vt<ctx>) {
|
|||
}
|
||||
}
|
||||
let outer = cx.allow_block;
|
||||
alt ex.node {
|
||||
match ex.node {
|
||||
expr_call(f, args, _) => {
|
||||
cx.allow_block = true;
|
||||
v.visit_expr(f, cx, v);
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ In other cases, like an enum on the stack, the memory cannot be freed
|
|||
but its type can change:
|
||||
|
||||
let mut x = some(5);
|
||||
alt x {
|
||||
match x {
|
||||
some(ref y) => { ... }
|
||||
none => { ... }
|
||||
}
|
||||
|
|
@ -105,7 +105,7 @@ Finally, in some cases, both dangers can arise. For example, something
|
|||
like the following:
|
||||
|
||||
let mut x = ~some(5);
|
||||
alt x {
|
||||
match x {
|
||||
~some(ref y) => { ... }
|
||||
~none => { ... }
|
||||
}
|
||||
|
|
@ -343,7 +343,7 @@ enum categorization {
|
|||
cat_stack_upvar(cmt), // upvar in stack closure
|
||||
cat_deref(cmt, uint, ptr_kind), // deref of a ptr
|
||||
cat_comp(cmt, comp_kind), // adjust to locate an internal component
|
||||
cat_discr(cmt, ast::node_id), // alt discriminant (see preserve())
|
||||
cat_discr(cmt, ast::node_id), // match discriminant (see preserve())
|
||||
}
|
||||
|
||||
// different kinds of pointers:
|
||||
|
|
@ -456,7 +456,7 @@ impl methods of get_type_for_node for ty::ctxt {
|
|||
|
||||
impl error_methods for borrowck_ctxt {
|
||||
fn report_if_err(bres: bckres<()>) {
|
||||
alt bres {
|
||||
match bres {
|
||||
ok(()) => (),
|
||||
err(e) => self.report(e)
|
||||
}
|
||||
|
|
@ -478,7 +478,7 @@ impl error_methods for borrowck_ctxt {
|
|||
}
|
||||
|
||||
fn add_to_mutbl_map(cmt: cmt) {
|
||||
alt cmt.cat {
|
||||
match cmt.cat {
|
||||
cat_local(id) | cat_arg(id) => {
|
||||
self.mutbl_map.insert(id, ());
|
||||
}
|
||||
|
|
@ -492,7 +492,7 @@ impl error_methods for borrowck_ctxt {
|
|||
|
||||
impl to_str_methods for borrowck_ctxt {
|
||||
fn cat_to_repr(cat: categorization) -> ~str {
|
||||
alt cat {
|
||||
match cat {
|
||||
cat_special(sk_method) => ~"method",
|
||||
cat_special(sk_static_item) => ~"static_item",
|
||||
cat_special(sk_self) => ~"self",
|
||||
|
|
@ -514,7 +514,7 @@ impl to_str_methods for borrowck_ctxt {
|
|||
}
|
||||
|
||||
fn mut_to_str(mutbl: ast::mutability) -> ~str {
|
||||
alt mutbl {
|
||||
match mutbl {
|
||||
m_mutbl => ~"mutable",
|
||||
m_const => ~"const",
|
||||
m_imm => ~"immutable"
|
||||
|
|
@ -522,7 +522,7 @@ impl to_str_methods for borrowck_ctxt {
|
|||
}
|
||||
|
||||
fn ptr_sigil(ptr: ptr_kind) -> ~str {
|
||||
alt ptr {
|
||||
match ptr {
|
||||
uniq_ptr => ~"~",
|
||||
gc_ptr => ~"@",
|
||||
region_ptr(_) => ~"&",
|
||||
|
|
@ -531,7 +531,7 @@ impl to_str_methods for borrowck_ctxt {
|
|||
}
|
||||
|
||||
fn comp_to_repr(comp: comp_kind) -> ~str {
|
||||
alt comp {
|
||||
match comp {
|
||||
comp_field(fld, _) => *fld,
|
||||
comp_index(*) => ~"[]",
|
||||
comp_tuple => ~"()",
|
||||
|
|
@ -540,7 +540,7 @@ impl to_str_methods for borrowck_ctxt {
|
|||
}
|
||||
|
||||
fn lp_to_str(lp: @loan_path) -> ~str {
|
||||
alt *lp {
|
||||
match *lp {
|
||||
lp_local(node_id) => {
|
||||
fmt!{"local(%d)", node_id}
|
||||
}
|
||||
|
|
@ -569,7 +569,7 @@ impl to_str_methods for borrowck_ctxt {
|
|||
|
||||
fn cmt_to_str(cmt: cmt) -> ~str {
|
||||
let mut_str = self.mut_to_str(cmt.mutbl);
|
||||
alt cmt.cat {
|
||||
match cmt.cat {
|
||||
cat_special(sk_method) => ~"method",
|
||||
cat_special(sk_static_item) => ~"static item",
|
||||
cat_special(sk_self) => ~"self reference",
|
||||
|
|
@ -589,7 +589,7 @@ impl to_str_methods for borrowck_ctxt {
|
|||
cat_comp(_, comp_tuple) => ~"tuple content",
|
||||
cat_comp(_, comp_variant(_)) => ~"enum content",
|
||||
cat_comp(_, comp_index(t, _)) => {
|
||||
alt ty::get(t).struct {
|
||||
match ty::get(t).struct {
|
||||
ty::ty_evec(*) => mut_str + ~" vec content",
|
||||
ty::ty_estr(*) => mut_str + ~" str content",
|
||||
_ => mut_str + ~" indexed content"
|
||||
|
|
@ -602,7 +602,7 @@ impl to_str_methods for borrowck_ctxt {
|
|||
}
|
||||
|
||||
fn bckerr_code_to_str(code: bckerr_code) -> ~str {
|
||||
alt code {
|
||||
match code {
|
||||
err_mutbl(req, act) => {
|
||||
fmt!{"creating %s alias to aliasable, %s memory",
|
||||
self.mut_to_str(req), self.mut_to_str(act)}
|
||||
|
|
@ -644,7 +644,7 @@ impl to_str_methods for borrowck_ctxt {
|
|||
// mutability can be "overridden" if the component is embedded in a
|
||||
// mutable structure.
|
||||
fn inherent_mutability(ck: comp_kind) -> mutability {
|
||||
alt ck {
|
||||
match ck {
|
||||
comp_tuple | comp_variant(_) => m_imm,
|
||||
comp_field(_, m) | comp_index(_, m) => m
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ export opt_deref_kind;
|
|||
// derefable (we model an index as the combination of a deref and then a
|
||||
// pointer adjustment).
|
||||
fn opt_deref_kind(t: ty::t) -> option<deref_kind> {
|
||||
alt ty::get(t).struct {
|
||||
match ty::get(t).struct {
|
||||
ty::ty_uniq(*) |
|
||||
ty::ty_evec(_, ty::vstore_uniq) |
|
||||
ty::ty_estr(ty::vstore_uniq) => {
|
||||
|
|
@ -83,7 +83,7 @@ fn opt_deref_kind(t: ty::t) -> option<deref_kind> {
|
|||
}
|
||||
|
||||
fn deref_kind(tcx: ty::ctxt, t: ty::t) -> deref_kind {
|
||||
alt opt_deref_kind(t) {
|
||||
match opt_deref_kind(t) {
|
||||
some(k) => k,
|
||||
none => {
|
||||
tcx.sess.bug(
|
||||
|
|
@ -97,7 +97,7 @@ impl public_methods for borrowck_ctxt {
|
|||
fn cat_borrow_of_expr(expr: @ast::expr) -> cmt {
|
||||
// a borrowed expression must be either an @, ~, or a @vec, ~vec
|
||||
let expr_ty = ty::expr_ty(self.tcx, expr);
|
||||
alt ty::get(expr_ty).struct {
|
||||
match ty::get(expr_ty).struct {
|
||||
ty::ty_evec(*) | ty::ty_estr(*) => {
|
||||
self.cat_index(expr, expr)
|
||||
}
|
||||
|
|
@ -128,14 +128,14 @@ impl public_methods for borrowck_ctxt {
|
|||
|
||||
let tcx = self.tcx;
|
||||
let expr_ty = tcx.ty(expr);
|
||||
alt expr.node {
|
||||
match expr.node {
|
||||
ast::expr_unary(ast::deref, e_base) => {
|
||||
if self.method_map.contains_key(expr.id) {
|
||||
return self.cat_rvalue(expr, expr_ty);
|
||||
}
|
||||
|
||||
let base_cmt = self.cat_expr(e_base);
|
||||
alt self.cat_deref(expr, base_cmt, 0u, true) {
|
||||
match self.cat_deref(expr, base_cmt, 0u, true) {
|
||||
some(cmt) => return cmt,
|
||||
none => {
|
||||
tcx.sess.span_bug(
|
||||
|
|
@ -190,7 +190,7 @@ impl public_methods for borrowck_ctxt {
|
|||
span: span,
|
||||
expr_ty: ty::t,
|
||||
def: ast::def) -> cmt {
|
||||
alt def {
|
||||
match def {
|
||||
ast::def_fn(*) | ast::def_mod(_) |
|
||||
ast::def_foreign_mod(_) | ast::def_const(_) |
|
||||
ast::def_use(_) | ast::def_variant(*) |
|
||||
|
|
@ -208,7 +208,7 @@ impl public_methods for borrowck_ctxt {
|
|||
|
||||
// m: mutability of the argument
|
||||
// lp: loan path, must be none for aliasable things
|
||||
let {m,lp} = alt ty::resolved_mode(self.tcx, mode) {
|
||||
let {m,lp} = match ty::resolved_mode(self.tcx, mode) {
|
||||
ast::by_mutbl_ref => {
|
||||
{m: m_mutbl, lp: none}
|
||||
}
|
||||
|
|
@ -241,7 +241,7 @@ impl public_methods for borrowck_ctxt {
|
|||
ast::def_upvar(upvid, inner, fn_node_id) => {
|
||||
let ty = ty::node_id_to_type(self.tcx, fn_node_id);
|
||||
let proto = ty::ty_fn_proto(ty);
|
||||
alt proto {
|
||||
match proto {
|
||||
ast::proto_block => {
|
||||
let upcmt = self.cat_def(id, span, expr_ty, *inner);
|
||||
@{id:id, span:span,
|
||||
|
|
@ -311,7 +311,7 @@ impl public_methods for borrowck_ctxt {
|
|||
/// or if the container is mutable.
|
||||
fn inherited_mutability(base_m: ast::mutability,
|
||||
comp_m: ast::mutability) -> ast::mutability {
|
||||
alt comp_m {
|
||||
match comp_m {
|
||||
m_imm => {base_m} // imm: as mutable as the container
|
||||
m_mutbl | m_const => {comp_m}
|
||||
}
|
||||
|
|
@ -319,7 +319,7 @@ impl public_methods for borrowck_ctxt {
|
|||
|
||||
fn cat_field<N:ast_node>(node: N, base_cmt: cmt,
|
||||
f_name: ast::ident) -> cmt {
|
||||
let f_mutbl = alt field_mutbl(self.tcx, base_cmt.ty, f_name) {
|
||||
let f_mutbl = match field_mutbl(self.tcx, base_cmt.ty, f_name) {
|
||||
some(f_mutbl) => f_mutbl,
|
||||
none => {
|
||||
self.tcx.sess.span_bug(
|
||||
|
|
@ -339,7 +339,7 @@ impl public_methods for borrowck_ctxt {
|
|||
fn cat_deref<N:ast_node>(node: N, base_cmt: cmt, derefs: uint,
|
||||
expl: bool) -> option<cmt> {
|
||||
do ty::deref(self.tcx, base_cmt.ty, expl).map |mt| {
|
||||
alt deref_kind(self.tcx, base_cmt.ty) {
|
||||
match deref_kind(self.tcx, base_cmt.ty) {
|
||||
deref_ptr(ptr) => {
|
||||
let lp = do base_cmt.lp.chain |l| {
|
||||
// Given that the ptr itself is loanable, we can
|
||||
|
|
@ -347,7 +347,7 @@ impl public_methods for borrowck_ctxt {
|
|||
// the only way to reach the data they point at.
|
||||
// Other ptr types admit aliases and are therefore
|
||||
// not loanable.
|
||||
alt ptr {
|
||||
match ptr {
|
||||
uniq_ptr => {some(@lp_deref(l, ptr))}
|
||||
gc_ptr | region_ptr(_) | unsafe_ptr => {none}
|
||||
}
|
||||
|
|
@ -355,7 +355,7 @@ impl public_methods for borrowck_ctxt {
|
|||
|
||||
// for unique ptrs, we inherit mutability from the
|
||||
// owning reference.
|
||||
let m = alt ptr {
|
||||
let m = match ptr {
|
||||
uniq_ptr => {
|
||||
self.inherited_mutability(base_cmt.mutbl, mt.mutbl)
|
||||
}
|
||||
|
|
@ -383,7 +383,7 @@ impl public_methods for borrowck_ctxt {
|
|||
fn cat_index(expr: @ast::expr, base: @ast::expr) -> cmt {
|
||||
let base_cmt = self.cat_autoderef(base);
|
||||
|
||||
let mt = alt ty::index(self.tcx, base_cmt.ty) {
|
||||
let mt = match ty::index(self.tcx, base_cmt.ty) {
|
||||
some(mt) => mt,
|
||||
none => {
|
||||
self.tcx.sess.span_bug(
|
||||
|
|
@ -393,18 +393,18 @@ impl public_methods for borrowck_ctxt {
|
|||
}
|
||||
};
|
||||
|
||||
return alt deref_kind(self.tcx, base_cmt.ty) {
|
||||
return match deref_kind(self.tcx, base_cmt.ty) {
|
||||
deref_ptr(ptr) => {
|
||||
// (a) the contents are loanable if the base is loanable
|
||||
// and this is a *unique* vector
|
||||
let deref_lp = alt ptr {
|
||||
let deref_lp = match ptr {
|
||||
uniq_ptr => {base_cmt.lp.map(|lp| @lp_deref(lp, uniq_ptr))}
|
||||
_ => {none}
|
||||
};
|
||||
|
||||
// (b) for unique ptrs, we inherit mutability from the
|
||||
// owning reference.
|
||||
let m = alt ptr {
|
||||
let m = match ptr {
|
||||
uniq_ptr => {
|
||||
self.inherited_mutability(base_cmt.mutbl, mt.mutbl)
|
||||
}
|
||||
|
|
@ -465,7 +465,7 @@ impl private_methods for borrowck_ctxt {
|
|||
let mut ctr = 0u;
|
||||
loop {
|
||||
ctr += 1u;
|
||||
alt self.cat_deref(base, cmt, ctr, false) {
|
||||
match self.cat_deref(base, cmt, ctr, false) {
|
||||
none => return cmt,
|
||||
some(cmt1) => cmt = cmt1
|
||||
}
|
||||
|
|
@ -477,7 +477,7 @@ fn field_mutbl(tcx: ty::ctxt,
|
|||
base_ty: ty::t,
|
||||
f_name: ast::ident) -> option<ast::mutability> {
|
||||
// Need to refactor so that records/class fields can be treated uniformly.
|
||||
alt ty::get(base_ty).struct {
|
||||
match ty::get(base_ty).struct {
|
||||
ty::ty_rec(fields) => {
|
||||
for fields.each |f| {
|
||||
if f.ident == f_name {
|
||||
|
|
@ -488,7 +488,7 @@ fn field_mutbl(tcx: ty::ctxt,
|
|||
ty::ty_class(did, substs) => {
|
||||
for ty::lookup_class_fields(tcx, did).each |fld| {
|
||||
if fld.ident == f_name {
|
||||
let m = alt fld.mutability {
|
||||
let m = match fld.mutability {
|
||||
ast::class_mutable => ast::m_mutbl,
|
||||
ast::class_immutable => ast::m_imm
|
||||
};
|
||||
|
|
|
|||
|
|
@ -64,14 +64,14 @@ impl methods for assignment_type {
|
|||
fn checked_by_liveness() -> bool {
|
||||
// the liveness pass guarantees that immutable local variables
|
||||
// are only assigned once; but it doesn't consider &mut
|
||||
alt self {
|
||||
match self {
|
||||
at_straight_up => true,
|
||||
at_swap => true,
|
||||
at_mutbl_ref => false
|
||||
}
|
||||
}
|
||||
fn ing_form(desc: ~str) -> ~str {
|
||||
alt self {
|
||||
match self {
|
||||
at_straight_up => ~"assigning to " + desc,
|
||||
at_swap => ~"swapping to and from " + desc,
|
||||
at_mutbl_ref => ~"taking mut reference to " + desc
|
||||
|
|
@ -83,7 +83,7 @@ impl methods for check_loan_ctxt {
|
|||
fn tcx() -> ty::ctxt { self.bccx.tcx }
|
||||
|
||||
fn purity(scope_id: ast::node_id) -> option<purity_cause> {
|
||||
let default_purity = alt self.declared_purity {
|
||||
let default_purity = match self.declared_purity {
|
||||
// an unsafe declaration overrides all
|
||||
ast::unsafe_fn => return none,
|
||||
|
||||
|
|
@ -101,12 +101,12 @@ impl methods for check_loan_ctxt {
|
|||
let region_map = self.tcx().region_map;
|
||||
let pure_map = self.req_maps.pure_map;
|
||||
loop {
|
||||
alt pure_map.find(scope_id) {
|
||||
match pure_map.find(scope_id) {
|
||||
none => (),
|
||||
some(e) => return some(pc_cmt(e))
|
||||
}
|
||||
|
||||
alt region_map.find(scope_id) {
|
||||
match region_map.find(scope_id) {
|
||||
none => return default_purity,
|
||||
some(next_scope_id) => scope_id = next_scope_id
|
||||
}
|
||||
|
|
@ -128,7 +128,7 @@ impl methods for check_loan_ctxt {
|
|||
}
|
||||
}
|
||||
|
||||
alt region_map.find(scope_id) {
|
||||
match region_map.find(scope_id) {
|
||||
none => return,
|
||||
some(next_scope_id) => scope_id = next_scope_id,
|
||||
}
|
||||
|
|
@ -173,9 +173,9 @@ impl methods for check_loan_ctxt {
|
|||
// (c) B is a pure fn;
|
||||
// (d) B is not a fn.
|
||||
|
||||
alt opt_expr {
|
||||
match opt_expr {
|
||||
some(expr) => {
|
||||
alt expr.node {
|
||||
match expr.node {
|
||||
ast::expr_path(_) if pc == pc_pure_fn => {
|
||||
let def = self.tcx().def_map.get(expr.id);
|
||||
let did = ast_util::def_id_of_def(def);
|
||||
|
|
@ -198,9 +198,9 @@ impl methods for check_loan_ctxt {
|
|||
}
|
||||
|
||||
let callee_ty = ty::node_id_to_type(tcx, callee_id);
|
||||
alt ty::get(callee_ty).struct {
|
||||
match ty::get(callee_ty).struct {
|
||||
ty::ty_fn(fn_ty) => {
|
||||
alt fn_ty.purity {
|
||||
match fn_ty.purity {
|
||||
ast::pure_fn => return, // case (c) above
|
||||
ast::impure_fn | ast::unsafe_fn | ast::extern_fn => {
|
||||
self.report_purity_error(
|
||||
|
|
@ -219,14 +219,14 @@ impl methods for check_loan_ctxt {
|
|||
fn is_stack_closure(id: ast::node_id) -> bool {
|
||||
let fn_ty = ty::node_id_to_type(self.tcx(), id);
|
||||
let proto = ty::ty_fn_proto(fn_ty);
|
||||
alt proto {
|
||||
match proto {
|
||||
ast::proto_block => true,
|
||||
ast::proto_bare | ast::proto_uniq | ast::proto_box => false
|
||||
}
|
||||
}
|
||||
|
||||
fn is_allowed_pure_arg(expr: @ast::expr) -> bool {
|
||||
return alt expr.node {
|
||||
return match expr.node {
|
||||
ast::expr_path(_) => {
|
||||
let def = self.tcx().def_map.get(expr.id);
|
||||
let did = ast_util::def_id_of_def(def);
|
||||
|
|
@ -241,7 +241,7 @@ impl methods for check_loan_ctxt {
|
|||
}
|
||||
|
||||
fn check_for_conflicting_loans(scope_id: ast::node_id) {
|
||||
let new_loanss = alt self.req_maps.req_loan_map.find(scope_id) {
|
||||
let new_loanss = match self.req_maps.req_loan_map.find(scope_id) {
|
||||
none => return,
|
||||
some(loanss) => loanss
|
||||
};
|
||||
|
|
@ -251,7 +251,7 @@ impl methods for check_loan_ctxt {
|
|||
for (*new_loanss).each |new_loans| {
|
||||
for (*new_loans).each |new_loan| {
|
||||
if old_loan.lp != new_loan.lp { again; }
|
||||
alt (old_loan.mutbl, new_loan.mutbl) {
|
||||
match (old_loan.mutbl, new_loan.mutbl) {
|
||||
(m_const, _) | (_, m_const) |
|
||||
(m_mutbl, m_mutbl) | (m_imm, m_imm) => {
|
||||
/*ok*/
|
||||
|
|
@ -276,16 +276,16 @@ impl methods for check_loan_ctxt {
|
|||
}
|
||||
|
||||
fn is_local_variable(cmt: cmt) -> bool {
|
||||
alt cmt.cat {
|
||||
match cmt.cat {
|
||||
cat_local(_) => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
||||
fn is_self_field(cmt: cmt) -> bool {
|
||||
alt cmt.cat {
|
||||
match cmt.cat {
|
||||
cat_comp(cmt_base, comp_field(*)) => {
|
||||
alt cmt_base.cat {
|
||||
match cmt_base.cat {
|
||||
cat_special(sk_self) => true,
|
||||
_ => false
|
||||
}
|
||||
|
|
@ -307,7 +307,7 @@ impl methods for check_loan_ctxt {
|
|||
// liveness guarantees that immutable local variables
|
||||
// are only assigned once
|
||||
} else {
|
||||
alt cmt.mutbl {
|
||||
match cmt.mutbl {
|
||||
m_mutbl => { /*ok*/ }
|
||||
m_const | m_imm => {
|
||||
self.bccx.span_err(
|
||||
|
|
@ -321,7 +321,7 @@ impl methods for check_loan_ctxt {
|
|||
// if this is a pure function, only loan-able state can be
|
||||
// assigned, because it is uniquely tied to this function and
|
||||
// is not visible from the outside
|
||||
alt self.purity(ex.id) {
|
||||
match self.purity(ex.id) {
|
||||
none => (),
|
||||
some(pc) => {
|
||||
if cmt.lp.is_none() {
|
||||
|
|
@ -352,7 +352,7 @@ impl methods for check_loan_ctxt {
|
|||
lp: @loan_path) {
|
||||
|
||||
for self.walk_loans_of(ex.id, lp) |loan| {
|
||||
alt loan.mutbl {
|
||||
match loan.mutbl {
|
||||
m_mutbl | m_const => { /*ok*/ }
|
||||
m_imm => {
|
||||
self.bccx.span_err(
|
||||
|
|
@ -375,7 +375,7 @@ impl methods for check_loan_ctxt {
|
|||
// let mut x = {f: some(3)};
|
||||
// let y = &x; // x loaned out as immutable
|
||||
// x.f = none; // changes type of y.f, which appears to be imm
|
||||
alt *lp {
|
||||
match *lp {
|
||||
lp_comp(lp_base, ck) if inherent_mutability(ck) != m_mutbl => {
|
||||
self.check_for_loan_conflicting_with_assignment(
|
||||
at, ex, cmt, lp_base);
|
||||
|
|
@ -385,7 +385,7 @@ impl methods for check_loan_ctxt {
|
|||
}
|
||||
|
||||
fn report_purity_error(pc: purity_cause, sp: span, msg: ~str) {
|
||||
alt pc {
|
||||
match pc {
|
||||
pc_pure_fn => {
|
||||
self.tcx().sess.span_err(
|
||||
sp,
|
||||
|
|
@ -414,7 +414,7 @@ impl methods for check_loan_ctxt {
|
|||
debug!{"check_move_out_from_cmt(cmt=%s)",
|
||||
self.bccx.cmt_to_repr(cmt)};
|
||||
|
||||
alt cmt.cat {
|
||||
match cmt.cat {
|
||||
// Rvalues, locals, and arguments can be moved:
|
||||
cat_rvalue | cat_local(_) | cat_arg(_) => {}
|
||||
|
||||
|
|
@ -437,7 +437,7 @@ impl methods for check_loan_ctxt {
|
|||
self.bccx.add_to_mutbl_map(cmt);
|
||||
|
||||
// check for a conflicting loan:
|
||||
let lp = alt cmt.lp {
|
||||
let lp = match cmt.lp {
|
||||
none => return,
|
||||
some(lp) => lp
|
||||
};
|
||||
|
|
@ -459,7 +459,7 @@ impl methods for check_loan_ctxt {
|
|||
// safe to consider the use a last_use.
|
||||
fn check_last_use(expr: @ast::expr) {
|
||||
let cmt = self.bccx.cat_expr(expr);
|
||||
let lp = alt cmt.lp {
|
||||
let lp = match cmt.lp {
|
||||
none => return,
|
||||
some(lp) => lp
|
||||
};
|
||||
|
|
@ -476,7 +476,7 @@ impl methods for check_loan_ctxt {
|
|||
callee_id: ast::node_id,
|
||||
callee_span: span,
|
||||
args: ~[@ast::expr]) {
|
||||
alt self.purity(expr.id) {
|
||||
match self.purity(expr.id) {
|
||||
none => {}
|
||||
some(pc) => {
|
||||
self.check_pure_callee_or_arg(
|
||||
|
|
@ -491,7 +491,7 @@ impl methods for check_loan_ctxt {
|
|||
ty::ty_fn_args(
|
||||
ty::node_id_to_type(self.tcx(), callee_id));
|
||||
do vec::iter2(args, arg_tys) |arg, arg_ty| {
|
||||
alt ty::resolved_mode(self.tcx(), arg_ty.mode) {
|
||||
match ty::resolved_mode(self.tcx(), arg_ty.mode) {
|
||||
ast::by_move => {
|
||||
self.check_move_out(arg);
|
||||
}
|
||||
|
|
@ -521,7 +521,7 @@ fn check_loans_in_fn(fk: visit::fn_kind, decl: ast::fn_decl, body: ast::blk,
|
|||
// of otherwise immutable fields and typestate wouldn't be
|
||||
// able to "see" into those functions anyway, so it
|
||||
// wouldn't be very helpful.
|
||||
alt fk {
|
||||
match fk {
|
||||
visit::fk_ctor(*) => {
|
||||
self.in_ctor = true;
|
||||
self.declared_purity = decl.purity;
|
||||
|
|
@ -551,7 +551,7 @@ fn check_loans_in_fn(fk: visit::fn_kind, decl: ast::fn_decl, body: ast::blk,
|
|||
fn check_loans_in_local(local: @ast::local,
|
||||
&&self: check_loan_ctxt,
|
||||
vt: visit::vt<check_loan_ctxt>) {
|
||||
alt local.node.init {
|
||||
match local.node.init {
|
||||
some({op: ast::init_move, expr: expr}) => {
|
||||
self.check_move_out(expr);
|
||||
}
|
||||
|
|
@ -565,7 +565,7 @@ fn check_loans_in_expr(expr: @ast::expr,
|
|||
vt: visit::vt<check_loan_ctxt>) {
|
||||
self.check_for_conflicting_loans(expr.id);
|
||||
|
||||
alt expr.node {
|
||||
match expr.node {
|
||||
ast::expr_path(*) if self.bccx.last_use_map.contains_key(expr.id) => {
|
||||
self.check_last_use(expr);
|
||||
}
|
||||
|
|
@ -601,7 +601,7 @@ fn check_loans_in_expr(expr: @ast::expr,
|
|||
}
|
||||
}
|
||||
ast::expr_addr_of(mutbl, base) => {
|
||||
alt mutbl {
|
||||
match mutbl {
|
||||
m_const => { /*all memory is const*/ }
|
||||
m_mutbl => {
|
||||
// If we are taking an &mut ptr, make sure the memory
|
||||
|
|
@ -645,7 +645,7 @@ fn check_loans_in_block(blk: ast::blk,
|
|||
do save_and_restore(self.declared_purity) {
|
||||
self.check_for_conflicting_loans(blk.node.id);
|
||||
|
||||
alt blk.node.rules {
|
||||
match blk.node.rules {
|
||||
ast::default_blk => {
|
||||
}
|
||||
ast::unchecked_blk => {
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ fn req_loans_in_fn(fk: visit::fn_kind,
|
|||
let old_root_ub = self.root_ub;
|
||||
self.root_ub = body.node.id;
|
||||
|
||||
alt fk {
|
||||
match fk {
|
||||
visit::fk_anon(*) | visit::fk_fn_block(*) => {}
|
||||
visit::fk_item_fn(*) | visit::fk_method(*) |
|
||||
visit::fk_ctor(*) | visit::fk_dtor(*) => {
|
||||
|
|
@ -99,14 +99,14 @@ fn req_loans_in_expr(ex: @ast::expr,
|
|||
}
|
||||
|
||||
// Special checks for various kinds of expressions:
|
||||
alt ex.node {
|
||||
match ex.node {
|
||||
ast::expr_addr_of(mutbl, base) => {
|
||||
let base_cmt = self.bccx.cat_expr(base);
|
||||
|
||||
// make sure that the thing we are pointing out stays valid
|
||||
// for the lifetime `scope_r` of the resulting ptr:
|
||||
let scope_r =
|
||||
alt check ty::get(tcx.ty(ex)).struct {
|
||||
match check ty::get(tcx.ty(ex)).struct {
|
||||
ty::ty_rptr(r, _) => r
|
||||
};
|
||||
self.guarantee_valid(base_cmt, mutbl, scope_r);
|
||||
|
|
@ -117,7 +117,7 @@ fn req_loans_in_expr(ex: @ast::expr,
|
|||
let arg_tys = ty::ty_fn_args(ty::expr_ty(self.tcx(), f));
|
||||
let scope_r = ty::re_scope(ex.id);
|
||||
do vec::iter2(args, arg_tys) |arg, arg_ty| {
|
||||
alt ty::resolved_mode(self.tcx(), arg_ty.mode) {
|
||||
match ty::resolved_mode(self.tcx(), arg_ty.mode) {
|
||||
ast::by_mutbl_ref => {
|
||||
let arg_cmt = self.bccx.cat_expr(arg);
|
||||
self.guarantee_valid(arg_cmt, m_mutbl, scope_r);
|
||||
|
|
@ -151,7 +151,7 @@ fn req_loans_in_expr(ex: @ast::expr,
|
|||
// immutable (whereas something like {f:int} would be
|
||||
// fine).
|
||||
//
|
||||
alt opt_deref_kind(arg_ty.ty) {
|
||||
match opt_deref_kind(arg_ty.ty) {
|
||||
some(deref_ptr(region_ptr(_))) |
|
||||
some(deref_ptr(unsafe_ptr)) => {
|
||||
/* region pointers are (by induction) guaranteed */
|
||||
|
|
@ -265,7 +265,7 @@ impl methods for gather_loan_ctxt {
|
|||
region_to_str(self.tcx(), scope_r)};
|
||||
let _i = indenter();
|
||||
|
||||
alt cmt.lp {
|
||||
match cmt.lp {
|
||||
// If this expression is a loanable path, we MUST take out a
|
||||
// loan. This is somewhat non-obvious. You might think,
|
||||
// for example, that if we have an immutable local variable
|
||||
|
|
@ -277,11 +277,11 @@ impl methods for gather_loan_ctxt {
|
|||
// it within that scope, the loan will be detected and an
|
||||
// error will be reported.
|
||||
some(_) => {
|
||||
alt self.bccx.loan(cmt, scope_r, req_mutbl) {
|
||||
match self.bccx.loan(cmt, scope_r, req_mutbl) {
|
||||
err(e) => { self.bccx.report(e); }
|
||||
ok(loans) if loans.len() == 0 => {}
|
||||
ok(loans) => {
|
||||
alt scope_r {
|
||||
match scope_r {
|
||||
ty::re_scope(scope_id) => {
|
||||
self.add_loans(scope_id, loans);
|
||||
|
||||
|
|
@ -325,7 +325,7 @@ impl methods for gather_loan_ctxt {
|
|||
}
|
||||
};
|
||||
|
||||
alt result {
|
||||
match result {
|
||||
ok(pc_ok) => {
|
||||
// we were able guarantee the validity of the ptr,
|
||||
// perhaps by rooting or because it is immutably
|
||||
|
|
@ -335,7 +335,7 @@ impl methods for gather_loan_ctxt {
|
|||
ok(pc_if_pure(e)) => {
|
||||
// we are only able to guarantee the validity if
|
||||
// the scope is pure
|
||||
alt scope_r {
|
||||
match scope_r {
|
||||
ty::re_scope(pure_id) => {
|
||||
// if the scope is some block/expr in the fn,
|
||||
// then just require that this scope be pure
|
||||
|
|
@ -374,7 +374,7 @@ impl methods for gather_loan_ctxt {
|
|||
// mutable memory.
|
||||
fn check_mutbl(req_mutbl: ast::mutability,
|
||||
cmt: cmt) -> bckres<preserve_condition> {
|
||||
alt (req_mutbl, cmt.mutbl) {
|
||||
match (req_mutbl, cmt.mutbl) {
|
||||
(m_const, _) |
|
||||
(m_imm, m_imm) |
|
||||
(m_mutbl, m_mutbl) => {
|
||||
|
|
@ -397,7 +397,7 @@ impl methods for gather_loan_ctxt {
|
|||
}
|
||||
|
||||
fn add_loans(scope_id: ast::node_id, loans: @dvec<loan>) {
|
||||
alt self.req_maps.req_loan_map.find(scope_id) {
|
||||
match self.req_maps.req_loan_map.find(scope_id) {
|
||||
some(l) => {
|
||||
(*l).push(loans);
|
||||
}
|
||||
|
|
@ -432,7 +432,7 @@ impl methods for gather_loan_ctxt {
|
|||
// To see what I mean about ids etc, consider:
|
||||
//
|
||||
// let x = @@3;
|
||||
// alt x {
|
||||
// match x {
|
||||
// @@y { ... }
|
||||
// }
|
||||
//
|
||||
|
|
@ -450,7 +450,7 @@ impl methods for gather_loan_ctxt {
|
|||
let _i = indenter();
|
||||
|
||||
let tcx = self.tcx();
|
||||
alt pat.node {
|
||||
match pat.node {
|
||||
ast::pat_wild => {
|
||||
// _
|
||||
}
|
||||
|
|
@ -460,7 +460,7 @@ impl methods for gather_loan_ctxt {
|
|||
}
|
||||
ast::pat_enum(_, some(subpats)) => {
|
||||
// variant(x, y, z)
|
||||
let enum_did = alt self.bccx.tcx.def_map
|
||||
let enum_did = match self.bccx.tcx.def_map
|
||||
.find(pat.id) {
|
||||
some(ast::def_variant(enum_did, _)) => enum_did,
|
||||
e => tcx.sess.span_bug(pat.span,
|
||||
|
|
@ -523,7 +523,7 @@ impl methods for gather_loan_ctxt {
|
|||
|
||||
ast::pat_box(subpat) | ast::pat_uniq(subpat) => {
|
||||
// @p1, ~p1
|
||||
alt self.bccx.cat_deref(subpat, cmt, 0u, true) {
|
||||
match self.bccx.cat_deref(subpat, cmt, 0u, true) {
|
||||
some(subcmt) => {
|
||||
self.gather_pat(subcmt, subpat, arm_id, alt_id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ impl public_methods for borrowck_ctxt {
|
|||
let lc = loan_ctxt_(@{bccx: self,
|
||||
scope_region: scope_region,
|
||||
loans: @dvec()});
|
||||
alt lc.loan(cmt, mutbl) {
|
||||
match lc.loan(cmt, mutbl) {
|
||||
ok(()) => {ok(lc.loans)}
|
||||
err(e) => {err(e)}
|
||||
}
|
||||
|
|
@ -70,7 +70,7 @@ impl loan_methods for loan_ctxt {
|
|||
~"loan() called with non-lendable value");
|
||||
}
|
||||
|
||||
alt cmt.cat {
|
||||
match cmt.cat {
|
||||
cat_binding(_) | cat_rvalue | cat_special(_) => {
|
||||
// should never be loanable
|
||||
self.bccx.tcx.sess.span_bug(
|
||||
|
|
@ -131,7 +131,7 @@ impl loan_methods for loan_ctxt {
|
|||
fn loan_stable_comp(cmt: cmt,
|
||||
cmt_base: cmt,
|
||||
req_mutbl: ast::mutability) -> bckres<()> {
|
||||
let base_mutbl = alt req_mutbl {
|
||||
let base_mutbl = match req_mutbl {
|
||||
m_imm => m_imm,
|
||||
m_const | m_mutbl => m_const
|
||||
};
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ impl public_methods for preserve_condition {
|
|||
// combines two preservation conditions such that if either of
|
||||
// them requires purity, the result requires purity
|
||||
fn combine(pc: preserve_condition) -> preserve_condition {
|
||||
alt self {
|
||||
match self {
|
||||
pc_ok => {pc}
|
||||
pc_if_pure(e) => {self}
|
||||
}
|
||||
|
|
@ -63,7 +63,7 @@ impl private_methods for &preserve_ctxt {
|
|||
self.root_managed_data};
|
||||
let _i = indenter();
|
||||
|
||||
alt cmt.cat {
|
||||
match cmt.cat {
|
||||
cat_special(sk_self) | cat_special(sk_heap_upvar) => {
|
||||
self.compare_scope(cmt, ty::re_scope(self.item_ub))
|
||||
}
|
||||
|
|
@ -160,7 +160,7 @@ impl private_methods for &preserve_ctxt {
|
|||
if base.mutbl == m_imm {
|
||||
let non_rooting_ctxt =
|
||||
preserve_ctxt({root_managed_data: false with **self});
|
||||
alt (&non_rooting_ctxt).preserve(base) {
|
||||
match (&non_rooting_ctxt).preserve(base) {
|
||||
ok(pc_ok) => {
|
||||
ok(pc_ok)
|
||||
}
|
||||
|
|
@ -191,7 +191,7 @@ impl private_methods for &preserve_ctxt {
|
|||
// As an example, consider this scenario:
|
||||
//
|
||||
// let mut x = @some(3);
|
||||
// alt *x { some(y) {...} none {...} }
|
||||
// match *x { some(y) {...} none {...} }
|
||||
//
|
||||
// Technically, the value `x` need only be rooted
|
||||
// in the `some` arm. However, we evaluate `x` in trans
|
||||
|
|
@ -201,7 +201,7 @@ impl private_methods for &preserve_ctxt {
|
|||
// As a second example, consider *this* scenario:
|
||||
//
|
||||
// let x = @mut @some(3);
|
||||
// alt x { @@some(y) {...} @@none {...} }
|
||||
// match x { @@some(y) {...} @@none {...} }
|
||||
//
|
||||
// Here again, `x` need only be rooted in the `some` arm.
|
||||
// In this case, the value which needs to be rooted is
|
||||
|
|
@ -220,7 +220,7 @@ impl private_methods for &preserve_ctxt {
|
|||
// also yielded suboptimal results for patterns like:
|
||||
//
|
||||
// let x = @mut @...;
|
||||
// alt x { @@some_variant(y) | @@some_other_variant(y) {...} }
|
||||
// match x { @@some_variant(y) | @@some_other_variant(y) =>
|
||||
//
|
||||
// The reason is that we would root the value once for
|
||||
// each pattern and not once per arm. This is also easily
|
||||
|
|
@ -234,7 +234,7 @@ impl private_methods for &preserve_ctxt {
|
|||
|
||||
// current scope must be the arm, which is always a child of alt:
|
||||
assert {
|
||||
alt check self.scope_region {
|
||||
match check self.scope_region {
|
||||
ty::re_scope(arm_id) => {
|
||||
self.tcx().region_map.get(arm_id) == alt_id
|
||||
}
|
||||
|
|
@ -259,11 +259,11 @@ impl private_methods for &preserve_ctxt {
|
|||
code: bckerr_code) -> bckres<preserve_condition> {
|
||||
// Variant contents and unique pointers: must be immutably
|
||||
// rooted to a preserved address.
|
||||
alt self.preserve(cmt_base) {
|
||||
match self.preserve(cmt_base) {
|
||||
// the base is preserved, but if we are not mutable then
|
||||
// purity is required
|
||||
ok(pc_ok) => {
|
||||
alt cmt_base.mutbl {
|
||||
match cmt_base.mutbl {
|
||||
m_mutbl | m_const => {
|
||||
ok(pc_if_pure({cmt:cmt, code:code}))
|
||||
}
|
||||
|
|
@ -322,7 +322,7 @@ impl private_methods for &preserve_ctxt {
|
|||
}
|
||||
|
||||
let root_region = ty::re_scope(self.root_ub);
|
||||
alt self.scope_region {
|
||||
match self.scope_region {
|
||||
// we can only root values if the desired region is some concrete
|
||||
// scope within the fn body
|
||||
ty::re_scope(scope_id) => {
|
||||
|
|
|
|||
|
|
@ -101,14 +101,14 @@ fn compute_capture_vars(tcx: ty::ctxt,
|
|||
// now go through anything that is referenced but was not explicitly
|
||||
// named and add that
|
||||
|
||||
let implicit_mode = alt fn_proto {
|
||||
let implicit_mode = match fn_proto {
|
||||
ast::proto_block => cap_ref,
|
||||
ast::proto_bare | ast::proto_box | ast::proto_uniq => cap_copy
|
||||
};
|
||||
|
||||
do vec::iter(*freevars) |fvar| {
|
||||
let fvar_def_id = ast_util::def_id_of_def(fvar.def).node;
|
||||
alt cap_map.find(fvar_def_id) {
|
||||
match cap_map.find(fvar_def_id) {
|
||||
option::some(_) => { /* was explicitly named, do nothing */ }
|
||||
option::none => {
|
||||
cap_map.insert(fvar_def_id, {def:fvar.def,
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ fn check_crate(tcx: ty::ctxt, crate: @crate) {
|
|||
|
||||
fn check_expr(tcx: ty::ctxt, ex: @expr, &&s: (), v: visit::vt<()>) {
|
||||
visit::visit_expr(ex, s, v);
|
||||
alt ex.node {
|
||||
match ex.node {
|
||||
expr_alt(scrut, arms, mode) => {
|
||||
check_arms(tcx, arms);
|
||||
/* Check for exhaustiveness */
|
||||
|
|
@ -33,7 +33,7 @@ fn check_expr(tcx: ty::ctxt, ex: @expr, &&s: (), v: visit::vt<()>) {
|
|||
// Vacuously exhaustive
|
||||
return;
|
||||
}
|
||||
alt ty::get(pat_ty).struct {
|
||||
match ty::get(pat_ty).struct {
|
||||
ty_enum(did, _) => {
|
||||
if (*enum_variants(tcx, did)).is_empty() && arms.is_empty() {
|
||||
|
||||
|
|
@ -58,7 +58,7 @@ fn check_arms(tcx: ty::ctxt, arms: ~[arm]) {
|
|||
for arms.each |arm| {
|
||||
for arm.pats.each |pat| {
|
||||
let v = ~[pat];
|
||||
alt is_useful(tcx, seen, v) {
|
||||
match is_useful(tcx, seen, v) {
|
||||
not_useful => {
|
||||
tcx.sess.span_err(pat.span, ~"unreachable pattern");
|
||||
}
|
||||
|
|
@ -70,7 +70,7 @@ fn check_arms(tcx: ty::ctxt, arms: ~[arm]) {
|
|||
}
|
||||
|
||||
fn raw_pat(p: @pat) -> @pat {
|
||||
alt p.node {
|
||||
match p.node {
|
||||
pat_ident(_, _, some(s)) => { raw_pat(s) }
|
||||
_ => { p }
|
||||
}
|
||||
|
|
@ -78,20 +78,20 @@ fn raw_pat(p: @pat) -> @pat {
|
|||
|
||||
fn check_exhaustive(tcx: ty::ctxt, sp: span, pats: ~[@pat]) {
|
||||
assert(pats.is_not_empty());
|
||||
let ext = alt is_useful(tcx, vec::map(pats, |p| ~[p]), ~[wild()]) {
|
||||
let ext = match is_useful(tcx, vec::map(pats, |p| ~[p]), ~[wild()]) {
|
||||
not_useful => return, // This is good, wildcard pattern isn't reachable
|
||||
useful_ => none,
|
||||
useful(ty, ctor) => {
|
||||
alt ty::get(ty).struct {
|
||||
match ty::get(ty).struct {
|
||||
ty::ty_bool => {
|
||||
alt check ctor {
|
||||
match check ctor {
|
||||
val(const_int(1i64)) => some(@~"true"),
|
||||
val(const_int(0i64)) => some(@~"false")
|
||||
}
|
||||
}
|
||||
ty::ty_enum(id, _) => {
|
||||
let vid = alt check ctor { variant(id) => id };
|
||||
alt check vec::find(*ty::enum_variants(tcx, id),
|
||||
let vid = match check ctor { variant(id) => id };
|
||||
match check vec::find(*ty::enum_variants(tcx, id),
|
||||
|v| v.id == vid) {
|
||||
some(v) => some(v.name)
|
||||
}
|
||||
|
|
@ -100,7 +100,7 @@ fn check_exhaustive(tcx: ty::ctxt, sp: span, pats: ~[@pat]) {
|
|||
}
|
||||
}
|
||||
};
|
||||
let msg = ~"non-exhaustive patterns" + alt ext {
|
||||
let msg = ~"non-exhaustive patterns" + match ext {
|
||||
some(s) => ~": " + *s + ~" not covered",
|
||||
none => ~""
|
||||
};
|
||||
|
|
@ -134,19 +134,19 @@ enum ctor {
|
|||
fn is_useful(tcx: ty::ctxt, m: matrix, v: ~[@pat]) -> useful {
|
||||
if m.len() == 0u { return useful_; }
|
||||
if m[0].len() == 0u { return not_useful; }
|
||||
let real_pat = alt vec::find(m, |r| r[0].id != 0) {
|
||||
let real_pat = match vec::find(m, |r| r[0].id != 0) {
|
||||
some(r) => r[0], none => v[0]
|
||||
};
|
||||
let left_ty = if real_pat.id == 0 { ty::mk_nil(tcx) }
|
||||
else { ty::node_id_to_type(tcx, real_pat.id) };
|
||||
|
||||
alt pat_ctor_id(tcx, v[0]) {
|
||||
match pat_ctor_id(tcx, v[0]) {
|
||||
none => {
|
||||
alt missing_ctor(tcx, m, left_ty) {
|
||||
match missing_ctor(tcx, m, left_ty) {
|
||||
none => {
|
||||
alt ty::get(left_ty).struct {
|
||||
match ty::get(left_ty).struct {
|
||||
ty::ty_bool => {
|
||||
alt is_useful_specialized(tcx, m, v, val(const_int(1i64)),
|
||||
match is_useful_specialized(tcx, m, v, val(const_int(1i64)),
|
||||
0u, left_ty){
|
||||
not_useful => {
|
||||
is_useful_specialized(tcx, m, v, val(const_int(0i64)),
|
||||
|
|
@ -157,7 +157,7 @@ fn is_useful(tcx: ty::ctxt, m: matrix, v: ~[@pat]) -> useful {
|
|||
}
|
||||
ty::ty_enum(eid, _) => {
|
||||
for (*ty::enum_variants(tcx, eid)).each |va| {
|
||||
alt is_useful_specialized(tcx, m, v, variant(va.id),
|
||||
match is_useful_specialized(tcx, m, v, variant(va.id),
|
||||
va.args.len(), left_ty) {
|
||||
not_useful => (),
|
||||
u => return u
|
||||
|
|
@ -172,7 +172,7 @@ fn is_useful(tcx: ty::ctxt, m: matrix, v: ~[@pat]) -> useful {
|
|||
}
|
||||
}
|
||||
some(ctor) => {
|
||||
alt is_useful(tcx, vec::filter_map(m, |r| default(tcx, r) ),
|
||||
match is_useful(tcx, vec::filter_map(m, |r| default(tcx, r) ),
|
||||
vec::tail(v)) {
|
||||
useful_ => useful(left_ty, ctor),
|
||||
u => u
|
||||
|
|
@ -190,7 +190,9 @@ fn is_useful(tcx: ty::ctxt, m: matrix, v: ~[@pat]) -> useful {
|
|||
fn is_useful_specialized(tcx: ty::ctxt, m: matrix, v: ~[@pat], ctor: ctor,
|
||||
arity: uint, lty: ty::t) -> useful {
|
||||
let ms = vec::filter_map(m, |r| specialize(tcx, r, ctor, arity, lty) );
|
||||
alt is_useful(tcx, ms, option::get(specialize(tcx, v, ctor, arity, lty))){
|
||||
let could_be_useful = is_useful(
|
||||
tcx, ms, option::get(specialize(tcx, v, ctor, arity, lty)));
|
||||
match could_be_useful {
|
||||
useful_ => useful(lty, ctor),
|
||||
u => u
|
||||
}
|
||||
|
|
@ -198,10 +200,10 @@ fn is_useful_specialized(tcx: ty::ctxt, m: matrix, v: ~[@pat], ctor: ctor,
|
|||
|
||||
fn pat_ctor_id(tcx: ty::ctxt, p: @pat) -> option<ctor> {
|
||||
let pat = raw_pat(p);
|
||||
alt pat.node {
|
||||
match pat.node {
|
||||
pat_wild => { none }
|
||||
pat_ident(_, _, _) | pat_enum(_, _) => {
|
||||
alt tcx.def_map.find(pat.id) {
|
||||
match tcx.def_map.find(pat.id) {
|
||||
some(def_variant(_, id)) => some(variant(id)),
|
||||
_ => none
|
||||
}
|
||||
|
|
@ -218,10 +220,10 @@ fn pat_ctor_id(tcx: ty::ctxt, p: @pat) -> option<ctor> {
|
|||
|
||||
fn is_wild(tcx: ty::ctxt, p: @pat) -> bool {
|
||||
let pat = raw_pat(p);
|
||||
alt pat.node {
|
||||
match pat.node {
|
||||
pat_wild => { true }
|
||||
pat_ident(_, _, _) => {
|
||||
alt tcx.def_map.find(pat.id) {
|
||||
match tcx.def_map.find(pat.id) {
|
||||
some(def_variant(_, _)) => { false }
|
||||
_ => { true }
|
||||
}
|
||||
|
|
@ -231,7 +233,7 @@ fn is_wild(tcx: ty::ctxt, p: @pat) -> bool {
|
|||
}
|
||||
|
||||
fn missing_ctor(tcx: ty::ctxt, m: matrix, left_ty: ty::t) -> option<ctor> {
|
||||
alt ty::get(left_ty).struct {
|
||||
match ty::get(left_ty).struct {
|
||||
ty::ty_box(_) | ty::ty_uniq(_) | ty::ty_tup(_) | ty::ty_rec(_) => {
|
||||
for m.each |r| {
|
||||
if !is_wild(tcx, r[0]) { return none; }
|
||||
|
|
@ -259,7 +261,7 @@ fn missing_ctor(tcx: ty::ctxt, m: matrix, left_ty: ty::t) -> option<ctor> {
|
|||
ty::ty_bool => {
|
||||
let mut true_found = false, false_found = false;
|
||||
for m.each |r| {
|
||||
alt check pat_ctor_id(tcx, r[0]) {
|
||||
match check pat_ctor_id(tcx, r[0]) {
|
||||
none => (),
|
||||
some(val(const_int(1i64))) => true_found = true,
|
||||
some(val(const_int(0i64))) => false_found = true
|
||||
|
|
@ -274,13 +276,13 @@ fn missing_ctor(tcx: ty::ctxt, m: matrix, left_ty: ty::t) -> option<ctor> {
|
|||
}
|
||||
|
||||
fn ctor_arity(tcx: ty::ctxt, ctor: ctor, ty: ty::t) -> uint {
|
||||
alt ty::get(ty).struct {
|
||||
match ty::get(ty).struct {
|
||||
ty::ty_tup(fs) => fs.len(),
|
||||
ty::ty_rec(fs) => fs.len(),
|
||||
ty::ty_box(_) | ty::ty_uniq(_) => 1u,
|
||||
ty::ty_enum(eid, _) => {
|
||||
let id = alt check ctor { variant(id) => id };
|
||||
alt check vec::find(*ty::enum_variants(tcx, eid), |v| v.id == id ) {
|
||||
let id = match check ctor { variant(id) => id };
|
||||
match check vec::find(*ty::enum_variants(tcx, eid), |v| v.id == id ) {
|
||||
some(v) => v.args.len()
|
||||
}
|
||||
}
|
||||
|
|
@ -295,11 +297,11 @@ fn wild() -> @pat {
|
|||
fn specialize(tcx: ty::ctxt, r: ~[@pat], ctor_id: ctor, arity: uint,
|
||||
left_ty: ty::t) -> option<~[@pat]> {
|
||||
let r0 = raw_pat(r[0]);
|
||||
alt r0.node {
|
||||
match r0.node {
|
||||
pat_wild => some(vec::append(vec::from_elem(arity, wild()),
|
||||
vec::tail(r))),
|
||||
pat_ident(_, _, _) => {
|
||||
alt tcx.def_map.find(r0.id) {
|
||||
match tcx.def_map.find(r0.id) {
|
||||
some(def_variant(_, id)) => {
|
||||
if variant(id) == ctor_id { some(vec::tail(r)) }
|
||||
else { none }
|
||||
|
|
@ -308,9 +310,9 @@ fn specialize(tcx: ty::ctxt, r: ~[@pat], ctor_id: ctor, arity: uint,
|
|||
}
|
||||
}
|
||||
pat_enum(_, args) => {
|
||||
alt check tcx.def_map.get(r0.id) {
|
||||
match check tcx.def_map.get(r0.id) {
|
||||
def_variant(_, id) if variant(id) == ctor_id => {
|
||||
let args = alt args {
|
||||
let args = match args {
|
||||
some(args) => args,
|
||||
none => vec::from_elem(arity, wild())
|
||||
};
|
||||
|
|
@ -320,11 +322,11 @@ fn specialize(tcx: ty::ctxt, r: ~[@pat], ctor_id: ctor, arity: uint,
|
|||
}
|
||||
}
|
||||
pat_rec(flds, _) => {
|
||||
let ty_flds = alt check ty::get(left_ty).struct {
|
||||
let ty_flds = match check ty::get(left_ty).struct {
|
||||
ty::ty_rec(flds) => flds
|
||||
};
|
||||
let args = vec::map(ty_flds, |ty_f| {
|
||||
alt vec::find(flds, |f| f.ident == ty_f.ident ) {
|
||||
match vec::find(flds, |f| f.ident == ty_f.ident ) {
|
||||
some(f) => f.pat, _ => wild()
|
||||
}
|
||||
});
|
||||
|
|
@ -334,7 +336,7 @@ fn specialize(tcx: ty::ctxt, r: ~[@pat], ctor_id: ctor, arity: uint,
|
|||
pat_box(a) | pat_uniq(a) => some(vec::append(~[a], vec::tail(r))),
|
||||
pat_lit(expr) => {
|
||||
let e_v = eval_const_expr(tcx, expr);
|
||||
let match_ = alt check ctor_id {
|
||||
let match_ = match check ctor_id {
|
||||
val(v) => compare_const_vals(e_v, v) == 0,
|
||||
range(c_lo, c_hi) => {
|
||||
compare_const_vals(c_lo, e_v) >= 0 &&
|
||||
|
|
@ -345,7 +347,7 @@ fn specialize(tcx: ty::ctxt, r: ~[@pat], ctor_id: ctor, arity: uint,
|
|||
if match_ { some(vec::tail(r)) } else { none }
|
||||
}
|
||||
pat_range(lo, hi) => {
|
||||
let (c_lo, c_hi) = alt check ctor_id {
|
||||
let (c_lo, c_hi) = match check ctor_id {
|
||||
val(v) => (v, v),
|
||||
range(lo, hi) => (lo, hi),
|
||||
single => return some(vec::tail(r)),
|
||||
|
|
@ -373,14 +375,14 @@ fn check_local(tcx: ty::ctxt, loc: @local, &&s: (), v: visit::vt<()>) {
|
|||
}
|
||||
|
||||
fn is_refutable(tcx: ty::ctxt, pat: @pat) -> bool {
|
||||
alt tcx.def_map.find(pat.id) {
|
||||
match tcx.def_map.find(pat.id) {
|
||||
some(def_variant(enum_id, var_id)) => {
|
||||
if vec::len(*ty::enum_variants(tcx, enum_id)) != 1u { return true; }
|
||||
}
|
||||
_ => ()
|
||||
}
|
||||
|
||||
alt pat.node {
|
||||
match pat.node {
|
||||
pat_box(sub) | pat_uniq(sub) | pat_ident(_, _, some(sub)) => {
|
||||
is_refutable(tcx, sub)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ fn check_crate(sess: session, crate: @crate, ast_map: ast_map::map,
|
|||
fn check_item(sess: session, ast_map: ast_map::map,
|
||||
def_map: resolve3::DefMap,
|
||||
it: @item, &&_is_const: bool, v: visit::vt<bool>) {
|
||||
alt it.node {
|
||||
match it.node {
|
||||
item_const(_, ex) => {
|
||||
v.visit_expr(ex, true, v);
|
||||
check_item_recursion(sess, ast_map, def_map, it);
|
||||
|
|
@ -38,13 +38,13 @@ fn check_item(sess: session, ast_map: ast_map::map,
|
|||
|
||||
fn check_pat(p: @pat, &&_is_const: bool, v: visit::vt<bool>) {
|
||||
fn is_str(e: @expr) -> bool {
|
||||
alt e.node {
|
||||
match e.node {
|
||||
expr_vstore(@{node: expr_lit(@{node: lit_str(_), _}), _},
|
||||
vstore_uniq) => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
alt p.node {
|
||||
match p.node {
|
||||
// Let through plain ~-string literals here
|
||||
pat_lit(a) => if !is_str(a) { v.visit_expr(a, true, v); }
|
||||
pat_range(a, b) => {
|
||||
|
|
@ -59,7 +59,7 @@ fn check_expr(sess: session, def_map: resolve3::DefMap,
|
|||
method_map: typeck::method_map, tcx: ty::ctxt,
|
||||
e: @expr, &&is_const: bool, v: visit::vt<bool>) {
|
||||
if is_const {
|
||||
alt e.node {
|
||||
match e.node {
|
||||
expr_unary(box(_), _) | expr_unary(uniq(_), _) |
|
||||
expr_unary(deref, _) => {
|
||||
sess.span_err(e.span,
|
||||
|
|
@ -83,7 +83,7 @@ fn check_expr(sess: session, def_map: resolve3::DefMap,
|
|||
}
|
||||
}
|
||||
expr_path(_) => {
|
||||
alt def_map.find(e.id) {
|
||||
match def_map.find(e.id) {
|
||||
some(def_const(def_id)) => {
|
||||
if !ast_util::is_local(def_id) {
|
||||
sess.span_err(
|
||||
|
|
@ -117,7 +117,7 @@ fn check_expr(sess: session, def_map: resolve3::DefMap,
|
|||
}
|
||||
}
|
||||
}
|
||||
alt e.node {
|
||||
match e.node {
|
||||
expr_lit(@{node: lit_int(v, t), _}) => {
|
||||
if t != ty_char {
|
||||
if (v as u64) > ast_util::int_ty_max(
|
||||
|
|
@ -175,11 +175,11 @@ fn check_item_recursion(sess: session, ast_map: ast_map::map,
|
|||
}
|
||||
|
||||
fn visit_expr(e: @expr, &&env: env, v: visit::vt<env>) {
|
||||
alt e.node {
|
||||
match e.node {
|
||||
expr_path(path) => {
|
||||
alt env.def_map.find(e.id) {
|
||||
match env.def_map.find(e.id) {
|
||||
some(def_const(def_id)) => {
|
||||
alt check env.ast_map.get(def_id.node) {
|
||||
match check env.ast_map.get(def_id.node) {
|
||||
ast_map::node_item(it, _) => {
|
||||
v.visit_item(it, env, v);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ fn check_crate(tcx: ty::ctxt, crate: @crate) {
|
|||
visit::visit_item(i, {in_loop: false, can_ret: true}, v);
|
||||
},
|
||||
visit_expr: |e: @expr, cx: ctx, v: visit::vt<ctx>| {
|
||||
alt e.node {
|
||||
match e.node {
|
||||
expr_while(e, b) => {
|
||||
v.visit_expr(e, cx, v);
|
||||
v.visit_block(b, {in_loop: true with cx}, v);
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ enum constness {
|
|||
}
|
||||
|
||||
fn join(a: constness, b: constness) -> constness {
|
||||
alt (a,b) {
|
||||
match (a,b) {
|
||||
(integral_const, integral_const) => integral_const,
|
||||
(integral_const, general_const)
|
||||
| (general_const, integral_const)
|
||||
|
|
@ -58,13 +58,13 @@ fn classify(e: @expr,
|
|||
def_map: resolve3::DefMap,
|
||||
tcx: ty::ctxt) -> constness {
|
||||
let did = ast_util::local_def(e.id);
|
||||
alt tcx.ccache.find(did) {
|
||||
match tcx.ccache.find(did) {
|
||||
some(x) => x,
|
||||
none => {
|
||||
let cn =
|
||||
alt e.node {
|
||||
match e.node {
|
||||
ast::expr_lit(lit) => {
|
||||
alt lit.node {
|
||||
match lit.node {
|
||||
ast::lit_str(*) |
|
||||
ast::lit_float(*) => general_const,
|
||||
_ => integral_const
|
||||
|
|
@ -87,7 +87,7 @@ fn classify(e: @expr,
|
|||
}
|
||||
|
||||
ast::expr_vstore(e, vstore) => {
|
||||
alt vstore {
|
||||
match vstore {
|
||||
ast::vstore_fixed(_) |
|
||||
ast::vstore_slice(_) => classify(e, def_map, tcx),
|
||||
ast::vstore_uniq |
|
||||
|
|
@ -134,7 +134,7 @@ fn classify(e: @expr,
|
|||
// FIXME: #1272, we can probably do something CCI-ish
|
||||
// surrounding nonlocal constants. But we don't yet.
|
||||
ast::expr_path(_) => {
|
||||
alt def_map.find(e.id) {
|
||||
match def_map.find(e.id) {
|
||||
some(ast::def_const(def_id)) => {
|
||||
if ast_util::is_local(def_id) {
|
||||
let ty = ty::expr_ty(tcx, e);
|
||||
|
|
@ -191,24 +191,24 @@ enum const_val {
|
|||
fn eval_const_expr(tcx: middle::ty::ctxt, e: @expr) -> const_val {
|
||||
import middle::ty;
|
||||
fn fromb(b: bool) -> const_val { const_int(b as i64) }
|
||||
alt check e.node {
|
||||
match check e.node {
|
||||
expr_unary(neg, inner) => {
|
||||
alt check eval_const_expr(tcx, inner) {
|
||||
match check eval_const_expr(tcx, inner) {
|
||||
const_float(f) => const_float(-f),
|
||||
const_int(i) => const_int(-i),
|
||||
const_uint(i) => const_uint(-i)
|
||||
}
|
||||
}
|
||||
expr_unary(not, inner) => {
|
||||
alt check eval_const_expr(tcx, inner) {
|
||||
match check eval_const_expr(tcx, inner) {
|
||||
const_int(i) => const_int(!i),
|
||||
const_uint(i) => const_uint(!i)
|
||||
}
|
||||
}
|
||||
expr_binary(op, a, b) => {
|
||||
alt check (eval_const_expr(tcx, a), eval_const_expr(tcx, b)) {
|
||||
match check (eval_const_expr(tcx, a), eval_const_expr(tcx, b)) {
|
||||
(const_float(a), const_float(b)) => {
|
||||
alt check op {
|
||||
match check op {
|
||||
add => const_float(a + b),
|
||||
subtract => const_float(a - b),
|
||||
mul => const_float(a * b),
|
||||
|
|
@ -223,7 +223,7 @@ fn eval_const_expr(tcx: middle::ty::ctxt, e: @expr) -> const_val {
|
|||
}
|
||||
}
|
||||
(const_int(a), const_int(b)) => {
|
||||
alt check op {
|
||||
match check op {
|
||||
add => const_int(a + b),
|
||||
subtract => const_int(a - b),
|
||||
mul => const_int(a * b),
|
||||
|
|
@ -243,7 +243,7 @@ fn eval_const_expr(tcx: middle::ty::ctxt, e: @expr) -> const_val {
|
|||
}
|
||||
}
|
||||
(const_uint(a), const_uint(b)) => {
|
||||
alt check op {
|
||||
match check op {
|
||||
add => const_uint(a + b),
|
||||
subtract => const_uint(a - b),
|
||||
mul => const_uint(a * b),
|
||||
|
|
@ -264,13 +264,13 @@ fn eval_const_expr(tcx: middle::ty::ctxt, e: @expr) -> const_val {
|
|||
}
|
||||
// shifts can have any integral type as their rhs
|
||||
(const_int(a), const_uint(b)) => {
|
||||
alt check op {
|
||||
match check op {
|
||||
shl => const_int(a << b),
|
||||
shr => const_int(a >> b)
|
||||
}
|
||||
}
|
||||
(const_uint(a), const_int(b)) => {
|
||||
alt check op {
|
||||
match check op {
|
||||
shl => const_uint(a << b),
|
||||
shr => const_uint(a >> b)
|
||||
}
|
||||
|
|
@ -280,23 +280,23 @@ fn eval_const_expr(tcx: middle::ty::ctxt, e: @expr) -> const_val {
|
|||
expr_cast(base, _) => {
|
||||
let ety = ty::expr_ty(tcx, e);
|
||||
let base = eval_const_expr(tcx, base);
|
||||
alt check ty::get(ety).struct {
|
||||
match check ty::get(ety).struct {
|
||||
ty::ty_float(_) => {
|
||||
alt check base {
|
||||
match check base {
|
||||
const_uint(u) => const_float(u as f64),
|
||||
const_int(i) => const_float(i as f64),
|
||||
const_float(_) => base
|
||||
}
|
||||
}
|
||||
ty::ty_uint(_) => {
|
||||
alt check base {
|
||||
match check base {
|
||||
const_uint(_) => base,
|
||||
const_int(i) => const_uint(i as u64),
|
||||
const_float(f) => const_uint(f as u64)
|
||||
}
|
||||
}
|
||||
ty::ty_int(_) | ty::ty_bool => {
|
||||
alt check base {
|
||||
match check base {
|
||||
const_uint(u) => const_int(u as i64),
|
||||
const_int(_) => base,
|
||||
const_float(f) => const_int(f as i64)
|
||||
|
|
@ -311,7 +311,7 @@ fn eval_const_expr(tcx: middle::ty::ctxt, e: @expr) -> const_val {
|
|||
}
|
||||
|
||||
fn lit_to_const(lit: @lit) -> const_val {
|
||||
alt lit.node {
|
||||
match lit.node {
|
||||
lit_str(s) => const_str(*s),
|
||||
lit_int(n, _) => const_int(n),
|
||||
lit_uint(n, _) => const_uint(n),
|
||||
|
|
@ -323,7 +323,7 @@ fn lit_to_const(lit: @lit) -> const_val {
|
|||
}
|
||||
|
||||
fn compare_const_vals(a: const_val, b: const_val) -> int {
|
||||
alt (a, b) {
|
||||
match (a, b) {
|
||||
(const_int(a), const_int(b)) => {
|
||||
if a == b {
|
||||
0
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ fn collect_freevars(def_map: resolve3::DefMap, blk: ast::blk)
|
|||
fn ignore_item(_i: @ast::item, &&_depth: int, _v: visit::vt<int>) { }
|
||||
|
||||
let walk_expr = fn@(expr: @ast::expr, &&depth: int, v: visit::vt<int>) {
|
||||
alt expr.node {
|
||||
match expr.node {
|
||||
ast::expr_fn(proto, decl, _, _) => {
|
||||
if proto != ast::proto_bare {
|
||||
visit::visit_expr(expr, depth + 1, v);
|
||||
|
|
@ -49,12 +49,12 @@ fn collect_freevars(def_map: resolve3::DefMap, blk: ast::blk)
|
|||
}
|
||||
ast::expr_path(path) => {
|
||||
let mut i = 0;
|
||||
alt def_map.find(expr.id) {
|
||||
match def_map.find(expr.id) {
|
||||
none => fail (~"Not found: " + path_to_str(path)),
|
||||
some(df) => {
|
||||
let mut def = df;
|
||||
while i < depth {
|
||||
alt copy def {
|
||||
match copy def {
|
||||
ast::def_upvar(_, inner, _) => { def = *inner; }
|
||||
_ => break
|
||||
}
|
||||
|
|
@ -104,7 +104,7 @@ fn annotate_freevars(def_map: resolve3::DefMap, crate: @ast::crate) ->
|
|||
}
|
||||
|
||||
fn get_freevars(tcx: ty::ctxt, fid: ast::node_id) -> freevar_info {
|
||||
alt tcx.freevars.find(fid) {
|
||||
match tcx.freevars.find(fid) {
|
||||
none => fail ~"get_freevars: " + int::str(fid) + ~" has no freevars",
|
||||
some(d) => return d
|
||||
}
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ fn with_appropriate_checker(cx: ctx, id: node_id, b: fn(check_fn)) {
|
|||
}
|
||||
|
||||
let fty = ty::node_id_to_type(cx.tcx, id);
|
||||
alt ty::ty_fn_proto(fty) {
|
||||
match ty::ty_fn_proto(fty) {
|
||||
proto_uniq => b(check_for_uniq),
|
||||
proto_box => b(check_for_box),
|
||||
proto_bare => b(check_for_bare),
|
||||
|
|
@ -166,7 +166,7 @@ fn check_fn(fk: visit::fn_kind, decl: fn_decl, body: blk, sp: span,
|
|||
// errors and produce a list of the def id's for all capture
|
||||
// variables. This list is used below to avoid checking and reporting
|
||||
// on a given variable twice.
|
||||
let cap_clause = alt fk {
|
||||
let cap_clause = match fk {
|
||||
visit::fk_anon(_, cc) | visit::fk_fn_block(cc) => cc,
|
||||
visit::fk_item_fn(*) | visit::fk_method(*) |
|
||||
visit::fk_ctor(*) | visit::fk_dtor(*) => @~[]
|
||||
|
|
@ -190,7 +190,7 @@ fn check_fn(fk: visit::fn_kind, decl: fn_decl, body: blk, sp: span,
|
|||
// if this is the last use of the variable, then it will be
|
||||
// a move and not a copy
|
||||
let is_move = {
|
||||
alt check cx.last_use_map.find(fn_id) {
|
||||
match check cx.last_use_map.find(fn_id) {
|
||||
some(vars) => (*vars).contains(id),
|
||||
none => false
|
||||
}
|
||||
|
|
@ -205,7 +205,7 @@ fn check_fn(fk: visit::fn_kind, decl: fn_decl, body: blk, sp: span,
|
|||
}
|
||||
|
||||
fn check_block(b: blk, cx: ctx, v: visit::vt<ctx>) {
|
||||
alt b.node.expr {
|
||||
match b.node.expr {
|
||||
some(ex) => maybe_copy(cx, ex),
|
||||
_ => ()
|
||||
}
|
||||
|
|
@ -214,7 +214,7 @@ fn check_block(b: blk, cx: ctx, v: visit::vt<ctx>) {
|
|||
|
||||
fn check_expr(e: @expr, cx: ctx, v: visit::vt<ctx>) {
|
||||
debug!{"kind::check_expr(%s)", expr_to_str(e)};
|
||||
alt e.node {
|
||||
match e.node {
|
||||
expr_assign(_, ex) |
|
||||
expr_unary(box(_), ex) | expr_unary(uniq(_), ex) |
|
||||
expr_ret(some(ex)) => {
|
||||
|
|
@ -233,11 +233,11 @@ fn check_expr(e: @expr, cx: ctx, v: visit::vt<ctx>) {
|
|||
}
|
||||
expr_rec(fields, def) => {
|
||||
for fields.each |field| { maybe_copy(cx, field.node.expr); }
|
||||
alt def {
|
||||
match def {
|
||||
some(ex) => {
|
||||
// All noncopyable fields must be overridden
|
||||
let t = ty::expr_ty(cx.tcx, ex);
|
||||
let ty_fields = alt ty::get(t).struct {
|
||||
let ty_fields = match ty::get(t).struct {
|
||||
ty::ty_rec(f) => f,
|
||||
_ => cx.tcx.sess.span_bug(ex.span, ~"bad expr type in record")
|
||||
};
|
||||
|
|
@ -258,7 +258,7 @@ fn check_expr(e: @expr, cx: ctx, v: visit::vt<ctx>) {
|
|||
expr_call(f, args, _) => {
|
||||
let mut i = 0u;
|
||||
for ty::ty_fn_args(ty::expr_ty(cx.tcx, f)).each |arg_t| {
|
||||
alt ty::arg_mode(cx.tcx, arg_t) {
|
||||
match ty::arg_mode(cx.tcx, arg_t) {
|
||||
by_copy => maybe_copy(cx, args[i]),
|
||||
by_ref | by_val | by_mutbl_ref | by_move => ()
|
||||
}
|
||||
|
|
@ -267,13 +267,13 @@ fn check_expr(e: @expr, cx: ctx, v: visit::vt<ctx>) {
|
|||
}
|
||||
expr_path(_) | expr_field(_, _, _) => {
|
||||
do option::iter(cx.tcx.node_type_substs.find(e.id)) |ts| {
|
||||
let bounds = alt check e.node {
|
||||
let bounds = match check e.node {
|
||||
expr_path(_) => {
|
||||
let did = ast_util::def_id_of_def(cx.tcx.def_map.get(e.id));
|
||||
ty::lookup_item_type(cx.tcx, did).bounds
|
||||
}
|
||||
expr_field(base, _, _) => {
|
||||
alt cx.method_map.get(e.id).origin {
|
||||
match cx.method_map.get(e.id).origin {
|
||||
typeck::method_static(did) => {
|
||||
// n.b.: When we encode class/impl methods, the bounds
|
||||
// that we encode include both the class/impl bounds
|
||||
|
|
@ -312,10 +312,10 @@ fn check_expr(e: @expr, cx: ctx, v: visit::vt<ctx>) {
|
|||
}
|
||||
|
||||
fn check_stmt(stmt: @stmt, cx: ctx, v: visit::vt<ctx>) {
|
||||
alt stmt.node {
|
||||
match stmt.node {
|
||||
stmt_decl(@{node: decl_local(locals), _}, _) => {
|
||||
for locals.each |local| {
|
||||
alt local.node.init {
|
||||
match local.node.init {
|
||||
some({op: init_assign, expr}) => maybe_copy(cx, expr),
|
||||
_ => {}
|
||||
}
|
||||
|
|
@ -327,7 +327,7 @@ fn check_stmt(stmt: @stmt, cx: ctx, v: visit::vt<ctx>) {
|
|||
}
|
||||
|
||||
fn check_ty(aty: @ty, cx: ctx, v: visit::vt<ctx>) {
|
||||
alt aty.node {
|
||||
match aty.node {
|
||||
ty_path(_, id) => {
|
||||
do option::iter(cx.tcx.node_type_substs.find(id)) |ts| {
|
||||
let did = ast_util::def_id_of_def(cx.tcx.def_map.get(id));
|
||||
|
|
@ -373,9 +373,9 @@ fn maybe_copy(cx: ctx, ex: @expr) {
|
|||
}
|
||||
|
||||
fn is_nullary_variant(cx: ctx, ex: @expr) -> bool {
|
||||
alt ex.node {
|
||||
match ex.node {
|
||||
expr_path(_) => {
|
||||
alt cx.tcx.def_map.get(ex.id) {
|
||||
match cx.tcx.def_map.get(ex.id) {
|
||||
def_variant(edid, vdid) => {
|
||||
vec::len(ty::enum_variant_with_id(cx.tcx, edid, vdid).args) == 0u
|
||||
}
|
||||
|
|
@ -398,14 +398,14 @@ fn check_copy_ex(cx: ctx, ex: @expr, implicit_copy: bool) {
|
|||
fn check_imm_free_var(cx: ctx, def: def, sp: span) {
|
||||
let msg = ~"mutable variables cannot be implicitly captured; \
|
||||
use a capture clause";
|
||||
alt def {
|
||||
match def {
|
||||
def_local(_, is_mutbl) => {
|
||||
if is_mutbl {
|
||||
cx.tcx.sess.span_err(sp, msg);
|
||||
}
|
||||
}
|
||||
def_arg(_, mode) => {
|
||||
alt ty::resolved_mode(cx.tcx, mode) {
|
||||
match ty::resolved_mode(cx.tcx, mode) {
|
||||
by_ref | by_val | by_move | by_copy => { /* ok */ }
|
||||
by_mutbl_ref => {
|
||||
cx.tcx.sess.span_err(sp, msg);
|
||||
|
|
@ -449,7 +449,7 @@ fn check_send(cx: ctx, ty: ty::t, sp: span) -> bool {
|
|||
// note: also used from middle::typeck::regionck!
|
||||
fn check_owned(tcx: ty::ctxt, ty: ty::t, sp: span) -> bool {
|
||||
if !ty::kind_is_owned(ty::type_kind(tcx, ty)) {
|
||||
alt ty::get(ty).struct {
|
||||
match ty::get(ty).struct {
|
||||
ty::ty_param(*) => {
|
||||
tcx.sess.span_err(sp, ~"value may contain borrowed \
|
||||
pointers; use `owned` bound");
|
||||
|
|
@ -496,7 +496,7 @@ fn check_cast_for_escaping_regions(
|
|||
// Determine what type we are casting to; if it is not an trait, then no
|
||||
// worries.
|
||||
let target_ty = ty::expr_ty(cx.tcx, target);
|
||||
let target_substs = alt ty::get(target_ty).struct {
|
||||
let target_substs = match ty::get(target_ty).struct {
|
||||
ty::ty_trait(_, substs) => {substs}
|
||||
_ => { return; /* not a cast to a trait */ }
|
||||
};
|
||||
|
|
@ -504,7 +504,7 @@ fn check_cast_for_escaping_regions(
|
|||
// Check, based on the region associated with the trait, whether it can
|
||||
// possibly escape the enclosing fn item (note that all type parameters
|
||||
// must have been declared on the enclosing fn item):
|
||||
alt target_substs.self_r {
|
||||
match target_substs.self_r {
|
||||
some(ty::re_scope(*)) => { return; /* case (1) */ }
|
||||
none | some(ty::re_static) | some(ty::re_free(*)) => {}
|
||||
some(ty::re_bound(*)) | some(ty::re_var(*)) => {
|
||||
|
|
@ -519,7 +519,7 @@ fn check_cast_for_escaping_regions(
|
|||
let target_params = ty::param_tys_in_type(target_ty);
|
||||
let source_ty = ty::expr_ty(cx.tcx, source);
|
||||
do ty::walk_ty(source_ty) |ty| {
|
||||
alt ty::get(ty).struct {
|
||||
match ty::get(ty).struct {
|
||||
ty::ty_param(source_param) => {
|
||||
if target_params.contains(source_param) {
|
||||
/* case (2) */
|
||||
|
|
|
|||
|
|
@ -98,9 +98,9 @@ class LanguageItemCollector {
|
|||
fn match_and_collect_meta_item(item_def_id: def_id,
|
||||
meta_item: meta_item) {
|
||||
|
||||
alt meta_item.node {
|
||||
match meta_item.node {
|
||||
meta_name_value(key, literal) => {
|
||||
alt literal.node {
|
||||
match literal.node {
|
||||
lit_str(value) => {
|
||||
self.match_and_collect_item(item_def_id,
|
||||
*key,
|
||||
|
|
@ -122,13 +122,13 @@ class LanguageItemCollector {
|
|||
return; // Didn't match.
|
||||
}
|
||||
|
||||
alt self.item_refs.find(value) {
|
||||
match self.item_refs.find(value) {
|
||||
none => {
|
||||
// Didn't match.
|
||||
}
|
||||
some(item_ref) => {
|
||||
// Check for duplicates.
|
||||
alt copy *item_ref {
|
||||
match copy *item_ref {
|
||||
some(original_def_id)
|
||||
if original_def_id != item_def_id => {
|
||||
|
||||
|
|
@ -168,7 +168,7 @@ class LanguageItemCollector {
|
|||
do iter_crate_data(crate_store) |crate_number, _crate_metadata| {
|
||||
for each_path(crate_store, crate_number) |path_entry| {
|
||||
let def_id;
|
||||
alt path_entry.def_like {
|
||||
match path_entry.def_like {
|
||||
dl_def(def_ty(did)) => {
|
||||
def_id = did;
|
||||
}
|
||||
|
|
@ -189,7 +189,7 @@ class LanguageItemCollector {
|
|||
|
||||
fn check_completeness() {
|
||||
for self.item_refs.each |key, item_ref| {
|
||||
alt copy *item_ref {
|
||||
match copy *item_ref {
|
||||
none => {
|
||||
self.session.err(fmt!{"no item found for `%s`", key});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ enum lint {
|
|||
// This is pretty unfortunate. We really want some sort of "deriving Enum"
|
||||
// type of thing.
|
||||
fn int_to_lint(i: int) -> lint {
|
||||
alt check i {
|
||||
match check i {
|
||||
0 => ctypes,
|
||||
1 => unused_imports,
|
||||
2 => while_true,
|
||||
|
|
@ -70,7 +70,7 @@ fn int_to_lint(i: int) -> lint {
|
|||
}
|
||||
|
||||
fn level_to_str(lv: level) -> ~str {
|
||||
alt lv {
|
||||
match lv {
|
||||
allow => ~"allow",
|
||||
warn => ~"warn",
|
||||
deny => ~"deny",
|
||||
|
|
@ -166,7 +166,7 @@ fn mk_lint_settings() -> lint_settings {
|
|||
}
|
||||
|
||||
fn get_lint_level(modes: lint_modes, lint: lint) -> level {
|
||||
alt modes.find(lint as uint) {
|
||||
match modes.find(lint as uint) {
|
||||
some(c) => c,
|
||||
none => allow
|
||||
}
|
||||
|
|
@ -176,7 +176,7 @@ fn get_lint_settings_level(settings: lint_settings,
|
|||
lint_mode: lint,
|
||||
_expr_id: ast::node_id,
|
||||
item_id: ast::node_id) -> level {
|
||||
alt settings.settings_map.find(item_id) {
|
||||
match settings.settings_map.find(item_id) {
|
||||
some(modes) => get_lint_level(modes, lint_mode),
|
||||
none => get_lint_level(settings.default_settings, lint_mode)
|
||||
}
|
||||
|
|
@ -230,10 +230,10 @@ impl methods for ctxt {
|
|||
attr::attr_metas(attr::find_attrs_by_name(attrs,
|
||||
level_name));
|
||||
for metas.each |meta| {
|
||||
alt meta.node {
|
||||
match meta.node {
|
||||
ast::meta_list(_, metas) => {
|
||||
for metas.each |meta| {
|
||||
alt meta.node {
|
||||
match meta.node {
|
||||
ast::meta_word(lintname) => {
|
||||
vec::push(triples, (meta, level, lintname));
|
||||
}
|
||||
|
|
@ -255,7 +255,7 @@ impl methods for ctxt {
|
|||
|
||||
for triples.each |pair| {
|
||||
let (meta, level, lintname) = pair;
|
||||
alt self.dict.find(*lintname) {
|
||||
match self.dict.find(*lintname) {
|
||||
none => {
|
||||
self.span_lint(
|
||||
new_ctxt.get_level(unrecognized_lint),
|
||||
|
|
@ -354,9 +354,9 @@ fn item_stopping_visitor<E>(v: visit::vt<E>) -> visit::vt<E> {
|
|||
fn check_item_while_true(cx: ty::ctxt, it: @ast::item) {
|
||||
let visit = item_stopping_visitor(visit::mk_simple_visitor(@{
|
||||
visit_expr: fn@(e: @ast::expr) {
|
||||
alt e.node {
|
||||
match e.node {
|
||||
ast::expr_while(cond, _) => {
|
||||
alt cond.node {
|
||||
match cond.node {
|
||||
ast::expr_lit(@{node: ast::lit_bool(true),_}) => {
|
||||
cx.sess.span_lint(
|
||||
while_true, e.id, it.id,
|
||||
|
|
@ -380,9 +380,9 @@ fn check_item_ctypes(cx: ty::ctxt, it: @ast::item) {
|
|||
decl: ast::fn_decl) {
|
||||
let tys = vec::map(decl.inputs, |a| a.ty );
|
||||
for vec::each(vec::append_one(tys, decl.output)) |ty| {
|
||||
alt ty.node {
|
||||
match ty.node {
|
||||
ast::ty_path(_, id) => {
|
||||
alt cx.def_map.get(id) {
|
||||
match cx.def_map.get(id) {
|
||||
ast::def_prim_ty(ast::ty_int(ast::ty_i)) => {
|
||||
cx.sess.span_lint(
|
||||
ctypes, id, fn_id,
|
||||
|
|
@ -405,11 +405,11 @@ fn check_item_ctypes(cx: ty::ctxt, it: @ast::item) {
|
|||
}
|
||||
}
|
||||
|
||||
alt it.node {
|
||||
match it.node {
|
||||
ast::item_foreign_mod(nmod) if attr::foreign_abi(it.attrs) !=
|
||||
either::right(ast::foreign_abi_rust_intrinsic) => {
|
||||
for nmod.items.each |ni| {
|
||||
alt ni.node {
|
||||
match ni.node {
|
||||
ast::foreign_item_fn(decl, tps) => {
|
||||
check_foreign_fn(cx, it.id, decl);
|
||||
}
|
||||
|
|
@ -423,7 +423,7 @@ fn check_item_ctypes(cx: ty::ctxt, it: @ast::item) {
|
|||
fn check_item_path_statement(cx: ty::ctxt, it: @ast::item) {
|
||||
let visit = item_stopping_visitor(visit::mk_simple_visitor(@{
|
||||
visit_stmt: fn@(s: @ast::stmt) {
|
||||
alt s.node {
|
||||
match s.node {
|
||||
ast::stmt_semi(@{id: id,
|
||||
callee_id: _,
|
||||
node: ast::expr_path(@path),
|
||||
|
|
@ -458,7 +458,7 @@ fn check_item_non_camel_case_types(cx: ty::ctxt, it: @ast::item) {
|
|||
}
|
||||
}
|
||||
|
||||
alt it.node {
|
||||
match it.node {
|
||||
ast::item_ty(*) | ast::item_class(*) |
|
||||
ast::item_trait(*) | ast::item_impl(*) => {
|
||||
check_case(cx, it.ident, it.id, it.id, it.span)
|
||||
|
|
@ -480,13 +480,13 @@ fn check_fn(tcx: ty::ctxt, fk: visit::fn_kind, decl: ast::fn_decl,
|
|||
|
||||
// don't complain about blocks, since they tend to get their modes
|
||||
// specified from the outside
|
||||
alt fk {
|
||||
match fk {
|
||||
visit::fk_fn_block(*) => { return; }
|
||||
_ => {}
|
||||
}
|
||||
|
||||
let fn_ty = ty::node_id_to_type(tcx, id);
|
||||
alt check ty::get(fn_ty).struct {
|
||||
match check ty::get(fn_ty).struct {
|
||||
ty::ty_fn(fn_ty) => {
|
||||
let mut counter = 0;
|
||||
do vec::iter2(fn_ty.inputs, decl.inputs) |arg_ty, arg_ast| {
|
||||
|
|
@ -495,7 +495,7 @@ fn check_fn(tcx: ty::ctxt, fk: visit::fn_kind, decl: ast::fn_decl,
|
|||
counter,
|
||||
ty_to_str(tcx, arg_ty.ty),
|
||||
mode_to_str(arg_ast.mode)};
|
||||
alt arg_ast.mode {
|
||||
match arg_ast.mode {
|
||||
ast::expl(ast::by_copy) => {
|
||||
/* always allow by-copy */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -201,7 +201,7 @@ enum var_kind {
|
|||
}
|
||||
|
||||
fn relevant_def(def: def) -> option<relevant_def> {
|
||||
alt def {
|
||||
match def {
|
||||
def_self(_) => some(rdef_self),
|
||||
def_arg(nid, _) | def_local(nid, _) => some(rdef_var(nid)),
|
||||
_ => none
|
||||
|
|
@ -260,7 +260,7 @@ class ir_maps {
|
|||
vec::push(self.var_kinds, vk);
|
||||
self.num_vars += 1u;
|
||||
|
||||
alt vk {
|
||||
match vk {
|
||||
vk_local(node_id, _) | vk_arg(node_id, _, _) => {
|
||||
self.variable_map.insert(node_id, v);
|
||||
}
|
||||
|
|
@ -277,7 +277,7 @@ class ir_maps {
|
|||
}
|
||||
|
||||
fn variable(node_id: node_id, span: span) -> variable {
|
||||
alt self.variable_map.find(node_id) {
|
||||
match self.variable_map.find(node_id) {
|
||||
some(var) => var,
|
||||
none => {
|
||||
self.tcx.sess.span_bug(
|
||||
|
|
@ -287,7 +287,7 @@ class ir_maps {
|
|||
}
|
||||
|
||||
fn variable_name(var: variable) -> ident {
|
||||
alt self.var_kinds[*var] {
|
||||
match self.var_kinds[*var] {
|
||||
vk_local(_, name) | vk_arg(_, name, _) => name,
|
||||
vk_field(name) => @(~"self." + *name),
|
||||
vk_self => @~"self",
|
||||
|
|
@ -300,7 +300,7 @@ class ir_maps {
|
|||
}
|
||||
|
||||
fn captures(expr: @expr) -> @~[capture_info] {
|
||||
alt self.capture_map.find(expr.id) {
|
||||
match self.capture_map.find(expr.id) {
|
||||
some(caps) => caps,
|
||||
none => {
|
||||
self.tcx.sess.span_bug(expr.span, ~"no registered caps");
|
||||
|
|
@ -315,11 +315,11 @@ class ir_maps {
|
|||
fn add_last_use(expr_id: node_id, var: variable) {
|
||||
let vk = self.var_kinds[*var];
|
||||
debug!{"Node %d is a last use of variable %?", expr_id, vk};
|
||||
alt vk {
|
||||
match vk {
|
||||
vk_arg(id, name, by_move) |
|
||||
vk_arg(id, name, by_copy) |
|
||||
vk_local(id, name) => {
|
||||
let v = alt self.last_use_map.find(expr_id) {
|
||||
let v = match self.last_use_map.find(expr_id) {
|
||||
some(v) => v,
|
||||
none => {
|
||||
let v = @dvec();
|
||||
|
|
@ -359,7 +359,7 @@ fn visit_fn(fk: visit::fn_kind, decl: fn_decl, body: blk,
|
|||
// and so forth:
|
||||
visit::visit_fn(fk, decl, body, sp, id, fn_maps, v);
|
||||
|
||||
alt fk {
|
||||
match fk {
|
||||
visit::fk_ctor(_, _, _, _, class_did) => {
|
||||
add_class_fields(fn_maps, class_did);
|
||||
}
|
||||
|
|
@ -414,7 +414,7 @@ fn visit_local(local: @local, &&self: @ir_maps, vt: vt<@ir_maps>) {
|
|||
}
|
||||
|
||||
fn visit_expr(expr: @expr, &&self: @ir_maps, vt: vt<@ir_maps>) {
|
||||
alt expr.node {
|
||||
match expr.node {
|
||||
// live nodes required for uses or definitions of variables:
|
||||
expr_path(_) => {
|
||||
let def = self.tcx.def_map.get(expr.id);
|
||||
|
|
@ -435,10 +435,10 @@ fn visit_expr(expr: @expr, &&self: @ir_maps, vt: vt<@ir_maps>) {
|
|||
proto, cap_clause);
|
||||
let mut call_caps = ~[];
|
||||
for cvs.each |cv| {
|
||||
alt relevant_def(cv.def) {
|
||||
match relevant_def(cv.def) {
|
||||
some(rv) => {
|
||||
let cv_ln = (*self).add_live_node(lnk_freevar(cv.span));
|
||||
let is_move = alt cv.mode {
|
||||
let is_move = match cv.mode {
|
||||
cap_move | cap_drop => true, // var must be dead afterwards
|
||||
cap_copy | cap_ref => false // var can still be used
|
||||
};
|
||||
|
|
@ -533,7 +533,7 @@ class liveness {
|
|||
// _______________________________________________________________________
|
||||
|
||||
fn live_node(node_id: node_id, span: span) -> live_node {
|
||||
alt self.ir.live_node_map.find(node_id) {
|
||||
match self.ir.live_node_map.find(node_id) {
|
||||
some(ln) => ln,
|
||||
none => {
|
||||
// This must be a mismatch between the ir_map construction
|
||||
|
|
@ -548,14 +548,14 @@ class liveness {
|
|||
}
|
||||
|
||||
fn variable_from_rdef(rv: relevant_def, span: span) -> variable {
|
||||
alt rv {
|
||||
match rv {
|
||||
rdef_self => self.s.self_var,
|
||||
rdef_var(nid) => self.variable(nid, span)
|
||||
}
|
||||
}
|
||||
|
||||
fn variable_from_path(expr: @expr) -> option<variable> {
|
||||
alt expr.node {
|
||||
match expr.node {
|
||||
expr_path(_) => {
|
||||
let def = self.tcx.def_map.get(expr.id);
|
||||
relevant_def(def).map(
|
||||
|
|
@ -572,7 +572,7 @@ class liveness {
|
|||
|
||||
fn variable_from_def_map(node_id: node_id,
|
||||
span: span) -> option<variable> {
|
||||
alt self.tcx.def_map.find(node_id) {
|
||||
match self.tcx.def_map.find(node_id) {
|
||||
some(def) => {
|
||||
relevant_def(def).map(
|
||||
|rdef| self.variable_from_rdef(rdef, span)
|
||||
|
|
@ -794,7 +794,7 @@ class liveness {
|
|||
fn propagate_through_fn_block(decl: fn_decl, blk: blk) -> live_node {
|
||||
// inputs passed by & mode should be considered live on exit:
|
||||
for decl.inputs.each |arg| {
|
||||
alt ty::resolved_mode(self.tcx, arg.mode) {
|
||||
match ty::resolved_mode(self.tcx, arg.mode) {
|
||||
by_mutbl_ref | by_ref | by_val => {
|
||||
// These are "non-owned" modes, so register a read at
|
||||
// the end. This will prevent us from moving out of
|
||||
|
|
@ -836,7 +836,7 @@ class liveness {
|
|||
}
|
||||
|
||||
fn propagate_through_stmt(stmt: @stmt, succ: live_node) -> live_node {
|
||||
alt stmt.node {
|
||||
match stmt.node {
|
||||
stmt_decl(decl, _) => {
|
||||
return self.propagate_through_decl(decl, succ);
|
||||
}
|
||||
|
|
@ -848,7 +848,7 @@ class liveness {
|
|||
}
|
||||
|
||||
fn propagate_through_decl(decl: @decl, succ: live_node) -> live_node {
|
||||
alt decl.node {
|
||||
match decl.node {
|
||||
decl_local(locals) => {
|
||||
do locals.foldr(succ) |local, succ| {
|
||||
self.propagate_through_local(local, succ)
|
||||
|
|
@ -900,7 +900,7 @@ class liveness {
|
|||
}
|
||||
|
||||
fn propagate_through_expr(expr: @expr, succ: live_node) -> live_node {
|
||||
alt expr.node {
|
||||
match expr.node {
|
||||
// Interesting cases with control flow or which gen/kill
|
||||
|
||||
expr_path(_) => {
|
||||
|
|
@ -912,7 +912,7 @@ class liveness {
|
|||
// then we treat it as a read of that variable.
|
||||
// Otherwise, we ignore it and just propagate down to
|
||||
// process `e`.
|
||||
alt self.as_self_field(e, nm) {
|
||||
match self.as_self_field(e, nm) {
|
||||
some((ln, var)) => {
|
||||
self.init_from_succ(ln, succ);
|
||||
self.acc(ln, var, ACC_READ | ACC_USE);
|
||||
|
|
@ -1185,9 +1185,9 @@ class liveness {
|
|||
// these errors are detected in the later pass borrowck. We
|
||||
// just ignore such cases and treat them as reads.
|
||||
|
||||
alt expr.node {
|
||||
match expr.node {
|
||||
expr_path(_) => succ,
|
||||
expr_field(e, nm, _) => alt self.as_self_field(e, nm) {
|
||||
expr_field(e, nm, _) => match self.as_self_field(e, nm) {
|
||||
some(_) => succ,
|
||||
none => self.propagate_through_expr(e, succ)
|
||||
}
|
||||
|
|
@ -1199,9 +1199,9 @@ class liveness {
|
|||
fn write_lvalue(expr: @expr,
|
||||
succ: live_node,
|
||||
acc: uint) -> live_node {
|
||||
alt expr.node {
|
||||
match expr.node {
|
||||
expr_path(_) => self.access_path(expr, succ, acc),
|
||||
expr_field(e, nm, _) => alt self.as_self_field(e, nm) {
|
||||
expr_field(e, nm, _) => match self.as_self_field(e, nm) {
|
||||
some((ln, var)) => {
|
||||
self.init_from_succ(ln, succ);
|
||||
self.acc(ln, var, acc);
|
||||
|
|
@ -1220,7 +1220,7 @@ class liveness {
|
|||
|
||||
fn access_path(expr: @expr, succ: live_node, acc: uint) -> live_node {
|
||||
let def = self.tcx.def_map.get(expr.id);
|
||||
alt relevant_def(def) {
|
||||
match relevant_def(def) {
|
||||
some(rdef_self) => {
|
||||
// Accessing `self` is like accessing every field of
|
||||
// the current object. This allows something like
|
||||
|
|
@ -1259,10 +1259,10 @@ class liveness {
|
|||
// If we checking a constructor, then we treat self.f as a
|
||||
// variable. we use the live_node id that will be assigned to
|
||||
// the reference to self but the variable id for `f`.
|
||||
alt expr.node {
|
||||
match expr.node {
|
||||
expr_path(_) => {
|
||||
let def = self.tcx.def_map.get(expr.id);
|
||||
alt def {
|
||||
match def {
|
||||
def_self(_) => {
|
||||
// Note: the field_map is empty unless we are in a ctor
|
||||
return self.ir.field_map.find(fld).map(|var| {
|
||||
|
|
@ -1345,12 +1345,12 @@ class liveness {
|
|||
// Checking for error conditions
|
||||
|
||||
fn check_local(local: @local, &&self: @liveness, vt: vt<@liveness>) {
|
||||
alt local.node.init {
|
||||
match local.node.init {
|
||||
some({op: op, expr: expr}) => {
|
||||
|
||||
// Initializer:
|
||||
|
||||
alt op {
|
||||
match op {
|
||||
init_move => self.check_move_from_expr(expr, vt),
|
||||
init_assign => ()
|
||||
}
|
||||
|
|
@ -1367,7 +1367,7 @@ fn check_local(local: @local, &&self: @liveness, vt: vt<@liveness>) {
|
|||
debug!{"check_local() with no initializer"};
|
||||
do (*self).pat_bindings(local.node.pat) |ln, var, sp| {
|
||||
if !self.warn_about_unused(sp, ln, var) {
|
||||
alt (*self).live_on_exit(ln, var) {
|
||||
match (*self).live_on_exit(ln, var) {
|
||||
none => { /* not live: good */ }
|
||||
some(lnk) => {
|
||||
self.report_illegal_read(
|
||||
|
|
@ -1384,7 +1384,7 @@ fn check_local(local: @local, &&self: @liveness, vt: vt<@liveness>) {
|
|||
}
|
||||
|
||||
fn check_expr(expr: @expr, &&self: @liveness, vt: vt<@liveness>) {
|
||||
alt expr.node {
|
||||
match expr.node {
|
||||
expr_path(_) => {
|
||||
for (*self).variable_from_def_map(expr.id, expr.span).each |var| {
|
||||
let ln = (*self).live_node(expr.id, expr.span);
|
||||
|
|
@ -1437,7 +1437,7 @@ fn check_expr(expr: @expr, &&self: @liveness, vt: vt<@liveness>) {
|
|||
let targs = ty::ty_fn_args(ty::expr_ty(self.tcx, f));
|
||||
vt.visit_expr(f, self, vt);
|
||||
do vec::iter2(args, targs) |arg_expr, arg_ty| {
|
||||
alt ty::resolved_mode(self.tcx, arg_ty.mode) {
|
||||
match ty::resolved_mode(self.tcx, arg_ty.mode) {
|
||||
by_val | by_copy | by_ref | by_mutbl_ref => {
|
||||
vt.visit_expr(arg_expr, self, vt);
|
||||
}
|
||||
|
|
@ -1480,7 +1480,7 @@ enum read_kind {
|
|||
impl check_methods for @liveness {
|
||||
fn check_fields(sp: span, entry_ln: live_node) {
|
||||
for self.ir.field_map.each |nm, var| {
|
||||
alt (*self).live_on_entry(entry_ln, var) {
|
||||
match (*self).live_on_entry(entry_ln, var) {
|
||||
none => { /* ok */ }
|
||||
some(lnk_exit) => {
|
||||
self.tcx.sess.span_err(
|
||||
|
|
@ -1508,7 +1508,7 @@ impl check_methods for @liveness {
|
|||
self.tcx.sess.span_err(
|
||||
sp, ~"some control paths may return");
|
||||
} else {
|
||||
alt fk {
|
||||
match fk {
|
||||
visit::fk_ctor(*) => {
|
||||
// ctors are written as though they are unit.
|
||||
}
|
||||
|
|
@ -1525,14 +1525,14 @@ impl check_methods for @liveness {
|
|||
debug!{"check_move_from_var(%s, %s)",
|
||||
ln.to_str(), var.to_str()};
|
||||
|
||||
alt (*self).live_on_exit(ln, var) {
|
||||
match (*self).live_on_exit(ln, var) {
|
||||
none => {}
|
||||
some(lnk) => self.report_illegal_move(span, lnk, var)
|
||||
}
|
||||
}
|
||||
|
||||
fn consider_last_use(expr: @expr, ln: live_node, var: variable) {
|
||||
alt (*self).live_on_exit(ln, var) {
|
||||
match (*self).live_on_exit(ln, var) {
|
||||
some(_) => {}
|
||||
none => (*self.ir).add_last_use(expr.id, var)
|
||||
}
|
||||
|
|
@ -1547,9 +1547,9 @@ impl check_methods for @liveness {
|
|||
return vt.visit_expr(expr, self, vt);
|
||||
}
|
||||
|
||||
alt expr.node {
|
||||
match expr.node {
|
||||
expr_path(_) => {
|
||||
alt (*self).variable_from_path(expr) {
|
||||
match (*self).variable_from_path(expr) {
|
||||
some(var) => {
|
||||
let ln = (*self).live_node(expr.id, expr.span);
|
||||
self.check_move_from_var(expr.span, ln, var);
|
||||
|
|
@ -1582,9 +1582,9 @@ impl check_methods for @liveness {
|
|||
}
|
||||
|
||||
fn check_lvalue(expr: @expr, vt: vt<@liveness>) {
|
||||
alt expr.node {
|
||||
match expr.node {
|
||||
expr_path(_) => {
|
||||
alt self.tcx.def_map.get(expr.id) {
|
||||
match self.tcx.def_map.get(expr.id) {
|
||||
def_local(nid, false) => {
|
||||
// Assignment to an immutable variable or argument:
|
||||
// only legal if there is no later assignment.
|
||||
|
|
@ -1594,7 +1594,7 @@ impl check_methods for @liveness {
|
|||
self.warn_about_dead_assign(expr.span, ln, var);
|
||||
}
|
||||
def => {
|
||||
alt relevant_def(def) {
|
||||
match relevant_def(def) {
|
||||
some(rdef_var(nid)) => {
|
||||
let ln = (*self).live_node(expr.id, expr.span);
|
||||
let var = (*self).variable(nid, expr.span);
|
||||
|
|
@ -1623,7 +1623,7 @@ impl check_methods for @liveness {
|
|||
|
||||
fn check_for_reassignment(ln: live_node, var: variable,
|
||||
orig_span: span) {
|
||||
alt (*self).assigned_on_exit(ln, var) {
|
||||
match (*self).assigned_on_exit(ln, var) {
|
||||
some(lnk_expr(span)) => {
|
||||
self.tcx.sess.span_err(
|
||||
span,
|
||||
|
|
@ -1651,7 +1651,7 @@ impl check_methods for @liveness {
|
|||
// we give a slightly different error message in those cases.
|
||||
if lnk == lnk_exit {
|
||||
let vk = self.ir.var_kinds[*var];
|
||||
alt vk {
|
||||
match vk {
|
||||
vk_arg(_, name, _) => {
|
||||
self.tcx.sess.span_err(
|
||||
move_span,
|
||||
|
|
@ -1691,7 +1691,7 @@ impl check_methods for @liveness {
|
|||
lnk: live_node_kind,
|
||||
var: variable,
|
||||
rk: read_kind) {
|
||||
let msg = alt rk {
|
||||
let msg = match rk {
|
||||
possibly_uninitialized_variable => {
|
||||
~"possibly uninitialized variable"
|
||||
}
|
||||
|
|
@ -1699,7 +1699,7 @@ impl check_methods for @liveness {
|
|||
moved_variable => ~"moved variable"
|
||||
};
|
||||
let name = (*self.ir).variable_name(var);
|
||||
alt lnk {
|
||||
match lnk {
|
||||
lnk_freevar(span) => {
|
||||
self.tcx.sess.span_err(
|
||||
span,
|
||||
|
|
@ -1727,13 +1727,13 @@ impl check_methods for @liveness {
|
|||
fn warn_about_unused_args(sp: span, decl: fn_decl, entry_ln: live_node) {
|
||||
for decl.inputs.each |arg| {
|
||||
let var = (*self).variable(arg.id, arg.ty.span);
|
||||
alt ty::resolved_mode(self.tcx, arg.mode) {
|
||||
match ty::resolved_mode(self.tcx, arg.mode) {
|
||||
by_mutbl_ref => {
|
||||
// for mutable reference arguments, something like
|
||||
// x = 1;
|
||||
// is not worth warning about, as it has visible
|
||||
// side effects outside the fn.
|
||||
alt (*self).assigned_on_entry(entry_ln, var) {
|
||||
match (*self).assigned_on_entry(entry_ln, var) {
|
||||
some(_) => { /*ok*/ }
|
||||
none => {
|
||||
// but if it is not written, it ought to be used
|
||||
|
|
|
|||
|
|
@ -22,9 +22,9 @@ fn pat_id_map(dm: resolve3::DefMap, pat: @pat) -> pat_id_map {
|
|||
}
|
||||
|
||||
fn pat_is_variant(dm: resolve3::DefMap, pat: @pat) -> bool {
|
||||
alt pat.node {
|
||||
match pat.node {
|
||||
pat_enum(_, _) => true,
|
||||
pat_ident(_, _, none) => alt dm.find(pat.id) {
|
||||
pat_ident(_, _, none) => match dm.find(pat.id) {
|
||||
some(def_variant(_, _)) => true,
|
||||
_ => false
|
||||
}
|
||||
|
|
@ -35,7 +35,7 @@ fn pat_is_variant(dm: resolve3::DefMap, pat: @pat) -> bool {
|
|||
fn pat_bindings(dm: resolve3::DefMap, pat: @pat,
|
||||
it: fn(node_id, span, @path)) {
|
||||
do walk_pat(pat) |p| {
|
||||
alt p.node {
|
||||
match p.node {
|
||||
pat_ident(_, pth, _) if !pat_is_variant(dm, p) => {
|
||||
it(p.id, p.span, pth);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ fn scope_contains(region_map: region_map, superscope: ast::node_id,
|
|||
subscope: ast::node_id) -> bool {
|
||||
let mut subscope = subscope;
|
||||
while superscope != subscope {
|
||||
alt region_map.find(subscope) {
|
||||
match region_map.find(subscope) {
|
||||
none => return false,
|
||||
some(scope) => subscope = scope
|
||||
}
|
||||
|
|
@ -103,7 +103,7 @@ fn subregion(region_map: region_map,
|
|||
super_region: ty::region,
|
||||
sub_region: ty::region) -> bool {
|
||||
super_region == sub_region ||
|
||||
alt (super_region, sub_region) {
|
||||
match (super_region, sub_region) {
|
||||
(ty::re_static, _) => {true}
|
||||
|
||||
(ty::re_scope(super_scope), ty::re_scope(sub_scope)) |
|
||||
|
|
@ -128,7 +128,7 @@ fn nearest_common_ancestor(region_map: region_map, scope_a: ast::node_id,
|
|||
let mut result = ~[scope];
|
||||
let mut scope = scope;
|
||||
loop {
|
||||
alt region_map.find(scope) {
|
||||
match region_map.find(scope) {
|
||||
none => return result,
|
||||
some(superscope) => {
|
||||
vec::push(result, superscope);
|
||||
|
|
@ -172,7 +172,7 @@ fn nearest_common_ancestor(region_map: region_map, scope_a: ast::node_id,
|
|||
|
||||
/// Extracts that current parent from cx, failing if there is none.
|
||||
fn parent_id(cx: ctxt, span: span) -> ast::node_id {
|
||||
alt cx.parent {
|
||||
match cx.parent {
|
||||
none => {
|
||||
cx.sess.span_bug(span, ~"crate should not be parent here");
|
||||
}
|
||||
|
|
@ -184,7 +184,7 @@ fn parent_id(cx: ctxt, span: span) -> ast::node_id {
|
|||
|
||||
/// Records the current parent (if any) as the parent of `child_id`.
|
||||
fn record_parent(cx: ctxt, child_id: ast::node_id) {
|
||||
alt cx.parent {
|
||||
match cx.parent {
|
||||
none => { /* no-op */ }
|
||||
some(parent_id) => {
|
||||
debug!{"parent of node %d is node %d", child_id, parent_id};
|
||||
|
|
@ -207,10 +207,10 @@ fn resolve_arm(arm: ast::arm, cx: ctxt, visitor: visit::vt<ctxt>) {
|
|||
}
|
||||
|
||||
fn resolve_pat(pat: @ast::pat, cx: ctxt, visitor: visit::vt<ctxt>) {
|
||||
alt pat.node {
|
||||
match pat.node {
|
||||
ast::pat_ident(_, path, _) => {
|
||||
let defn_opt = cx.def_map.find(pat.id);
|
||||
alt defn_opt {
|
||||
match defn_opt {
|
||||
some(ast::def_variant(_,_)) => {
|
||||
/* Nothing to do; this names a variant. */
|
||||
}
|
||||
|
|
@ -230,7 +230,7 @@ fn resolve_expr(expr: @ast::expr, cx: ctxt, visitor: visit::vt<ctxt>) {
|
|||
record_parent(cx, expr.id);
|
||||
|
||||
let mut new_cx = cx;
|
||||
alt expr.node {
|
||||
match expr.node {
|
||||
ast::expr_call(*) => {
|
||||
debug!{"node %d: %s", expr.id, pprust::expr_to_str(expr)};
|
||||
new_cx.parent = some(expr.id);
|
||||
|
|
@ -276,7 +276,7 @@ fn resolve_fn(fk: visit::fn_kind, decl: ast::fn_decl, body: ast::blk,
|
|||
sp: span, id: ast::node_id, cx: ctxt,
|
||||
visitor: visit::vt<ctxt>) {
|
||||
|
||||
let fn_cx = alt fk {
|
||||
let fn_cx = match fk {
|
||||
visit::fk_item_fn(*) | visit::fk_method(*) |
|
||||
visit::fk_ctor(*) | visit::fk_dtor(*) => {
|
||||
// Top-level functions are a root scope.
|
||||
|
|
@ -380,7 +380,7 @@ impl methods for determine_rp_ctxt {
|
|||
from, to,
|
||||
ast_map::node_id_to_str(self.ast_map, from),
|
||||
ast_map::node_id_to_str(self.ast_map, to)};
|
||||
let vec = alt self.dep_map.find(from) {
|
||||
let vec = match self.dep_map.find(from) {
|
||||
some(vec) => {vec}
|
||||
none => {
|
||||
let vec = @dvec();
|
||||
|
|
@ -424,7 +424,7 @@ impl methods for determine_rp_ctxt {
|
|||
// (anon_implies_rp) to true when we enter an item and setting
|
||||
// that flag to false when we enter a method.
|
||||
fn region_is_relevant(r: @ast::region) -> bool {
|
||||
alt r.node {
|
||||
match r.node {
|
||||
ast::re_anon => self.anon_implies_rp,
|
||||
ast::re_named(@~"self") => true,
|
||||
ast::re_named(_) => false
|
||||
|
|
@ -485,7 +485,7 @@ fn determine_rp_in_ty(ty: @ast::ty,
|
|||
// if this type directly references a region, either via a
|
||||
// region pointer like &r.ty or a region-parameterized path
|
||||
// like path/r, add to the worklist/set
|
||||
alt ty.node {
|
||||
match ty.node {
|
||||
ast::ty_rptr(r, _) |
|
||||
ast::ty_path(@{rp: some(r), _}, _) => {
|
||||
debug!{"referenced type with regions %s", pprust::ty_to_str(ty)};
|
||||
|
|
@ -501,9 +501,9 @@ fn determine_rp_in_ty(ty: @ast::ty,
|
|||
// to the dep_map. If the type is not defined in this crate,
|
||||
// then check whether it is region-parameterized and consider
|
||||
// that as a direct dependency.
|
||||
alt ty.node {
|
||||
match ty.node {
|
||||
ast::ty_path(_, id) => {
|
||||
alt cx.def_map.get(id) {
|
||||
match cx.def_map.get(id) {
|
||||
ast::def_ty(did) | ast::def_class(did, _) => {
|
||||
if did.crate == ast::local_crate {
|
||||
cx.add_dep(did.node, cx.item_id);
|
||||
|
|
@ -522,7 +522,7 @@ fn determine_rp_in_ty(ty: @ast::ty,
|
|||
_ => {}
|
||||
}
|
||||
|
||||
alt ty.node {
|
||||
match ty.node {
|
||||
ast::ty_fn(*) => {
|
||||
do cx.with(cx.item_id, false) {
|
||||
visit::visit_ty(ty, cx, visitor);
|
||||
|
|
@ -561,7 +561,7 @@ fn determine_rp_in_crate(sess: session,
|
|||
while cx.worklist.len() != 0 {
|
||||
let id = cx.worklist.pop();
|
||||
debug!{"popped %d from worklist", id};
|
||||
alt cx.dep_map.find(id) {
|
||||
match cx.dep_map.find(id) {
|
||||
none => {}
|
||||
some(vec) => {
|
||||
for vec.each |to_id| {
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -25,7 +25,7 @@ enum opt {
|
|||
range(@ast::expr, @ast::expr)
|
||||
}
|
||||
fn opt_eq(tcx: ty::ctxt, a: opt, b: opt) -> bool {
|
||||
alt (a, b) {
|
||||
match (a, b) {
|
||||
(lit(a), lit(b)) => const_eval::compare_lit_exprs(tcx, a, b) == 0,
|
||||
(range(a1, a2), range(b1, b2)) => {
|
||||
const_eval::compare_lit_exprs(tcx, a1, b1) == 0 &&
|
||||
|
|
@ -44,9 +44,9 @@ fn trans_opt(bcx: block, o: opt) -> opt_result {
|
|||
let _icx = bcx.insn_ctxt(~"alt::trans_opt");
|
||||
let ccx = bcx.ccx();
|
||||
let mut bcx = bcx;
|
||||
alt o {
|
||||
match o {
|
||||
lit(l) => {
|
||||
alt l.node {
|
||||
match l.node {
|
||||
ast::expr_vstore(@{node: ast::expr_lit(
|
||||
@{node: ast::lit_str(s), _}), _},
|
||||
ast::vstore_uniq) => {
|
||||
|
|
@ -112,7 +112,7 @@ type match_ = ~[match_branch];
|
|||
|
||||
fn has_nested_bindings(m: match_, col: uint) -> bool {
|
||||
for vec::each(m) |br| {
|
||||
alt br.pats[col].node {
|
||||
match br.pats[col].node {
|
||||
ast::pat_ident(_, _, some(_)) => return true,
|
||||
_ => ()
|
||||
}
|
||||
|
|
@ -125,7 +125,7 @@ fn expand_nested_bindings(bcx: block, m: match_, col: uint, val: ValueRef)
|
|||
|
||||
let mut result = ~[];
|
||||
for vec::each(m) |br| {
|
||||
alt br.pats[col].node {
|
||||
match br.pats[col].node {
|
||||
ast::pat_ident(mode, name, some(inner)) => {
|
||||
let pats = vec::append(
|
||||
vec::slice(br.pats, 0u, col),
|
||||
|
|
@ -155,13 +155,13 @@ fn enter_match(bcx: block, dm: DefMap, m: match_, col: uint, val: ValueRef,
|
|||
e: enter_pat) -> match_ {
|
||||
let mut result = ~[];
|
||||
for vec::each(m) |br| {
|
||||
alt e(br.pats[col]) {
|
||||
match e(br.pats[col]) {
|
||||
some(sub) => {
|
||||
let pats = vec::append(
|
||||
vec::append(sub, vec::view(br.pats, 0u, col)),
|
||||
vec::view(br.pats, col + 1u, br.pats.len()));
|
||||
let self = br.pats[col];
|
||||
let bound = alt self.node {
|
||||
let bound = match self.node {
|
||||
ast::pat_ident(mode, name, none)
|
||||
if !pat_is_variant(dm, self) => {
|
||||
vec::append(br.bound,
|
||||
|
|
@ -186,7 +186,7 @@ fn enter_default(bcx: block, dm: DefMap, m: match_, col: uint, val: ValueRef)
|
|||
-> match_ {
|
||||
|
||||
do enter_match(bcx, dm, m, col, val) |p| {
|
||||
alt p.node {
|
||||
match p.node {
|
||||
ast::pat_wild | ast::pat_rec(_, _) | ast::pat_tup(_) => some(~[]),
|
||||
ast::pat_ident(_, _, none) if !pat_is_variant(dm, p) => some(~[]),
|
||||
_ => none
|
||||
|
|
@ -199,7 +199,7 @@ fn enter_opt(bcx: block, m: match_, opt: opt, col: uint,
|
|||
let tcx = bcx.tcx();
|
||||
let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp()};
|
||||
do enter_match(bcx, tcx.def_map, m, col, val) |p| {
|
||||
alt p.node {
|
||||
match p.node {
|
||||
ast::pat_enum(_, subpats) => {
|
||||
if opt_eq(tcx, variant_opt(tcx, p.id), opt) {
|
||||
some(option::get_default(subpats,
|
||||
|
|
@ -225,7 +225,7 @@ fn enter_rec(bcx: block, dm: DefMap, m: match_, col: uint,
|
|||
fields: ~[ast::ident], val: ValueRef) -> match_ {
|
||||
let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp()};
|
||||
do enter_match(bcx, dm, m, col, val) |p| {
|
||||
alt p.node {
|
||||
match p.node {
|
||||
ast::pat_rec(fpats, _) => {
|
||||
let mut pats = ~[];
|
||||
for vec::each(fields) |fname| {
|
||||
|
|
@ -246,7 +246,7 @@ fn enter_tup(bcx: block, dm: DefMap, m: match_, col: uint, val: ValueRef,
|
|||
n_elts: uint) -> match_ {
|
||||
let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp()};
|
||||
do enter_match(bcx, dm, m, col, val) |p| {
|
||||
alt p.node {
|
||||
match p.node {
|
||||
ast::pat_tup(elts) => some(elts),
|
||||
_ => some(vec::from_elem(n_elts, dummy))
|
||||
}
|
||||
|
|
@ -257,7 +257,7 @@ fn enter_box(bcx: block, dm: DefMap, m: match_, col: uint, val: ValueRef)
|
|||
-> match_ {
|
||||
let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp()};
|
||||
do enter_match(bcx, dm, m, col, val) |p| {
|
||||
alt p.node {
|
||||
match p.node {
|
||||
ast::pat_box(sub) => some(~[sub]),
|
||||
_ => some(~[dummy])
|
||||
}
|
||||
|
|
@ -268,7 +268,7 @@ fn enter_uniq(bcx: block, dm: DefMap, m: match_, col: uint, val: ValueRef)
|
|||
-> match_ {
|
||||
let dummy = @{id: 0, node: ast::pat_wild, span: dummy_sp()};
|
||||
do enter_match(bcx, dm, m, col, val) |p| {
|
||||
alt p.node {
|
||||
match p.node {
|
||||
ast::pat_uniq(sub) => some(~[sub]),
|
||||
_ => some(~[dummy])
|
||||
}
|
||||
|
|
@ -287,7 +287,7 @@ fn get_options(ccx: @crate_ctxt, m: match_, col: uint) -> ~[opt] {
|
|||
if pat_is_variant(ccx.tcx.def_map, cur) {
|
||||
add_to_set(ccx.tcx, found, variant_opt(ccx.tcx, br.pats[col].id));
|
||||
} else {
|
||||
alt cur.node {
|
||||
match cur.node {
|
||||
ast::pat_lit(l) => add_to_set(ccx.tcx, found, lit(l)),
|
||||
ast::pat_range(l1, l2) => {
|
||||
add_to_set(ccx.tcx, found, range(l1, l2));
|
||||
|
|
@ -304,7 +304,9 @@ fn extract_variant_args(bcx: block, pat_id: ast::node_id,
|
|||
{vals: ~[ValueRef], bcx: block} {
|
||||
let _icx = bcx.insn_ctxt(~"alt::extract_variant_args");
|
||||
let ccx = bcx.fcx.ccx;
|
||||
let enum_ty_substs = alt check ty::get(node_id_type(bcx, pat_id)).struct {
|
||||
let enum_ty_substs = match check ty::get(node_id_type(bcx, pat_id))
|
||||
.struct {
|
||||
|
||||
ty::ty_enum(id, substs) => { assert id == vdefs.enm; substs.tps }
|
||||
};
|
||||
let mut blobptr = val;
|
||||
|
|
@ -328,7 +330,7 @@ fn extract_variant_args(bcx: block, pat_id: ast::node_id,
|
|||
fn collect_record_fields(m: match_, col: uint) -> ~[ast::ident] {
|
||||
let mut fields: ~[ast::ident] = ~[];
|
||||
for vec::each(m) |br| {
|
||||
alt br.pats[col].node {
|
||||
match br.pats[col].node {
|
||||
ast::pat_rec(fs, _) => {
|
||||
for vec::each(fs) |f| {
|
||||
if !vec::any(fields, |x| str::eq(f.ident, x)) {
|
||||
|
|
@ -346,7 +348,7 @@ fn root_pats_as_necessary(bcx: block, m: match_, col: uint, val: ValueRef) {
|
|||
for vec::each(m) |br| {
|
||||
let pat_id = br.pats[col].id;
|
||||
|
||||
alt bcx.ccx().maps.root_map.find({id:pat_id, derefs:0u}) {
|
||||
match bcx.ccx().maps.root_map.find({id:pat_id, derefs:0u}) {
|
||||
none => (),
|
||||
some(scope_id) => {
|
||||
// Note: the scope_id will always be the id of the alt. See the
|
||||
|
|
@ -364,7 +366,7 @@ fn root_pats_as_necessary(bcx: block, m: match_, col: uint, val: ValueRef) {
|
|||
|
||||
fn any_box_pat(m: match_, col: uint) -> bool {
|
||||
for vec::each(m) |br| {
|
||||
alt br.pats[col].node {
|
||||
match br.pats[col].node {
|
||||
ast::pat_box(_) => return true,
|
||||
_ => ()
|
||||
}
|
||||
|
|
@ -374,7 +376,7 @@ fn any_box_pat(m: match_, col: uint) -> bool {
|
|||
|
||||
fn any_uniq_pat(m: match_, col: uint) -> bool {
|
||||
for vec::each(m) |br| {
|
||||
alt br.pats[col].node {
|
||||
match br.pats[col].node {
|
||||
ast::pat_uniq(_) => return true,
|
||||
_ => ()
|
||||
}
|
||||
|
|
@ -384,7 +386,7 @@ fn any_uniq_pat(m: match_, col: uint) -> bool {
|
|||
|
||||
fn any_tup_pat(m: match_, col: uint) -> bool {
|
||||
for vec::each(m) |br| {
|
||||
alt br.pats[col].node {
|
||||
match br.pats[col].node {
|
||||
ast::pat_tup(_) => return true,
|
||||
_ => ()
|
||||
}
|
||||
|
|
@ -397,7 +399,7 @@ type mk_fail = fn@() -> BasicBlockRef;
|
|||
|
||||
fn pick_col(m: match_) -> uint {
|
||||
fn score(p: @ast::pat) -> uint {
|
||||
alt p.node {
|
||||
match p.node {
|
||||
ast::pat_lit(_) | ast::pat_enum(_, _) | ast::pat_range(_, _) => 1u,
|
||||
ast::pat_ident(_, _, some(p)) => score(p),
|
||||
_ => 0u
|
||||
|
|
@ -435,7 +437,7 @@ fn compile_submatch(bcx: block, m: match_, vals: ~[ValueRef],
|
|||
if m.len() == 0u { Br(bcx, option::get(chk)()); return; }
|
||||
if m[0].pats.len() == 0u {
|
||||
let data = m[0].data;
|
||||
alt data.guard {
|
||||
match data.guard {
|
||||
some(e) => {
|
||||
// Temporarily set bindings. They'll be rewritten to PHI nodes
|
||||
// for the actual arm block.
|
||||
|
|
@ -512,7 +514,7 @@ fn compile_submatch(bcx: block, m: match_, vals: ~[ValueRef],
|
|||
|
||||
if any_tup_pat(m, col) {
|
||||
let tup_ty = node_id_type(bcx, pat_id);
|
||||
let n_tup_elts = alt ty::get(tup_ty).struct {
|
||||
let n_tup_elts = match ty::get(tup_ty).struct {
|
||||
ty::ty_tup(elts) => elts.len(),
|
||||
_ => ccx.sess.bug(~"non-tuple type in tuple pattern")
|
||||
};
|
||||
|
|
@ -553,7 +555,7 @@ fn compile_submatch(bcx: block, m: match_, vals: ~[ValueRef],
|
|||
let mut kind = no_branch;
|
||||
let mut test_val = val;
|
||||
if opts.len() > 0u {
|
||||
alt opts[0] {
|
||||
match opts[0] {
|
||||
var(_, vdef) => {
|
||||
if (*ty::enum_variants(tcx, vdef.enm)).len() == 1u {
|
||||
kind = single;
|
||||
|
|
@ -578,12 +580,12 @@ fn compile_submatch(bcx: block, m: match_, vals: ~[ValueRef],
|
|||
}
|
||||
}
|
||||
for vec::each(opts) |o| {
|
||||
alt o {
|
||||
match o {
|
||||
range(_, _) => { kind = compare; break }
|
||||
_ => ()
|
||||
}
|
||||
}
|
||||
let else_cx = alt kind {
|
||||
let else_cx = match kind {
|
||||
no_branch | single => bcx,
|
||||
_ => sub_block(bcx, ~"match_else")
|
||||
};
|
||||
|
|
@ -601,10 +603,10 @@ fn compile_submatch(bcx: block, m: match_, vals: ~[ValueRef],
|
|||
let mut opt_cx = else_cx;
|
||||
if !exhaustive || i < len {
|
||||
opt_cx = sub_block(bcx, ~"match_case");
|
||||
alt kind {
|
||||
match kind {
|
||||
single => Br(bcx, opt_cx.llbb),
|
||||
switch => {
|
||||
alt check trans_opt(bcx, opt) {
|
||||
match check trans_opt(bcx, opt) {
|
||||
single_result(r) => {
|
||||
llvm::LLVMAddCase(sw, r.val, opt_cx.llbb);
|
||||
bcx = r.bcx;
|
||||
|
|
@ -615,7 +617,7 @@ fn compile_submatch(bcx: block, m: match_, vals: ~[ValueRef],
|
|||
let t = node_id_type(bcx, pat_id);
|
||||
let {bcx: after_cx, val: matches} = {
|
||||
do with_scope_result(bcx, none, ~"compare_scope") |bcx| {
|
||||
alt trans_opt(bcx, opt) {
|
||||
match trans_opt(bcx, opt) {
|
||||
single_result({bcx, val}) => {
|
||||
trans_compare(bcx, ast::eq, test_val, t, val, t)
|
||||
}
|
||||
|
|
@ -638,7 +640,7 @@ fn compile_submatch(bcx: block, m: match_, vals: ~[ValueRef],
|
|||
} else if kind == compare { Br(bcx, else_cx.llbb); }
|
||||
let mut size = 0u;
|
||||
let mut unpacked = ~[];
|
||||
alt opt {
|
||||
match opt {
|
||||
var(_, vdef) => {
|
||||
let args = extract_variant_args(opt_cx, pat_id, vdef, val);
|
||||
size = args.vals.len();
|
||||
|
|
@ -671,7 +673,7 @@ fn make_phi_bindings(bcx: block, map: ~[exit_node],
|
|||
let mut vals = ~[];
|
||||
for vec::each(map) |ex| {
|
||||
if ex.to as uint == our_block {
|
||||
alt assoc(name, ex.bound) {
|
||||
match assoc(name, ex.bound) {
|
||||
some(binding) => {
|
||||
vec::push(llbbs, ex.from);
|
||||
vec::push(vals, binding.val);
|
||||
|
|
@ -774,14 +776,14 @@ fn trans_alt_inner(scope_cx: block, expr: @ast::expr, arms: ~[ast::arm],
|
|||
|
||||
fn mk_fail(bcx: block, sp: span, msg: ~str,
|
||||
done: @mut option<BasicBlockRef>) -> BasicBlockRef {
|
||||
alt *done { some(bb) => return bb, _ => () }
|
||||
match *done { some(bb) => return bb, _ => () }
|
||||
let fail_cx = sub_block(bcx, ~"case_fallthrough");
|
||||
trans_fail(fail_cx, some(sp), msg);
|
||||
*done = some(fail_cx.llbb);
|
||||
return fail_cx.llbb;
|
||||
}
|
||||
let t = node_id_type(bcx, expr.id);
|
||||
let mk_fail = alt mode {
|
||||
let mk_fail = match mode {
|
||||
ast::alt_check => {
|
||||
let fail_cx = @mut none;
|
||||
// Cached fail-on-fallthrough block
|
||||
|
|
@ -829,7 +831,7 @@ fn bind_irrefutable_pat(bcx: block, pat: @ast::pat, val: ValueRef,
|
|||
let mut bcx = bcx;
|
||||
|
||||
// Necessary since bind_irrefutable_pat is called outside trans_alt
|
||||
alt pat.node {
|
||||
match pat.node {
|
||||
ast::pat_ident(_, _,inner) => {
|
||||
if pat_is_variant(bcx.tcx().def_map, pat) { return bcx; }
|
||||
if make_copy {
|
||||
|
|
@ -841,7 +843,7 @@ fn bind_irrefutable_pat(bcx: block, pat: @ast::pat, val: ValueRef,
|
|||
bcx.fcx.lllocals.insert(pat.id, local_mem(alloc));
|
||||
add_clean(bcx, alloc, ty);
|
||||
} else { bcx.fcx.lllocals.insert(pat.id, local_mem(val)); }
|
||||
alt inner {
|
||||
match inner {
|
||||
some(pat) => { bcx = bind_irrefutable_pat(bcx, pat, val, true); }
|
||||
_ => ()
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -49,7 +49,7 @@ fn count_insn(cx: block, category: ~str) {
|
|||
s += ~"/";
|
||||
s += category;
|
||||
|
||||
let n = alt h.find(s) {
|
||||
let n = match h.find(s) {
|
||||
some(n) => n,
|
||||
_ => 0u
|
||||
};
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ enum environment_value {
|
|||
}
|
||||
|
||||
fn ev_to_str(ccx: @crate_ctxt, ev: environment_value) -> ~str {
|
||||
alt ev {
|
||||
match ev {
|
||||
env_copy(v, t, lk) => fmt!{"copy(%s,%s)", val_str(ccx.tn, v),
|
||||
ty_to_str(ccx.tcx, t)},
|
||||
env_move(v, t, lk) => fmt!{"move(%s,%s)", val_str(ccx.tn, v),
|
||||
|
|
@ -124,7 +124,7 @@ fn mk_closure_tys(tcx: ty::ctxt,
|
|||
|
||||
// Compute the closed over data
|
||||
for vec::each(bound_values) |bv| {
|
||||
vec::push(bound_tys, alt bv {
|
||||
vec::push(bound_tys, match bv {
|
||||
env_copy(_, t, _) => t,
|
||||
env_move(_, t, _) => t,
|
||||
env_ref(_, t, _) => t
|
||||
|
|
@ -153,7 +153,7 @@ fn allocate_cbox(bcx: block,
|
|||
}
|
||||
|
||||
// Allocate and initialize the box:
|
||||
let {bcx, val} = alt ck {
|
||||
let {bcx, val} = match ck {
|
||||
ty::ck_box => malloc_raw(bcx, cdata_ty, heap_shared),
|
||||
ty::ck_uniq => malloc_raw(bcx, cdata_ty, heap_exchange),
|
||||
ty::ck_block => {
|
||||
|
|
@ -211,7 +211,7 @@ fn store_environment(bcx: block,
|
|||
|
||||
let bound_data = GEPi(bcx, llbox,
|
||||
~[0u, abi::box_field_body, i]);
|
||||
alt bv {
|
||||
match bv {
|
||||
env_copy(val, ty, lv_owned) => {
|
||||
let val1 = load_if_immediate(bcx, val, ty);
|
||||
bcx = base::copy_val(bcx, INIT, bound_data, val1, ty);
|
||||
|
|
@ -267,14 +267,14 @@ fn build_closure(bcx0: block,
|
|||
debug!{"Node id is %s",
|
||||
syntax::ast_map::node_id_to_str(bcx.ccx().tcx.items, nid)};
|
||||
let mut ty = node_id_type(bcx, nid);
|
||||
alt cap_var.mode {
|
||||
match cap_var.mode {
|
||||
capture::cap_ref => {
|
||||
assert ck == ty::ck_block;
|
||||
ty = ty::mk_mut_ptr(tcx, ty);
|
||||
vec::push(env_vals, env_ref(lv.val, ty, lv.kind));
|
||||
}
|
||||
capture::cap_copy => {
|
||||
let mv = alt check ccx.maps.last_use_map.find(id) {
|
||||
let mv = match check ccx.maps.last_use_map.find(id) {
|
||||
none => false,
|
||||
some(vars) => (*vars).contains(nid)
|
||||
};
|
||||
|
|
@ -292,7 +292,7 @@ fn build_closure(bcx0: block,
|
|||
}
|
||||
}
|
||||
do option::iter(include_ret_handle) |flagptr| {
|
||||
let our_ret = alt bcx.fcx.loop_ret {
|
||||
let our_ret = match bcx.fcx.loop_ret {
|
||||
some({retptr, _}) => retptr,
|
||||
none => bcx.fcx.llretptr
|
||||
};
|
||||
|
|
@ -323,12 +323,12 @@ fn load_environment(fcx: fn_ctxt,
|
|||
// Populate the upvars from the environment.
|
||||
let mut i = 0u;
|
||||
do vec::iter(cap_vars) |cap_var| {
|
||||
alt cap_var.mode {
|
||||
match cap_var.mode {
|
||||
capture::cap_drop => { /* ignore */ }
|
||||
_ => {
|
||||
let mut upvarptr =
|
||||
GEPi(bcx, llcdata, ~[0u, i]);
|
||||
alt ck {
|
||||
match ck {
|
||||
ty::ck_block => { upvarptr = Load(bcx, upvarptr); }
|
||||
ty::ck_uniq | ty::ck_box => ()
|
||||
}
|
||||
|
|
@ -368,7 +368,7 @@ fn trans_expr_fn(bcx: block,
|
|||
let trans_closure_env = fn@(ck: ty::closure_kind) -> result {
|
||||
let cap_vars = capture::compute_capture_vars(
|
||||
ccx.tcx, id, proto, cap_clause);
|
||||
let ret_handle = alt is_loop_body { some(x) => x, none => none };
|
||||
let ret_handle = match is_loop_body { some(x) => x, none => none };
|
||||
let {llbox, cdata_ty, bcx} = build_closure(bcx, cap_vars, ck, id,
|
||||
ret_handle);
|
||||
trans_closure(ccx, sub_path, decl, body, llfn, no_self,
|
||||
|
|
@ -383,7 +383,7 @@ fn trans_expr_fn(bcx: block,
|
|||
{bcx: bcx, val: llbox}
|
||||
};
|
||||
|
||||
let {bcx: bcx, val: closure} = alt proto {
|
||||
let {bcx: bcx, val: closure} = match proto {
|
||||
ast::proto_block => trans_closure_env(ty::ck_block),
|
||||
ast::proto_box => trans_closure_env(ty::ck_box),
|
||||
ast::proto_uniq => trans_closure_env(ty::ck_uniq),
|
||||
|
|
@ -417,7 +417,7 @@ fn make_fn_glue(
|
|||
}
|
||||
};
|
||||
|
||||
return alt ty::get(t).struct {
|
||||
return match ty::get(t).struct {
|
||||
ty::ty_fn({proto: ast::proto_bare, _}) |
|
||||
ty::ty_fn({proto: ast::proto_block, _}) => bcx,
|
||||
ty::ty_fn({proto: ast::proto_uniq, _}) => fn_env(ty::ck_uniq),
|
||||
|
|
@ -433,7 +433,7 @@ fn make_opaque_cbox_take_glue(
|
|||
-> block {
|
||||
// Easy cases:
|
||||
let _icx = bcx.insn_ctxt(~"closure::make_opaque_cbox_take_glue");
|
||||
alt ck {
|
||||
match ck {
|
||||
ty::ck_block => return bcx,
|
||||
ty::ck_box => {
|
||||
incr_refcnt_of_boxed(bcx, Load(bcx, cboxptr));
|
||||
|
|
@ -485,7 +485,7 @@ fn make_opaque_cbox_drop_glue(
|
|||
cboxptr: ValueRef) // ptr to the opaque closure
|
||||
-> block {
|
||||
let _icx = bcx.insn_ctxt(~"closure::make_opaque_cbox_drop_glue");
|
||||
alt ck {
|
||||
match ck {
|
||||
ty::ck_block => bcx,
|
||||
ty::ck_box => {
|
||||
decr_refcnt_maybe_free(bcx, Load(bcx, cboxptr),
|
||||
|
|
@ -504,7 +504,7 @@ fn make_opaque_cbox_free_glue(
|
|||
cbox: ValueRef) // ptr to the opaque closure
|
||||
-> block {
|
||||
let _icx = bcx.insn_ctxt(~"closure::make_opaque_cbox_free_glue");
|
||||
alt ck {
|
||||
match ck {
|
||||
ty::ck_block => return bcx,
|
||||
ty::ck_box | ty::ck_uniq => { /* hard cases: */ }
|
||||
}
|
||||
|
|
@ -524,7 +524,7 @@ fn make_opaque_cbox_free_glue(
|
|||
abi::tydesc_field_drop_glue, none);
|
||||
|
||||
// Free the ty descr (if necc) and the box itself
|
||||
alt ck {
|
||||
match ck {
|
||||
ty::ck_block => fail ~"Impossible",
|
||||
ty::ck_box => trans_free(bcx, cbox),
|
||||
ty::ck_uniq => trans_unique_free(bcx, cbox)
|
||||
|
|
|
|||
|
|
@ -292,7 +292,7 @@ fn add_clean_temp_mem(cx: block, val: ValueRef, ty: ty::t) {
|
|||
}
|
||||
}
|
||||
fn add_clean_free(cx: block, ptr: ValueRef, heap: heap) {
|
||||
let free_fn = alt heap {
|
||||
let free_fn = match heap {
|
||||
heap_shared => |a| base::trans_free(a, ptr),
|
||||
heap_exchange => |a| base::trans_unique_free(a, ptr)
|
||||
};
|
||||
|
|
@ -310,7 +310,7 @@ fn add_clean_free(cx: block, ptr: ValueRef, heap: heap) {
|
|||
fn revoke_clean(cx: block, val: ValueRef) {
|
||||
do in_scope_cx(cx) |info| {
|
||||
do option::iter(vec::position(info.cleanups, |cu| {
|
||||
alt cu {
|
||||
match cu {
|
||||
clean_temp(v, _, _) if v == val => true,
|
||||
_ => false
|
||||
}
|
||||
|
|
@ -453,7 +453,7 @@ fn struct_elt(llstructty: TypeRef, n: uint) -> TypeRef unsafe {
|
|||
fn in_scope_cx(cx: block, f: fn(scope_info)) {
|
||||
let mut cur = cx;
|
||||
loop {
|
||||
alt cur.kind {
|
||||
match cur.kind {
|
||||
block_scope(inf) => { f(inf); return; }
|
||||
_ => ()
|
||||
}
|
||||
|
|
@ -462,7 +462,7 @@ fn in_scope_cx(cx: block, f: fn(scope_info)) {
|
|||
}
|
||||
|
||||
fn block_parent(cx: block) -> block {
|
||||
alt cx.parent {
|
||||
match cx.parent {
|
||||
some(b) => b,
|
||||
none => cx.sess().bug(fmt!{"block_parent called on root block %?",
|
||||
cx})
|
||||
|
|
@ -483,7 +483,7 @@ impl bcx_cxs for block {
|
|||
ty_to_str(self.tcx(), t)
|
||||
}
|
||||
fn to_str() -> ~str {
|
||||
alt self.node_info {
|
||||
match self.node_info {
|
||||
some(node_info) => {
|
||||
fmt!{"[block %d]", node_info.id}
|
||||
}
|
||||
|
|
@ -535,7 +535,7 @@ fn T_f64() -> TypeRef { return llvm::LLVMDoubleType(); }
|
|||
fn T_bool() -> TypeRef { return T_i1(); }
|
||||
|
||||
fn T_int(targ_cfg: @session::config) -> TypeRef {
|
||||
return alt targ_cfg.arch {
|
||||
return match targ_cfg.arch {
|
||||
session::arch_x86 => T_i32(),
|
||||
session::arch_x86_64 => T_i64(),
|
||||
session::arch_arm => T_i32()
|
||||
|
|
@ -543,7 +543,7 @@ fn T_int(targ_cfg: @session::config) -> TypeRef {
|
|||
}
|
||||
|
||||
fn T_int_ty(cx: @crate_ctxt, t: ast::int_ty) -> TypeRef {
|
||||
alt t {
|
||||
match t {
|
||||
ast::ty_i => cx.int_type,
|
||||
ast::ty_char => T_char(),
|
||||
ast::ty_i8 => T_i8(),
|
||||
|
|
@ -554,7 +554,7 @@ fn T_int_ty(cx: @crate_ctxt, t: ast::int_ty) -> TypeRef {
|
|||
}
|
||||
|
||||
fn T_uint_ty(cx: @crate_ctxt, t: ast::uint_ty) -> TypeRef {
|
||||
alt t {
|
||||
match t {
|
||||
ast::ty_u => cx.int_type,
|
||||
ast::ty_u8 => T_i8(),
|
||||
ast::ty_u16 => T_i16(),
|
||||
|
|
@ -564,7 +564,7 @@ fn T_uint_ty(cx: @crate_ctxt, t: ast::uint_ty) -> TypeRef {
|
|||
}
|
||||
|
||||
fn T_float_ty(cx: @crate_ctxt, t: ast::float_ty) -> TypeRef {
|
||||
alt t {
|
||||
match t {
|
||||
ast::ty_f => cx.float_type,
|
||||
ast::ty_f32 => T_f32(),
|
||||
ast::ty_f64 => T_f64()
|
||||
|
|
@ -572,7 +572,7 @@ fn T_float_ty(cx: @crate_ctxt, t: ast::float_ty) -> TypeRef {
|
|||
}
|
||||
|
||||
fn T_float(targ_cfg: @session::config) -> TypeRef {
|
||||
return alt targ_cfg.arch {
|
||||
return match targ_cfg.arch {
|
||||
session::arch_x86 => T_f64(),
|
||||
session::arch_x86_64 => T_f64(),
|
||||
session::arch_arm => T_f64()
|
||||
|
|
@ -657,7 +657,7 @@ fn T_tydesc_field(cx: @crate_ctxt, field: uint) -> TypeRef unsafe {
|
|||
|
||||
fn T_glue_fn(cx: @crate_ctxt) -> TypeRef {
|
||||
let s = ~"glue_fn";
|
||||
alt name_has_type(cx.tn, s) {
|
||||
match name_has_type(cx.tn, s) {
|
||||
some(t) => return t,
|
||||
_ => ()
|
||||
}
|
||||
|
|
@ -764,7 +764,7 @@ fn T_taskptr(cx: @crate_ctxt) -> TypeRef { return T_ptr(cx.task_type); }
|
|||
// This type must never be used directly; it must always be cast away.
|
||||
fn T_typaram(tn: type_names) -> TypeRef {
|
||||
let s = ~"typaram";
|
||||
alt name_has_type(tn, s) {
|
||||
match name_has_type(tn, s) {
|
||||
some(t) => return t,
|
||||
_ => ()
|
||||
}
|
||||
|
|
@ -787,7 +787,7 @@ fn T_enum_discrim(cx: @crate_ctxt) -> TypeRef {
|
|||
|
||||
fn T_opaque_enum(cx: @crate_ctxt) -> TypeRef {
|
||||
let s = ~"opaque_enum";
|
||||
alt name_has_type(cx.tn, s) {
|
||||
match name_has_type(cx.tn, s) {
|
||||
some(t) => return t,
|
||||
_ => ()
|
||||
}
|
||||
|
|
@ -856,7 +856,7 @@ fn C_u8(i: uint) -> ValueRef { return C_integral(T_i8(), i as u64, False); }
|
|||
// This is a 'c-like' raw string, which differs from
|
||||
// our boxed-and-length-annotated strings.
|
||||
fn C_cstr(cx: @crate_ctxt, s: ~str) -> ValueRef {
|
||||
alt cx.const_cstr_cache.find(s) {
|
||||
match cx.const_cstr_cache.find(s) {
|
||||
some(llval) => return llval,
|
||||
none => ()
|
||||
}
|
||||
|
|
@ -942,7 +942,7 @@ type mono_id = @{def: ast::def_id, params: ~[mono_param_id]};
|
|||
pure fn hash_mono_id(mi: &mono_id) -> uint {
|
||||
let mut h = syntax::ast_util::hash_def(&mi.def);
|
||||
for vec::each(mi.params) |param| {
|
||||
h = h * alt param {
|
||||
h = h * match param {
|
||||
mono_precise(ty, vts) => {
|
||||
let mut h = ty::type_id(ty);
|
||||
do option::iter(vts) |vts| {
|
||||
|
|
@ -978,7 +978,7 @@ fn align_to(cx: block, off: ValueRef, align: ValueRef) -> ValueRef {
|
|||
fn path_str(p: path) -> ~str {
|
||||
let mut r = ~"", first = true;
|
||||
for vec::each(p) |e| {
|
||||
alt e { ast_map::path_name(s) | ast_map::path_mod(s) => {
|
||||
match e { ast_map::path_name(s) | ast_map::path_mod(s) => {
|
||||
if first { first = false; }
|
||||
else { r += ~"::"; }
|
||||
r += *s;
|
||||
|
|
@ -990,7 +990,7 @@ fn path_str(p: path) -> ~str {
|
|||
fn node_id_type(bcx: block, id: ast::node_id) -> ty::t {
|
||||
let tcx = bcx.tcx();
|
||||
let t = ty::node_id_to_type(tcx, id);
|
||||
alt bcx.fcx.param_substs {
|
||||
match bcx.fcx.param_substs {
|
||||
some(substs) => ty::subst_tps(tcx, substs.tys, t),
|
||||
_ => { assert !ty::type_has_params(t); t }
|
||||
}
|
||||
|
|
@ -1001,7 +1001,7 @@ fn expr_ty(bcx: block, ex: @ast::expr) -> ty::t {
|
|||
fn node_id_type_params(bcx: block, id: ast::node_id) -> ~[ty::t] {
|
||||
let tcx = bcx.tcx();
|
||||
let params = ty::node_id_to_type_params(tcx, id);
|
||||
alt bcx.fcx.param_substs {
|
||||
match bcx.fcx.param_substs {
|
||||
some(substs) => {
|
||||
vec::map(params, |t| ty::subst_tps(tcx, substs.tys, t))
|
||||
}
|
||||
|
|
@ -1012,7 +1012,7 @@ fn node_id_type_params(bcx: block, id: ast::node_id) -> ~[ty::t] {
|
|||
fn field_idx_strict(cx: ty::ctxt, sp: span, ident: ast::ident,
|
||||
fields: ~[ty::field])
|
||||
-> uint {
|
||||
alt ty::field_idx(ident, fields) {
|
||||
match ty::field_idx(ident, fields) {
|
||||
none => cx.sess.span_bug(
|
||||
sp, fmt!{"base expr doesn't appear to \
|
||||
have a field named %s", *ident}),
|
||||
|
|
|
|||
|
|
@ -5,12 +5,12 @@ import base::get_insn_ctxt;
|
|||
fn const_lit(cx: @crate_ctxt, e: @ast::expr, lit: ast::lit)
|
||||
-> ValueRef {
|
||||
let _icx = cx.insn_ctxt(~"trans_lit");
|
||||
alt lit.node {
|
||||
match lit.node {
|
||||
ast::lit_int(i, t) => C_integral(T_int_ty(cx, t), i as u64, True),
|
||||
ast::lit_uint(u, t) => C_integral(T_uint_ty(cx, t), u, False),
|
||||
ast::lit_int_unsuffixed(i) => {
|
||||
let lit_int_ty = ty::node_id_to_type(cx.tcx, e.id);
|
||||
alt ty::get(lit_int_ty).struct {
|
||||
match ty::get(lit_int_ty).struct {
|
||||
ty::ty_int(t) => {
|
||||
C_integral(T_int_ty(cx, t), i as u64, True)
|
||||
}
|
||||
|
|
@ -45,7 +45,7 @@ fn const_vec_and_sz(cx: @crate_ctxt, e: @ast::expr, es: &[@ast::expr])
|
|||
|
||||
fn const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef {
|
||||
let _icx = cx.insn_ctxt(~"const_expr");
|
||||
alt e.node {
|
||||
match e.node {
|
||||
ast::expr_lit(lit) => consts::const_lit(cx, e, *lit),
|
||||
ast::expr_binary(b, e1, e2) => {
|
||||
let te1 = const_expr(cx, e1);
|
||||
|
|
@ -58,7 +58,7 @@ fn const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef {
|
|||
let ty = ty::expr_ty(cx.tcx, e1);
|
||||
let is_float = ty::type_is_fp(ty);
|
||||
let signed = ty::type_is_signed(ty);
|
||||
return alt b {
|
||||
return match b {
|
||||
ast::add => {
|
||||
if is_float { llvm::LLVMConstFAdd(te1, te2) }
|
||||
else { llvm::LLVMConstAdd(te1, te2) }
|
||||
|
|
@ -103,7 +103,7 @@ fn const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef {
|
|||
let te = const_expr(cx, e);
|
||||
let ty = ty::expr_ty(cx.tcx, e);
|
||||
let is_float = ty::type_is_fp(ty);
|
||||
return alt u {
|
||||
return match u {
|
||||
ast::box(_) |
|
||||
ast::uniq(_) |
|
||||
ast::deref => cx.sess.span_bug(e.span,
|
||||
|
|
@ -119,7 +119,9 @@ fn const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef {
|
|||
let ety = ty::expr_ty(cx.tcx, e), llty = type_of::type_of(cx, ety);
|
||||
let basety = ty::expr_ty(cx.tcx, base);
|
||||
let v = const_expr(cx, base);
|
||||
alt check (base::cast_type_kind(basety), base::cast_type_kind(ety)) {
|
||||
match check (base::cast_type_kind(basety),
|
||||
base::cast_type_kind(ety)) {
|
||||
|
||||
(base::cast_integral, base::cast_integral) => {
|
||||
let s = if ty::type_is_signed(basety) { True } else { False };
|
||||
llvm::LLVMConstIntCast(v, llty, s)
|
||||
|
|
@ -162,9 +164,9 @@ fn const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef {
|
|||
const_expr(cx, e)
|
||||
}
|
||||
ast::expr_vstore(sub, ast::vstore_slice(_)) => {
|
||||
alt sub.node {
|
||||
match sub.node {
|
||||
ast::expr_lit(lit) => {
|
||||
alt lit.node {
|
||||
match lit.node {
|
||||
ast::lit_str(*) => { const_expr(cx, sub) }
|
||||
_ => { cx.sess.span_bug(e.span,
|
||||
~"bad const-slice lit") }
|
||||
|
|
@ -186,11 +188,11 @@ fn const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef {
|
|||
}
|
||||
}
|
||||
ast::expr_path(path) => {
|
||||
alt cx.tcx.def_map.find(e.id) {
|
||||
match cx.tcx.def_map.find(e.id) {
|
||||
some(ast::def_const(def_id)) => {
|
||||
// Don't know how to handle external consts
|
||||
assert ast_util::is_local(def_id);
|
||||
alt cx.tcx.items.get(def_id.node) {
|
||||
match cx.tcx.items.get(def_id.node) {
|
||||
ast_map::node_item(@{
|
||||
node: ast::item_const(_, subexpr), _
|
||||
}, _) => {
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ fn cast_safely<T: copy, U>(val: T) -> U unsafe {
|
|||
}
|
||||
|
||||
fn md_from_metadata<T>(val: debug_metadata) -> T unsafe {
|
||||
alt val {
|
||||
match val {
|
||||
file_metadata(md) => cast_safely(md),
|
||||
compile_unit_metadata(md) => cast_safely(md),
|
||||
subprogram_metadata(md) => cast_safely(md),
|
||||
|
|
@ -165,7 +165,7 @@ fn create_compile_unit(cx: @crate_ctxt)
|
|||
let cache = get_cache(cx);
|
||||
let crate_name = option::get(cx.dbg_cx).crate_file;
|
||||
let tg = CompileUnitTag;
|
||||
alt cached_metadata::<@metadata<compile_unit_md>>(cache, tg,
|
||||
match cached_metadata::<@metadata<compile_unit_md>>(cache, tg,
|
||||
|md| md.data.name == crate_name) {
|
||||
option::some(md) => return md,
|
||||
option::none => ()
|
||||
|
|
@ -208,7 +208,7 @@ fn get_file_path_and_dir(work_dir: ~str, full_path: ~str) -> (~str, ~str) {
|
|||
fn create_file(cx: @crate_ctxt, full_path: ~str) -> @metadata<file_md> {
|
||||
let cache = get_cache(cx);;
|
||||
let tg = FileDescriptorTag;
|
||||
alt cached_metadata::<@metadata<file_md>>(
|
||||
match cached_metadata::<@metadata<file_md>>(
|
||||
cache, tg, |md| md.data.path == full_path) {
|
||||
option::some(md) => return md,
|
||||
option::none => ()
|
||||
|
|
@ -235,7 +235,7 @@ fn create_block(cx: block) -> @metadata<block_md> {
|
|||
let cache = get_cache(cx.ccx());
|
||||
let mut cx = cx;
|
||||
while option::is_none(cx.node_info) {
|
||||
alt cx.parent {
|
||||
match cx.parent {
|
||||
some(b) => cx = b,
|
||||
none => fail
|
||||
}
|
||||
|
|
@ -253,12 +253,12 @@ fn create_block(cx: block) -> @metadata<block_md> {
|
|||
option::none {}
|
||||
}*/
|
||||
|
||||
let parent = alt cx.parent {
|
||||
let parent = match cx.parent {
|
||||
none => create_function(cx.fcx).node,
|
||||
some(bcx) => create_block(bcx).node
|
||||
};
|
||||
let file_node = create_file(cx.ccx(), fname);
|
||||
let unique_id = alt cache.find(LexicalBlockTag) {
|
||||
let unique_id = match cache.find(LexicalBlockTag) {
|
||||
option::some(v) => vec::len(v) as int,
|
||||
option::none => 0
|
||||
};
|
||||
|
|
@ -285,15 +285,15 @@ fn create_basic_type(cx: @crate_ctxt, t: ty::t, ty: ast::prim_ty, span: span)
|
|||
-> @metadata<tydesc_md> {
|
||||
let cache = get_cache(cx);
|
||||
let tg = BasicTypeDescriptorTag;
|
||||
alt cached_metadata::<@metadata<tydesc_md>>(
|
||||
match cached_metadata::<@metadata<tydesc_md>>(
|
||||
cache, tg, |md| ty::type_id(t) == md.data.hash) {
|
||||
option::some(md) => return md,
|
||||
option::none => ()
|
||||
}
|
||||
|
||||
let (name, encoding) = alt check ty {
|
||||
let (name, encoding) = match check ty {
|
||||
ast::ty_bool => (~"bool", DW_ATE_boolean),
|
||||
ast::ty_int(m) => alt m {
|
||||
ast::ty_int(m) => match m {
|
||||
ast::ty_char => (~"char", DW_ATE_unsigned),
|
||||
ast::ty_i => (~"int", DW_ATE_signed),
|
||||
ast::ty_i8 => (~"i8", DW_ATE_signed_char),
|
||||
|
|
@ -301,14 +301,14 @@ fn create_basic_type(cx: @crate_ctxt, t: ty::t, ty: ast::prim_ty, span: span)
|
|||
ast::ty_i32 => (~"i32", DW_ATE_signed),
|
||||
ast::ty_i64 => (~"i64", DW_ATE_signed)
|
||||
}
|
||||
ast::ty_uint(m) => alt m {
|
||||
ast::ty_uint(m) => match m {
|
||||
ast::ty_u => (~"uint", DW_ATE_unsigned),
|
||||
ast::ty_u8 => (~"u8", DW_ATE_unsigned_char),
|
||||
ast::ty_u16 => (~"u16", DW_ATE_unsigned),
|
||||
ast::ty_u32 => (~"u32", DW_ATE_unsigned),
|
||||
ast::ty_u64 => (~"u64", DW_ATE_unsigned)
|
||||
}
|
||||
ast::ty_float(m) => alt m {
|
||||
ast::ty_float(m) => match m {
|
||||
ast::ty_f => (~"float", DW_ATE_float),
|
||||
ast::ty_f32 => (~"f32", DW_ATE_float),
|
||||
ast::ty_f64 => (~"f64", DW_ATE_float)
|
||||
|
|
@ -341,7 +341,7 @@ fn create_pointer_type(cx: @crate_ctxt, t: ty::t, span: span,
|
|||
-> @metadata<tydesc_md> {
|
||||
let tg = PointerTypeTag;
|
||||
/*let cache = cx.llmetadata;
|
||||
alt cached_metadata::<@metadata<tydesc_md>>(
|
||||
match cached_metadata::<@metadata<tydesc_md>>(
|
||||
cache, tg, {|md| ty::hash_ty(t) == ty::hash_ty(md.data.hash)}) {
|
||||
option::some(md) { return md; }
|
||||
option::none {}
|
||||
|
|
@ -434,7 +434,7 @@ fn create_boxed_type(cx: @crate_ctxt, outer: ty::t, _inner: ty::t,
|
|||
-> @metadata<tydesc_md> {
|
||||
//let tg = StructureTypeTag;
|
||||
/*let cache = cx.llmetadata;
|
||||
alt cached_metadata::<@metadata<tydesc_md>>(
|
||||
match cached_metadata::<@metadata<tydesc_md>>(
|
||||
cache, tg, {|md| ty::hash_ty(outer) == ty::hash_ty(md.data.hash)}) {
|
||||
option::some(md) { return md; }
|
||||
option::none {}
|
||||
|
|
@ -516,7 +516,7 @@ fn create_vec(cx: @crate_ctxt, vec_t: ty::t, elem_t: ty::t,
|
|||
fn create_ty(_cx: @crate_ctxt, _t: ty::t, _ty: @ast::ty)
|
||||
-> @metadata<tydesc_md> {
|
||||
/*let cache = get_cache(cx);
|
||||
alt cached_metadata::<@metadata<tydesc_md>>(
|
||||
match cached_metadata::<@metadata<tydesc_md>>(
|
||||
cache, tg, {|md| t == md.data.hash}) {
|
||||
option::some(md) { return md; }
|
||||
option::none {}
|
||||
|
|
@ -536,7 +536,7 @@ fn create_ty(_cx: @crate_ctxt, _t: ty::t, _ty: @ast::ty)
|
|||
fail;
|
||||
/*
|
||||
fn t_to_ty(cx: crate_ctxt, t: ty::t, span: span) -> @ast::ty {
|
||||
let ty = alt ty::get(t).struct {
|
||||
let ty = match ty::get(t).struct {
|
||||
ty::ty_nil { ast::ty_nil }
|
||||
ty::ty_bot { ast::ty_bot }
|
||||
ty::ty_bool { ast::ty_bool }
|
||||
|
|
@ -566,9 +566,9 @@ fn create_ty(_cx: @crate_ctxt, _t: ty::t, _ty: @ast::ty)
|
|||
return @{node: ty, span: span};
|
||||
}
|
||||
|
||||
alt ty.node {
|
||||
match ty.node {
|
||||
ast::ty_box(mt) {
|
||||
let inner_t = alt ty::get(t).struct {
|
||||
let inner_t = match ty::get(t).struct {
|
||||
ty::ty_box(boxed) { boxed.ty }
|
||||
_ { cx.sess.span_bug(ty.span, "t_to_ty was incoherent"); }
|
||||
};
|
||||
|
|
@ -578,7 +578,7 @@ fn create_ty(_cx: @crate_ctxt, _t: ty::t, _ty: @ast::ty)
|
|||
}
|
||||
|
||||
ast::ty_uniq(mt) {
|
||||
let inner_t = alt ty::get(t).struct {
|
||||
let inner_t = match ty::get(t).struct {
|
||||
ty::ty_uniq(boxed) { boxed.ty }
|
||||
// Hoping we'll have a way to eliminate this check soon.
|
||||
_ { cx.sess.span_bug(ty.span, "t_to_ty was incoherent"); }
|
||||
|
|
@ -604,7 +604,7 @@ fn create_ty(_cx: @crate_ctxt, _t: ty::t, _ty: @ast::ty)
|
|||
}
|
||||
|
||||
ast::ty_path(_, id) {
|
||||
alt cx.tcx.def_map.get(id) {
|
||||
match cx.tcx.def_map.get(id) {
|
||||
ast::def_prim_ty(pty) {
|
||||
return create_basic_type(cx, t, pty, ty.span);
|
||||
}
|
||||
|
|
@ -639,13 +639,13 @@ fn create_local_var(bcx: block, local: @ast::local)
|
|||
let cx = bcx.ccx();
|
||||
let cache = get_cache(cx);
|
||||
let tg = AutoVariableTag;
|
||||
alt cached_metadata::<@metadata<local_var_md>>(
|
||||
match cached_metadata::<@metadata<local_var_md>>(
|
||||
cache, tg, |md| md.data.id == local.node.id) {
|
||||
option::some(md) => return md,
|
||||
option::none => ()
|
||||
}
|
||||
|
||||
let name = alt local.node.pat.node {
|
||||
let name = match local.node.pat.node {
|
||||
ast::pat_ident(_, pth, _) => ast_util::path_to_ident(pth),
|
||||
// FIXME this should be handled (#2533)
|
||||
_ => fail ~"no single variable name for local"
|
||||
|
|
@ -655,7 +655,7 @@ fn create_local_var(bcx: block, local: @ast::local)
|
|||
let ty = node_id_type(bcx, local.node.id);
|
||||
let tymd = create_ty(cx, ty, local.node.ty);
|
||||
let filemd = create_file(cx, loc.file.name);
|
||||
let context = alt bcx.parent {
|
||||
let context = match bcx.parent {
|
||||
none => create_function(bcx.fcx).node,
|
||||
some(_) => create_block(bcx).node
|
||||
};
|
||||
|
|
@ -664,14 +664,14 @@ fn create_local_var(bcx: block, local: @ast::local)
|
|||
let mdval = @{node: mdnode, data: {id: local.node.id}};
|
||||
update_cache(cache, AutoVariableTag, local_var_metadata(mdval));
|
||||
|
||||
let llptr = alt bcx.fcx.lllocals.find(local.node.id) {
|
||||
let llptr = match bcx.fcx.lllocals.find(local.node.id) {
|
||||
option::some(local_mem(v)) => v,
|
||||
option::some(_) => {
|
||||
bcx.tcx().sess.span_bug(local.span, ~"local is bound to \
|
||||
something weird");
|
||||
}
|
||||
option::none => {
|
||||
alt bcx.fcx.lllocals.get(local.node.pat.id) {
|
||||
match bcx.fcx.lllocals.get(local.node.pat.id) {
|
||||
local_imm(v) => v,
|
||||
_ => bcx.tcx().sess.span_bug(local.span, ~"local is bound to \
|
||||
something weird")
|
||||
|
|
@ -689,7 +689,7 @@ fn create_arg(bcx: block, arg: ast::arg, sp: span)
|
|||
let fcx = bcx.fcx, cx = fcx.ccx;
|
||||
let cache = get_cache(cx);
|
||||
let tg = ArgVariableTag;
|
||||
alt cached_metadata::<@metadata<argument_md>>(
|
||||
match cached_metadata::<@metadata<argument_md>>(
|
||||
cache, ArgVariableTag, |md| md.data.id == arg.id) {
|
||||
option::some(md) => return md,
|
||||
option::none => ()
|
||||
|
|
@ -706,7 +706,7 @@ fn create_arg(bcx: block, arg: ast::arg, sp: span)
|
|||
let mdval = @{node: mdnode, data: {id: arg.id}};
|
||||
update_cache(cache, tg, argument_metadata(mdval));
|
||||
|
||||
let llptr = alt fcx.llargs.get(arg.id) {
|
||||
let llptr = match fcx.llargs.get(arg.id) {
|
||||
local_mem(v) | local_imm(v) => v,
|
||||
};
|
||||
let declargs = ~[llmdnode(~[llptr]), mdnode];
|
||||
|
|
@ -740,9 +740,9 @@ fn create_function(fcx: fn_ctxt) -> @metadata<subprogram_md> {
|
|||
let sp = option::get(fcx.span);
|
||||
log(debug, codemap::span_to_str(sp, cx.sess.codemap));
|
||||
|
||||
let (ident, ret_ty, id) = alt cx.tcx.items.get(fcx.id) {
|
||||
let (ident, ret_ty, id) = match cx.tcx.items.get(fcx.id) {
|
||||
ast_map::node_item(item, _) => {
|
||||
alt item.node {
|
||||
match item.node {
|
||||
ast::item_fn(decl, _, _) => {
|
||||
(item.ident, decl.output, item.id)
|
||||
}
|
||||
|
|
@ -758,7 +758,7 @@ fn create_function(fcx: fn_ctxt) -> @metadata<subprogram_md> {
|
|||
(nm, ctor.node.dec.output, ctor.node.id)
|
||||
}
|
||||
ast_map::node_expr(expr) => {
|
||||
alt expr.node {
|
||||
match expr.node {
|
||||
ast::expr_fn(_, decl, _, _) => {
|
||||
(@dbg_cx.names(~"fn"), decl.output, expr.id)
|
||||
}
|
||||
|
|
@ -778,7 +778,7 @@ fn create_function(fcx: fn_ctxt) -> @metadata<subprogram_md> {
|
|||
log(debug, id);
|
||||
|
||||
let cache = get_cache(cx);
|
||||
alt cached_metadata::<@metadata<subprogram_md>>(
|
||||
match cached_metadata::<@metadata<subprogram_md>>(
|
||||
cache, SubprogramTag, |md| md.data.id == id) {
|
||||
option::some(md) => return md,
|
||||
option::none => ()
|
||||
|
|
@ -788,7 +788,7 @@ fn create_function(fcx: fn_ctxt) -> @metadata<subprogram_md> {
|
|||
sp.lo);
|
||||
let file_node = create_file(cx, loc.file.name).node;
|
||||
let ty_node = if cx.sess.opts.extra_debuginfo {
|
||||
alt ret_ty.node {
|
||||
match ret_ty.node {
|
||||
ast::ty_nil => llnull(),
|
||||
_ => create_ty(cx, ty::node_id_to_type(cx.tcx, id), ret_ty).node
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ enum x86_64_reg_class {
|
|||
}
|
||||
|
||||
fn is_sse(++c: x86_64_reg_class) -> bool {
|
||||
return alt c {
|
||||
return match c {
|
||||
sse_fs_class | sse_fv_class |
|
||||
sse_ds_class | sse_dv_class => true,
|
||||
_ => false
|
||||
|
|
@ -73,7 +73,7 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] {
|
|||
}
|
||||
|
||||
fn ty_align(ty: TypeRef) -> uint {
|
||||
return alt llvm::LLVMGetTypeKind(ty) as int {
|
||||
return match llvm::LLVMGetTypeKind(ty) as int {
|
||||
8 /* integer */ => {
|
||||
((llvm::LLVMGetIntTypeWidth(ty) as uint) + 7u) / 8u
|
||||
}
|
||||
|
|
@ -94,7 +94,7 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] {
|
|||
}
|
||||
|
||||
fn ty_size(ty: TypeRef) -> uint {
|
||||
return alt llvm::LLVMGetTypeKind(ty) as int {
|
||||
return match llvm::LLVMGetTypeKind(ty) as int {
|
||||
8 /* integer */ => {
|
||||
((llvm::LLVMGetIntTypeWidth(ty) as uint) + 7u) / 8u
|
||||
}
|
||||
|
|
@ -179,7 +179,7 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] {
|
|||
return;
|
||||
}
|
||||
|
||||
alt llvm::LLVMGetTypeKind(ty) as int {
|
||||
match llvm::LLVMGetTypeKind(ty) as int {
|
||||
8 /* integer */ |
|
||||
12 /* pointer */ => {
|
||||
unify(cls, ix + off / 8u, integer_class);
|
||||
|
|
@ -285,7 +285,7 @@ fn llreg_ty(cls: ~[x86_64_reg_class]) -> TypeRef {
|
|||
let mut i = 0u;
|
||||
let e = vec::len(cls);
|
||||
while i < e {
|
||||
alt cls[i] {
|
||||
match cls[i] {
|
||||
integer_class => {
|
||||
vec::push(tys, T_i64());
|
||||
}
|
||||
|
|
@ -326,7 +326,7 @@ fn x86_64_tys(atys: ~[TypeRef],
|
|||
rty: TypeRef,
|
||||
ret_def: bool) -> x86_64_tys {
|
||||
fn is_reg_ty(ty: TypeRef) -> bool {
|
||||
return alt llvm::LLVMGetTypeKind(ty) as int {
|
||||
return match llvm::LLVMGetTypeKind(ty) as int {
|
||||
8 /* integer */ |
|
||||
12 /* pointer */ |
|
||||
2 /* float */ |
|
||||
|
|
@ -401,7 +401,7 @@ fn decl_x86_64_fn(tys: x86_64_tys,
|
|||
let llfn = decl(fnty);
|
||||
|
||||
do vec::iteri(tys.attrs) |i, a| {
|
||||
alt a {
|
||||
match a {
|
||||
option::some(attr) => {
|
||||
let llarg = get_param(llfn, i);
|
||||
llvm::LLVMAddAttribute(llarg, attr as c_uint);
|
||||
|
|
@ -413,7 +413,7 @@ fn decl_x86_64_fn(tys: x86_64_tys,
|
|||
}
|
||||
|
||||
fn link_name(i: @ast::foreign_item) -> ~str {
|
||||
alt attr::first_attr_value_str_by_name(i.attrs, ~"link_name") {
|
||||
match attr::first_attr_value_str_by_name(i.attrs, ~"link_name") {
|
||||
none => return *i.ident,
|
||||
option::some(ln) => return *ln
|
||||
}
|
||||
|
|
@ -430,7 +430,7 @@ type c_stack_tys = {
|
|||
|
||||
fn c_arg_and_ret_lltys(ccx: @crate_ctxt,
|
||||
id: ast::node_id) -> (~[TypeRef], TypeRef, ty::t) {
|
||||
alt ty::get(ty::node_id_to_type(ccx.tcx, id)).struct {
|
||||
match ty::get(ty::node_id_to_type(ccx.tcx, id)).struct {
|
||||
ty::ty_fn({inputs: arg_tys, output: ret_ty, _}) => {
|
||||
let llargtys = type_of_explicit_args(ccx, arg_tys);
|
||||
let llretty = type_of::type_of(ccx, ret_ty);
|
||||
|
|
@ -587,7 +587,7 @@ fn trans_foreign_mod(ccx: @crate_ctxt,
|
|||
let mut i = 0u;
|
||||
let n = vec::len(tys.arg_tys);
|
||||
|
||||
alt tys.x86_64_tys {
|
||||
match tys.x86_64_tys {
|
||||
some(x86_64) => {
|
||||
let mut atys = x86_64.arg_tys;
|
||||
let mut attrs = x86_64.attrs;
|
||||
|
|
@ -629,10 +629,10 @@ fn trans_foreign_mod(ccx: @crate_ctxt,
|
|||
fn build_ret(bcx: block, tys: @c_stack_tys,
|
||||
llargbundle: ValueRef, llretval: ValueRef) {
|
||||
let _icx = bcx.insn_ctxt(~"foreign::shim::build_ret");
|
||||
alt tys.x86_64_tys {
|
||||
match tys.x86_64_tys {
|
||||
some(x86_64) => {
|
||||
do vec::iteri(x86_64.attrs) |i, a| {
|
||||
alt a {
|
||||
match a {
|
||||
some(attr) => {
|
||||
llvm::LLVMAddInstrAttribute(
|
||||
llretval, (i + 1u) as c_uint,
|
||||
|
|
@ -680,7 +680,7 @@ fn trans_foreign_mod(ccx: @crate_ctxt,
|
|||
fn base_fn(ccx: @crate_ctxt, lname: ~str, tys: @c_stack_tys,
|
||||
cc: lib::llvm::CallConv) -> ValueRef {
|
||||
// Declare the "prototype" for the base function F:
|
||||
alt tys.x86_64_tys {
|
||||
match tys.x86_64_tys {
|
||||
some(x86_64) => {
|
||||
do decl_x86_64_fn(x86_64) |fnty| {
|
||||
decl_fn(ccx.llmod, lname, cc, fnty)
|
||||
|
|
@ -747,14 +747,14 @@ fn trans_foreign_mod(ccx: @crate_ctxt,
|
|||
build_args, build_ret);
|
||||
}
|
||||
|
||||
let mut cc = alt abi {
|
||||
let mut cc = match abi {
|
||||
ast::foreign_abi_rust_intrinsic |
|
||||
ast::foreign_abi_cdecl => lib::llvm::CCallConv,
|
||||
ast::foreign_abi_stdcall => lib::llvm::X86StdcallCallConv
|
||||
};
|
||||
|
||||
for vec::each(foreign_mod.items) |foreign_item| {
|
||||
alt foreign_item.node {
|
||||
match foreign_item.node {
|
||||
ast::foreign_item_fn(fn_decl, typarams) => {
|
||||
let id = foreign_item.id;
|
||||
if abi != ast::foreign_abi_rust_intrinsic {
|
||||
|
|
@ -772,7 +772,7 @@ fn trans_foreign_mod(ccx: @crate_ctxt,
|
|||
// monomorphic_fn, but ones without are emitted here
|
||||
if typarams.is_empty() {
|
||||
let llwrapfn = get_item_val(ccx, id);
|
||||
let path = alt ccx.tcx.items.find(id) {
|
||||
let path = match ccx.tcx.items.find(id) {
|
||||
some(ast_map::node_foreign_item(_, _, pt)) => pt,
|
||||
_ => {
|
||||
ccx.sess.span_bug(foreign_item.span,
|
||||
|
|
@ -799,7 +799,7 @@ fn trans_intrinsic(ccx: @crate_ctxt, decl: ValueRef, item: @ast::foreign_item,
|
|||
let fcx = new_fn_ctxt_w_id(ccx, path, decl, item.id,
|
||||
some(substs), some(item.span));
|
||||
let mut bcx = top_scope_block(fcx, none), lltop = bcx.llbb;
|
||||
alt check *item.ident {
|
||||
match check *item.ident {
|
||||
~"atomic_xchng" => {
|
||||
let old = AtomicRMW(bcx, Xchg,
|
||||
get_param(decl, first_real_arg),
|
||||
|
|
@ -925,7 +925,7 @@ fn trans_intrinsic(ccx: @crate_ctxt, decl: ValueRef, item: @ast::foreign_item,
|
|||
let tp_sz = shape::llsize_of_real(ccx, lltp_ty),
|
||||
out_sz = shape::llsize_of_real(ccx, llout_ty);
|
||||
if tp_sz != out_sz {
|
||||
let sp = alt check ccx.tcx.items.get(option::get(ref_id)) {
|
||||
let sp = match check ccx.tcx.items.get(option::get(ref_id)) {
|
||||
ast_map::node_expr(e) => e.span
|
||||
};
|
||||
ccx.sess.span_fatal(
|
||||
|
|
@ -1045,7 +1045,7 @@ fn trans_foreign_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl,
|
|||
fn build_args(bcx: block, tys: @c_stack_tys,
|
||||
llwrapfn: ValueRef, llargbundle: ValueRef) {
|
||||
let _icx = bcx.insn_ctxt(~"foreign::foreign::wrap::build_args");
|
||||
alt tys.x86_64_tys {
|
||||
match tys.x86_64_tys {
|
||||
option::some(x86_64) => {
|
||||
let mut atys = x86_64.arg_tys;
|
||||
let mut attrs = x86_64.attrs;
|
||||
|
|
@ -1099,7 +1099,7 @@ fn trans_foreign_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl,
|
|||
fn build_ret(bcx: block, tys: @c_stack_tys,
|
||||
llargbundle: ValueRef) {
|
||||
let _icx = bcx.insn_ctxt(~"foreign::foreign::wrap::build_ret");
|
||||
alt tys.x86_64_tys {
|
||||
match tys.x86_64_tys {
|
||||
option::some(x86_64) => {
|
||||
if x86_64.sret || !tys.ret_def {
|
||||
RetVoid(bcx);
|
||||
|
|
@ -1161,11 +1161,11 @@ fn register_foreign_fn(ccx: @crate_ctxt, sp: span,
|
|||
|
||||
fn abi_of_foreign_fn(ccx: @crate_ctxt, i: @ast::foreign_item)
|
||||
-> ast::foreign_abi {
|
||||
alt attr::first_attr_value_str_by_name(i.attrs, ~"abi") {
|
||||
none => alt check ccx.tcx.items.get(i.id) {
|
||||
match attr::first_attr_value_str_by_name(i.attrs, ~"abi") {
|
||||
none => match check ccx.tcx.items.get(i.id) {
|
||||
ast_map::node_foreign_item(_, abi, _) => abi
|
||||
}
|
||||
some(_) => alt attr::foreign_abi(i.attrs) {
|
||||
some(_) => match attr::foreign_abi(i.attrs) {
|
||||
either::right(abi) => abi,
|
||||
either::left(msg) => ccx.sess.span_fatal(i.span, msg)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ fn trans_method_callee(bcx: block, callee_id: ast::node_id,
|
|||
self: @ast::expr, mentry: typeck::method_map_entry)
|
||||
-> lval_maybe_callee {
|
||||
let _icx = bcx.insn_ctxt(~"impl::trans_method_callee");
|
||||
alt mentry.origin {
|
||||
match mentry.origin {
|
||||
typeck::method_static(did) => {
|
||||
let {bcx, val} = trans_self_arg(bcx, self, mentry.derefs);
|
||||
{env: self_env(val, node_id_type(bcx, self.id), none)
|
||||
|
|
@ -60,7 +60,7 @@ fn trans_method_callee(bcx: block, callee_id: ast::node_id,
|
|||
}
|
||||
typeck::method_param({trait_id:iid, method_num:off,
|
||||
param_num:p, bound_num:b}) => {
|
||||
alt check bcx.fcx.param_substs {
|
||||
match check bcx.fcx.param_substs {
|
||||
some(substs) => {
|
||||
trans_monomorphized_callee(bcx, callee_id, self, mentry.derefs,
|
||||
iid, off, p, b, substs)
|
||||
|
|
@ -83,7 +83,7 @@ fn method_from_methods(ms: ~[@ast::method], name: ast::ident)
|
|||
fn method_with_name(ccx: @crate_ctxt, impl_id: ast::def_id,
|
||||
name: ast::ident) -> ast::def_id {
|
||||
if impl_id.crate == ast::local_crate {
|
||||
alt check ccx.tcx.items.get(impl_id.node) {
|
||||
match check ccx.tcx.items.get(impl_id.node) {
|
||||
ast_map::node_item(@{node: ast::item_impl(_, _, _, ms), _}, _) => {
|
||||
method_from_methods(ms, name)
|
||||
}
|
||||
|
|
@ -101,7 +101,7 @@ fn method_with_name(ccx: @crate_ctxt, impl_id: ast::def_id,
|
|||
fn method_ty_param_count(ccx: @crate_ctxt, m_id: ast::def_id,
|
||||
i_id: ast::def_id) -> uint {
|
||||
if m_id.crate == ast::local_crate {
|
||||
alt check ccx.tcx.items.get(m_id.node) {
|
||||
match check ccx.tcx.items.get(m_id.node) {
|
||||
ast_map::node_method(m, _, _) => vec::len(m.tps),
|
||||
}
|
||||
} else {
|
||||
|
|
@ -116,7 +116,7 @@ fn trans_monomorphized_callee(bcx: block, callee_id: ast::node_id,
|
|||
n_param: uint, n_bound: uint,
|
||||
substs: param_substs) -> lval_maybe_callee {
|
||||
let _icx = bcx.insn_ctxt(~"impl::trans_monomorphized_callee");
|
||||
alt find_vtable_in_fn_ctxt(substs, n_param, n_bound) {
|
||||
match find_vtable_in_fn_ctxt(substs, n_param, n_bound) {
|
||||
typeck::vtable_static(impl_did, impl_substs, sub_origins) => {
|
||||
let ccx = bcx.ccx();
|
||||
let mname = ty::trait_methods(ccx.tcx, trait_id)[n_method].ident;
|
||||
|
|
@ -173,7 +173,7 @@ fn find_vtable_in_fn_ctxt(ps: param_substs, n_param: uint, n_bound: uint)
|
|||
for vec::each(*ps.bounds) |bounds| {
|
||||
if i >= n_param { break; }
|
||||
for vec::each(*bounds) |bound| {
|
||||
alt bound { ty::bound_trait(_) => vtable_off += 1u, _ => () }
|
||||
match bound { ty::bound_trait(_) => vtable_off += 1u, _ => () }
|
||||
}
|
||||
i += 1u;
|
||||
}
|
||||
|
|
@ -189,9 +189,9 @@ fn resolve_vtables_in_fn_ctxt(fcx: fn_ctxt, vts: typeck::vtable_res)
|
|||
// eliminate any vtable_params.
|
||||
fn resolve_vtable_in_fn_ctxt(fcx: fn_ctxt, vt: typeck::vtable_origin)
|
||||
-> typeck::vtable_origin {
|
||||
alt vt {
|
||||
match vt {
|
||||
typeck::vtable_static(iid, tys, sub) => {
|
||||
let tys = alt fcx.param_substs {
|
||||
let tys = match fcx.param_substs {
|
||||
some(substs) => {
|
||||
vec::map(tys, |t| ty::subst_tps(fcx.ccx.tcx, substs.tys, t))
|
||||
}
|
||||
|
|
@ -200,7 +200,7 @@ fn resolve_vtable_in_fn_ctxt(fcx: fn_ctxt, vt: typeck::vtable_origin)
|
|||
typeck::vtable_static(iid, tys, resolve_vtables_in_fn_ctxt(fcx, sub))
|
||||
}
|
||||
typeck::vtable_param(n_param, n_bound) => {
|
||||
alt check fcx.param_substs {
|
||||
match check fcx.param_substs {
|
||||
some(substs) => {
|
||||
find_vtable_in_fn_ctxt(substs, n_param, n_bound)
|
||||
}
|
||||
|
|
@ -211,7 +211,7 @@ fn resolve_vtable_in_fn_ctxt(fcx: fn_ctxt, vt: typeck::vtable_origin)
|
|||
}
|
||||
|
||||
fn vtable_id(ccx: @crate_ctxt, origin: typeck::vtable_origin) -> mono_id {
|
||||
alt check origin {
|
||||
match check origin {
|
||||
typeck::vtable_static(impl_id, substs, sub_vtables) => {
|
||||
make_mono_id(ccx, impl_id, substs,
|
||||
if (*sub_vtables).len() == 0u { none }
|
||||
|
|
@ -227,9 +227,9 @@ fn vtable_id(ccx: @crate_ctxt, origin: typeck::vtable_origin) -> mono_id {
|
|||
fn get_vtable(ccx: @crate_ctxt, origin: typeck::vtable_origin)
|
||||
-> ValueRef {
|
||||
let hash_id = vtable_id(ccx, origin);
|
||||
alt ccx.vtables.find(hash_id) {
|
||||
match ccx.vtables.find(hash_id) {
|
||||
some(val) => val,
|
||||
none => alt check origin {
|
||||
none => match check origin {
|
||||
typeck::vtable_static(id, substs, sub_vtables) => {
|
||||
make_impl_vtable(ccx, id, substs, sub_vtables)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,11 +34,11 @@ fn find_reachable(crate_mod: _mod, exp_map: resolve3::ExportMap,
|
|||
fn traverse_exports(cx: ctx, vis: ~[@view_item]) -> bool {
|
||||
let mut found_export = false;
|
||||
for vec::each(vis) |vi| {
|
||||
alt vi.node {
|
||||
match vi.node {
|
||||
view_item_export(vps) => {
|
||||
found_export = true;
|
||||
for vec::each(vps) |vp| {
|
||||
alt vp.node {
|
||||
match vp.node {
|
||||
view_path_simple(_, _, id) | view_path_glob(_, id) |
|
||||
view_path_list(_, _, id) => {
|
||||
traverse_export(cx, id);
|
||||
|
|
@ -60,11 +60,11 @@ fn traverse_export(cx: ctx, exp_id: node_id) {
|
|||
|
||||
fn traverse_def_id(cx: ctx, did: def_id) {
|
||||
if did.crate != local_crate { return; }
|
||||
let n = alt cx.tcx.items.find(did.node) {
|
||||
let n = match cx.tcx.items.find(did.node) {
|
||||
none => return, // This can happen for self, for example
|
||||
some(n) => n
|
||||
};
|
||||
alt n {
|
||||
match n {
|
||||
ast_map::node_item(item, _) => traverse_public_item(cx, item),
|
||||
ast_map::node_method(_, impl_id, _) => traverse_def_id(cx, impl_id),
|
||||
ast_map::node_foreign_item(item, _, _) => {
|
||||
|
|
@ -89,7 +89,7 @@ fn traverse_public_mod(cx: ctx, m: _mod) {
|
|||
fn traverse_public_item(cx: ctx, item: @item) {
|
||||
if cx.rmap.contains_key(item.id) { return; }
|
||||
cx.rmap.insert(item.id, ());
|
||||
alt item.node {
|
||||
match item.node {
|
||||
item_mod(m) => traverse_public_mod(cx, m),
|
||||
item_foreign_mod(nm) => {
|
||||
if !traverse_exports(cx, nm.view_items) {
|
||||
|
|
@ -127,7 +127,7 @@ fn traverse_public_item(cx: ctx, item: @item) {
|
|||
}
|
||||
}
|
||||
for vec::each(items) |item| {
|
||||
alt item.node {
|
||||
match item.node {
|
||||
class_method(m) => {
|
||||
cx.rmap.insert(m.id, ());
|
||||
if tps.len() > 0u ||
|
||||
|
|
@ -156,9 +156,9 @@ fn traverse_ty(ty: @ty, cx: ctx, v: visit::vt<ctx>) {
|
|||
if cx.rmap.contains_key(ty.id) { return; }
|
||||
cx.rmap.insert(ty.id, ());
|
||||
|
||||
alt ty.node {
|
||||
match ty.node {
|
||||
ty_path(p, p_id) => {
|
||||
alt cx.tcx.def_map.find(p_id) {
|
||||
match cx.tcx.def_map.find(p_id) {
|
||||
// Kind of a hack to check this here, but I'm not sure what else
|
||||
// to do
|
||||
some(def_prim_ty(_)) => { /* do nothing */ }
|
||||
|
|
@ -173,9 +173,9 @@ fn traverse_ty(ty: @ty, cx: ctx, v: visit::vt<ctx>) {
|
|||
|
||||
fn traverse_inline_body(cx: ctx, body: blk) {
|
||||
fn traverse_expr(e: @expr, cx: ctx, v: visit::vt<ctx>) {
|
||||
alt e.node {
|
||||
match e.node {
|
||||
expr_path(_) => {
|
||||
alt cx.tcx.def_map.find(e.id) {
|
||||
match cx.tcx.def_map.find(e.id) {
|
||||
some(d) => {
|
||||
traverse_def_id(cx, def_id_of_def(d));
|
||||
}
|
||||
|
|
@ -184,7 +184,7 @@ fn traverse_inline_body(cx: ctx, body: blk) {
|
|||
}
|
||||
}
|
||||
expr_field(_, _, _) => {
|
||||
alt cx.method_map.find(e.id) {
|
||||
match cx.method_map.find(e.id) {
|
||||
some({origin: typeck::method_static(did), _}) => {
|
||||
traverse_def_id(cx, did);
|
||||
}
|
||||
|
|
@ -213,7 +213,7 @@ fn traverse_all_resources_and_impls(cx: ctx, crate_mod: _mod) {
|
|||
visit_expr: |_e, _cx, _v| { },
|
||||
visit_item: |i, cx, v| {
|
||||
visit::visit_item(i, cx, v);
|
||||
alt i.node {
|
||||
match i.node {
|
||||
item_class(_, _, _, _, some(_)) => {
|
||||
traverse_public_item(cx, i);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ impl methods for reflector {
|
|||
fn vstore_name_and_extra(t: ty::t,
|
||||
vstore: ty::vstore,
|
||||
f: fn(~str,~[ValueRef])) {
|
||||
alt vstore {
|
||||
match vstore {
|
||||
ty::vstore_fixed(n) => {
|
||||
let extra = vec::append(~[self.c_uint(n)],
|
||||
self.c_size_and_align(t));
|
||||
|
|
@ -114,7 +114,7 @@ impl methods for reflector {
|
|||
debug!{"reflect::visit_ty %s",
|
||||
ty_to_str(bcx.ccx().tcx, t)};
|
||||
|
||||
alt ty::get(t).struct {
|
||||
match ty::get(t).struct {
|
||||
ty::ty_bot => self.leaf(~"bot"),
|
||||
ty::ty_nil => self.leaf(~"nil"),
|
||||
ty::ty_bool => self.leaf(~"bool"),
|
||||
|
|
@ -178,19 +178,19 @@ impl methods for reflector {
|
|||
// FIXME (#2594): fetch constants out of intrinsic:: for the
|
||||
// numbers.
|
||||
ty::ty_fn(fty) => {
|
||||
let pureval = alt fty.purity {
|
||||
let pureval = match fty.purity {
|
||||
ast::pure_fn => 0u,
|
||||
ast::unsafe_fn => 1u,
|
||||
ast::impure_fn => 2u,
|
||||
ast::extern_fn => 3u
|
||||
};
|
||||
let protoval = alt fty.proto {
|
||||
let protoval = match fty.proto {
|
||||
ast::proto_bare => 0u,
|
||||
ast::proto_uniq => 2u,
|
||||
ast::proto_box => 3u,
|
||||
ast::proto_block => 4u
|
||||
};
|
||||
let retval = alt fty.ret_style {
|
||||
let retval = match fty.ret_style {
|
||||
ast::noreturn => 0u,
|
||||
ast::return_val => 1u
|
||||
};
|
||||
|
|
@ -200,9 +200,9 @@ impl methods for reflector {
|
|||
self.c_uint(retval)];
|
||||
self.visit(~"enter_fn", extra);
|
||||
for fty.inputs.eachi |i, arg| {
|
||||
let modeval = alt arg.mode {
|
||||
let modeval = match arg.mode {
|
||||
ast::infer(_) => 0u,
|
||||
ast::expl(e) => alt e {
|
||||
ast::expl(e) => match e {
|
||||
ast::by_ref => 1u,
|
||||
ast::by_val => 2u,
|
||||
ast::by_mutbl_ref => 3u,
|
||||
|
|
@ -274,7 +274,7 @@ impl methods for reflector {
|
|||
ty::ty_type => self.leaf(~"type"),
|
||||
ty::ty_opaque_box => self.leaf(~"opaque_box"),
|
||||
ty::ty_opaque_closure_ptr(ck) => {
|
||||
let ckval = alt ck {
|
||||
let ckval = match ck {
|
||||
ty::ck_block => 0u,
|
||||
ty::ck_box => 1u,
|
||||
ty::ck_uniq => 2u
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@ fn enum_kind(ccx: @crate_ctxt, did: ast::def_id) -> enum_kind {
|
|||
|
||||
// Returns the code corresponding to the pointer size on this architecture.
|
||||
fn s_int(tcx: ty_ctxt) -> u8 {
|
||||
return alt tcx.sess.targ_cfg.arch {
|
||||
return match tcx.sess.targ_cfg.arch {
|
||||
session::arch_x86 => shape_i32,
|
||||
session::arch_x86_64 => shape_i64,
|
||||
session::arch_arm => shape_i32
|
||||
|
|
@ -157,7 +157,7 @@ fn s_int(tcx: ty_ctxt) -> u8 {
|
|||
}
|
||||
|
||||
fn s_uint(tcx: ty_ctxt) -> u8 {
|
||||
return alt tcx.sess.targ_cfg.arch {
|
||||
return match tcx.sess.targ_cfg.arch {
|
||||
session::arch_x86 => shape_u32,
|
||||
session::arch_x86_64 => shape_u64,
|
||||
session::arch_arm => shape_u32
|
||||
|
|
@ -165,7 +165,7 @@ fn s_uint(tcx: ty_ctxt) -> u8 {
|
|||
}
|
||||
|
||||
fn s_float(tcx: ty_ctxt) -> u8 {
|
||||
return alt tcx.sess.targ_cfg.arch {
|
||||
return match tcx.sess.targ_cfg.arch {
|
||||
session::arch_x86 => shape_f64,
|
||||
session::arch_x86_64 => shape_f64,
|
||||
session::arch_arm => shape_f64
|
||||
|
|
@ -213,7 +213,7 @@ fn add_substr(&dest: ~[u8], src: ~[u8]) {
|
|||
}
|
||||
|
||||
fn shape_of(ccx: @crate_ctxt, t: ty::t) -> ~[u8] {
|
||||
alt ty::get(t).struct {
|
||||
match ty::get(t).struct {
|
||||
ty::ty_nil | ty::ty_bool | ty::ty_uint(ast::ty_u8) |
|
||||
ty::ty_bot => ~[shape_u8],
|
||||
ty::ty_int(ast::ty_i) => ~[s_int(ccx.tcx)],
|
||||
|
|
@ -233,13 +233,13 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t) -> ~[u8] {
|
|||
shape_of(ccx, tvec::expand_boxed_vec_ty(ccx.tcx, t))
|
||||
}
|
||||
ty::ty_enum(did, substs) => {
|
||||
alt enum_kind(ccx, did) {
|
||||
match enum_kind(ccx, did) {
|
||||
tk_unit => ~[s_variant_enum_t(ccx.tcx)],
|
||||
tk_enum => ~[s_variant_enum_t(ccx.tcx)],
|
||||
tk_newtype | tk_complex => {
|
||||
let mut s = ~[shape_enum], id;
|
||||
let nom_id = mk_nominal_id(ccx.tcx, did, none, substs.tps);
|
||||
alt ccx.shape_cx.tag_id_to_index.find(nom_id) {
|
||||
match ccx.shape_cx.tag_id_to_index.find(nom_id) {
|
||||
none => {
|
||||
id = ccx.shape_cx.next_tag_id;
|
||||
ccx.shape_cx.tag_id_to_index.insert(nom_id, id);
|
||||
|
|
@ -678,7 +678,7 @@ fn llalign_of(cx: @crate_ctxt, t: TypeRef) -> ValueRef {
|
|||
// Computes the size of the data part of an enum.
|
||||
fn static_size_of_enum(cx: @crate_ctxt, t: ty::t) -> uint {
|
||||
if cx.enum_sizes.contains_key(t) { return cx.enum_sizes.get(t); }
|
||||
alt ty::get(t).struct {
|
||||
match ty::get(t).struct {
|
||||
ty::ty_enum(tid, substs) => {
|
||||
// Compute max(variant sizes).
|
||||
let mut max_size = 0u;
|
||||
|
|
@ -712,7 +712,7 @@ fn simplify_type(tcx: ty::ctxt, typ: ty::t) -> ty::t {
|
|||
ty::mk_ptr(tcx, {ty: ty::mk_nil(tcx), mutbl: ast::m_imm})
|
||||
}
|
||||
fn simplifier(tcx: ty::ctxt, typ: ty::t) -> ty::t {
|
||||
alt ty::get(typ).struct {
|
||||
match ty::get(typ).struct {
|
||||
ty::ty_box(_) | ty::ty_opaque_box | ty::ty_uniq(_) |
|
||||
ty::ty_evec(_, ty::vstore_uniq) | ty::ty_evec(_, ty::vstore_box) |
|
||||
ty::ty_estr(ty::vstore_uniq) | ty::ty_estr(ty::vstore_box) |
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ import util::ppaux::ty_to_str;
|
|||
fn expand_boxed_vec_ty(tcx: ty::ctxt, t: ty::t) -> ty::t {
|
||||
let unit_ty = ty::sequence_element_type(tcx, t);
|
||||
let unboxed_vec_ty = ty::mk_mut_unboxed_vec(tcx, unit_ty);
|
||||
alt ty::get(t).struct {
|
||||
match ty::get(t).struct {
|
||||
ty::ty_estr(ty::vstore_uniq) | ty::ty_evec(_, ty::vstore_uniq) => {
|
||||
ty::mk_imm_uniq(tcx, unboxed_vec_ty)
|
||||
}
|
||||
|
|
@ -156,10 +156,10 @@ fn trans_evec(bcx: block, elements: evec_elements,
|
|||
let unit_sz = llsize_of(ccx, llunitty);
|
||||
|
||||
let mut {bcx, val, dataptr} =
|
||||
alt vst {
|
||||
match vst {
|
||||
ast::vstore_fixed(_) => {
|
||||
// Destination should be pre-allocated for us.
|
||||
let v = alt dest {
|
||||
let v = match dest {
|
||||
base::save_in(v) => {
|
||||
PointerCast(bcx, v, T_ptr(llunitty))
|
||||
}
|
||||
|
|
@ -245,7 +245,7 @@ fn trans_evec(bcx: block, elements: evec_elements,
|
|||
|
||||
for vec::each(temp_cleanups) |cln| { revoke_clean(bcx, cln); }
|
||||
|
||||
alt vst {
|
||||
match vst {
|
||||
ast::vstore_fixed(_) => {
|
||||
// We wrote into the destination in the fixed case.
|
||||
return bcx;
|
||||
|
|
@ -261,7 +261,7 @@ fn trans_evec(bcx: block, elements: evec_elements,
|
|||
|
||||
fn trans_vstore(bcx: block, e: @ast::expr,
|
||||
v: ast::vstore, dest: dest) -> block {
|
||||
alt e.node {
|
||||
match e.node {
|
||||
ast::expr_lit(@{node: ast::lit_str(s), span: _}) => {
|
||||
return trans_estr(bcx, s, some(v), dest);
|
||||
}
|
||||
|
|
@ -288,12 +288,12 @@ fn get_base_and_len(cx: block, v: ValueRef, e_ty: ty::t)
|
|||
let llunitty = type_of::type_of(ccx, unit_ty);
|
||||
let unit_sz = llsize_of(ccx, llunitty);
|
||||
|
||||
let vstore = alt ty::get(vec_ty).struct {
|
||||
let vstore = match ty::get(vec_ty).struct {
|
||||
ty::ty_estr(vst) | ty::ty_evec(_, vst) => vst,
|
||||
_ => ty::vstore_uniq
|
||||
};
|
||||
|
||||
alt vstore {
|
||||
match vstore {
|
||||
ty::vstore_fixed(n) => {
|
||||
let base = GEPi(cx, v, ~[0u, 0u]);
|
||||
let n = if ty::type_is_str(e_ty) { n + 1u } else { n };
|
||||
|
|
@ -319,7 +319,7 @@ fn trans_estr(bcx: block, s: @~str, vstore: option<ast::vstore>,
|
|||
if dest == base::ignore { return bcx; }
|
||||
let ccx = bcx.ccx();
|
||||
|
||||
let c = alt vstore {
|
||||
let c = match vstore {
|
||||
some(ast::vstore_fixed(_)) => {
|
||||
// "hello"/_ => "hello"/5 => ~[i8 x 6] in llvm
|
||||
debug!{"trans_estr: fixed: %s", *s};
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ fn type_of_explicit_args(cx: @crate_ctxt,
|
|||
do vec::map(inputs) |arg| {
|
||||
let arg_ty = arg.ty;
|
||||
let llty = type_of(cx, arg_ty);
|
||||
alt ty::resolved_mode(cx.tcx, arg.mode) {
|
||||
match ty::resolved_mode(cx.tcx, arg.mode) {
|
||||
ast::by_val => llty,
|
||||
_ => T_ptr(llty)
|
||||
}
|
||||
|
|
@ -51,7 +51,7 @@ fn type_of_non_gc_box(cx: @crate_ctxt, t: ty::t) -> TypeRef {
|
|||
if t != t_norm {
|
||||
type_of_non_gc_box(cx, t_norm)
|
||||
} else {
|
||||
alt ty::get(t).struct {
|
||||
match ty::get(t).struct {
|
||||
ty::ty_box(mt) => {
|
||||
T_ptr(T_box(cx, type_of(cx, mt.ty)))
|
||||
}
|
||||
|
|
@ -83,7 +83,7 @@ fn type_of(cx: @crate_ctxt, t: ty::t) -> TypeRef {
|
|||
llty = type_of(cx, t_norm);
|
||||
cx.lltypes.insert(t, llty);
|
||||
} else {
|
||||
llty = alt ty::get(t).struct {
|
||||
llty = match ty::get(t).struct {
|
||||
ty::ty_nil | ty::ty_bot => T_nil(),
|
||||
ty::ty_bool => T_bool(),
|
||||
ty::ty_int(t) => T_int_ty(cx, t),
|
||||
|
|
@ -166,7 +166,7 @@ fn type_of(cx: @crate_ctxt, t: ty::t) -> TypeRef {
|
|||
cx.lltypes.insert(t, llty);
|
||||
|
||||
// If this was a class, fill in the type now.
|
||||
alt ty::get(t).struct {
|
||||
match ty::get(t).struct {
|
||||
ty::ty_class(did, ts) => {
|
||||
// Only instance vars are record fields at runtime.
|
||||
let fields = ty::lookup_class_fields(cx.tcx, did);
|
||||
|
|
@ -225,7 +225,7 @@ fn type_of_enum(cx: @crate_ctxt, did: ast::def_id, t: ty::t)
|
|||
}
|
||||
|
||||
fn llvm_type_name(cx: @crate_ctxt, t: ty::t) -> ~str {
|
||||
let (name, did, tps) = alt check ty::get(t).struct {
|
||||
let (name, did, tps) = match check ty::get(t).struct {
|
||||
ty::ty_enum(did, substs) => (~"enum", did, substs.tps),
|
||||
ty::ty_class(did, substs) => (~"class", did, substs.tps)
|
||||
};
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ type ctx = {ccx: @crate_ctxt,
|
|||
|
||||
fn type_uses_for(ccx: @crate_ctxt, fn_id: def_id, n_tps: uint)
|
||||
-> ~[type_uses] {
|
||||
alt ccx.type_use_cache.find(fn_id) {
|
||||
match ccx.type_use_cache.find(fn_id) {
|
||||
some(uses) => return uses,
|
||||
none => ()
|
||||
}
|
||||
|
|
@ -45,7 +45,7 @@ fn type_uses_for(ccx: @crate_ctxt, fn_id: def_id, n_tps: uint)
|
|||
ccx.type_use_cache.insert(fn_id, vec::from_elem(n_tps, 3u));
|
||||
|
||||
let cx = {ccx: ccx, uses: vec::to_mut(vec::from_elem(n_tps, 0u))};
|
||||
alt ty::get(ty::lookup_item_type(cx.ccx.tcx, fn_id).ty).struct {
|
||||
match ty::get(ty::lookup_item_type(cx.ccx.tcx, fn_id).ty).struct {
|
||||
ty::ty_fn({inputs, _}) => {
|
||||
for vec::each(inputs) |arg| {
|
||||
if arg.mode == expl(by_val) { type_needs(cx, use_repr, arg.ty); }
|
||||
|
|
@ -59,12 +59,12 @@ fn type_uses_for(ccx: @crate_ctxt, fn_id: def_id, n_tps: uint)
|
|||
ccx.type_use_cache.insert(fn_id, uses);
|
||||
return uses;
|
||||
}
|
||||
let map_node = alt ccx.tcx.items.find(fn_id_loc.node) {
|
||||
let map_node = match ccx.tcx.items.find(fn_id_loc.node) {
|
||||
some(x) => x,
|
||||
none => ccx.sess.bug(fmt!{"type_uses_for: unbound item ID %?",
|
||||
fn_id_loc})
|
||||
};
|
||||
alt check map_node {
|
||||
match check map_node {
|
||||
ast_map::node_item(@{node: item_fn(_, _, body), _}, _) |
|
||||
ast_map::node_method(@{body, _}, _, _) => {
|
||||
handle_body(cx, body);
|
||||
|
|
@ -75,7 +75,7 @@ fn type_uses_for(ccx: @crate_ctxt, fn_id: def_id, n_tps: uint)
|
|||
ast_map::node_foreign_item(i@@{node: foreign_item_fn(_, _), _},
|
||||
abi, _) => {
|
||||
if abi == foreign_abi_rust_intrinsic {
|
||||
let flags = alt check *i.ident {
|
||||
let flags = match check *i.ident {
|
||||
~"size_of" | ~"pref_align_of" | ~"min_align_of" |
|
||||
~"init" | ~"reinterpret_cast" |
|
||||
~"move_val" | ~"move_val_init" => {
|
||||
|
|
@ -120,7 +120,7 @@ fn type_needs_inner(cx: ctx, use: uint, ty: ty::t,
|
|||
enums_seen: @list<def_id>) {
|
||||
do ty::maybe_walk_ty(ty) |ty| {
|
||||
if ty::type_has_params(ty) {
|
||||
alt ty::get(ty).struct {
|
||||
match ty::get(ty).struct {
|
||||
/*
|
||||
This previously included ty_box -- that was wrong
|
||||
because if we cast an @T to an trait (for example) and return
|
||||
|
|
@ -156,7 +156,7 @@ fn node_type_needs(cx: ctx, use: uint, id: node_id) {
|
|||
}
|
||||
|
||||
fn mark_for_expr(cx: ctx, e: @expr) {
|
||||
alt e.node {
|
||||
match e.node {
|
||||
expr_vstore(_, _) |
|
||||
expr_vec(_, _) |
|
||||
expr_rec(_, _) | expr_struct(*) | expr_tup(_) |
|
||||
|
|
@ -168,7 +168,7 @@ fn mark_for_expr(cx: ctx, e: @expr) {
|
|||
}
|
||||
expr_cast(base, _) => {
|
||||
let result_t = ty::node_id_to_type(cx.ccx.tcx, e.id);
|
||||
alt ty::get(result_t).struct {
|
||||
match ty::get(result_t).struct {
|
||||
ty::ty_trait(*) => {
|
||||
// When we're casting to an trait, we need the
|
||||
// tydesc for the expr that's being cast.
|
||||
|
|
@ -178,7 +178,7 @@ fn mark_for_expr(cx: ctx, e: @expr) {
|
|||
}
|
||||
}
|
||||
expr_binary(op, lhs, _) => {
|
||||
alt op {
|
||||
match op {
|
||||
eq | lt | le | ne | ge | gt => {
|
||||
node_type_needs(cx, use_tydesc, lhs.id)
|
||||
}
|
||||
|
|
@ -195,7 +195,7 @@ fn mark_for_expr(cx: ctx, e: @expr) {
|
|||
}
|
||||
}
|
||||
expr_fn(*) | expr_fn_block(*) => {
|
||||
alt ty::ty_fn_proto(ty::expr_ty(cx.ccx.tcx, e)) {
|
||||
match ty::ty_fn_proto(ty::expr_ty(cx.ccx.tcx, e)) {
|
||||
proto_bare | proto_uniq => {}
|
||||
proto_box | proto_block => {
|
||||
for vec::each(*freevars::get_freevars(cx.ccx.tcx, e.id)) |fv| {
|
||||
|
|
@ -216,7 +216,7 @@ fn mark_for_expr(cx: ctx, e: @expr) {
|
|||
type_needs(cx, use_repr, ty::type_autoderef(cx.ccx.tcx, base_ty));
|
||||
|
||||
do option::iter(cx.ccx.maps.method_map.find(e.id)) |mth| {
|
||||
alt mth.origin {
|
||||
match mth.origin {
|
||||
typeck::method_static(did) => {
|
||||
do option::iter(cx.ccx.tcx.node_type_substs.find(e.id)) |ts| {
|
||||
do vec::iter2(type_uses_for(cx.ccx, did, ts.len()), ts)
|
||||
|
|
@ -235,7 +235,7 @@ fn mark_for_expr(cx: ctx, e: @expr) {
|
|||
}
|
||||
expr_call(f, _, _) => {
|
||||
vec::iter(ty::ty_fn_args(ty::node_id_to_type(cx.ccx.tcx, f.id)), |a| {
|
||||
alt a.mode {
|
||||
match a.mode {
|
||||
expl(by_move) | expl(by_copy) | expl(by_val) => {
|
||||
type_needs(cx, use_repr, a.ty);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ fn make_free_glue(bcx: block, vptr: ValueRef, t: ty::t)
|
|||
}
|
||||
|
||||
fn content_ty(t: ty::t) -> ty::t {
|
||||
alt ty::get(t).struct {
|
||||
match ty::get(t).struct {
|
||||
ty::ty_uniq({ty: ct, _}) => ct,
|
||||
_ => core::unreachable()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -240,7 +240,7 @@ fn implies(a: t, b: t) -> bool {
|
|||
}
|
||||
|
||||
fn trit_str(t: trit) -> ~str {
|
||||
alt t { dont_care { ~"?" } ttrue { ~"1" } tfalse { ~"0" } }
|
||||
match t { dont_care { ~"?" } ttrue { ~"1" } tfalse { ~"0" } }
|
||||
}
|
||||
|
||||
// FIXME (#2538): Would be nice to have unit tests for some of these
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ fn collect_ids_block(b: blk, rs: @mut ~[node_id]) {
|
|||
}
|
||||
|
||||
fn collect_ids_stmt(s: @stmt, rs: @mut ~[node_id]) {
|
||||
alt s.node {
|
||||
match s.node {
|
||||
stmt_decl(_, id) | stmt_expr(_, id) | stmt_semi(_, id) {
|
||||
debug!{"node_id %s", int::str(id)};
|
||||
debug!{"%s", stmt_to_str(*s)};
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ fn comma_str(args: ~[@constr_arg_use]) -> ~str {
|
|||
let mut comma = false;
|
||||
for args.each |a| {
|
||||
if comma { rslt += ~", "; } else { comma = true; }
|
||||
alt a.node {
|
||||
match a.node {
|
||||
carg_base { rslt += ~"*"; }
|
||||
carg_ident(i) { rslt += *i.ident; }
|
||||
carg_lit(l) { rslt += lit_to_str(l); }
|
||||
|
|
@ -59,7 +59,7 @@ fn tritv_to_str(fcx: fn_ctxt, v: tritv::t) -> ~str {
|
|||
let mut s = ~"";
|
||||
let mut comma = false;
|
||||
for constraints(fcx).each |p| {
|
||||
alt v.get(p.bit_num) {
|
||||
match v.get(p.bit_num) {
|
||||
dont_care { }
|
||||
tt {
|
||||
s +=
|
||||
|
|
@ -261,7 +261,7 @@ fn get_ts_ann(ccx: crate_ctxt, i: node_id) -> option<ts_ann> {
|
|||
|
||||
/********* utils ********/
|
||||
fn node_id_to_ts_ann(ccx: crate_ctxt, id: node_id) -> ts_ann {
|
||||
alt get_ts_ann(ccx, id) {
|
||||
match get_ts_ann(ccx, id) {
|
||||
none {
|
||||
error!{"node_id_to_ts_ann: no ts_ann for node_id %d", id};
|
||||
fail;
|
||||
|
|
@ -277,7 +277,7 @@ fn node_id_to_poststate(ccx: crate_ctxt, id: node_id) -> poststate {
|
|||
|
||||
fn stmt_to_ann(ccx: crate_ctxt, s: stmt) -> ts_ann {
|
||||
debug!{"stmt_to_ann"};
|
||||
alt s.node {
|
||||
match s.node {
|
||||
stmt_decl(_, id) | stmt_expr(_, id) | stmt_semi(_, id) {
|
||||
return node_id_to_ts_ann(ccx, id);
|
||||
}
|
||||
|
|
@ -445,21 +445,21 @@ fn new_crate_ctxt(cx: ty::ctxt) -> crate_ctxt {
|
|||
If it has a function type with a ! annotation,
|
||||
the answer is noreturn. */
|
||||
fn controlflow_expr(ccx: crate_ctxt, e: @expr) -> ret_style {
|
||||
alt ty::get(ty::node_id_to_type(ccx.tcx, e.id)).struct {
|
||||
match ty::get(ty::node_id_to_type(ccx.tcx, e.id)).struct {
|
||||
ty::ty_fn(f) { return f.ret_style; }
|
||||
_ { return return_val; }
|
||||
}
|
||||
}
|
||||
|
||||
fn constraints_expr(cx: ty::ctxt, e: @expr) -> ~[@ty::constr] {
|
||||
alt ty::get(ty::node_id_to_type(cx, e.id)).struct {
|
||||
match ty::get(ty::node_id_to_type(cx, e.id)).struct {
|
||||
ty::ty_fn(f) { return f.constraints; }
|
||||
_ { return ~[]; }
|
||||
}
|
||||
}
|
||||
|
||||
fn node_id_to_def_strict(cx: ty::ctxt, id: node_id) -> def {
|
||||
alt cx.def_map.find(id) {
|
||||
match cx.def_map.find(id) {
|
||||
none {
|
||||
error!{"node_id_to_def: node_id %d has no def", id};
|
||||
fail;
|
||||
|
|
@ -511,7 +511,7 @@ fn match_args(fcx: fn_ctxt, occs: @dvec<pred_args>,
|
|||
}
|
||||
|
||||
fn def_id_for_constr(tcx: ty::ctxt, t: node_id) -> def_id {
|
||||
alt tcx.def_map.find(t) {
|
||||
match tcx.def_map.find(t) {
|
||||
none {
|
||||
tcx.sess.bug(~"node_id_for_constr: bad node_id " + int::str(t));
|
||||
}
|
||||
|
|
@ -521,9 +521,9 @@ fn def_id_for_constr(tcx: ty::ctxt, t: node_id) -> def_id {
|
|||
}
|
||||
|
||||
fn expr_to_constr_arg(tcx: ty::ctxt, e: @expr) -> @constr_arg_use {
|
||||
alt e.node {
|
||||
match e.node {
|
||||
expr_path(p) {
|
||||
alt tcx.def_map.find(e.id) {
|
||||
match tcx.def_map.find(e.id) {
|
||||
some(def_local(nid, _)) | some(def_arg(nid, _)) |
|
||||
some(def_binding(nid, _)) | some(def_upvar(nid, _, _)) {
|
||||
return @respan(p.span,
|
||||
|
|
@ -559,9 +559,9 @@ fn exprs_to_constr_args(tcx: ty::ctxt,
|
|||
}
|
||||
|
||||
fn expr_to_constr(tcx: ty::ctxt, e: @expr) -> sp_constr {
|
||||
alt e.node {
|
||||
match e.node {
|
||||
expr_call(operator, args, _) {
|
||||
alt operator.node {
|
||||
match operator.node {
|
||||
expr_path(p) {
|
||||
return respan(e.span,
|
||||
{path: p,
|
||||
|
|
@ -601,7 +601,7 @@ fn substitute_constr_args(cx: ty::ctxt, actuals: ~[@expr], c: @ty::constr) ->
|
|||
fn substitute_arg(cx: ty::ctxt, actuals: ~[@expr], a: @constr_arg) ->
|
||||
@constr_arg_use {
|
||||
let num_actuals = vec::len(actuals);
|
||||
alt a.node {
|
||||
match a.node {
|
||||
carg_ident(i) {
|
||||
if i < num_actuals {
|
||||
return expr_to_constr_arg(cx, actuals[i]);
|
||||
|
|
@ -620,16 +620,16 @@ fn pred_args_matches(pattern: ~[constr_arg_general_<inst>],
|
|||
let mut i = 0u;
|
||||
for desc.node.args.each |c| {
|
||||
let n = pattern[i];
|
||||
alt c.node {
|
||||
match c.node {
|
||||
carg_ident(p) {
|
||||
alt n {
|
||||
match n {
|
||||
carg_ident(q) { if p.node != q.node { return false; } }
|
||||
_ { return false; }
|
||||
}
|
||||
}
|
||||
carg_base { if n != carg_base { return false; } }
|
||||
carg_lit(l) {
|
||||
alt n {
|
||||
match n {
|
||||
carg_lit(m) { if !const_eval::lit_eq(l, m) { return false; } }
|
||||
_ { return false; }
|
||||
}
|
||||
|
|
@ -669,7 +669,7 @@ fn find_instances(_fcx: fn_ctxt, subst: subst,
|
|||
if args_mention(d.node.args, find_in_subst_bool, subst) {
|
||||
let old_bit_num = d.node.bit_num;
|
||||
let newv = replace(subst, d);
|
||||
alt find_instance_(newv, v) {
|
||||
match find_instance_(newv, v) {
|
||||
some(d1) {vec::push(res, {from: old_bit_num, to: d1})}
|
||||
_ {}
|
||||
}
|
||||
|
|
@ -696,7 +696,7 @@ fn insts_to_str(stuff: ~[constr_arg_general_<inst>]) -> ~str {
|
|||
for stuff.each |i| {
|
||||
rslt +=
|
||||
~" " +
|
||||
alt i {
|
||||
match i {
|
||||
carg_ident(p) { *p.ident }
|
||||
carg_base { ~"*" }
|
||||
carg_lit(_) { ~"~[lit]" }
|
||||
|
|
@ -709,9 +709,9 @@ fn insts_to_str(stuff: ~[constr_arg_general_<inst>]) -> ~str {
|
|||
fn replace(subst: subst, d: pred_args) -> ~[constr_arg_general_<inst>] {
|
||||
let mut rslt: ~[constr_arg_general_<inst>] = ~[];
|
||||
for d.node.args.each |c| {
|
||||
alt c.node {
|
||||
match c.node {
|
||||
carg_ident(p) {
|
||||
alt find_in_subst(p.node, subst) {
|
||||
match find_in_subst(p.node, subst) {
|
||||
some(newv) { vec::push(rslt, carg_ident(newv)); }
|
||||
_ { vec::push(rslt, c.node); }
|
||||
}
|
||||
|
|
@ -736,7 +736,7 @@ fn for_constraints_mentioning(fcx: fn_ctxt, id: node_id,
|
|||
|
||||
fn local_node_id_to_def_id_strict(fcx: fn_ctxt, sp: span, i: node_id) ->
|
||||
def_id {
|
||||
alt local_node_id_to_def(fcx, i) {
|
||||
match local_node_id_to_def(fcx, i) {
|
||||
some(def_local(nid, _)) | some(def_arg(nid, _)) |
|
||||
some(def_upvar(nid, _, _)) {
|
||||
return local_def(nid);
|
||||
|
|
@ -760,7 +760,7 @@ fn local_node_id_to_def(fcx: fn_ctxt, i: node_id) -> option<def> {
|
|||
}
|
||||
|
||||
fn local_node_id_to_def_id(fcx: fn_ctxt, i: node_id) -> option<def_id> {
|
||||
alt local_node_id_to_def(fcx, i) {
|
||||
match local_node_id_to_def(fcx, i) {
|
||||
some(def_local(nid, _)) | some(def_arg(nid, _)) |
|
||||
some(def_binding(nid, _)) | some(def_upvar(nid, _, _)) {
|
||||
some(local_def(nid))
|
||||
|
|
@ -771,7 +771,7 @@ fn local_node_id_to_def_id(fcx: fn_ctxt, i: node_id) -> option<def_id> {
|
|||
|
||||
fn local_node_id_to_local_def_id(fcx: fn_ctxt, i: node_id) ->
|
||||
option<node_id> {
|
||||
alt local_node_id_to_def_id(fcx, i) {
|
||||
match local_node_id_to_def_id(fcx, i) {
|
||||
some(did) { some(did.node) }
|
||||
_ { none }
|
||||
}
|
||||
|
|
@ -798,7 +798,7 @@ fn copy_in_poststate_two(fcx: fn_ctxt, src_post: poststate,
|
|||
target_post: poststate, dest: inst, src: inst,
|
||||
ty: oper_type) {
|
||||
let mut subst;
|
||||
alt ty {
|
||||
match ty {
|
||||
oper_swap { subst = ~[{from: dest, to: src}, {from: src, to: dest}]; }
|
||||
oper_assign_op {
|
||||
return; // Don't do any propagation
|
||||
|
|
@ -863,7 +863,7 @@ fn args_mention<T>(args: ~[@constr_arg_use],
|
|||
s: ~[T]) -> bool {
|
||||
|
||||
for args.each |a| {
|
||||
alt a.node {
|
||||
match a.node {
|
||||
carg_ident(p1) { if q(s, p1.node) { return true; } } _ { }
|
||||
}
|
||||
}
|
||||
|
|
@ -875,7 +875,7 @@ fn use_var(fcx: fn_ctxt, v: node_id) {
|
|||
}
|
||||
|
||||
fn op_to_oper_ty(io: init_op) -> oper_type {
|
||||
alt io { init_move { oper_move } _ { oper_assign } }
|
||||
match io { init_move { oper_move } _ { oper_assign } }
|
||||
}
|
||||
|
||||
// default function visitor
|
||||
|
|
@ -894,7 +894,7 @@ fn args_to_constr_args(tcx: ty::ctxt, args: ~[arg],
|
|||
vec::push(
|
||||
actuals,
|
||||
@respan(a.span,
|
||||
alt a.node {
|
||||
match a.node {
|
||||
carg_base { carg_base }
|
||||
carg_ident(i) {
|
||||
if i < num_args {
|
||||
|
|
@ -945,7 +945,7 @@ fn locals_to_bindings(tcx: ty::ctxt, locals: ~[@local]) -> ~[binding] {
|
|||
fn callee_modes(fcx: fn_ctxt, callee: node_id) -> ~[mode] {
|
||||
let ty = ty::type_autoderef(fcx.ccx.tcx,
|
||||
ty::node_id_to_type(fcx.ccx.tcx, callee));
|
||||
alt ty::get(ty).struct {
|
||||
match ty::get(ty).struct {
|
||||
ty::ty_fn({inputs: args, _}) {
|
||||
let mut modes = ~[];
|
||||
for args.each |arg| { vec::push(modes, arg.mode); }
|
||||
|
|
@ -961,7 +961,7 @@ fn callee_modes(fcx: fn_ctxt, callee: node_id) -> ~[mode] {
|
|||
|
||||
fn callee_arg_init_ops(fcx: fn_ctxt, callee: node_id) -> ~[init_op] {
|
||||
do vec::map(callee_modes(fcx, callee)) |m| {
|
||||
alt ty::resolved_mode(fcx.ccx.tcx, m) {
|
||||
match ty::resolved_mode(fcx.ccx.tcx, m) {
|
||||
by_move { init_move }
|
||||
by_copy | by_ref | by_val | by_mutbl_ref { init_assign }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import dvec::{dvec, extensions};
|
|||
type ctxt = {cs: @mut ~[sp_constr], tcx: ty::ctxt};
|
||||
|
||||
fn collect_pred(e: @expr, cx: ctxt, v: visit::vt<ctxt>) {
|
||||
alt e.node {
|
||||
match e.node {
|
||||
expr_check(_, ch) { vec::push(*cx.cs, expr_to_constr(cx.tcx, ch)); }
|
||||
expr_if_check(ex, _, _) {
|
||||
vec::push(*cx.cs, expr_to_constr(cx.tcx, ex));
|
||||
|
|
@ -58,7 +58,7 @@ fn add_constraint(tcx: ty::ctxt, c: sp_constr, next: uint, tbl: constr_map) ->
|
|||
constraint_to_str(tcx, c) + ~" |-> " + uint::str(next));
|
||||
|
||||
let {path: p, def_id: d_id, args: args} = c.node;
|
||||
alt tbl.find(d_id) {
|
||||
match tbl.find(d_id) {
|
||||
some(ct) {
|
||||
(*ct.descs).push(respan(c.span, {args: args, bit_num: next}));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ fn find_pre_post_method(ccx: crate_ctxt, m: @method) {
|
|||
}
|
||||
|
||||
fn find_pre_post_item(ccx: crate_ctxt, i: item) {
|
||||
alt i.node {
|
||||
match i.node {
|
||||
item_const(_, e) {
|
||||
// do nothing -- item_consts don't refer to local vars
|
||||
}
|
||||
|
|
@ -100,9 +100,9 @@ fn join_then_else(fcx: fn_ctxt, antec: @expr, conseq: blk,
|
|||
maybe_alt: option<@expr>, id: node_id, chck: if_ty) {
|
||||
find_pre_post_expr(fcx, antec);
|
||||
find_pre_post_block(fcx, conseq);
|
||||
alt maybe_alt {
|
||||
match maybe_alt {
|
||||
none {
|
||||
alt chck {
|
||||
match chck {
|
||||
if_check {
|
||||
let c: sp_constr = expr_to_constr(fcx.ccx.tcx, antec);
|
||||
gen(fcx, antec.id, c.node);
|
||||
|
|
@ -135,7 +135,7 @@ fn join_then_else(fcx: fn_ctxt, antec: @expr, conseq: blk,
|
|||
|
||||
/* Be sure to set the bit for the check condition here,
|
||||
so that it's *not* set in the alternative. */
|
||||
alt chck {
|
||||
match chck {
|
||||
if_check {
|
||||
let c: sp_constr = expr_to_constr(fcx.ccx.tcx, antec);
|
||||
gen(fcx, antec.id, c.node);
|
||||
|
|
@ -162,9 +162,9 @@ fn join_then_else(fcx: fn_ctxt, antec: @expr, conseq: blk,
|
|||
|
||||
fn gen_if_local(fcx: fn_ctxt, lhs: @expr, rhs: @expr, larger_id: node_id,
|
||||
new_var: node_id) {
|
||||
alt node_id_to_def(fcx.ccx, new_var) {
|
||||
match node_id_to_def(fcx.ccx, new_var) {
|
||||
some(d) {
|
||||
alt d {
|
||||
match d {
|
||||
def_local(nid, _) {
|
||||
find_pre_post_expr(fcx, rhs);
|
||||
let p = expr_pp(fcx.ccx, rhs);
|
||||
|
|
@ -181,12 +181,12 @@ fn gen_if_local(fcx: fn_ctxt, lhs: @expr, rhs: @expr, larger_id: node_id,
|
|||
fn handle_update(fcx: fn_ctxt, parent: @expr, lhs: @expr, rhs: @expr,
|
||||
ty: oper_type) {
|
||||
find_pre_post_expr(fcx, rhs);
|
||||
alt lhs.node {
|
||||
match lhs.node {
|
||||
expr_path(p) {
|
||||
let post = expr_postcond(fcx.ccx, parent);
|
||||
let tmp = post.clone();
|
||||
|
||||
alt ty {
|
||||
match ty {
|
||||
oper_move {
|
||||
if is_path(rhs) { forget_in_postcond(fcx, parent.id, rhs.id); }
|
||||
}
|
||||
|
|
@ -201,13 +201,13 @@ fn handle_update(fcx: fn_ctxt, parent: @expr, lhs: @expr, rhs: @expr,
|
|||
}
|
||||
|
||||
gen_if_local(fcx, lhs, rhs, parent.id, lhs.id);
|
||||
alt rhs.node {
|
||||
match rhs.node {
|
||||
expr_path(p1) {
|
||||
let d = local_node_id_to_local_def_id(fcx, lhs.id);
|
||||
let d1 = local_node_id_to_local_def_id(fcx, rhs.id);
|
||||
alt d {
|
||||
match d {
|
||||
some(id) {
|
||||
alt d1 {
|
||||
match d1 {
|
||||
some(id1) {
|
||||
let instlhs =
|
||||
{ident: path_to_ident(p), node: id};
|
||||
|
|
@ -232,7 +232,7 @@ fn handle_update(fcx: fn_ctxt, parent: @expr, lhs: @expr, rhs: @expr,
|
|||
fn forget_args_moved_in(fcx: fn_ctxt, parent: @expr, modes: ~[mode],
|
||||
operands: ~[@expr]) {
|
||||
do vec::iteri(modes) |i,mode| {
|
||||
alt ty::resolved_mode(fcx.ccx.tcx, mode) {
|
||||
match ty::resolved_mode(fcx.ccx.tcx, mode) {
|
||||
by_move { forget_in_postcond(fcx, parent.id, operands[i].id); }
|
||||
by_ref | by_val | by_mutbl_ref | by_copy { }
|
||||
}
|
||||
|
|
@ -251,7 +251,7 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) {
|
|||
fn do_rand_(fcx: fn_ctxt, e: @expr) { find_pre_post_expr(fcx, e); }
|
||||
|
||||
|
||||
alt e.node {
|
||||
match e.node {
|
||||
expr_call(operator, operands, _) {
|
||||
/* copy */
|
||||
|
||||
|
|
@ -270,7 +270,7 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) {
|
|||
operands);
|
||||
|
||||
/* if this is a failing call, its postcondition sets everything */
|
||||
alt controlflow_expr(fcx.ccx, operator) {
|
||||
match controlflow_expr(fcx.ccx, operator) {
|
||||
noreturn { set_postcond_false(fcx.ccx, e.id); }
|
||||
_ { }
|
||||
}
|
||||
|
|
@ -315,7 +315,7 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) {
|
|||
}
|
||||
expr_rec(fields, maybe_base) {
|
||||
let mut es = field_exprs(fields);
|
||||
alt maybe_base { none {/* no-op */ } some(b) { vec::push(es, b); } }
|
||||
match maybe_base { none {/* no-op */ } some(b) { vec::push(es, b); } }
|
||||
find_pre_post_exprs(fcx, es, e.id);
|
||||
}
|
||||
expr_tup(elts) { find_pre_post_exprs(fcx, elts, e.id); }
|
||||
|
|
@ -331,7 +331,7 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) {
|
|||
}
|
||||
expr_lit(_) { clear_pp(expr_pp(fcx.ccx, e)); }
|
||||
expr_ret(maybe_val) {
|
||||
alt maybe_val {
|
||||
match maybe_val {
|
||||
none {
|
||||
clear_precond(fcx.ccx, e.id);
|
||||
set_postcond_false(fcx.ccx, e.id);
|
||||
|
|
@ -391,7 +391,7 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) {
|
|||
expr_alt(ex, alts, _) {
|
||||
find_pre_post_expr(fcx, ex);
|
||||
fn do_an_alt(fcx: fn_ctxt, an_alt: arm) -> pre_and_post {
|
||||
alt an_alt.guard {
|
||||
match an_alt.guard {
|
||||
some(e) { find_pre_post_expr(fcx, e); }
|
||||
_ {}
|
||||
}
|
||||
|
|
@ -422,7 +422,7 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) {
|
|||
}
|
||||
expr_fail(maybe_val) {
|
||||
let mut prestate;
|
||||
alt maybe_val {
|
||||
match maybe_val {
|
||||
none { prestate = empty_prestate(num_local_vars); }
|
||||
some(fail_val) {
|
||||
find_pre_post_expr(fcx, fail_val);
|
||||
|
|
@ -453,13 +453,13 @@ fn find_pre_post_expr(fcx: fn_ctxt, e: @expr) {
|
|||
|
||||
fn find_pre_post_stmt(fcx: fn_ctxt, s: stmt) {
|
||||
debug!{"stmt = %s", stmt_to_str(s)};
|
||||
alt s.node {
|
||||
match s.node {
|
||||
stmt_decl(adecl, id) {
|
||||
alt adecl.node {
|
||||
match adecl.node {
|
||||
decl_local(alocals) {
|
||||
let prev_pp = empty_pre_post(num_constraints(fcx.enclosing));
|
||||
for alocals.each |alocal| {
|
||||
alt alocal.node.init {
|
||||
match alocal.node.init {
|
||||
some(an_init) {
|
||||
/* LHS always becomes initialized,
|
||||
whether or not this is a move */
|
||||
|
|
@ -473,7 +473,7 @@ fn find_pre_post_stmt(fcx: fn_ctxt, s: stmt) {
|
|||
copy_pre_post(fcx.ccx, id, an_init.expr);
|
||||
|
||||
let mut p = none;
|
||||
alt an_init.expr.node {
|
||||
match an_init.expr.node {
|
||||
expr_path(_p) { p = some(_p); }
|
||||
_ { }
|
||||
}
|
||||
|
|
@ -481,7 +481,7 @@ fn find_pre_post_stmt(fcx: fn_ctxt, s: stmt) {
|
|||
do pat_bindings(fcx.ccx.tcx.def_map, alocal.node.pat)
|
||||
|p_id, _s, n| {
|
||||
let ident = path_to_ident(n);
|
||||
alt p {
|
||||
match p {
|
||||
some(p) {
|
||||
copy_in_postcond(fcx, id,
|
||||
{ident: ident, node: p_id},
|
||||
|
|
@ -557,7 +557,7 @@ fn find_pre_post_block(fcx: fn_ctxt, b: blk) {
|
|||
|
||||
let mut pps: ~[pre_and_post] = ~[];
|
||||
for b.node.stmts.each |s| { vec::push(pps, stmt_pp(fcx.ccx, *s)); }
|
||||
alt b.node.expr {
|
||||
match b.node.expr {
|
||||
none {/* no-op */ }
|
||||
some(e) { vec::push(pps, expr_pp(fcx.ccx, e)); }
|
||||
}
|
||||
|
|
@ -584,7 +584,7 @@ fn find_pre_post_fn(fcx: fn_ctxt, body: blk) {
|
|||
find_pre_post_block(fcx, body);
|
||||
|
||||
// Treat the tail expression as a return statement
|
||||
alt body.node.expr {
|
||||
match body.node.expr {
|
||||
some(tailexpr) { set_postcond_false(fcx.ccx, tailexpr.id); }
|
||||
none {/* fallthrough */ }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,9 +15,9 @@ import driver::session::session;
|
|||
import std::map::hashmap;
|
||||
|
||||
fn forbid_upvar(fcx: fn_ctxt, rhs_id: node_id, sp: span, t: oper_type) {
|
||||
alt t {
|
||||
match t {
|
||||
oper_move {
|
||||
alt local_node_id_to_def(fcx, rhs_id) {
|
||||
match local_node_id_to_def(fcx, rhs_id) {
|
||||
some(def_upvar(_, _, _)) {
|
||||
fcx.ccx.tcx.sess.span_err(sp,
|
||||
~"tried to deinitialize a variable \
|
||||
|
|
@ -35,12 +35,12 @@ fn handle_move_or_copy(fcx: fn_ctxt, post: poststate, rhs_path: @path,
|
|||
forbid_upvar(fcx, rhs_id, rhs_path.span, op_to_oper_ty(init_op));
|
||||
|
||||
let rhs_d_id = local_node_id_to_def_id(fcx, rhs_id);
|
||||
alt rhs_d_id {
|
||||
match rhs_d_id {
|
||||
some(rhsid) {
|
||||
// RHS is a local var
|
||||
let instrhs =
|
||||
{ident: path_to_ident(rhs_path), node: rhsid.node};
|
||||
alt destlhs {
|
||||
match destlhs {
|
||||
local_dest(instlhs) {
|
||||
copy_in_poststate(fcx, post, instlhs, instrhs,
|
||||
op_to_oper_ty(init_op));
|
||||
|
|
@ -59,14 +59,14 @@ fn seq_states(fcx: fn_ctxt, pres: prestate, bindings: ~[binding]) ->
|
|||
let mut changed = false;
|
||||
let mut post = pres.clone();
|
||||
for bindings.each |b| {
|
||||
alt b.rhs {
|
||||
match b.rhs {
|
||||
some(an_init) {
|
||||
// an expression, with or without a destination
|
||||
changed |=
|
||||
find_pre_post_state_expr(fcx, post, an_init.expr) || changed;
|
||||
post = expr_poststate(fcx.ccx, an_init.expr).clone();
|
||||
for b.lhs.each |d| {
|
||||
alt an_init.expr.node {
|
||||
match an_init.expr.node {
|
||||
expr_path(p) {
|
||||
handle_move_or_copy(fcx, post, p, an_init.expr.id, d,
|
||||
an_init.op);
|
||||
|
|
@ -94,7 +94,7 @@ fn find_pre_post_state_sub(fcx: fn_ctxt, pres: prestate, e: @expr,
|
|||
changed = set_prestate_ann(fcx.ccx, parent, pres) || changed;
|
||||
|
||||
let post = expr_poststate(fcx.ccx, e).clone();
|
||||
alt c {
|
||||
match c {
|
||||
none { }
|
||||
some(c1) { set_in_poststate_(bit_num(fcx, c1), post); }
|
||||
}
|
||||
|
|
@ -115,7 +115,7 @@ fn find_pre_post_state_two(fcx: fn_ctxt, pres: prestate, lhs: @expr,
|
|||
|
||||
let post = expr_poststate(fcx.ccx, rhs).clone();
|
||||
|
||||
alt lhs.node {
|
||||
match lhs.node {
|
||||
expr_path(p) {
|
||||
// for termination, need to make sure intermediate changes don't set
|
||||
// changed flag
|
||||
|
|
@ -123,7 +123,7 @@ fn find_pre_post_state_two(fcx: fn_ctxt, pres: prestate, lhs: @expr,
|
|||
// for substitution purposes
|
||||
let tmp = post.clone();
|
||||
|
||||
alt ty {
|
||||
match ty {
|
||||
oper_move {
|
||||
if is_path(rhs) { forget_in_poststate(fcx, post, rhs.id); }
|
||||
forget_in_poststate(fcx, post, lhs.id);
|
||||
|
|
@ -135,13 +135,13 @@ fn find_pre_post_state_two(fcx: fn_ctxt, pres: prestate, lhs: @expr,
|
|||
_ { forget_in_poststate(fcx, post, lhs.id); }
|
||||
}
|
||||
|
||||
alt rhs.node {
|
||||
match rhs.node {
|
||||
expr_path(p1) {
|
||||
let d = local_node_id_to_local_def_id(fcx, lhs.id);
|
||||
let d1 = local_node_id_to_local_def_id(fcx, rhs.id);
|
||||
alt d {
|
||||
match d {
|
||||
some(id) {
|
||||
alt d1 {
|
||||
match d1 {
|
||||
some(id1) {
|
||||
let instlhs =
|
||||
{ident: path_to_ident(p), node: id};
|
||||
|
|
@ -188,7 +188,7 @@ fn find_pre_post_state_exprs(fcx: fn_ctxt, pres: prestate, id: node_id,
|
|||
let rs = seq_states(fcx, pres, arg_bindings(ops, es));
|
||||
let mut changed = rs.changed | set_prestate_ann(fcx.ccx, id, pres);
|
||||
/* if this is a failing call, it sets everything as initialized */
|
||||
alt cf {
|
||||
match cf {
|
||||
noreturn {
|
||||
let post = false_postcond(num_constraints(fcx.enclosing));
|
||||
changed |= set_poststate_ann(fcx.ccx, id, post);
|
||||
|
|
@ -205,9 +205,9 @@ fn join_then_else(fcx: fn_ctxt, antec: @expr, conseq: blk,
|
|||
set_prestate_ann(fcx.ccx, id, pres) |
|
||||
find_pre_post_state_expr(fcx, pres, antec);
|
||||
|
||||
alt maybe_alt {
|
||||
match maybe_alt {
|
||||
none {
|
||||
alt chk {
|
||||
match chk {
|
||||
if_check {
|
||||
let c: sp_constr = expr_to_constr(fcx.ccx.tcx, antec);
|
||||
let conseq_prestate = expr_poststate(fcx.ccx, antec).clone();
|
||||
|
|
@ -232,7 +232,7 @@ fn join_then_else(fcx: fn_ctxt, antec: @expr, conseq: blk,
|
|||
altern);
|
||||
|
||||
let mut conseq_prestate = expr_poststate(fcx.ccx, antec);
|
||||
alt chk {
|
||||
match chk {
|
||||
if_check {
|
||||
let c: sp_constr = expr_to_constr(fcx.ccx.tcx, antec);
|
||||
conseq_prestate = conseq_prestate.clone();
|
||||
|
|
@ -282,7 +282,7 @@ fn find_pre_post_state_cap_clause(fcx: fn_ctxt, e_id: node_id,
|
|||
fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool {
|
||||
let num_constrs = num_constraints(fcx.enclosing);
|
||||
|
||||
alt e.node {
|
||||
match e.node {
|
||||
expr_new(p, _, v) {
|
||||
return find_pre_post_state_two(fcx, pres, p, v, e.id, oper_pure);
|
||||
}
|
||||
|
|
@ -330,7 +330,7 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool {
|
|||
init_assign),
|
||||
exs, return_val);
|
||||
|
||||
let base_pres = alt vec::last_opt(exs) { none { pres }
|
||||
let base_pres = match vec::last_opt(exs) { none { pres }
|
||||
some(f) { expr_poststate(fcx.ccx, f) }};
|
||||
option::iter(maybe_base, |base| {
|
||||
changed |= find_pre_post_state_expr(fcx, base_pres, base) |
|
||||
|
|
@ -366,7 +366,7 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool {
|
|||
|
||||
set_poststate_ann(fcx.ccx, e.id, post);
|
||||
|
||||
alt maybe_ret_val {
|
||||
match maybe_ret_val {
|
||||
none {/* do nothing */ }
|
||||
some(ret_val) {
|
||||
changed |= find_pre_post_state_expr(fcx, pres, ret_val);
|
||||
|
|
@ -452,7 +452,7 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool {
|
|||
if vec::len(alts) > 0u {
|
||||
a_post = false_postcond(num_constrs);
|
||||
for alts.each |an_alt| {
|
||||
alt an_alt.guard {
|
||||
match an_alt.guard {
|
||||
some(e) {
|
||||
changed |= find_pre_post_state_expr(fcx, e_post, e);
|
||||
}
|
||||
|
|
@ -512,9 +512,9 @@ fn find_pre_post_state_stmt(fcx: fn_ctxt, pres: prestate, s: @stmt) -> bool {
|
|||
debug!{"*prestate = %s", stmt_ann.states.prestate.to_str()};
|
||||
debug!{"*poststate = %s", stmt_ann.states.prestate.to_str()};
|
||||
|
||||
alt s.node {
|
||||
match s.node {
|
||||
stmt_decl(adecl, id) {
|
||||
alt adecl.node {
|
||||
match adecl.node {
|
||||
decl_local(alocals) {
|
||||
set_prestate(stmt_ann, pres);
|
||||
let c_and_p = seq_states(fcx, pres,
|
||||
|
|
@ -574,7 +574,7 @@ fn find_pre_post_state_block(fcx: fn_ctxt, pres0: prestate, b: blk) -> bool {
|
|||
pres = stmt_poststate(fcx.ccx, *s);
|
||||
}
|
||||
let mut post = pres;
|
||||
alt b.node.expr {
|
||||
match b.node.expr {
|
||||
none { }
|
||||
some(e) {
|
||||
changed |= find_pre_post_state_expr(fcx, pres, e);
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ class t {
|
|||
}
|
||||
pure fn set(i: uint, t: trit) -> bool {
|
||||
let old = self.get(i);
|
||||
alt t {
|
||||
match t {
|
||||
dont_care {
|
||||
self.uncertain.set(i, true);
|
||||
self.val.set(i, false);
|
||||
|
|
@ -103,7 +103,7 @@ class t {
|
|||
let mut rslt: ~[uint] = ~[];
|
||||
for uint::range(0, self.nbits) |i| {
|
||||
vec::push(rslt,
|
||||
alt self.get(i) {
|
||||
match self.get(i) {
|
||||
dont_care { 2 }
|
||||
ttrue { 1 }
|
||||
tfalse { 0 }
|
||||
|
|
@ -116,7 +116,7 @@ class t {
|
|||
let mut rs: str = "";
|
||||
for uint::range(0, self.nbits) |i| {
|
||||
rs +=
|
||||
alt self.get(i) {
|
||||
match self.get(i) {
|
||||
dont_care { "?" }
|
||||
ttrue { "1" }
|
||||
tfalse { "0" }
|
||||
|
|
@ -177,10 +177,10 @@ fn minus(a: trit, b: trit) -> trit {
|
|||
0 - 1 is an error
|
||||
0 - anything else - 0
|
||||
*/
|
||||
alt a {
|
||||
match a {
|
||||
dont_care { dont_care }
|
||||
ttrue {
|
||||
alt b {
|
||||
match b {
|
||||
ttrue { dont_care }
|
||||
tfalse { ttrue }
|
||||
/* internally contradictory, but
|
||||
|
|
@ -191,7 +191,7 @@ fn minus(a: trit, b: trit) -> trit {
|
|||
}
|
||||
}
|
||||
tfalse {
|
||||
alt b {
|
||||
match b {
|
||||
ttrue { tfalse }
|
||||
/* see above comment */
|
||||
_ {
|
||||
|
|
@ -203,11 +203,11 @@ fn minus(a: trit, b: trit) -> trit {
|
|||
}
|
||||
|
||||
fn trit_or(a: trit, b: trit) -> trit {
|
||||
alt a {
|
||||
match a {
|
||||
dont_care { b }
|
||||
ttrue { ttrue }
|
||||
tfalse {
|
||||
alt b {
|
||||
match b {
|
||||
ttrue { dont_care }
|
||||
/* FIXME (#2538): ??????
|
||||
Again, unit tests would help here
|
||||
|
|
@ -226,11 +226,11 @@ fn trit_or(a: trit, b: trit) -> trit {
|
|||
// to make it so that all constraints start out in a 0 state
|
||||
// (we consider a constraint false until proven true), too.
|
||||
fn trit_and(a: trit, b: trit) -> trit {
|
||||
alt a {
|
||||
match a {
|
||||
dont_care { b }
|
||||
// also seems wrong for case b = ttrue
|
||||
ttrue {
|
||||
alt b {
|
||||
match b {
|
||||
dont_care { ttrue }
|
||||
// ??? Seems wrong
|
||||
ttrue {
|
||||
|
|
|
|||
|
|
@ -510,7 +510,7 @@ impl of purity_to_str for purity {
|
|||
fn param_bounds_to_kind(bounds: param_bounds) -> kind {
|
||||
let mut kind = kind_noncopyable();
|
||||
for vec::each(*bounds) |bound| {
|
||||
alt bound {
|
||||
match bound {
|
||||
bound_copy => {
|
||||
kind = raise_kind(kind, kind_implicitly_copyable());
|
||||
}
|
||||
|
|
@ -608,14 +608,14 @@ fn mk_t(cx: ctxt, st: sty) -> t { mk_t_with_id(cx, st, none) }
|
|||
// and returns the box as cast to an unsafe ptr (see comments for t above).
|
||||
fn mk_t_with_id(cx: ctxt, st: sty, o_def_id: option<ast::def_id>) -> t {
|
||||
let key = {struct: st, o_def_id: o_def_id};
|
||||
alt cx.interner.find(key) {
|
||||
match cx.interner.find(key) {
|
||||
some(t) => unsafe { return unsafe::reinterpret_cast(t); }
|
||||
_ => ()
|
||||
}
|
||||
let mut flags = 0u;
|
||||
fn rflags(r: region) -> uint {
|
||||
(has_regions as uint) | {
|
||||
alt r {
|
||||
match r {
|
||||
ty::re_var(_) => needs_infer as uint,
|
||||
_ => 0u
|
||||
}
|
||||
|
|
@ -627,7 +627,7 @@ fn mk_t_with_id(cx: ctxt, st: sty, o_def_id: option<ast::def_id>) -> t {
|
|||
substs.self_r.iter(|r| f |= rflags(r));
|
||||
return f;
|
||||
}
|
||||
alt st {
|
||||
match st {
|
||||
ty_estr(vstore_slice(r)) => {
|
||||
flags |= rflags(r);
|
||||
}
|
||||
|
|
@ -786,7 +786,7 @@ fn mk_with_id(cx: ctxt, base: t, def_id: ast::def_id) -> t {
|
|||
|
||||
// Converts s to its machine type equivalent
|
||||
pure fn mach_sty(cfg: @session::config, t: t) -> sty {
|
||||
alt get(t).struct {
|
||||
match get(t).struct {
|
||||
ty_int(ast::ty_i) => ty_int(cfg.int_type),
|
||||
ty_uint(ast::ty_u) => ty_uint(cfg.uint_type),
|
||||
ty_float(ast::ty_f) => ty_float(cfg.float_type),
|
||||
|
|
@ -802,7 +802,7 @@ fn default_arg_mode_for_ty(ty: ty::t) -> ast::rmode {
|
|||
// Returns the narrowest lifetime enclosing the evaluation of the expression
|
||||
// with id `id`.
|
||||
fn encl_region(cx: ctxt, id: ast::node_id) -> ty::region {
|
||||
alt cx.region_map.find(id) {
|
||||
match cx.region_map.find(id) {
|
||||
some(encl_scope) => ty::re_scope(encl_scope),
|
||||
none => ty::re_static
|
||||
}
|
||||
|
|
@ -814,7 +814,7 @@ fn walk_ty(ty: t, f: fn(t)) {
|
|||
|
||||
fn maybe_walk_ty(ty: t, f: fn(t) -> bool) {
|
||||
if !f(ty) { return; }
|
||||
alt get(ty).struct {
|
||||
match get(ty).struct {
|
||||
ty_nil | ty_bot | ty_bool | ty_int(_) | ty_uint(_) | ty_float(_) |
|
||||
ty_estr(_) | ty_type | ty_opaque_box | ty_self |
|
||||
ty_opaque_closure_ptr(_) | ty_var(_) | ty_var_integral(_) |
|
||||
|
|
@ -851,7 +851,7 @@ fn fold_sty(sty: sty, fldop: fn(t) -> t) -> sty {
|
|||
tps: substs.tps.map(|t| fldop(t))}
|
||||
}
|
||||
|
||||
alt sty {
|
||||
match sty {
|
||||
ty_box(tm) => {
|
||||
ty_box({ty: fldop(tm.ty), mutbl: tm.mutbl})
|
||||
}
|
||||
|
|
@ -947,7 +947,7 @@ fn fold_regions_and_ty(
|
|||
}
|
||||
|
||||
let tb = ty::get(ty);
|
||||
alt tb.struct {
|
||||
match tb.struct {
|
||||
ty::ty_rptr(r, mt) => {
|
||||
let m_r = fldr(r);
|
||||
let m_t = fldt(mt.ty);
|
||||
|
|
@ -1004,7 +1004,7 @@ fn fold_region(cx: ctxt, t0: t, fldop: fn(region, bool) -> region) -> t {
|
|||
fldop: fn(region, bool) -> region) -> t {
|
||||
let tb = get(t0);
|
||||
if !tbox_has_flag(tb, has_regions) { return t0; }
|
||||
alt tb.struct {
|
||||
match tb.struct {
|
||||
ty_rptr(r, {ty: t1, mutbl: m}) => {
|
||||
let m_r = fldop(r, under_r);
|
||||
let m_t1 = do_fold(cx, t1, true, fldop);
|
||||
|
|
@ -1039,7 +1039,7 @@ fn subst_tps(cx: ctxt, tps: ~[t], typ: t) -> t {
|
|||
if tps.len() == 0u { return typ; }
|
||||
let tb = ty::get(typ);
|
||||
if !tbox_has_flag(tb, has_params) { return typ; }
|
||||
alt tb.struct {
|
||||
match tb.struct {
|
||||
ty_param(p) => tps[p.idx],
|
||||
sty => fold_sty_to_ty(cx, sty, |t| subst_tps(cx, tps, t))
|
||||
}
|
||||
|
|
@ -1076,13 +1076,13 @@ fn subst(cx: ctxt,
|
|||
typ: t) -> t {
|
||||
let tb = get(typ);
|
||||
if !tbox_has_flag(tb, needs_subst) { return typ; }
|
||||
alt tb.struct {
|
||||
match tb.struct {
|
||||
ty_param(p) => substs.tps[p.idx],
|
||||
ty_self => substs.self_ty.get(),
|
||||
_ => {
|
||||
fold_regions_and_ty(
|
||||
cx, typ,
|
||||
|r| alt r {
|
||||
|r| match r {
|
||||
re_bound(br_self) => substs.self_r.get(),
|
||||
_ => r
|
||||
},
|
||||
|
|
@ -1100,14 +1100,14 @@ fn type_is_nil(ty: t) -> bool { get(ty).struct == ty_nil }
|
|||
fn type_is_bot(ty: t) -> bool { get(ty).struct == ty_bot }
|
||||
|
||||
fn type_is_var(ty: t) -> bool {
|
||||
alt get(ty).struct {
|
||||
match get(ty).struct {
|
||||
ty_var(_) => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
||||
fn type_is_var_integral(ty: t) -> bool {
|
||||
alt get(ty).struct {
|
||||
match get(ty).struct {
|
||||
ty_var_integral(_) => true,
|
||||
_ => false
|
||||
}
|
||||
|
|
@ -1116,7 +1116,7 @@ fn type_is_var_integral(ty: t) -> bool {
|
|||
fn type_is_bool(ty: t) -> bool { get(ty).struct == ty_bool }
|
||||
|
||||
fn type_is_structural(ty: t) -> bool {
|
||||
alt get(ty).struct {
|
||||
match get(ty).struct {
|
||||
ty_rec(_) | ty_class(*) | ty_tup(_) | ty_enum(*) | ty_fn(_) |
|
||||
ty_trait(*) |
|
||||
ty_evec(_, vstore_fixed(_)) | ty_estr(vstore_fixed(_)) |
|
||||
|
|
@ -1131,21 +1131,21 @@ fn type_is_copyable(cx: ctxt, ty: t) -> bool {
|
|||
}
|
||||
|
||||
fn type_is_sequence(ty: t) -> bool {
|
||||
alt get(ty).struct {
|
||||
match get(ty).struct {
|
||||
ty_estr(_) | ty_evec(_, _) => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
||||
fn type_is_str(ty: t) -> bool {
|
||||
alt get(ty).struct {
|
||||
match get(ty).struct {
|
||||
ty_estr(_) => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
||||
fn sequence_element_type(cx: ctxt, ty: t) -> t {
|
||||
alt get(ty).struct {
|
||||
match get(ty).struct {
|
||||
ty_estr(_) => return mk_mach_uint(cx, ast::ty_u8),
|
||||
ty_evec(mt, _) | ty_unboxed_vec(mt) => return mt.ty,
|
||||
_ => cx.sess.bug(
|
||||
|
|
@ -1154,7 +1154,7 @@ fn sequence_element_type(cx: ctxt, ty: t) -> t {
|
|||
}
|
||||
|
||||
fn get_element_type(ty: t, i: uint) -> t {
|
||||
alt get(ty).struct {
|
||||
match get(ty).struct {
|
||||
ty_rec(flds) => return flds[i].mt.ty,
|
||||
ty_tup(ts) => return ts[i],
|
||||
_ => fail ~"get_element_type called on invalid type"
|
||||
|
|
@ -1162,14 +1162,14 @@ fn get_element_type(ty: t, i: uint) -> t {
|
|||
}
|
||||
|
||||
pure fn type_is_box(ty: t) -> bool {
|
||||
alt get(ty).struct {
|
||||
match get(ty).struct {
|
||||
ty_box(_) => return true,
|
||||
_ => return false
|
||||
}
|
||||
}
|
||||
|
||||
pure fn type_is_boxed(ty: t) -> bool {
|
||||
alt get(ty).struct {
|
||||
match get(ty).struct {
|
||||
ty_box(_) | ty_opaque_box |
|
||||
ty_evec(_, vstore_box) | ty_estr(vstore_box) => true,
|
||||
_ => false
|
||||
|
|
@ -1177,35 +1177,35 @@ pure fn type_is_boxed(ty: t) -> bool {
|
|||
}
|
||||
|
||||
pure fn type_is_region_ptr(ty: t) -> bool {
|
||||
alt get(ty).struct {
|
||||
match get(ty).struct {
|
||||
ty_rptr(_, _) => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
||||
pure fn type_is_slice(ty: t) -> bool {
|
||||
alt get(ty).struct {
|
||||
match get(ty).struct {
|
||||
ty_evec(_, vstore_slice(_)) | ty_estr(vstore_slice(_)) => true,
|
||||
_ => return false
|
||||
}
|
||||
}
|
||||
|
||||
pure fn type_is_unique_box(ty: t) -> bool {
|
||||
alt get(ty).struct {
|
||||
match get(ty).struct {
|
||||
ty_uniq(_) => return true,
|
||||
_ => return false
|
||||
}
|
||||
}
|
||||
|
||||
pure fn type_is_unsafe_ptr(ty: t) -> bool {
|
||||
alt get(ty).struct {
|
||||
match get(ty).struct {
|
||||
ty_ptr(_) => return true,
|
||||
_ => return false
|
||||
}
|
||||
}
|
||||
|
||||
pure fn type_is_vec(ty: t) -> bool {
|
||||
return alt get(ty).struct {
|
||||
return match get(ty).struct {
|
||||
ty_evec(_, _) | ty_unboxed_vec(_) => true,
|
||||
ty_estr(_) => true,
|
||||
_ => false
|
||||
|
|
@ -1213,7 +1213,7 @@ pure fn type_is_vec(ty: t) -> bool {
|
|||
}
|
||||
|
||||
pure fn type_is_unique(ty: t) -> bool {
|
||||
alt get(ty).struct {
|
||||
match get(ty).struct {
|
||||
ty_uniq(_) => return true,
|
||||
ty_evec(_, vstore_uniq) => true,
|
||||
ty_estr(vstore_uniq) => true,
|
||||
|
|
@ -1227,7 +1227,7 @@ pure fn type_is_unique(ty: t) -> bool {
|
|||
contents are abstract to rustc.)
|
||||
*/
|
||||
pure fn type_is_scalar(ty: t) -> bool {
|
||||
alt get(ty).struct {
|
||||
match get(ty).struct {
|
||||
ty_nil | ty_bool | ty_int(_) | ty_float(_) | ty_uint(_) |
|
||||
ty_var_integral(_) | ty_type | ty_ptr(_) => true,
|
||||
_ => false
|
||||
|
|
@ -1240,13 +1240,13 @@ fn type_is_immediate(ty: t) -> bool {
|
|||
}
|
||||
|
||||
fn type_needs_drop(cx: ctxt, ty: t) -> bool {
|
||||
alt cx.needs_drop_cache.find(ty) {
|
||||
match cx.needs_drop_cache.find(ty) {
|
||||
some(result) => return result,
|
||||
none => {/* fall through */ }
|
||||
}
|
||||
|
||||
let mut accum = false;
|
||||
let result = alt get(ty).struct {
|
||||
let result = match get(ty).struct {
|
||||
// scalar types
|
||||
ty_nil | ty_bot | ty_bool | ty_int(_) | ty_float(_) | ty_uint(_) |
|
||||
ty_type | ty_ptr(_) | ty_rptr(_, _) |
|
||||
|
|
@ -1286,7 +1286,7 @@ fn type_needs_drop(cx: ctxt, ty: t) -> bool {
|
|||
accum
|
||||
}
|
||||
ty_fn(fty) => {
|
||||
alt fty.proto {
|
||||
match fty.proto {
|
||||
proto_bare | proto_block => false,
|
||||
_ => true
|
||||
}
|
||||
|
|
@ -1303,7 +1303,7 @@ fn type_needs_drop(cx: ctxt, ty: t) -> bool {
|
|||
// that only contain scalars and shared boxes can avoid unwind
|
||||
// cleanups.
|
||||
fn type_needs_unwind_cleanup(cx: ctxt, ty: t) -> bool {
|
||||
alt cx.needs_unwind_cleanup_cache.find(ty) {
|
||||
match cx.needs_unwind_cleanup_cache.find(ty) {
|
||||
some(result) => return result,
|
||||
none => ()
|
||||
}
|
||||
|
|
@ -1320,7 +1320,7 @@ fn type_needs_unwind_cleanup_(cx: ctxt, ty: t,
|
|||
encountered_box: bool) -> bool {
|
||||
|
||||
// Prevent infinite recursion
|
||||
alt tycache.find(ty) {
|
||||
match tycache.find(ty) {
|
||||
some(_) => return false,
|
||||
none => { tycache.insert(ty, ()); }
|
||||
}
|
||||
|
|
@ -1329,7 +1329,7 @@ fn type_needs_unwind_cleanup_(cx: ctxt, ty: t,
|
|||
let mut needs_unwind_cleanup = false;
|
||||
do maybe_walk_ty(ty) |ty| {
|
||||
let old_encountered_box = encountered_box;
|
||||
let result = alt get(ty).struct {
|
||||
let result = match get(ty).struct {
|
||||
ty_box(_) | ty_opaque_box => {
|
||||
encountered_box = true;
|
||||
true
|
||||
|
|
@ -1528,7 +1528,7 @@ pure fn kind_is_owned(k: kind) -> bool {
|
|||
}
|
||||
|
||||
fn proto_kind(p: proto) -> kind {
|
||||
alt p {
|
||||
match p {
|
||||
ast::proto_block => kind_noncopyable(),
|
||||
ast::proto_box => kind_safe_for_default_mode() | kind_owned(),
|
||||
ast::proto_uniq => kind_send_copy() | kind_owned(),
|
||||
|
|
@ -1571,7 +1571,7 @@ fn test_kinds() {
|
|||
// This is used to prevent objects containing mutable state from being
|
||||
// implicitly copied and to compute whether things have const kind.
|
||||
fn mutability_kind(m: mutability) -> kind {
|
||||
alt (m) {
|
||||
match (m) {
|
||||
m_mutbl => remove_const(remove_implicit(kind_top())),
|
||||
m_const => remove_implicit(kind_top()),
|
||||
m_imm => kind_top()
|
||||
|
|
@ -1583,7 +1583,7 @@ fn mutable_type_kind(cx: ctxt, ty: mt) -> kind {
|
|||
}
|
||||
|
||||
fn type_kind(cx: ctxt, ty: t) -> kind {
|
||||
alt cx.kind_cache.find(ty) {
|
||||
match cx.kind_cache.find(ty) {
|
||||
some(result) => return result,
|
||||
none => {/* fall through */ }
|
||||
}
|
||||
|
|
@ -1591,7 +1591,7 @@ fn type_kind(cx: ctxt, ty: t) -> kind {
|
|||
// Insert a default in case we loop back on self recursively.
|
||||
cx.kind_cache.insert(ty, kind_top());
|
||||
|
||||
let mut result = alt get(ty).struct {
|
||||
let mut result = match get(ty).struct {
|
||||
// Scalar and unique types are sendable, constant, and owned
|
||||
ty_nil | ty_bot | ty_bool | ty_int(_) | ty_uint(_) | ty_float(_) |
|
||||
ty_ptr(_) => {
|
||||
|
|
@ -1743,7 +1743,7 @@ fn type_kind(cx: ctxt, ty: t) -> kind {
|
|||
/// gives a rough estimate of how much space it takes to represent
|
||||
/// an instance of `ty`. Used for the mode transition.
|
||||
fn type_size(cx: ctxt, ty: t) -> uint {
|
||||
alt get(ty).struct {
|
||||
match get(ty).struct {
|
||||
ty_nil | ty_bot | ty_bool | ty_int(_) | ty_uint(_) | ty_float(_) |
|
||||
ty_ptr(_) | ty_box(_) | ty_uniq(_) | ty_estr(vstore_uniq) |
|
||||
ty_trait(*) | ty_rptr(*) | ty_evec(_, vstore_uniq) |
|
||||
|
|
@ -1828,7 +1828,7 @@ fn is_instantiable(cx: ctxt, r_ty: t) -> bool {
|
|||
ty_to_str(cx, r_ty),
|
||||
ty_to_str(cx, ty)};
|
||||
|
||||
let r = alt get(ty).struct {
|
||||
let r = match get(ty).struct {
|
||||
ty_nil |
|
||||
ty_bot |
|
||||
ty_bool |
|
||||
|
|
@ -1919,7 +1919,7 @@ fn type_structurally_contains(cx: ctxt, ty: t, test: fn(sty) -> bool) ->
|
|||
let sty = get(ty).struct;
|
||||
debug!{"type_structurally_contains: %s", ty_to_str(cx, ty)};
|
||||
if test(sty) { return true; }
|
||||
alt sty {
|
||||
match sty {
|
||||
ty_enum(did, substs) => {
|
||||
for vec::each(*enum_variants(cx, did)) |variant| {
|
||||
for variant.args.each |aty| {
|
||||
|
|
@ -1960,7 +1960,7 @@ fn type_structurally_contains(cx: ctxt, ty: t, test: fn(sty) -> bool) ->
|
|||
|
||||
fn type_structurally_contains_uniques(cx: ctxt, ty: t) -> bool {
|
||||
return type_structurally_contains(cx, ty, |sty| {
|
||||
alt sty {
|
||||
match sty {
|
||||
ty_uniq(_) |
|
||||
ty_evec(_, vstore_uniq) |
|
||||
ty_estr(vstore_uniq) => true,
|
||||
|
|
@ -1970,14 +1970,14 @@ fn type_structurally_contains_uniques(cx: ctxt, ty: t) -> bool {
|
|||
}
|
||||
|
||||
fn type_is_integral(ty: t) -> bool {
|
||||
alt get(ty).struct {
|
||||
match get(ty).struct {
|
||||
ty_var_integral(_) | ty_int(_) | ty_uint(_) | ty_bool => true,
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
||||
fn type_is_fp(ty: t) -> bool {
|
||||
alt get(ty).struct {
|
||||
match get(ty).struct {
|
||||
ty_float(_) => true,
|
||||
_ => false
|
||||
}
|
||||
|
|
@ -1988,7 +1988,7 @@ fn type_is_numeric(ty: t) -> bool {
|
|||
}
|
||||
|
||||
fn type_is_signed(ty: t) -> bool {
|
||||
alt get(ty).struct {
|
||||
match get(ty).struct {
|
||||
ty_int(_) => true,
|
||||
_ => false
|
||||
}
|
||||
|
|
@ -1998,7 +1998,7 @@ fn type_is_signed(ty: t) -> bool {
|
|||
// that the cycle collector might care about.
|
||||
fn type_is_pod(cx: ctxt, ty: t) -> bool {
|
||||
let mut result = true;
|
||||
alt get(ty).struct {
|
||||
match get(ty).struct {
|
||||
// Scalar types
|
||||
ty_nil | ty_bot | ty_bool | ty_int(_) | ty_float(_) | ty_uint(_) |
|
||||
ty_type | ty_ptr(_) => result = true,
|
||||
|
|
@ -2053,7 +2053,7 @@ fn type_is_pod(cx: ctxt, ty: t) -> bool {
|
|||
}
|
||||
|
||||
fn type_is_enum(ty: t) -> bool {
|
||||
alt get(ty).struct {
|
||||
match get(ty).struct {
|
||||
ty_enum(_, _) => return true,
|
||||
_ => return false
|
||||
}
|
||||
|
|
@ -2062,7 +2062,7 @@ fn type_is_enum(ty: t) -> bool {
|
|||
// Whether a type is enum like, that is a enum type with only nullary
|
||||
// constructors
|
||||
fn type_is_c_like_enum(cx: ctxt, ty: t) -> bool {
|
||||
alt get(ty).struct {
|
||||
match get(ty).struct {
|
||||
ty_enum(did, substs) => {
|
||||
let variants = enum_variants(cx, did);
|
||||
let some_n_ary = vec::any(*variants, |v| vec::len(v.args) > 0u);
|
||||
|
|
@ -2073,7 +2073,7 @@ fn type_is_c_like_enum(cx: ctxt, ty: t) -> bool {
|
|||
}
|
||||
|
||||
fn type_param(ty: t) -> option<uint> {
|
||||
alt get(ty).struct {
|
||||
match get(ty).struct {
|
||||
ty_param(p) => return some(p.idx),
|
||||
_ => {/* fall through */ }
|
||||
}
|
||||
|
|
@ -2088,7 +2088,7 @@ fn deref(cx: ctxt, t: t, expl: bool) -> option<mt> {
|
|||
deref_sty(cx, get(t).struct, expl)
|
||||
}
|
||||
fn deref_sty(cx: ctxt, sty: sty, expl: bool) -> option<mt> {
|
||||
alt sty {
|
||||
match sty {
|
||||
ty_rptr(_, mt) | ty_box(mt) | ty_uniq(mt) => {
|
||||
some(mt)
|
||||
}
|
||||
|
|
@ -2114,7 +2114,7 @@ fn deref_sty(cx: ctxt, sty: sty, expl: bool) -> option<mt> {
|
|||
fn type_autoderef(cx: ctxt, t: t) -> t {
|
||||
let mut t = t;
|
||||
loop {
|
||||
alt deref(cx, t, false) {
|
||||
match deref(cx, t, false) {
|
||||
none => return t,
|
||||
some(mt) => t = mt.ty
|
||||
}
|
||||
|
|
@ -2127,7 +2127,7 @@ fn index(cx: ctxt, t: t) -> option<mt> {
|
|||
}
|
||||
|
||||
fn index_sty(cx: ctxt, sty: sty) -> option<mt> {
|
||||
alt sty {
|
||||
match sty {
|
||||
ty_evec(mt, _) => some(mt),
|
||||
ty_estr(_) => some({ty: mk_u8(cx), mutbl: ast::m_imm}),
|
||||
_ => none
|
||||
|
|
@ -2135,7 +2135,7 @@ fn index_sty(cx: ctxt, sty: sty) -> option<mt> {
|
|||
}
|
||||
|
||||
pure fn hash_bound_region(br: &bound_region) -> uint {
|
||||
alt *br { // no idea if this is any good
|
||||
match *br { // no idea if this is any good
|
||||
ty::br_self => 0u,
|
||||
ty::br_anon => 1u,
|
||||
ty::br_named(str) => str::hash(str),
|
||||
|
|
@ -2163,7 +2163,7 @@ pure fn hash_type_structure(st: sty) -> uint {
|
|||
h
|
||||
}
|
||||
pure fn hash_region(r: ®ion) -> uint {
|
||||
alt *r { // no idea if this is any good
|
||||
match *r { // no idea if this is any good
|
||||
re_bound(br) => (hash_bound_region(&br)) << 2u | 0u,
|
||||
re_free(id, br) => ((id as uint) << 4u) |
|
||||
(hash_bound_region(&br)) << 2u | 1u,
|
||||
|
|
@ -2176,10 +2176,10 @@ pure fn hash_type_structure(st: sty) -> uint {
|
|||
let h = hash_subtys(h, substs.tps);
|
||||
h + substs.self_r.map_default(0u, |r| hash_region(&r))
|
||||
}
|
||||
alt st {
|
||||
match st {
|
||||
ty_nil => 0u,
|
||||
ty_bool => 1u,
|
||||
ty_int(t) => alt t {
|
||||
ty_int(t) => match t {
|
||||
ast::ty_i => 2u,
|
||||
ast::ty_char => 3u,
|
||||
ast::ty_i8 => 4u,
|
||||
|
|
@ -2187,14 +2187,14 @@ pure fn hash_type_structure(st: sty) -> uint {
|
|||
ast::ty_i32 => 6u,
|
||||
ast::ty_i64 => 7u
|
||||
}
|
||||
ty_uint(t) => alt t {
|
||||
ty_uint(t) => match t {
|
||||
ast::ty_u => 8u,
|
||||
ast::ty_u8 => 9u,
|
||||
ast::ty_u16 => 10u,
|
||||
ast::ty_u32 => 11u,
|
||||
ast::ty_u64 => 12u
|
||||
}
|
||||
ty_float(t) => alt t {
|
||||
ty_float(t) => match t {
|
||||
ast::ty_f => 13u,
|
||||
ast::ty_f32 => 14u,
|
||||
ast::ty_f64 => 15u
|
||||
|
|
@ -2246,7 +2246,7 @@ pure fn hash_type_structure(st: sty) -> uint {
|
|||
}
|
||||
|
||||
fn node_id_to_type(cx: ctxt, id: ast::node_id) -> t {
|
||||
alt smallintmap::find(*cx.node_types, id as uint) {
|
||||
match smallintmap::find(*cx.node_types, id as uint) {
|
||||
some(t) => t,
|
||||
none => cx.sess.bug(fmt!{"node_id_to_type: unbound node ID %s",
|
||||
ast_map::node_id_to_str(cx.items, id)})
|
||||
|
|
@ -2254,7 +2254,7 @@ fn node_id_to_type(cx: ctxt, id: ast::node_id) -> t {
|
|||
}
|
||||
|
||||
fn node_id_to_type_params(cx: ctxt, id: ast::node_id) -> ~[t] {
|
||||
alt cx.node_type_substs.find(id) {
|
||||
match cx.node_type_substs.find(id) {
|
||||
none => return ~[],
|
||||
some(ts) => return ts
|
||||
}
|
||||
|
|
@ -2266,35 +2266,35 @@ fn node_id_has_type_params(cx: ctxt, id: ast::node_id) -> bool {
|
|||
|
||||
// Type accessors for substructures of types
|
||||
fn ty_fn_args(fty: t) -> ~[arg] {
|
||||
alt get(fty).struct {
|
||||
match get(fty).struct {
|
||||
ty_fn(f) => f.inputs,
|
||||
_ => fail ~"ty_fn_args() called on non-fn type"
|
||||
}
|
||||
}
|
||||
|
||||
fn ty_fn_proto(fty: t) -> ast::proto {
|
||||
alt get(fty).struct {
|
||||
match get(fty).struct {
|
||||
ty_fn(f) => f.proto,
|
||||
_ => fail ~"ty_fn_proto() called on non-fn type"
|
||||
}
|
||||
}
|
||||
|
||||
pure fn ty_fn_ret(fty: t) -> t {
|
||||
alt get(fty).struct {
|
||||
match get(fty).struct {
|
||||
ty_fn(f) => f.output,
|
||||
_ => fail ~"ty_fn_ret() called on non-fn type"
|
||||
}
|
||||
}
|
||||
|
||||
fn ty_fn_ret_style(fty: t) -> ast::ret_style {
|
||||
alt get(fty).struct {
|
||||
match get(fty).struct {
|
||||
ty_fn(f) => f.ret_style,
|
||||
_ => fail ~"ty_fn_ret_style() called on non-fn type"
|
||||
}
|
||||
}
|
||||
|
||||
fn is_fn_ty(fty: t) -> bool {
|
||||
alt get(fty).struct {
|
||||
match get(fty).struct {
|
||||
ty_fn(_) => return true,
|
||||
_ => return false
|
||||
}
|
||||
|
|
@ -2312,14 +2312,14 @@ fn is_pred_ty(fty: t) -> bool {
|
|||
}
|
||||
|
||||
fn ty_var_id(typ: t) -> tv_vid {
|
||||
alt get(typ).struct {
|
||||
match get(typ).struct {
|
||||
ty_var(vid) => return vid,
|
||||
_ => { error!{"ty_var_id called on non-var ty"}; fail; }
|
||||
}
|
||||
}
|
||||
|
||||
fn ty_var_integral_id(typ: t) -> tvi_vid {
|
||||
alt get(typ).struct {
|
||||
match get(typ).struct {
|
||||
ty_var_integral(vid) => return vid,
|
||||
_ => { error!{"ty_var_integral_id called on ty other than \
|
||||
ty_var_integral"};
|
||||
|
|
@ -2361,7 +2361,7 @@ fn expr_has_ty_params(cx: ctxt, expr: @ast::expr) -> bool {
|
|||
}
|
||||
|
||||
fn expr_is_lval(method_map: typeck::method_map, e: @ast::expr) -> bool {
|
||||
alt e.node {
|
||||
match e.node {
|
||||
ast::expr_path(_) | ast::expr_unary(ast::deref, _) => true,
|
||||
ast::expr_field(_, _, _) | ast::expr_index(_, _) => {
|
||||
!method_map.contains_key(e.id)
|
||||
|
|
@ -2371,7 +2371,7 @@ fn expr_is_lval(method_map: typeck::method_map, e: @ast::expr) -> bool {
|
|||
}
|
||||
|
||||
fn stmt_node_id(s: @ast::stmt) -> ast::node_id {
|
||||
alt s.node {
|
||||
match s.node {
|
||||
ast::stmt_decl(_, id) | stmt_expr(_, id) | stmt_semi(_, id) => {
|
||||
return id;
|
||||
}
|
||||
|
|
@ -2385,13 +2385,13 @@ fn field_idx(id: ast::ident, fields: ~[field]) -> option<uint> {
|
|||
}
|
||||
|
||||
fn get_field(rec_ty: t, id: ast::ident) -> field {
|
||||
alt check vec::find(get_fields(rec_ty), |f| str::eq(f.ident, id)) {
|
||||
match check vec::find(get_fields(rec_ty), |f| str::eq(f.ident, id)) {
|
||||
some(f) => f
|
||||
}
|
||||
}
|
||||
|
||||
fn get_fields(rec_ty:t) -> ~[field] {
|
||||
alt check get(rec_ty).struct {
|
||||
match check get(rec_ty).struct {
|
||||
ty_rec(fields) => fields
|
||||
}
|
||||
}
|
||||
|
|
@ -2408,7 +2408,7 @@ fn method_idx(id: ast::ident, meths: ~[method]) -> option<uint> {
|
|||
fn param_tys_in_type(ty: t) -> ~[param_ty] {
|
||||
let mut rslt = ~[];
|
||||
do walk_ty(ty) |ty| {
|
||||
alt get(ty).struct {
|
||||
match get(ty).struct {
|
||||
ty_param(p) => {
|
||||
vec::push(rslt, p);
|
||||
}
|
||||
|
|
@ -2425,7 +2425,7 @@ fn occurs_check(tcx: ctxt, sp: span, vid: tv_vid, rt: t) {
|
|||
fn vars_in_type(ty: t) -> ~[tv_vid] {
|
||||
let mut rslt = ~[];
|
||||
do walk_ty(ty) |ty| {
|
||||
alt get(ty).struct {
|
||||
match get(ty).struct {
|
||||
ty_var(v) => vec::push(rslt, v),
|
||||
_ => ()
|
||||
}
|
||||
|
|
@ -2454,8 +2454,8 @@ fn occurs_check(tcx: ctxt, sp: span, vid: tv_vid, rt: t) {
|
|||
// the current head value for `m0`.
|
||||
fn canon<T:copy>(tbl: hashmap<ast::node_id, ast::inferable<T>>,
|
||||
m0: ast::inferable<T>) -> ast::inferable<T> {
|
||||
alt m0 {
|
||||
ast::infer(id) => alt tbl.find(id) {
|
||||
match m0 {
|
||||
ast::infer(id) => match tbl.find(id) {
|
||||
none => m0,
|
||||
some(m1) => {
|
||||
let cm1 = canon(tbl, m1);
|
||||
|
|
@ -2477,7 +2477,7 @@ fn canon_mode(cx: ctxt, m0: ast::mode) -> ast::mode {
|
|||
// Returns the head value for mode, failing if `m` was a infer(_) that
|
||||
// was never inferred. This should be safe for use after typeck.
|
||||
fn resolved_mode(cx: ctxt, m: ast::mode) -> ast::rmode {
|
||||
alt canon_mode(cx, m) {
|
||||
match canon_mode(cx, m) {
|
||||
ast::infer(_) => {
|
||||
cx.sess.bug(fmt!{"mode %? was never resolved", m});
|
||||
}
|
||||
|
|
@ -2490,7 +2490,7 @@ fn arg_mode(cx: ctxt, a: arg) -> ast::rmode { resolved_mode(cx, a.mode) }
|
|||
// Unifies `m1` and `m2`. Returns unified value or failure code.
|
||||
fn unify_mode(cx: ctxt, m1: ast::mode, m2: ast::mode)
|
||||
-> result<ast::mode, type_err> {
|
||||
alt (canon_mode(cx, m1), canon_mode(cx, m2)) {
|
||||
match (canon_mode(cx, m1), canon_mode(cx, m2)) {
|
||||
(m1, m2) if (m1 == m2) => {
|
||||
result::ok(m1)
|
||||
}
|
||||
|
|
@ -2511,7 +2511,7 @@ fn unify_mode(cx: ctxt, m1: ast::mode, m2: ast::mode)
|
|||
// If `m` was never unified, unifies it with `m_def`. Returns the final value
|
||||
// for `m`.
|
||||
fn set_default_mode(cx: ctxt, m: ast::mode, m_def: ast::rmode) {
|
||||
alt canon_mode(cx, m) {
|
||||
match canon_mode(cx, m) {
|
||||
ast::infer(id) => {
|
||||
cx.inferred_modes.insert(id, ast::expl(m_def));
|
||||
}
|
||||
|
|
@ -2520,7 +2520,7 @@ fn set_default_mode(cx: ctxt, m: ast::mode, m_def: ast::rmode) {
|
|||
}
|
||||
|
||||
fn ty_sort_str(cx: ctxt, t: t) -> ~str {
|
||||
alt get(t).struct {
|
||||
match get(t).struct {
|
||||
ty_nil | ty_bot | ty_bool | ty_int(_) |
|
||||
ty_uint(_) | ty_float(_) | ty_estr(_) |
|
||||
ty_type | ty_opaque_box | ty_opaque_closure_ptr(_) => {
|
||||
|
|
@ -2548,14 +2548,14 @@ fn ty_sort_str(cx: ctxt, t: t) -> ~str {
|
|||
|
||||
fn type_err_to_str(cx: ctxt, err: type_err) -> ~str {
|
||||
fn terr_vstore_kind_to_str(k: terr_vstore_kind) -> ~str {
|
||||
alt k { terr_vec => ~"[]", terr_str => ~"str" }
|
||||
match k { terr_vec => ~"[]", terr_str => ~"str" }
|
||||
}
|
||||
|
||||
alt err {
|
||||
match err {
|
||||
terr_mismatch => return ~"types differ",
|
||||
terr_ret_style_mismatch(expect, actual) => {
|
||||
fn to_str(s: ast::ret_style) -> ~str {
|
||||
alt s {
|
||||
match s {
|
||||
ast::noreturn => ~"non-returning",
|
||||
ast::return_val => ~"return-by-value"
|
||||
}
|
||||
|
|
@ -2631,7 +2631,7 @@ fn type_err_to_str(cx: ctxt, err: type_err) -> ~str {
|
|||
}
|
||||
|
||||
fn def_has_ty_params(def: ast::def) -> bool {
|
||||
alt def {
|
||||
match def {
|
||||
ast::def_fn(_, _) | ast::def_variant(_, _) | ast::def_class(_, _)
|
||||
=> true,
|
||||
_ => false
|
||||
|
|
@ -2643,7 +2643,7 @@ fn store_trait_methods(cx: ctxt, id: ast::node_id, ms: @~[method]) {
|
|||
}
|
||||
|
||||
fn trait_methods(cx: ctxt, id: ast::def_id) -> @~[method] {
|
||||
alt cx.trait_method_cache.find(id) {
|
||||
match cx.trait_method_cache.find(id) {
|
||||
some(ms) => return ms,
|
||||
_ => ()
|
||||
}
|
||||
|
|
@ -2657,7 +2657,7 @@ fn trait_methods(cx: ctxt, id: ast::def_id) -> @~[method] {
|
|||
fn impl_traits(cx: ctxt, id: ast::def_id) -> ~[t] {
|
||||
if id.crate == ast::local_crate {
|
||||
debug!{"(impl_traits) searching for trait impl %?", id};
|
||||
alt cx.items.find(id.node) {
|
||||
match cx.items.find(id.node) {
|
||||
some(ast_map::node_item(@{
|
||||
node: ast::item_impl(_, trait_refs, _, _),
|
||||
_},
|
||||
|
|
@ -2669,7 +2669,7 @@ fn impl_traits(cx: ctxt, id: ast::def_id) -> ~[t] {
|
|||
}
|
||||
some(ast_map::node_item(@{node: ast::item_class(*),
|
||||
_},_)) => {
|
||||
alt cx.def_map.find(id.node) {
|
||||
match cx.def_map.find(id.node) {
|
||||
some(def_ty(trait_id)) => {
|
||||
// XXX: Doesn't work cross-crate.
|
||||
debug!{"(impl_traits) found trait id %?", trait_id};
|
||||
|
|
@ -2692,7 +2692,7 @@ fn impl_traits(cx: ctxt, id: ast::def_id) -> ~[t] {
|
|||
}
|
||||
|
||||
fn ty_to_def_id(ty: t) -> option<ast::def_id> {
|
||||
alt get(ty).struct {
|
||||
match get(ty).struct {
|
||||
ty_trait(id, _) | ty_class(id, _) | ty_enum(id, _) => some(id),
|
||||
_ => none
|
||||
}
|
||||
|
|
@ -2723,7 +2723,7 @@ fn item_path_str(cx: ctxt, id: ast::def_id) -> ~str {
|
|||
Otherwise return none. */
|
||||
fn ty_dtor(cx: ctxt, class_id: def_id) -> option<def_id> {
|
||||
if is_local(class_id) {
|
||||
alt cx.items.find(class_id.node) {
|
||||
match cx.items.find(class_id.node) {
|
||||
some(ast_map::node_item(@{node: ast::item_class(_, _, _, _,
|
||||
some(dtor)), _}, _))
|
||||
=> some(local_def(dtor.node.id)),
|
||||
|
|
@ -2744,9 +2744,9 @@ fn item_path(cx: ctxt, id: ast::def_id) -> ast_map::path {
|
|||
csearch::get_item_path(cx, id)
|
||||
} else {
|
||||
let node = cx.items.get(id.node);
|
||||
alt node {
|
||||
match node {
|
||||
ast_map::node_item(item, path) => {
|
||||
let item_elt = alt item.node {
|
||||
let item_elt = match item.node {
|
||||
item_mod(_) | item_foreign_mod(_) => {
|
||||
ast_map::path_mod(item.ident)
|
||||
}
|
||||
|
|
@ -2796,14 +2796,14 @@ fn enum_is_univariant(cx: ctxt, id: ast::def_id) -> bool {
|
|||
}
|
||||
|
||||
fn type_is_empty(cx: ctxt, t: t) -> bool {
|
||||
alt ty::get(t).struct {
|
||||
match ty::get(t).struct {
|
||||
ty_enum(did, _) => (*enum_variants(cx, did)).is_empty(),
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
||||
fn enum_variants(cx: ctxt, id: ast::def_id) -> @~[variant_info] {
|
||||
alt cx.enum_var_cache.find(id) {
|
||||
match cx.enum_var_cache.find(id) {
|
||||
some(variants) => return variants,
|
||||
_ => { /* fallthrough */ }
|
||||
}
|
||||
|
|
@ -2816,7 +2816,7 @@ fn enum_variants(cx: ctxt, id: ast::def_id) -> @~[variant_info] {
|
|||
call eval_const_expr, it should never get called twice for the same
|
||||
expr, since check_enum_variants also updates the enum_var_cache
|
||||
*/
|
||||
alt cx.items.get(id.node) {
|
||||
match cx.items.get(id.node) {
|
||||
ast_map::node_item(@{node: ast::item_enum(variants, _), _}, _) => {
|
||||
let mut disr_val = -1;
|
||||
@vec::map(variants, |variant| {
|
||||
|
|
@ -2826,10 +2826,10 @@ fn enum_variants(cx: ctxt, id: ast::def_id) -> @~[variant_info] {
|
|||
ty_fn_args(ctor_ty).map(|a| a.ty)
|
||||
} else { ~[] }
|
||||
};
|
||||
alt variant.node.disr_expr {
|
||||
match variant.node.disr_expr {
|
||||
some (ex) => {
|
||||
// FIXME: issue #1417
|
||||
disr_val = alt const_eval::eval_const_expr(cx, ex) {
|
||||
disr_val = match const_eval::eval_const_expr(cx, ex) {
|
||||
const_eval::const_int(val) =>val as int,
|
||||
_ => cx.sess.bug(~"tag_variants: bad disr expr")
|
||||
}
|
||||
|
|
@ -2869,7 +2869,7 @@ fn enum_variant_with_id(cx: ctxt, enum_id: ast::def_id,
|
|||
// If the given item is in an external crate, looks up its type and adds it to
|
||||
// the type cache. Returns the type parameters and type.
|
||||
fn lookup_item_type(cx: ctxt, did: ast::def_id) -> ty_param_bounds_and_ty {
|
||||
alt cx.tcache.find(did) {
|
||||
match cx.tcache.find(did) {
|
||||
some(tpt) => return tpt,
|
||||
none => {
|
||||
// The item is in this crate. The caller should have added it to the
|
||||
|
|
@ -2891,7 +2891,7 @@ fn lookup_field_type(tcx: ctxt, class_id: def_id, id: def_id,
|
|||
node_id_to_type(tcx, id.node)
|
||||
}
|
||||
else {
|
||||
alt tcx.tcache.find(id) {
|
||||
match tcx.tcache.find(id) {
|
||||
some(tpt) => tpt.ty,
|
||||
none => {
|
||||
let tpt = csearch::get_field_type(tcx, class_id, id);
|
||||
|
|
@ -2907,9 +2907,9 @@ fn lookup_field_type(tcx: ctxt, class_id: def_id, id: def_id,
|
|||
// Fails if the id is not bound to a class.
|
||||
fn lookup_class_fields(cx: ctxt, did: ast::def_id) -> ~[field_ty] {
|
||||
if did.crate == ast::local_crate {
|
||||
alt cx.items.find(did.node) {
|
||||
match cx.items.find(did.node) {
|
||||
some(ast_map::node_item(i,_)) => {
|
||||
alt i.node {
|
||||
match i.node {
|
||||
ast::item_class(_, _, items, _, _) => {
|
||||
class_field_tys(items)
|
||||
}
|
||||
|
|
@ -2929,7 +2929,7 @@ fn lookup_class_fields(cx: ctxt, did: ast::def_id) -> ~[field_ty] {
|
|||
|
||||
fn lookup_class_field(cx: ctxt, parent: ast::def_id, field_id: ast::def_id)
|
||||
-> field_ty {
|
||||
alt vec::find(lookup_class_fields(cx, parent),
|
||||
match vec::find(lookup_class_fields(cx, parent),
|
||||
|f| f.id.node == field_id.node) {
|
||||
some(t) => t,
|
||||
none => cx.sess.bug(~"class ID not found in parent's fields")
|
||||
|
|
@ -2962,7 +2962,7 @@ fn lookup_class_method_by_name(cx:ctxt, did: ast::def_id, name: ident,
|
|||
-> ~[{name: ident, id: node_id, vis: visibility}] {
|
||||
|
||||
assert is_local(did);
|
||||
alt cx.items.find(did.node) {
|
||||
match cx.items.find(did.node) {
|
||||
some(ast_map::node_item(@{
|
||||
node: item_class(_,_,items,_,_), _
|
||||
}, _)) => {
|
||||
|
|
@ -2994,7 +2994,7 @@ fn lookup_class_method_by_name(cx:ctxt, did: ast::def_id, name: ident,
|
|||
fn class_field_tys(items: ~[@class_member]) -> ~[field_ty] {
|
||||
let mut rslt = ~[];
|
||||
for items.each |it| {
|
||||
alt it.node {
|
||||
match it.node {
|
||||
instance_var(nm, _, cm, id, vis) => {
|
||||
vec::push(rslt, {ident: nm, id: ast_util::local_def(id),
|
||||
vis: vis, mutability: cm});
|
||||
|
|
@ -3020,7 +3020,7 @@ fn class_items_as_mutable_fields(cx:ctxt, did: ast::def_id,
|
|||
// mutability.
|
||||
fn class_items_as_fields(cx:ctxt, did: ast::def_id,
|
||||
substs: substs) -> ~[field] {
|
||||
class_item_fields(cx, did, substs, |mt| alt mt {
|
||||
class_item_fields(cx, did, substs, |mt| match mt {
|
||||
class_mutable => m_mutbl,
|
||||
class_immutable => m_imm })
|
||||
}
|
||||
|
|
@ -3058,7 +3058,7 @@ fn is_binopable(_cx: ctxt, ty: t, op: ast::binop) -> bool {
|
|||
const opcat_logic: int = 7;
|
||||
|
||||
fn opcat(op: ast::binop) -> int {
|
||||
alt op {
|
||||
match op {
|
||||
ast::add => opcat_add,
|
||||
ast::subtract => opcat_sub,
|
||||
ast::mul => opcat_mult,
|
||||
|
|
@ -3081,7 +3081,7 @@ fn is_binopable(_cx: ctxt, ty: t, op: ast::binop) -> bool {
|
|||
}
|
||||
|
||||
fn tycat(ty: t) -> int {
|
||||
alt get(ty).struct {
|
||||
match get(ty).struct {
|
||||
ty_bool => tycat_bool,
|
||||
ty_int(_) | ty_uint(_) | ty_var_integral(_) => tycat_int,
|
||||
ty_float(_) => tycat_float,
|
||||
|
|
@ -3126,7 +3126,7 @@ fn normalize_ty(cx: ctxt, t: t) -> t {
|
|||
}
|
||||
}
|
||||
|
||||
alt cx.normalized_cache.find(t) {
|
||||
match cx.normalized_cache.find(t) {
|
||||
some(t) => return t,
|
||||
none => ()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -180,7 +180,7 @@ fn write_substs_to_tcx(tcx: ty::ctxt,
|
|||
}
|
||||
|
||||
fn lookup_def_tcx(tcx: ty::ctxt, sp: span, id: ast::node_id) -> ast::def {
|
||||
alt tcx.def_map.find(id) {
|
||||
match tcx.def_map.find(id) {
|
||||
some(x) => x,
|
||||
_ => {
|
||||
tcx.sess.span_fatal(sp, ~"internal error looking up a definition")
|
||||
|
|
@ -205,7 +205,7 @@ fn require_same_types(
|
|||
msg: fn() -> ~str) -> bool {
|
||||
|
||||
let l_tcx, l_infcx;
|
||||
alt maybe_infcx {
|
||||
match maybe_infcx {
|
||||
none => {
|
||||
l_tcx = tcx;
|
||||
l_infcx = infer::new_infer_ctxt(tcx);
|
||||
|
|
@ -216,7 +216,7 @@ fn require_same_types(
|
|||
}
|
||||
}
|
||||
|
||||
alt infer::mk_eqty(l_infcx, t1, t2) {
|
||||
match infer::mk_eqty(l_infcx, t1, t2) {
|
||||
result::ok(()) => true,
|
||||
result::err(terr) => {
|
||||
l_tcx.sess.span_err(span, msg() + ~": " +
|
||||
|
|
@ -227,10 +227,10 @@ fn require_same_types(
|
|||
}
|
||||
|
||||
fn arg_is_argv_ty(_tcx: ty::ctxt, a: ty::arg) -> bool {
|
||||
alt ty::get(a.ty).struct {
|
||||
match ty::get(a.ty).struct {
|
||||
ty::ty_evec(mt, vstore_uniq) => {
|
||||
if mt.mutbl != ast::m_imm { return false; }
|
||||
alt ty::get(mt.ty).struct {
|
||||
match ty::get(mt.ty).struct {
|
||||
ty::ty_estr(vstore_uniq) => return true,
|
||||
_ => return false
|
||||
}
|
||||
|
|
@ -245,12 +245,12 @@ fn check_main_fn_ty(ccx: @crate_ctxt,
|
|||
|
||||
let tcx = ccx.tcx;
|
||||
let main_t = ty::node_id_to_type(tcx, main_id);
|
||||
alt ty::get(main_t).struct {
|
||||
match ty::get(main_t).struct {
|
||||
ty::ty_fn({purity: ast::impure_fn, proto: ast::proto_bare,
|
||||
inputs, output, ret_style: ast::return_val}) => {
|
||||
alt tcx.items.find(main_id) {
|
||||
match tcx.items.find(main_id) {
|
||||
some(ast_map::node_item(it,_)) => {
|
||||
alt it.node {
|
||||
match it.node {
|
||||
ast::item_fn(_,ps,_) if vec::is_not_empty(ps) => {
|
||||
tcx.sess.span_err(main_span,
|
||||
~"main function is not allowed to have type parameters");
|
||||
|
|
@ -284,7 +284,7 @@ fn check_main_fn_ty(ccx: @crate_ctxt,
|
|||
fn check_for_main_fn(ccx: @crate_ctxt) {
|
||||
let tcx = ccx.tcx;
|
||||
if !tcx.sess.building_library {
|
||||
alt copy tcx.sess.main_fn {
|
||||
match copy tcx.sess.main_fn {
|
||||
some((id, sp)) => check_main_fn_ty(ccx, id, sp),
|
||||
none => tcx.sess.err(~"main function not found")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ fn get_region_reporting_err(tcx: ty::ctxt,
|
|||
span: span,
|
||||
res: result<ty::region, ~str>) -> ty::region {
|
||||
|
||||
alt res {
|
||||
match res {
|
||||
result::ok(r) => r,
|
||||
result::err(e) => {
|
||||
tcx.sess.span_err(span, e);
|
||||
|
|
@ -71,7 +71,7 @@ fn get_region_reporting_err(tcx: ty::ctxt,
|
|||
fn ast_region_to_region<AC: ast_conv, RS: region_scope copy owned>(
|
||||
self: AC, rscope: RS, span: span, a_r: @ast::region) -> ty::region {
|
||||
|
||||
let res = alt a_r.node {
|
||||
let res = match a_r.node {
|
||||
ast::re_anon => rscope.anon_region(),
|
||||
ast::re_named(id) => rscope.named_region(id)
|
||||
};
|
||||
|
|
@ -93,7 +93,7 @@ fn ast_path_to_substs_and_ty<AC: ast_conv, RS: region_scope copy owned>(
|
|||
// If the type is parameterized by the self region, then replace self
|
||||
// region with the current anon region binding (in other words,
|
||||
// whatever & would get replaced with).
|
||||
let self_r = alt (decl_rp, path.rp) {
|
||||
let self_r = match (decl_rp, path.rp) {
|
||||
(false, none) => {
|
||||
none
|
||||
}
|
||||
|
|
@ -168,14 +168,14 @@ fn ast_ty_to_ty<AC: ast_conv, RS: region_scope copy owned>(
|
|||
|
||||
let tcx = self.tcx();
|
||||
|
||||
alt a_seq_ty.ty.node {
|
||||
match a_seq_ty.ty.node {
|
||||
// to convert to an e{vec,str}, there can't be a mutability argument
|
||||
_ if a_seq_ty.mutbl != ast::m_imm => (),
|
||||
ast::ty_vec(mt) => {
|
||||
return ty::mk_evec(tcx, ast_mt_to_mt(self, rscope, mt), vst);
|
||||
}
|
||||
ast::ty_path(path, id) => {
|
||||
alt tcx.def_map.find(id) {
|
||||
match tcx.def_map.find(id) {
|
||||
some(ast::def_prim_ty(ast::ty_str)) => {
|
||||
check_path_args(tcx, path, NO_TPS | NO_REGIONS);
|
||||
return ty::mk_estr(tcx, vst);
|
||||
|
|
@ -212,7 +212,7 @@ fn ast_ty_to_ty<AC: ast_conv, RS: region_scope copy owned>(
|
|||
|
||||
let tcx = self.tcx();
|
||||
|
||||
alt tcx.ast_ty_to_ty_cache.find(ast_ty) {
|
||||
match tcx.ast_ty_to_ty_cache.find(ast_ty) {
|
||||
some(ty::atttce_resolved(ty)) => return ty,
|
||||
some(ty::atttce_unresolved) => {
|
||||
tcx.sess.span_fatal(ast_ty.span, ~"illegal recursive type; \
|
||||
|
|
@ -223,7 +223,7 @@ fn ast_ty_to_ty<AC: ast_conv, RS: region_scope copy owned>(
|
|||
}
|
||||
|
||||
tcx.ast_ty_to_ty_cache.insert(ast_ty, ty::atttce_unresolved);
|
||||
let typ = alt ast_ty.node {
|
||||
let typ = match ast_ty.node {
|
||||
ast::ty_nil => ty::mk_nil(tcx),
|
||||
ast::ty_bot => ty::mk_bot(tcx),
|
||||
ast::ty_box(mt) => {
|
||||
|
|
@ -265,17 +265,17 @@ fn ast_ty_to_ty<AC: ast_conv, RS: region_scope copy owned>(
|
|||
ty::mk_fn(tcx, ty_of_fn_decl(self, rscope, proto, decl, none))
|
||||
}
|
||||
ast::ty_path(path, id) => {
|
||||
let a_def = alt tcx.def_map.find(id) {
|
||||
let a_def = match tcx.def_map.find(id) {
|
||||
none => tcx.sess.span_fatal(ast_ty.span, fmt!{"unbound path %s",
|
||||
path_to_str(path)}),
|
||||
some(d) => d
|
||||
};
|
||||
alt a_def {
|
||||
match a_def {
|
||||
ast::def_ty(did) | ast::def_class(did, _) => {
|
||||
ast_path_to_ty(self, rscope, did, path, id).ty
|
||||
}
|
||||
ast::def_prim_ty(nty) => {
|
||||
alt nty {
|
||||
match nty {
|
||||
ast::ty_bool => {
|
||||
check_path_args(tcx, path, NO_TPS | NO_REGIONS);
|
||||
ty::mk_bool(tcx)
|
||||
|
|
@ -356,20 +356,20 @@ fn ty_of_arg<AC: ast_conv, RS: region_scope copy owned>(
|
|||
self: AC, rscope: RS, a: ast::arg,
|
||||
expected_ty: option<ty::arg>) -> ty::arg {
|
||||
|
||||
let ty = alt a.ty.node {
|
||||
let ty = match a.ty.node {
|
||||
ast::ty_infer if expected_ty.is_some() => expected_ty.get().ty,
|
||||
ast::ty_infer => self.ty_infer(a.ty.span),
|
||||
_ => ast_ty_to_ty(self, rscope, a.ty)
|
||||
};
|
||||
|
||||
let mode = {
|
||||
alt a.mode {
|
||||
match a.mode {
|
||||
ast::infer(_) if expected_ty.is_some() => {
|
||||
result::get(ty::unify_mode(self.tcx(), a.mode,
|
||||
expected_ty.get().mode))
|
||||
}
|
||||
ast::infer(_) => {
|
||||
alt ty::get(ty).struct {
|
||||
match ty::get(ty).struct {
|
||||
// If the type is not specified, then this must be a fn expr.
|
||||
// Leave the mode as infer(_), it will get inferred based
|
||||
// on constraints elsewhere.
|
||||
|
|
@ -417,7 +417,7 @@ fn ty_of_fn_decl<AC: ast_conv, RS: region_scope copy owned>(
|
|||
};
|
||||
|
||||
let expected_ret_ty = expected_tys.map(|e| e.output);
|
||||
let output_ty = alt decl.output.node {
|
||||
let output_ty = match decl.output.node {
|
||||
ast::ty_infer if expected_ret_ty.is_some() => expected_ret_ty.get(),
|
||||
ast::ty_infer => self.ty_infer(decl.output.span),
|
||||
_ => ast_ty_to_ty(self, rb, decl.output)
|
||||
|
|
|
|||
|
|
@ -177,7 +177,7 @@ fn check_bare_fn(ccx: @crate_ctxt,
|
|||
id: ast::node_id,
|
||||
self_info: option<self_info>) {
|
||||
let fty = ty::node_id_to_type(ccx.tcx, id);
|
||||
let fn_ty = alt check ty::get(fty).struct { ty::ty_fn(f) => f };
|
||||
let fn_ty = match check ty::get(fty).struct { ty::ty_fn(f) => f };
|
||||
check_fn(ccx, self_info, fn_ty, decl, body, false, none);
|
||||
}
|
||||
|
||||
|
|
@ -216,7 +216,7 @@ fn check_fn(ccx: @crate_ctxt,
|
|||
// in the case of function expressions, based on the outer context.
|
||||
let fcx: @fn_ctxt = {
|
||||
let {infcx, locals, purity, node_types, node_type_substs} =
|
||||
alt old_fcx {
|
||||
match old_fcx {
|
||||
none => {
|
||||
{infcx: infer::new_infer_ctxt(tcx),
|
||||
locals: int_hash(),
|
||||
|
|
@ -236,7 +236,7 @@ fn check_fn(ccx: @crate_ctxt,
|
|||
|
||||
let indirect_ret_ty = if indirect_ret {
|
||||
let ofcx = option::get(old_fcx);
|
||||
alt ofcx.indirect_ret_ty {
|
||||
match ofcx.indirect_ret_ty {
|
||||
some(t) => some(t),
|
||||
none => some(ofcx.ret_ty)
|
||||
}
|
||||
|
|
@ -260,7 +260,7 @@ fn check_fn(ccx: @crate_ctxt,
|
|||
|
||||
// We unify the tail expr's type with the
|
||||
// function result type, if there is a tail expr.
|
||||
alt body.node.expr {
|
||||
match body.node.expr {
|
||||
some(tail_expr) => {
|
||||
let tail_expr_ty = fcx.expr_ty(tail_expr);
|
||||
demand::suptype(fcx, tail_expr.span, fcx.ret_ty, tail_expr_ty);
|
||||
|
|
@ -293,7 +293,7 @@ fn check_fn(ccx: @crate_ctxt,
|
|||
let assign = fn@(nid: ast::node_id, ty_opt: option<ty::t>) {
|
||||
let var_id = fcx.infcx.next_ty_var_id();
|
||||
fcx.locals.insert(nid, var_id);
|
||||
alt ty_opt {
|
||||
match ty_opt {
|
||||
none => {/* nothing to do */ }
|
||||
some(typ) => {
|
||||
infer::mk_eqty(fcx.infcx, ty::mk_var(tcx, var_id), typ);
|
||||
|
|
@ -311,7 +311,7 @@ fn check_fn(ccx: @crate_ctxt,
|
|||
// Add explicitly-declared locals.
|
||||
let visit_local = fn@(local: @ast::local,
|
||||
&&e: (), v: visit::vt<()>) {
|
||||
let o_ty = alt local.node.ty.node {
|
||||
let o_ty = match local.node.ty.node {
|
||||
ast::ty_infer => none,
|
||||
_ => some(fcx.to_ty(local.node.ty))
|
||||
};
|
||||
|
|
@ -324,7 +324,7 @@ fn check_fn(ccx: @crate_ctxt,
|
|||
|
||||
// Add pattern bindings.
|
||||
let visit_pat = fn@(p: @ast::pat, &&e: (), v: visit::vt<()>) {
|
||||
alt p.node {
|
||||
match p.node {
|
||||
ast::pat_ident(_, path, _)
|
||||
if !pat_util::pat_is_variant(fcx.ccx.tcx.def_map, p) => {
|
||||
assign(p.id, none);
|
||||
|
|
@ -371,7 +371,7 @@ fn check_method(ccx: @crate_ctxt, method: @ast::method,
|
|||
|
||||
fn check_class_member(ccx: @crate_ctxt, class_t: self_info,
|
||||
cm: @ast::class_member) {
|
||||
alt cm.node {
|
||||
match cm.node {
|
||||
ast::instance_var(_,t,_,_,_) => (),
|
||||
ast::class_method(m) => check_method(ccx, m, class_t)
|
||||
}
|
||||
|
|
@ -383,7 +383,7 @@ fn check_no_duplicate_fields(tcx: ty::ctxt, fields:
|
|||
|x,y| str::eq(*x, *y));
|
||||
for fields.each |p| {
|
||||
let (id, sp) = p;
|
||||
alt field_names.find(id) {
|
||||
match field_names.find(id) {
|
||||
some(orig_sp) => {
|
||||
tcx.sess.span_err(sp, fmt!{"Duplicate field \
|
||||
name %s in record type declaration",
|
||||
|
|
@ -401,7 +401,7 @@ fn check_no_duplicate_fields(tcx: ty::ctxt, fields:
|
|||
}
|
||||
|
||||
fn check_item(ccx: @crate_ctxt, it: @ast::item) {
|
||||
alt it.node {
|
||||
match it.node {
|
||||
ast::item_const(_, e) => check_const(ccx, it.span, e, it.id),
|
||||
ast::item_enum(vs, _) => {
|
||||
check_enum_variants(ccx, it.span, vs, it.id);
|
||||
|
|
@ -419,7 +419,7 @@ fn check_item(ccx: @crate_ctxt, it: @ast::item) {
|
|||
}
|
||||
ast::item_trait(_, _, trait_methods) => {
|
||||
for trait_methods.each |trait_method| {
|
||||
alt trait_method {
|
||||
match trait_method {
|
||||
required(ty_m) => {
|
||||
// Nothing to do, since required methods don't have
|
||||
// bodies to check.
|
||||
|
|
@ -471,7 +471,7 @@ fn check_item(ccx: @crate_ctxt, it: @ast::item) {
|
|||
let tpt_ty = ty::node_id_to_type(ccx.tcx, it.id);
|
||||
check_bounds_are_used(ccx, t.span, tps, tpt_ty);
|
||||
// If this is a record ty, check for duplicate fields
|
||||
alt t.node {
|
||||
match t.node {
|
||||
ast::ty_rec(fields) => {
|
||||
check_no_duplicate_fields(ccx.tcx, fields.map(|f|
|
||||
(f.node.ident, f.span)));
|
||||
|
|
@ -519,7 +519,7 @@ impl of region_scope for @fn_ctxt {
|
|||
}
|
||||
fn named_region(id: ast::ident) -> result<ty::region, ~str> {
|
||||
do empty_rscope.named_region(id).chain_err |_e| {
|
||||
alt self.in_scope_regions.find(ty::br_named(id)) {
|
||||
match self.in_scope_regions.find(ty::br_named(id)) {
|
||||
some(r) => result::ok(r),
|
||||
none if *id == ~"blk" => self.block_region(),
|
||||
none => {
|
||||
|
|
@ -564,7 +564,7 @@ impl methods for @fn_ctxt {
|
|||
}
|
||||
|
||||
fn expr_ty(ex: @ast::expr) -> ty::t {
|
||||
alt self.node_types.find(ex.id) {
|
||||
match self.node_types.find(ex.id) {
|
||||
some(t) => t,
|
||||
none => {
|
||||
self.tcx().sess.bug(fmt!{"no type for expr %d (%s) in fcx %s",
|
||||
|
|
@ -573,7 +573,7 @@ impl methods for @fn_ctxt {
|
|||
}
|
||||
}
|
||||
fn node_ty(id: ast::node_id) -> ty::t {
|
||||
alt self.node_types.find(id) {
|
||||
match self.node_types.find(id) {
|
||||
some(t) => t,
|
||||
none => {
|
||||
self.tcx().sess.bug(
|
||||
|
|
@ -584,7 +584,7 @@ impl methods for @fn_ctxt {
|
|||
}
|
||||
}
|
||||
fn node_ty_substs(id: ast::node_id) -> ty::substs {
|
||||
alt self.node_type_substs.find(id) {
|
||||
match self.node_type_substs.find(id) {
|
||||
some(ts) => ts,
|
||||
none => {
|
||||
self.tcx().sess.bug(
|
||||
|
|
@ -637,7 +637,7 @@ impl methods for @fn_ctxt {
|
|||
}
|
||||
|
||||
fn require_unsafe(sp: span, op: ~str) {
|
||||
alt self.purity {
|
||||
match self.purity {
|
||||
ast::unsafe_fn => {/*ok*/}
|
||||
_ => {
|
||||
self.ccx.tcx.sess.span_err(
|
||||
|
|
@ -662,9 +662,9 @@ fn do_autoderef(fcx: @fn_ctxt, sp: span, t: ty::t) -> ty::t {
|
|||
let sty = structure_of(fcx, sp, t1);
|
||||
|
||||
// Some extra checks to detect weird cycles and so forth:
|
||||
alt sty {
|
||||
match sty {
|
||||
ty::ty_box(inner) | ty::ty_uniq(inner) | ty::ty_rptr(_, inner) => {
|
||||
alt ty::get(t1).struct {
|
||||
match ty::get(t1).struct {
|
||||
ty::ty_var(v1) => {
|
||||
ty::occurs_check(fcx.ccx.tcx, sp, v1,
|
||||
ty::mk_box(fcx.ccx.tcx, inner));
|
||||
|
|
@ -687,7 +687,7 @@ fn do_autoderef(fcx: @fn_ctxt, sp: span, t: ty::t) -> ty::t {
|
|||
}
|
||||
|
||||
// Otherwise, deref if type is derefable:
|
||||
alt ty::deref_sty(fcx.ccx.tcx, sty, false) {
|
||||
match ty::deref_sty(fcx.ccx.tcx, sty, false) {
|
||||
none => return t1,
|
||||
some(mt) => t1 = mt.ty
|
||||
}
|
||||
|
|
@ -698,7 +698,7 @@ fn do_autoderef(fcx: @fn_ctxt, sp: span, t: ty::t) -> ty::t {
|
|||
fn check_lit(fcx: @fn_ctxt, lit: @ast::lit) -> ty::t {
|
||||
let tcx = fcx.ccx.tcx;
|
||||
|
||||
alt lit.node {
|
||||
match lit.node {
|
||||
ast::lit_str(s) => ty::mk_estr(tcx, ty::vstore_slice(ty::re_static)),
|
||||
ast::lit_int(_, t) => ty::mk_mach_int(tcx, t),
|
||||
ast::lit_uint(_, t) => ty::mk_mach_uint(tcx, t),
|
||||
|
|
@ -740,7 +740,7 @@ fn impl_self_ty(fcx: @fn_ctxt, did: ast::def_id) -> ty_param_substs_and_ty {
|
|||
|
||||
let {n_tps, rp, raw_ty} = if did.crate == ast::local_crate {
|
||||
let rp = fcx.tcx().region_paramd_items.contains_key(did.node);
|
||||
alt check tcx.items.find(did.node) {
|
||||
match check tcx.items.find(did.node) {
|
||||
some(ast_map::node_item(@{node: ast::item_impl(ts, _, st, _),
|
||||
_}, _)) => {
|
||||
{n_tps: ts.len(),
|
||||
|
|
@ -818,7 +818,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
|||
// process the types bound by the function but not by any nested
|
||||
// functions. Therefore, we match one level of structure.
|
||||
let fn_ty =
|
||||
alt structure_of(fcx, sp, in_fty) {
|
||||
match structure_of(fcx, sp, in_fty) {
|
||||
sty @ ty::ty_fn(fn_ty) => {
|
||||
replace_bound_regions_in_fn_ty(
|
||||
fcx.ccx.tcx, @nil, none, fn_ty,
|
||||
|
|
@ -872,7 +872,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
|||
// right way to do this.
|
||||
for [false, true]/_.each |check_blocks| {
|
||||
for args.eachi |i, a| {
|
||||
let is_block = alt a.node {
|
||||
let is_block = match a.node {
|
||||
ast::expr_fn_block(*) => true,
|
||||
_ => false
|
||||
};
|
||||
|
|
@ -905,7 +905,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
|||
|
||||
// Index expressions need to be handled seperately, to inform
|
||||
// them that they appear in call position.
|
||||
let mut bot = alt f.node {
|
||||
let mut bot = match f.node {
|
||||
ast::expr_field(base, field, tys) => {
|
||||
check_field(fcx, f, true, base, field, tys)
|
||||
}
|
||||
|
|
@ -922,7 +922,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
|||
};
|
||||
|
||||
// Pull the return type out of the type of the function.
|
||||
alt structure_of(fcx, sp, fty) {
|
||||
match structure_of(fcx, sp, fty) {
|
||||
ty::ty_fn(f) => {
|
||||
bot |= (f.ret_style == ast::noreturn);
|
||||
fcx.write_ty(call_expr_id, f.output);
|
||||
|
|
@ -952,7 +952,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
|||
elsopt: option<@ast::expr>, id: ast::node_id,
|
||||
_sp: span) -> bool {
|
||||
let (if_t, if_bot) =
|
||||
alt elsopt {
|
||||
match elsopt {
|
||||
some(els) => {
|
||||
let if_t = fcx.infcx.next_ty_var();
|
||||
let thn_bot = check_block(fcx, thn);
|
||||
|
|
@ -976,7 +976,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
|||
-> option<(ty::t, bool)> {
|
||||
let lkup = method::lookup(fcx, op_ex, self_ex, op_ex.id,
|
||||
op_ex.callee_id, @opname, self_t, ~[], false);
|
||||
alt lkup.method() {
|
||||
match lkup.method() {
|
||||
some(origin) => {
|
||||
let {fty: method_ty, bot: bot} = {
|
||||
let method_ty = fcx.node_ty(op_ex.callee_id);
|
||||
|
|
@ -998,7 +998,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
|||
let lhs_bot = check_expr(fcx, lhs, none);
|
||||
let lhs_t = fcx.expr_ty(lhs);
|
||||
let lhs_t = structurally_resolved_type(fcx, lhs.span, lhs_t);
|
||||
return alt (op, ty::get(lhs_t).struct) {
|
||||
return match (op, ty::get(lhs_t).struct) {
|
||||
(_, _) if ty::type_is_integral(lhs_t) &&
|
||||
ast_util::is_shift_binop(op) => {
|
||||
// Shift is a special case: rhs can be any integral type
|
||||
|
|
@ -1013,7 +1013,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
|||
let tvar = fcx.infcx.next_ty_var();
|
||||
demand::suptype(fcx, expr.span, tvar, lhs_t);
|
||||
let rhs_bot = check_expr_with(fcx, rhs, tvar);
|
||||
let rhs_t = alt op {
|
||||
let rhs_t = match op {
|
||||
ast::eq | ast::lt | ast::le | ast::ne | ast::ge |
|
||||
ast::gt => {
|
||||
// these comparison operators are handled in a
|
||||
|
|
@ -1042,9 +1042,9 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
|||
lhs_expr: @ast::expr, lhs_resolved_t: ty::t,
|
||||
op: ast::binop, rhs: @ast::expr) -> (ty::t, bool) {
|
||||
let tcx = fcx.ccx.tcx;
|
||||
alt ast_util::binop_to_method_name(op) {
|
||||
match ast_util::binop_to_method_name(op) {
|
||||
some(name) => {
|
||||
alt lookup_op_method(fcx, ex,
|
||||
match lookup_op_method(fcx, ex,
|
||||
lhs_expr, lhs_resolved_t,
|
||||
name, ~[rhs]) {
|
||||
some(pair) => return pair,
|
||||
|
|
@ -1064,7 +1064,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
|||
// If the or operator is used it might be that the user forgot to
|
||||
// supply the do keyword. Let's be more helpful in that situation.
|
||||
if op == ast::or {
|
||||
alt ty::get(lhs_resolved_t).struct {
|
||||
match ty::get(lhs_resolved_t).struct {
|
||||
ty::ty_fn(f) => {
|
||||
tcx.sess.span_note(
|
||||
ex.span, ~"did you forget the 'do' keyword for the call?");
|
||||
|
|
@ -1078,7 +1078,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
|||
fn check_user_unop(fcx: @fn_ctxt, op_str: ~str, mname: ~str,
|
||||
ex: @ast::expr,
|
||||
rhs_expr: @ast::expr, rhs_t: ty::t) -> ty::t {
|
||||
alt lookup_op_method(fcx, ex, rhs_expr, rhs_t, mname, ~[]) {
|
||||
match lookup_op_method(fcx, ex, rhs_expr, rhs_t, mname, ~[]) {
|
||||
some((ret_ty, _)) => ret_ty,
|
||||
_ => {
|
||||
fcx.ccx.tcx.sess.span_err(
|
||||
|
|
@ -1096,9 +1096,9 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
|||
fn unpack_expected<O: copy>(fcx: @fn_ctxt, expected: option<ty::t>,
|
||||
unpack: fn(ty::sty) -> option<O>)
|
||||
-> option<O> {
|
||||
alt expected {
|
||||
match expected {
|
||||
some(t) => {
|
||||
alt resolve_type(fcx.infcx, t, force_tvar) {
|
||||
match resolve_type(fcx.infcx, t, force_tvar) {
|
||||
result::ok(t) => unpack(ty::get(t).struct),
|
||||
_ => none
|
||||
}
|
||||
|
|
@ -1121,7 +1121,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
|||
// def'n of br_cap_avoid() for a more lengthy explanation of
|
||||
// what's going on here.
|
||||
let expected_tys = do unpack_expected(fcx, expected) |sty| {
|
||||
alt sty {
|
||||
match sty {
|
||||
ty::ty_fn(fn_ty) => {
|
||||
let {fn_ty, _} =
|
||||
replace_bound_regions_in_fn_ty(
|
||||
|
|
@ -1160,9 +1160,9 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
|||
let base_t = do_autoderef(fcx, expr.span, expr_t);
|
||||
let mut handled = false;
|
||||
let n_tys = vec::len(tys);
|
||||
alt structure_of(fcx, expr.span, base_t) {
|
||||
match structure_of(fcx, expr.span, base_t) {
|
||||
ty::ty_rec(fields) => {
|
||||
alt ty::field_idx(field, fields) {
|
||||
match ty::field_idx(field, fields) {
|
||||
some(ix) => {
|
||||
if n_tys > 0u {
|
||||
tcx.sess.span_err(expr.span,
|
||||
|
|
@ -1194,7 +1194,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
|||
else {
|
||||
lookup_public_fields(tcx, base_id)
|
||||
};
|
||||
alt lookup_field_ty(tcx, base_id, cls_items, field, substs) {
|
||||
match lookup_field_ty(tcx, base_id, cls_items, field, substs) {
|
||||
some(field_ty) => {
|
||||
// (2) look up what field's type is, and return it
|
||||
fcx.write_ty(expr.id, field_ty);
|
||||
|
|
@ -1216,7 +1216,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
|||
let lkup = method::lookup(fcx, expr, base, borrow_lb,
|
||||
expr.id, field, expr_t, tps,
|
||||
is_self_ref);
|
||||
alt lkup.method() {
|
||||
match lkup.method() {
|
||||
some(entry) => {
|
||||
fcx.ccx.method_map.insert(expr.id, entry);
|
||||
|
||||
|
|
@ -1248,9 +1248,9 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
|||
let tcx = fcx.ccx.tcx;
|
||||
let id = expr.id;
|
||||
let mut bot = false;
|
||||
alt expr.node {
|
||||
match expr.node {
|
||||
ast::expr_vstore(ev, vst) => {
|
||||
let typ = alt ev.node {
|
||||
let typ = match ev.node {
|
||||
ast::expr_lit(@{node: ast::lit_str(s), span:_}) => {
|
||||
let tt = ast_expr_vstore_to_vstore(fcx, ev, str::len(*s), vst);
|
||||
ty::mk_estr(tcx, tt)
|
||||
|
|
@ -1315,8 +1315,8 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
|||
}
|
||||
ast::expr_unary(unop, oprnd) => {
|
||||
let exp_inner = do unpack_expected(fcx, expected) |sty| {
|
||||
alt unop {
|
||||
ast::box(_) | ast::uniq(_) => alt sty {
|
||||
match unop {
|
||||
ast::box(_) | ast::uniq(_) => match sty {
|
||||
ty::ty_box(mt) | ty::ty_uniq(mt) => some(mt.ty),
|
||||
_ => none
|
||||
}
|
||||
|
|
@ -1326,7 +1326,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
|||
};
|
||||
bot = check_expr(fcx, oprnd, exp_inner);
|
||||
let mut oprnd_t = fcx.expr_ty(oprnd);
|
||||
alt unop {
|
||||
match unop {
|
||||
ast::box(mutbl) => {
|
||||
oprnd_t = ty::mk_box(tcx, {ty: oprnd_t, mutbl: mutbl});
|
||||
}
|
||||
|
|
@ -1338,7 +1338,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
|||
|
||||
// deref'ing an unsafe pointer requires that we be in an unsafe
|
||||
// context
|
||||
alt sty {
|
||||
match sty {
|
||||
ty::ty_ptr(*) => {
|
||||
fcx.require_unsafe(
|
||||
expr.span,
|
||||
|
|
@ -1347,10 +1347,10 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
|||
_ => { /*ok*/ }
|
||||
}
|
||||
|
||||
alt ty::deref_sty(tcx, sty, true) {
|
||||
match ty::deref_sty(tcx, sty, true) {
|
||||
some(mt) => { oprnd_t = mt.ty }
|
||||
none => {
|
||||
alt sty {
|
||||
match sty {
|
||||
ty::ty_enum(*) => {
|
||||
tcx.sess.span_err(
|
||||
expr.span,
|
||||
|
|
@ -1389,7 +1389,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
|||
}
|
||||
ast::expr_addr_of(mutbl, oprnd) => {
|
||||
bot = check_expr(fcx, oprnd, unpack_expected(fcx, expected, |ty|
|
||||
alt ty { ty::ty_rptr(_, mt) => some(mt.ty), _ => none }
|
||||
match ty { ty::ty_rptr(_, mt) => some(mt.ty), _ => none }
|
||||
));
|
||||
//let region = region_of(fcx, oprnd);
|
||||
let region = fcx.infcx.next_region_var_with_scope_lb(expr.id);
|
||||
|
|
@ -1406,7 +1406,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
|||
ast::expr_mac(_) => tcx.sess.bug(~"unexpanded macro"),
|
||||
ast::expr_fail(expr_opt) => {
|
||||
bot = true;
|
||||
alt expr_opt {
|
||||
match expr_opt {
|
||||
none => {/* do nothing */ }
|
||||
some(e) => {
|
||||
check_expr_with(fcx, e,
|
||||
|
|
@ -1419,11 +1419,11 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
|||
ast::expr_again => { fcx.write_bot(id); bot = true; }
|
||||
ast::expr_ret(expr_opt) => {
|
||||
bot = true;
|
||||
let ret_ty = alt fcx.indirect_ret_ty {
|
||||
let ret_ty = match fcx.indirect_ret_ty {
|
||||
some(t) => t, none => fcx.ret_ty
|
||||
};
|
||||
alt expr_opt {
|
||||
none => alt fcx.mk_eqty(ret_ty, ty::mk_nil(tcx)) {
|
||||
match expr_opt {
|
||||
none => match fcx.mk_eqty(ret_ty, ty::mk_nil(tcx)) {
|
||||
result::ok(_) => { /* fall through */ }
|
||||
result::err(_) => {
|
||||
tcx.sess.span_err(
|
||||
|
|
@ -1482,7 +1482,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
|||
ast::expr_fn_block(decl, body, cap_clause) => {
|
||||
// Take the prototype from the expected type, but default to block:
|
||||
let proto = unpack_expected(fcx, expected, |sty|
|
||||
alt sty { ty::ty_fn({proto, _}) => some(proto), _ => none }
|
||||
match sty { ty::ty_fn({proto, _}) => some(proto), _ => none }
|
||||
).get_default(ast::proto_box);
|
||||
check_expr_fn(fcx, expr, proto, decl, body, false, expected);
|
||||
capture::check_capture_clause(tcx, expr.id, cap_clause);
|
||||
|
|
@ -1495,9 +1495,9 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
|||
// 1. a closure that returns a bool is expected
|
||||
// 2. the cloure that was given returns unit
|
||||
let expected_sty = unpack_expected(fcx, expected, |x| some(x));
|
||||
let (inner_ty, proto) = alt expected_sty {
|
||||
let (inner_ty, proto) = match expected_sty {
|
||||
some(ty::ty_fn(fty)) => {
|
||||
alt infer::mk_subty(fcx.infcx, fty.output, ty::mk_bool(tcx)) {
|
||||
match infer::mk_subty(fcx.infcx, fty.output, ty::mk_bool(tcx)) {
|
||||
result::ok(_) => (),
|
||||
result::err(err) => {
|
||||
tcx.sess.span_fatal(
|
||||
|
|
@ -1514,7 +1514,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
|||
type");
|
||||
}
|
||||
};
|
||||
alt check b.node {
|
||||
match check b.node {
|
||||
ast::expr_fn_block(decl, body, cap_clause) => {
|
||||
check_expr_fn(fcx, b, proto, decl, body, true, some(inner_ty));
|
||||
demand::suptype(fcx, b.span, inner_ty, fcx.expr_ty(b));
|
||||
|
|
@ -1523,7 +1523,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
|||
}
|
||||
let block_ty = structurally_resolved_type(
|
||||
fcx, expr.span, fcx.node_ty(b.id));
|
||||
alt check ty::get(block_ty).struct {
|
||||
match check ty::get(block_ty).struct {
|
||||
ty::ty_fn(fty) => {
|
||||
fcx.write_ty(expr.id, ty::mk_fn(tcx, {output: ty::mk_bool(tcx)
|
||||
with fty}));
|
||||
|
|
@ -1532,7 +1532,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
|||
}
|
||||
ast::expr_do_body(b) => {
|
||||
let expected_sty = unpack_expected(fcx, expected, |x| some(x));
|
||||
let (inner_ty, proto) = alt expected_sty {
|
||||
let (inner_ty, proto) = match expected_sty {
|
||||
some(ty::ty_fn(fty)) => {
|
||||
(ty::mk_fn(tcx, fty), fty.proto)
|
||||
}
|
||||
|
|
@ -1542,7 +1542,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
|||
passed to a `do` function");
|
||||
}
|
||||
};
|
||||
alt check b.node {
|
||||
match check b.node {
|
||||
ast::expr_fn_block(decl, body, cap_clause) => {
|
||||
check_expr_fn(fcx, b, proto, decl, body, true, some(inner_ty));
|
||||
demand::suptype(fcx, b.span, inner_ty, fcx.expr_ty(b));
|
||||
|
|
@ -1551,7 +1551,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
|||
}
|
||||
let block_ty = structurally_resolved_type(
|
||||
fcx, expr.span, fcx.node_ty(b.id));
|
||||
alt check ty::get(block_ty).struct {
|
||||
match check ty::get(block_ty).struct {
|
||||
ty::ty_fn(fty) => {
|
||||
fcx.write_ty(expr.id, ty::mk_fn(tcx, fty));
|
||||
}
|
||||
|
|
@ -1561,7 +1561,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
|||
// If this is an unchecked block, turn off purity-checking
|
||||
bot = check_block(fcx, b);
|
||||
let typ =
|
||||
alt b.node.expr {
|
||||
match b.node.expr {
|
||||
some(expr) => fcx.expr_ty(expr),
|
||||
none => ty::mk_nil(tcx)
|
||||
};
|
||||
|
|
@ -1578,7 +1578,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
|||
debug!{"t_1=%s", fcx.infcx.ty_to_str(t_1)};
|
||||
debug!{"t_e=%s", fcx.infcx.ty_to_str(t_e)};
|
||||
|
||||
alt ty::get(t_1).struct {
|
||||
match ty::get(t_1).struct {
|
||||
// This will be looked up later on
|
||||
ty::ty_trait(*) => (),
|
||||
|
||||
|
|
@ -1631,7 +1631,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
|||
let mut elt_ts = ~[];
|
||||
vec::reserve(elt_ts, vec::len(elts));
|
||||
let flds = unpack_expected(fcx, expected, |sty| {
|
||||
alt sty { ty::ty_tup(flds) => some(flds), _ => none }
|
||||
match sty { ty::ty_tup(flds) => some(flds), _ => none }
|
||||
});
|
||||
for elts.eachi |i, e| {
|
||||
check_expr(fcx, e, flds.map(|fs| fs[i]));
|
||||
|
|
@ -1647,7 +1647,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
|||
some(fcx.expr_ty(base.get()))
|
||||
} else { expected };
|
||||
let flds = unpack_expected(fcx, expected, |sty|
|
||||
alt sty { ty::ty_rec(flds) => some(flds), _ => none }
|
||||
match sty { ty::ty_rec(flds) => some(flds), _ => none }
|
||||
);
|
||||
let fields_t = vec::map(fields, |f| {
|
||||
bot |= check_expr(fcx, f.node.expr, flds.chain(|flds|
|
||||
|
|
@ -1659,7 +1659,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
|||
// should be f.node.expr.span, not f.span
|
||||
respan(f.node.expr.span, {ident: f.node.ident, mt: expr_mt})
|
||||
});
|
||||
alt base {
|
||||
match base {
|
||||
none => {
|
||||
fn get_node(f: spanned<field>) -> field { f.node }
|
||||
let typ = ty::mk_rec(tcx, vec::map(fields_t, get_node));
|
||||
|
|
@ -1674,7 +1674,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
|||
}
|
||||
some(bexpr) => {
|
||||
let bexpr_t = fcx.expr_ty(bexpr);
|
||||
let base_fields = alt structure_of(fcx, expr.span, bexpr_t) {
|
||||
let base_fields = match structure_of(fcx, expr.span, bexpr_t) {
|
||||
ty::ty_rec(flds) => flds,
|
||||
_ => {
|
||||
tcx.sess.span_fatal(expr.span,
|
||||
|
|
@ -1702,7 +1702,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
|||
ast::expr_struct(path, fields, base_expr) => {
|
||||
// Resolve the path.
|
||||
let class_id;
|
||||
alt tcx.def_map.find(id) {
|
||||
match tcx.def_map.find(id) {
|
||||
some(ast::def_class(type_def_id, _)) => {
|
||||
class_id = type_def_id;
|
||||
}
|
||||
|
|
@ -1718,7 +1718,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
|||
if class_id.crate == ast::local_crate {
|
||||
region_parameterized =
|
||||
tcx.region_paramd_items.contains_key(class_id.node);
|
||||
alt tcx.items.find(class_id.node) {
|
||||
match tcx.items.find(class_id.node) {
|
||||
some(ast_map::node_item(@{
|
||||
node: ast::item_class(type_parameters, _, _, _, _),
|
||||
_
|
||||
|
|
@ -1779,7 +1779,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
|||
|
||||
// Typecheck each field.
|
||||
for fields.each |field| {
|
||||
alt class_field_map.find(*field.node.ident) {
|
||||
match class_field_map.find(*field.node.ident) {
|
||||
none => {
|
||||
tcx.sess.span_err(field.span,
|
||||
fmt!{"structure has no field named \
|
||||
|
|
@ -1848,7 +1848,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
|||
let base_t = do_autoderef(fcx, expr.span, raw_base_t);
|
||||
bot |= check_expr(fcx, idx, none);
|
||||
let idx_t = fcx.expr_ty(idx);
|
||||
alt ty::index_sty(tcx, structure_of(fcx, expr.span, base_t)) {
|
||||
match ty::index_sty(tcx, structure_of(fcx, expr.span, base_t)) {
|
||||
some(mt) => {
|
||||
require_integral(fcx, idx.span, idx_t);
|
||||
fcx.write_ty(id, mt.ty);
|
||||
|
|
@ -1856,7 +1856,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
|||
none => {
|
||||
let resolved = structurally_resolved_type(fcx, expr.span,
|
||||
raw_base_t);
|
||||
alt lookup_op_method(fcx, expr, base, resolved, ~"index",
|
||||
match lookup_op_method(fcx, expr, base, resolved, ~"index",
|
||||
~[idx]) {
|
||||
some((ret_ty, _)) => fcx.write_ty(id, ret_ty),
|
||||
_ => {
|
||||
|
|
@ -1874,7 +1874,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
|||
debug!{"type of expr %s is %s, expected is %s",
|
||||
syntax::print::pprust::expr_to_str(expr),
|
||||
ty_to_str(tcx, fcx.expr_ty(expr)),
|
||||
alt expected {
|
||||
match expected {
|
||||
some(t) => ty_to_str(tcx, t),
|
||||
_ => ~"empty"
|
||||
}};
|
||||
|
|
@ -1904,7 +1904,7 @@ fn check_decl_local(fcx: @fn_ctxt, local: @ast::local) -> bool {
|
|||
|
||||
let t = ty::mk_var(fcx.ccx.tcx, fcx.locals.get(local.node.id));
|
||||
fcx.write_ty(local.node.id, t);
|
||||
alt local.node.init {
|
||||
match local.node.init {
|
||||
some(init) => {
|
||||
bot = check_decl_initializer(fcx, local.node.id, init);
|
||||
}
|
||||
|
|
@ -1927,10 +1927,10 @@ fn check_decl_local(fcx: @fn_ctxt, local: @ast::local) -> bool {
|
|||
fn check_stmt(fcx: @fn_ctxt, stmt: @ast::stmt) -> bool {
|
||||
let mut node_id;
|
||||
let mut bot = false;
|
||||
alt stmt.node {
|
||||
match stmt.node {
|
||||
ast::stmt_decl(decl, id) => {
|
||||
node_id = id;
|
||||
alt decl.node {
|
||||
match decl.node {
|
||||
ast::decl_local(ls) => for ls.each |l| {
|
||||
bot |= check_decl_local(fcx, l);
|
||||
}
|
||||
|
|
@ -1961,7 +1961,7 @@ fn check_block_no_value(fcx: @fn_ctxt, blk: ast::blk) -> bool {
|
|||
}
|
||||
|
||||
fn check_block(fcx0: @fn_ctxt, blk: ast::blk) -> bool {
|
||||
let fcx = alt blk.node.rules {
|
||||
let fcx = match blk.node.rules {
|
||||
ast::unchecked_blk => @fn_ctxt_({purity: ast::impure_fn with **fcx0}),
|
||||
ast::unsafe_blk => @fn_ctxt_({purity: ast::unsafe_fn with **fcx0}),
|
||||
ast::default_blk => fcx0
|
||||
|
|
@ -1971,7 +1971,7 @@ fn check_block(fcx0: @fn_ctxt, blk: ast::blk) -> bool {
|
|||
let mut warned = false;
|
||||
for blk.node.stmts.each |s| {
|
||||
if bot && !warned &&
|
||||
alt s.node {
|
||||
match s.node {
|
||||
ast::stmt_decl(@{node: ast::decl_local(_), _}, _) |
|
||||
ast::stmt_expr(_, _) | ast::stmt_semi(_, _) => {
|
||||
true
|
||||
|
|
@ -1983,7 +1983,7 @@ fn check_block(fcx0: @fn_ctxt, blk: ast::blk) -> bool {
|
|||
}
|
||||
bot |= check_stmt(fcx, s);
|
||||
}
|
||||
alt blk.node.expr {
|
||||
match blk.node.expr {
|
||||
none => fcx.write_nil(blk.node.id),
|
||||
some(e) => {
|
||||
if bot && !warned {
|
||||
|
|
@ -2044,7 +2044,7 @@ fn check_enum_variants(ccx: @crate_ctxt,
|
|||
let mut disr_val = 0;
|
||||
let mut variants = ~[];
|
||||
for vs.each |v| {
|
||||
alt v.node.disr_expr {
|
||||
match v.node.disr_expr {
|
||||
some(e) => {
|
||||
let fcx = blank_fn_ctxt(ccx, rty, e.id);
|
||||
check_expr(fcx, e, none);
|
||||
|
|
@ -2055,7 +2055,7 @@ fn check_enum_variants(ccx: @crate_ctxt,
|
|||
// Also, check_expr (from check_const pass) doesn't guarantee that
|
||||
// the expression in an form that eval_const_expr can handle, so
|
||||
// we may still get an internal compiler error
|
||||
alt const_eval::eval_const_expr(ccx.tcx, e) {
|
||||
match const_eval::eval_const_expr(ccx.tcx, e) {
|
||||
const_eval::const_int(val) => {
|
||||
disr_val = val as int;
|
||||
}
|
||||
|
|
@ -2088,7 +2088,7 @@ fn check_enum_variants(ccx: @crate_ctxt,
|
|||
// Check that it is possible to represent this enum:
|
||||
let mut outer = true, did = local_def(id);
|
||||
if ty::type_structurally_contains(ccx.tcx, rty, |sty| {
|
||||
alt sty {
|
||||
match sty {
|
||||
ty::ty_enum(id, _) if id == did => {
|
||||
if outer { outer = false; false }
|
||||
else { true }
|
||||
|
|
@ -2119,7 +2119,7 @@ fn self_ref(fcx: @fn_ctxt, id: ast::node_id) -> bool {
|
|||
}
|
||||
|
||||
fn lookup_local(fcx: @fn_ctxt, sp: span, id: ast::node_id) -> tv_vid {
|
||||
alt fcx.locals.find(id) {
|
||||
match fcx.locals.find(id) {
|
||||
some(x) => x,
|
||||
_ => {
|
||||
fcx.ccx.tcx.sess.span_fatal(sp,
|
||||
|
|
@ -2136,7 +2136,7 @@ fn lookup_def(fcx: @fn_ctxt, sp: span, id: ast::node_id) -> ast::def {
|
|||
fn ty_param_bounds_and_ty_for_def(fcx: @fn_ctxt, sp: span, defn: ast::def) ->
|
||||
ty_param_bounds_and_ty {
|
||||
|
||||
alt defn {
|
||||
match defn {
|
||||
ast::def_arg(nid, _) => {
|
||||
assert (fcx.locals.contains_key(nid));
|
||||
let typ = ty::mk_var(fcx.ccx.tcx, lookup_local(fcx, sp, nid));
|
||||
|
|
@ -2148,7 +2148,7 @@ fn ty_param_bounds_and_ty_for_def(fcx: @fn_ctxt, sp: span, defn: ast::def) ->
|
|||
return no_params(typ);
|
||||
}
|
||||
ast::def_self(_) => {
|
||||
alt fcx.self_info {
|
||||
match fcx.self_info {
|
||||
some(self_info) => {
|
||||
return no_params(self_info.self_ty);
|
||||
}
|
||||
|
|
@ -2223,7 +2223,7 @@ fn instantiate_path(fcx: @fn_ctxt,
|
|||
|
||||
// determine the region bound, using the value given by the user
|
||||
// (if any) and otherwise using a fresh region variable
|
||||
let self_r = alt pth.rp {
|
||||
let self_r = match pth.rp {
|
||||
some(r) if !tpt.rp => {
|
||||
fcx.ccx.tcx.sess.span_err
|
||||
(sp, ~"this item is not region-parameterized");
|
||||
|
|
@ -2267,7 +2267,7 @@ fn instantiate_path(fcx: @fn_ctxt,
|
|||
// Resolves `typ` by a single level if `typ` is a type variable. If no
|
||||
// resolution is possible, then an error is reported.
|
||||
fn structurally_resolved_type(fcx: @fn_ctxt, sp: span, tp: ty::t) -> ty::t {
|
||||
alt infer::resolve_type(fcx.infcx, tp, force_tvar) {
|
||||
match infer::resolve_type(fcx.infcx, tp, force_tvar) {
|
||||
result::ok(t_s) if !ty::type_is_var(t_s) => return t_s,
|
||||
_ => {
|
||||
fcx.ccx.tcx.sess.span_fatal
|
||||
|
|
@ -2298,7 +2298,7 @@ fn type_is_c_like_enum(fcx: @fn_ctxt, sp: span, typ: ty::t) -> bool {
|
|||
|
||||
fn ast_expr_vstore_to_vstore(fcx: @fn_ctxt, e: @ast::expr, n: uint,
|
||||
v: ast::vstore) -> ty::vstore {
|
||||
alt v {
|
||||
match v {
|
||||
ast::vstore_fixed(none) => ty::vstore_fixed(n),
|
||||
ast::vstore_fixed(some(u)) => {
|
||||
if n != u {
|
||||
|
|
@ -2309,7 +2309,7 @@ fn ast_expr_vstore_to_vstore(fcx: @fn_ctxt, e: @ast::expr, n: uint,
|
|||
}
|
||||
ast::vstore_uniq => ty::vstore_uniq,
|
||||
ast::vstore_box => ty::vstore_box,
|
||||
ast::vstore_slice(a_r) => alt fcx.block_region() {
|
||||
ast::vstore_slice(a_r) => match fcx.block_region() {
|
||||
result::ok(b_r) => {
|
||||
let rscope = in_anon_rscope(fcx, b_r);
|
||||
let r = astconv::ast_region_to_region(fcx, rscope, e.span, a_r);
|
||||
|
|
@ -2335,7 +2335,7 @@ fn check_bounds_are_used(ccx: @crate_ctxt,
|
|||
ccx.tcx, ty,
|
||||
|_r| {},
|
||||
|t| {
|
||||
alt ty::get(t).struct {
|
||||
match ty::get(t).struct {
|
||||
ty::ty_param({idx, _}) => { tps_used[idx] = true; }
|
||||
_ => ()
|
||||
}
|
||||
|
|
@ -2358,7 +2358,7 @@ fn check_intrinsic_type(ccx: @crate_ctxt, it: @ast::foreign_item) {
|
|||
{mode: ast::expl(m), ty: ty}
|
||||
}
|
||||
let tcx = ccx.tcx;
|
||||
let (n_tps, inputs, output) = alt *it.ident {
|
||||
let (n_tps, inputs, output) = match *it.ident {
|
||||
~"size_of" |
|
||||
~"pref_align_of" | ~"min_align_of" => (1u, ~[], ty::mk_uint(ccx.tcx)),
|
||||
~"init" => (1u, ~[], param(ccx, 0u)),
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ fn check_alt(fcx: @fn_ctxt,
|
|||
let mut result_ty = fcx.infcx.next_ty_var();
|
||||
let mut arm_non_bot = false;
|
||||
for arms.each |arm| {
|
||||
alt arm.guard {
|
||||
match arm.guard {
|
||||
some(e) => { check_expr_with(fcx, e, ty::mk_bool(tcx)); },
|
||||
none => ()
|
||||
}
|
||||
|
|
@ -68,7 +68,7 @@ fn check_pat_variant(pcx: pat_ctxt, pat: @ast::pat, path: @ast::path,
|
|||
instantiate_path(pcx.fcx, path, enum_tpt, pat.span, pat.id);
|
||||
|
||||
// Take the enum type params out of `expected`.
|
||||
alt structure_of(pcx.fcx, pat.span, expected) {
|
||||
match structure_of(pcx.fcx, pat.span, expected) {
|
||||
ty::ty_enum(_, expected_substs) => {
|
||||
// check that the type of the value being matched is a subtype
|
||||
// of the type of the pattern:
|
||||
|
|
@ -82,7 +82,7 @@ fn check_pat_variant(pcx: pat_ctxt, pat: @ast::pat, path: @ast::path,
|
|||
tcx, v_def_ids.enm, v_def_ids.var);
|
||||
vinfo.args.map(|t| { ty::subst(tcx, expected_substs, t) })
|
||||
};
|
||||
let arg_len = arg_types.len(), subpats_len = alt subpats {
|
||||
let arg_len = arg_types.len(), subpats_len = match subpats {
|
||||
none => arg_len,
|
||||
some(ps) => ps.len()
|
||||
};
|
||||
|
|
@ -127,7 +127,7 @@ fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) {
|
|||
let fcx = pcx.fcx;
|
||||
let tcx = pcx.fcx.ccx.tcx;
|
||||
|
||||
alt pat.node {
|
||||
match pat.node {
|
||||
ast::pat_wild => {
|
||||
fcx.write_ty(pat.id, expected);
|
||||
}
|
||||
|
|
@ -167,7 +167,7 @@ fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) {
|
|||
demand::suptype(fcx, pat.span, ct, typ);
|
||||
}
|
||||
fcx.write_ty(pat.id, typ);
|
||||
alt sub {
|
||||
match sub {
|
||||
some(p) => check_pat(pcx, p, expected),
|
||||
_ => ()
|
||||
}
|
||||
|
|
@ -179,7 +179,7 @@ fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) {
|
|||
check_pat_variant(pcx, pat, path, subpats, expected);
|
||||
}
|
||||
ast::pat_rec(fields, etc) => {
|
||||
let ex_fields = alt structure_of(fcx, pat.span, expected) {
|
||||
let ex_fields = match structure_of(fcx, pat.span, expected) {
|
||||
ty::ty_rec(fields) => fields,
|
||||
_ => {
|
||||
tcx.sess.span_fatal
|
||||
|
|
@ -201,7 +201,7 @@ fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) {
|
|||
str::eq(name, f.ident)
|
||||
}
|
||||
for fields.each |f| {
|
||||
alt vec::find(ex_fields, |a| matches(f.ident, a)) {
|
||||
match vec::find(ex_fields, |a| matches(f.ident, a)) {
|
||||
some(field) => {
|
||||
check_pat(pcx, f.pat, field.mt.ty);
|
||||
}
|
||||
|
|
@ -216,7 +216,7 @@ fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) {
|
|||
fcx.write_ty(pat.id, expected);
|
||||
}
|
||||
ast::pat_tup(elts) => {
|
||||
let ex_elts = alt structure_of(fcx, pat.span, expected) {
|
||||
let ex_elts = match structure_of(fcx, pat.span, expected) {
|
||||
ty::ty_tup(elts) => elts,
|
||||
_ => {
|
||||
tcx.sess.span_fatal
|
||||
|
|
@ -241,7 +241,7 @@ fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) {
|
|||
fcx.write_ty(pat.id, expected);
|
||||
}
|
||||
ast::pat_box(inner) => {
|
||||
alt structure_of(fcx, pat.span, expected) {
|
||||
match structure_of(fcx, pat.span, expected) {
|
||||
ty::ty_box(e_inner) => {
|
||||
check_pat(pcx, inner, e_inner.ty);
|
||||
fcx.write_ty(pat.id, expected);
|
||||
|
|
@ -256,7 +256,7 @@ fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) {
|
|||
}
|
||||
}
|
||||
ast::pat_uniq(inner) => {
|
||||
alt structure_of(fcx, pat.span, expected) {
|
||||
match structure_of(fcx, pat.span, expected) {
|
||||
ty::ty_uniq(e_inner) => {
|
||||
check_pat(pcx, inner, e_inner.ty);
|
||||
fcx.write_ty(pat.id, expected);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ fn suptype(fcx: @fn_ctxt, sp: span,
|
|||
expected: ty::t, actual: ty::t) {
|
||||
|
||||
// n.b.: order of actual, expected is reversed
|
||||
alt infer::mk_subty(fcx.infcx, actual, expected) {
|
||||
match infer::mk_subty(fcx.infcx, actual, expected) {
|
||||
result::ok(()) => { /* ok */ }
|
||||
result::err(err) => {
|
||||
fcx.report_mismatched_types(sp, expected, actual, err);
|
||||
|
|
@ -17,7 +17,7 @@ fn suptype(fcx: @fn_ctxt, sp: span,
|
|||
fn eqtype(fcx: @fn_ctxt, sp: span,
|
||||
expected: ty::t, actual: ty::t) {
|
||||
|
||||
alt infer::mk_eqty(fcx.infcx, actual, expected) {
|
||||
match infer::mk_eqty(fcx.infcx, actual, expected) {
|
||||
result::ok(()) => { /* ok */ }
|
||||
result::err(err) => {
|
||||
fcx.report_mismatched_types(sp, expected, actual, err);
|
||||
|
|
@ -29,7 +29,7 @@ fn eqtype(fcx: @fn_ctxt, sp: span,
|
|||
fn assign(fcx: @fn_ctxt, sp: span, borrow_lb: ast::node_id,
|
||||
expected: ty::t, expr: @ast::expr) {
|
||||
let expr_ty = fcx.expr_ty(expr);
|
||||
alt fcx.mk_assignty(expr, borrow_lb, expr_ty, expected) {
|
||||
match fcx.mk_assignty(expr, borrow_lb, expr_ty, expected) {
|
||||
result::ok(()) => { /* ok */ }
|
||||
result::err(err) => {
|
||||
fcx.report_mismatched_types(sp, expected, expr_ty, err);
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ fn transform_self_type_for_method(fcx: @fn_ctxt,
|
|||
impl_ty: ty::t,
|
||||
method_info: MethodInfo)
|
||||
-> ty::t {
|
||||
alt method_info.self_type {
|
||||
match method_info.self_type {
|
||||
sty_by_ref | sty_value => {
|
||||
impl_ty
|
||||
}
|
||||
|
|
@ -88,7 +88,7 @@ class lookup {
|
|||
|
||||
// Determine if there are any inherent methods we can call.
|
||||
let optional_inherent_methods;
|
||||
alt get_base_type_def_id(self.fcx.infcx,
|
||||
match get_base_type_def_id(self.fcx.infcx,
|
||||
self.self_expr.span,
|
||||
self.self_ty) {
|
||||
none => {
|
||||
|
|
@ -110,7 +110,7 @@ class lookup {
|
|||
|
||||
loop {
|
||||
// First, see whether this is a bounded parameter.
|
||||
alt ty::get(self.self_ty).struct {
|
||||
match ty::get(self.self_ty).struct {
|
||||
ty::ty_param(p) => {
|
||||
self.add_candidates_from_param(p.idx, p.def_id);
|
||||
}
|
||||
|
|
@ -151,7 +151,7 @@ class lookup {
|
|||
if self.candidates.len() > 0u { break; }
|
||||
|
||||
// check whether we can autoderef and if so loop around again.
|
||||
alt ty::deref(self.tcx(), self.self_ty, false) {
|
||||
match ty::deref(self.tcx(), self.self_ty, false) {
|
||||
none => break,
|
||||
some(mt) => {
|
||||
self.self_ty = mt.ty;
|
||||
|
|
@ -168,7 +168,7 @@ class lookup {
|
|||
~"multiple applicable methods in scope");
|
||||
|
||||
for self.candidates.eachi |i, candidate| {
|
||||
alt candidate.entry.origin {
|
||||
match candidate.entry.origin {
|
||||
method_static(did) => {
|
||||
self.report_static_candidate(i, did);
|
||||
}
|
||||
|
|
@ -189,7 +189,7 @@ class lookup {
|
|||
|
||||
fn report_static_candidate(idx: uint, did: ast::def_id) {
|
||||
let span = if did.crate == ast::local_crate {
|
||||
alt check self.tcx().items.get(did.node) {
|
||||
match check self.tcx().items.get(did.node) {
|
||||
ast_map::node_method(m, _, _) => m.span,
|
||||
}
|
||||
} else {
|
||||
|
|
@ -226,20 +226,20 @@ class lookup {
|
|||
let mut trait_bnd_idx = 0u; // count only trait bounds
|
||||
let bounds = tcx.ty_param_bounds.get(did.node);
|
||||
for vec::each(*bounds) |bound| {
|
||||
let (iid, bound_substs) = alt bound {
|
||||
let (iid, bound_substs) = match bound {
|
||||
ty::bound_copy | ty::bound_send | ty::bound_const |
|
||||
ty::bound_owned => {
|
||||
again; /* ok */
|
||||
}
|
||||
ty::bound_trait(bound_t) => {
|
||||
alt check ty::get(bound_t).struct {
|
||||
match check ty::get(bound_t).struct {
|
||||
ty::ty_trait(i, substs) => (i, substs)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
let trt_methods = ty::trait_methods(tcx, iid);
|
||||
alt vec::position(*trt_methods, |m| m.ident == self.m_name) {
|
||||
match vec::position(*trt_methods, |m| m.ident == self.m_name) {
|
||||
none => {
|
||||
/* check next bound */
|
||||
trait_bnd_idx += 1u;
|
||||
|
|
@ -329,14 +329,14 @@ class lookup {
|
|||
}
|
||||
|
||||
fn ty_from_did(did: ast::def_id) -> ty::t {
|
||||
alt check ty::get(ty::lookup_item_type(self.tcx(), did).ty).struct {
|
||||
match check ty::get(ty::lookup_item_type(self.tcx(), did).ty).struct {
|
||||
ty::ty_fn(fty) => {
|
||||
ty::mk_fn(self.tcx(), {proto: ast::proto_box with fty})
|
||||
}
|
||||
}
|
||||
/*
|
||||
if did.crate == ast::local_crate {
|
||||
alt check self.tcx().items.get(did.node) {
|
||||
match check self.tcx().items.get(did.node) {
|
||||
ast_map::node_method(m, _, _) {
|
||||
// NDM trait/impl regions
|
||||
let mt = ty_of_method(self.fcx.ccx, m, ast::rp_none);
|
||||
|
|
@ -344,7 +344,9 @@ class lookup {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
alt check ty::get(csearch::get_type(self.tcx(), did).ty).struct {
|
||||
match check ty::get(csearch::get_type(self.tcx(), did).ty)
|
||||
.struct {
|
||||
|
||||
ty::ty_fn(fty) {
|
||||
ty::mk_fn(self.tcx(), {proto: ast::proto_box with fty})
|
||||
}
|
||||
|
|
@ -408,7 +410,7 @@ class lookup {
|
|||
self.fcx.can_mk_subty(self.self_ty, impl_ty)
|
||||
};
|
||||
debug!{"matches = %?", matches};
|
||||
alt matches {
|
||||
match matches {
|
||||
result::err(_) => { /* keep looking */ }
|
||||
result::ok(_) => {
|
||||
if !self.candidate_impls.contains_key(im.did) {
|
||||
|
|
@ -454,7 +456,7 @@ class lookup {
|
|||
use_assignability: bool) {
|
||||
|
||||
// Add inherent methods.
|
||||
alt optional_inherent_methods {
|
||||
match optional_inherent_methods {
|
||||
none => {
|
||||
// Continue.
|
||||
}
|
||||
|
|
@ -473,7 +475,7 @@ class lookup {
|
|||
}
|
||||
|
||||
// Add trait methods.
|
||||
alt self.fcx.ccx.trait_map.find(self.expr.id) {
|
||||
match self.fcx.ccx.trait_map.find(self.expr.id) {
|
||||
none => {
|
||||
// Should only happen for placement new right now.
|
||||
}
|
||||
|
|
@ -484,7 +486,7 @@ class lookup {
|
|||
self.def_id_to_str(trait_id)};
|
||||
|
||||
let coherence_info = self.fcx.ccx.coherence_info;
|
||||
alt coherence_info.extension_methods.find(trait_id) {
|
||||
match coherence_info.extension_methods.find(trait_id) {
|
||||
none => {
|
||||
// Do nothing.
|
||||
}
|
||||
|
|
@ -523,7 +525,7 @@ class lookup {
|
|||
// Make the actual receiver type (cand.self_ty) assignable to the
|
||||
// required receiver type (cand.rcvr_ty). If this method is not
|
||||
// from an impl, this'll basically be a no-nop.
|
||||
alt self.fcx.mk_assignty(self.self_expr, self.borrow_lb,
|
||||
match self.fcx.mk_assignty(self.self_expr, self.borrow_lb,
|
||||
cand.self_ty, cand.rcvr_ty) {
|
||||
result::ok(_) => (),
|
||||
result::err(_) => {
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ fn visit_local(l: @ast::local, &&rcx: @rcx, v: rvt) {
|
|||
|
||||
fn visit_pat(p: @ast::pat, &&rcx: @rcx, v: rvt) {
|
||||
let fcx = rcx.fcx;
|
||||
alt p.node {
|
||||
match p.node {
|
||||
ast::pat_ident(_, path, _)
|
||||
if !pat_util::pat_is_variant(fcx.ccx.tcx.def_map, p) => {
|
||||
debug!{"visit_pat binding=%s", *path.idents[0]};
|
||||
|
|
@ -123,14 +123,14 @@ fn visit_block(b: ast::blk, &&rcx: @rcx, v: rvt) {
|
|||
fn visit_expr(e: @ast::expr, &&rcx: @rcx, v: rvt) {
|
||||
debug!{"visit_expr(e=%s)", pprust::expr_to_str(e)};
|
||||
|
||||
alt e.node {
|
||||
match e.node {
|
||||
ast::expr_path(*) => {
|
||||
// Avoid checking the use of local variables, as we already
|
||||
// check their definitions. The def'n always encloses the
|
||||
// use. So if the def'n is enclosed by the region, then the
|
||||
// uses will also be enclosed (and otherwise, an error will
|
||||
// have been reported at the def'n site).
|
||||
alt lookup_def(rcx.fcx, e.span, e.id) {
|
||||
match lookup_def(rcx.fcx, e.span, e.id) {
|
||||
ast::def_local(*) | ast::def_arg(*) | ast::def_upvar(*) => return,
|
||||
_ => ()
|
||||
}
|
||||
|
|
@ -150,12 +150,12 @@ fn visit_expr(e: @ast::expr, &&rcx: @rcx, v: rvt) {
|
|||
// is an extensive comment on the function
|
||||
// check_cast_for_escaping_regions() in kind.rs explaining how
|
||||
// it goes about doing that.
|
||||
alt rcx.resolve_node_type(e.id) {
|
||||
match rcx.resolve_node_type(e.id) {
|
||||
result::err(_) => { return; /* typeck will fail anyhow */ }
|
||||
result::ok(target_ty) => {
|
||||
alt ty::get(target_ty).struct {
|
||||
match ty::get(target_ty).struct {
|
||||
ty::ty_trait(_, substs) => {
|
||||
let trait_region = alt substs.self_r {
|
||||
let trait_region = match substs.self_r {
|
||||
some(r) => {r}
|
||||
none => {ty::re_static}
|
||||
};
|
||||
|
|
@ -191,7 +191,7 @@ fn visit_node(id: ast::node_id, span: span, rcx: @rcx) -> bool {
|
|||
// Try to resolve the type. If we encounter an error, then typeck
|
||||
// is going to fail anyway, so just stop here and let typeck
|
||||
// report errors later on in the writeback phase.
|
||||
let ty = alt rcx.resolve_node_type(id) {
|
||||
let ty = match rcx.resolve_node_type(id) {
|
||||
result::err(_) => return true,
|
||||
result::ok(ty) => ty
|
||||
};
|
||||
|
|
@ -232,7 +232,7 @@ fn constrain_regions_in_type(
|
|||
ppaux::region_to_str(tcx, encl_region),
|
||||
ppaux::region_to_str(tcx, region)};
|
||||
|
||||
alt region {
|
||||
match region {
|
||||
ty::re_bound(_) => {
|
||||
// a bound region is one which appears inside an fn type.
|
||||
// (e.g., the `&` in `fn(&T)`). Such regions need not be
|
||||
|
|
@ -243,7 +243,7 @@ fn constrain_regions_in_type(
|
|||
_ => ()
|
||||
}
|
||||
|
||||
alt rcx.fcx.mk_subr(encl_region, region) {
|
||||
match rcx.fcx.mk_subr(encl_region, region) {
|
||||
result::err(_) => {
|
||||
let region1 = rcx.fcx.infcx.resolve_region_if_possible(region);
|
||||
tcx.sess.span_err(
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ fn replace_bound_regions_in_fn_ty(
|
|||
|
||||
// Take self_info apart; the self_ty part is the only one we want
|
||||
// to update here.
|
||||
let self_ty = alt self_info {
|
||||
let self_ty = match self_info {
|
||||
some(s) => some(s.self_ty),
|
||||
none => none
|
||||
};
|
||||
|
|
@ -44,8 +44,8 @@ fn replace_bound_regions_in_fn_ty(
|
|||
|
||||
|
||||
// Glue updated self_ty back together with its original node_id.
|
||||
let new_self_info = alt self_info {
|
||||
some(s) => alt check t_self {
|
||||
let new_self_info = match self_info {
|
||||
some(s) => match check t_self {
|
||||
some(t) => some({self_ty: t, node_id: s.node_id})
|
||||
// this 'none' case shouldn't happen
|
||||
}
|
||||
|
|
@ -54,7 +54,7 @@ fn replace_bound_regions_in_fn_ty(
|
|||
|
||||
return {isr: isr,
|
||||
self_info: new_self_info,
|
||||
fn_ty: alt check ty::get(t_fn).struct { ty::ty_fn(o) => o }};
|
||||
fn_ty: match check ty::get(t_fn).struct { ty::ty_fn(o) => o }};
|
||||
|
||||
|
||||
// Takes `isr`, a (possibly empty) mapping from in-scope region
|
||||
|
|
@ -82,13 +82,13 @@ fn replace_bound_regions_in_fn_ty(
|
|||
fn append_isr(isr: isr_alist,
|
||||
to_r: fn(ty::bound_region) -> ty::region,
|
||||
r: ty::region) -> isr_alist {
|
||||
alt r {
|
||||
match r {
|
||||
ty::re_free(_, _) | ty::re_static | ty::re_scope(_) |
|
||||
ty::re_var(_) => {
|
||||
isr
|
||||
}
|
||||
ty::re_bound(br) => {
|
||||
alt isr.find(br) {
|
||||
match isr.find(br) {
|
||||
some(_) => isr,
|
||||
none => @cons((br, to_r(br)), isr)
|
||||
}
|
||||
|
|
@ -124,14 +124,14 @@ fn replace_bound_regions_in_fn_ty(
|
|||
ty: ty::t) -> ty::t {
|
||||
|
||||
do ty::fold_regions(tcx, ty) |r, in_fn| {
|
||||
alt r {
|
||||
match r {
|
||||
// As long as we are not within a fn() type, `&T` is
|
||||
// mapped to the free region anon_r. But within a fn
|
||||
// type, it remains bound.
|
||||
ty::re_bound(ty::br_anon) if in_fn => r,
|
||||
|
||||
ty::re_bound(br) => {
|
||||
alt isr.find(br) {
|
||||
match isr.find(br) {
|
||||
// In most cases, all named, bound regions will be
|
||||
// mapped to some free region.
|
||||
some(fr) => fr,
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import dvec::extensions;
|
|||
fn has_trait_bounds(tps: ~[ty::param_bounds]) -> bool {
|
||||
vec::any(tps, |bs| {
|
||||
vec::any(*bs, |b| {
|
||||
alt b { ty::bound_trait(_) => true, _ => false }
|
||||
match b { ty::bound_trait(_) => true, _ => false }
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
@ -18,7 +18,7 @@ fn lookup_vtables(fcx: @fn_ctxt, sp: span,
|
|||
let mut result = ~[], i = 0u;
|
||||
for substs.tps.each |ty| {
|
||||
for vec::each(*bounds[i]) |bound| {
|
||||
alt bound {
|
||||
match bound {
|
||||
ty::bound_trait(i_ty) => {
|
||||
let i_ty = ty::subst(tcx, substs, i_ty);
|
||||
vec::push(result, lookup_vtable(fcx, sp, ty, i_ty,
|
||||
|
|
@ -38,7 +38,7 @@ fn fixup_substs(fcx: @fn_ctxt, sp: span,
|
|||
// use a dummy type just to package up the substs that need fixing up
|
||||
let t = ty::mk_trait(tcx, id, substs);
|
||||
let t_f = fixup_ty(fcx, sp, t);
|
||||
alt check ty::get(t_f).struct {
|
||||
match check ty::get(t_f).struct {
|
||||
ty::ty_trait(_, substs_f) => substs_f,
|
||||
}
|
||||
}
|
||||
|
|
@ -61,21 +61,21 @@ fn lookup_vtable(fcx: @fn_ctxt, sp: span, ty: ty::t, trait_ty: ty::t,
|
|||
let _i = indenter();
|
||||
|
||||
let tcx = fcx.ccx.tcx;
|
||||
let (trait_id, trait_substs) = alt check ty::get(trait_ty).struct {
|
||||
let (trait_id, trait_substs) = match check ty::get(trait_ty).struct {
|
||||
ty::ty_trait(did, substs) => (did, substs)
|
||||
};
|
||||
let ty = fixup_ty(fcx, sp, ty);
|
||||
alt ty::get(ty).struct {
|
||||
match ty::get(ty).struct {
|
||||
ty::ty_param({idx: n, def_id: did}) => {
|
||||
let mut n_bound = 0u;
|
||||
for vec::each(*tcx.ty_param_bounds.get(did.node)) |bound| {
|
||||
alt bound {
|
||||
match bound {
|
||||
ty::bound_send | ty::bound_copy | ty::bound_const |
|
||||
ty::bound_owned => {
|
||||
/* ignore */
|
||||
}
|
||||
ty::bound_trait(ity) => {
|
||||
alt check ty::get(ity).struct {
|
||||
match check ty::get(ity).struct {
|
||||
ty::ty_trait(idid, substs) => {
|
||||
if trait_id == idid {
|
||||
debug!{"(checking vtable) @0 relating ty to trait ty
|
||||
|
|
@ -118,7 +118,7 @@ fn lookup_vtable(fcx: @fn_ctxt, sp: span, ty: ty::t, trait_ty: ty::t,
|
|||
|
||||
let mut impls_seen = new_def_hash();
|
||||
|
||||
alt fcx.ccx.coherence_info.extension_methods.find(trait_id) {
|
||||
match fcx.ccx.coherence_info.extension_methods.find(trait_id) {
|
||||
none => {
|
||||
// Nothing found. Continue.
|
||||
}
|
||||
|
|
@ -137,7 +137,7 @@ fn lookup_vtable(fcx: @fn_ctxt, sp: span, ty: ty::t, trait_ty: ty::t,
|
|||
// find the trait that im implements (if any)
|
||||
for vec::each(ty::impl_traits(tcx, im.did)) |of_ty| {
|
||||
// it must have the same id as the expected one
|
||||
alt ty::get(of_ty).struct {
|
||||
match ty::get(of_ty).struct {
|
||||
ty::ty_trait(id, _) if id != trait_id => again,
|
||||
_ => { /* ok */ }
|
||||
}
|
||||
|
|
@ -147,7 +147,7 @@ fn lookup_vtable(fcx: @fn_ctxt, sp: span, ty: ty::t, trait_ty: ty::t,
|
|||
let {substs: substs, ty: for_ty} =
|
||||
impl_self_ty(fcx, im.did);
|
||||
let im_bs = ty::lookup_item_type(tcx, im.did).bounds;
|
||||
alt fcx.mk_subty(ty, for_ty) {
|
||||
match fcx.mk_subty(ty, for_ty) {
|
||||
result::err(_) => again,
|
||||
result::ok(()) => ()
|
||||
}
|
||||
|
|
@ -176,7 +176,7 @@ fn lookup_vtable(fcx: @fn_ctxt, sp: span, ty: ty::t, trait_ty: ty::t,
|
|||
}
|
||||
}
|
||||
|
||||
alt found.len() {
|
||||
match found.len() {
|
||||
0u => { /* fallthrough */ }
|
||||
1u => { return found[0]; }
|
||||
_ => {
|
||||
|
|
@ -196,7 +196,7 @@ fn lookup_vtable(fcx: @fn_ctxt, sp: span, ty: ty::t, trait_ty: ty::t,
|
|||
|
||||
fn fixup_ty(fcx: @fn_ctxt, sp: span, ty: ty::t) -> ty::t {
|
||||
let tcx = fcx.ccx.tcx;
|
||||
alt resolve_type(fcx.infcx, ty, resolve_all | force_all) {
|
||||
match resolve_type(fcx.infcx, ty, resolve_all | force_all) {
|
||||
result::ok(new_type) => new_type,
|
||||
result::err(e) => {
|
||||
tcx.sess.span_fatal(
|
||||
|
|
@ -217,7 +217,7 @@ fn connect_trait_tps(fcx: @fn_ctxt, sp: span, impl_tys: ~[ty::t],
|
|||
let trait_ty = ty::subst_tps(tcx, impl_tys, ity);
|
||||
debug!{"(connect trait tps) trait type is %?, impl did is %?",
|
||||
ty::get(trait_ty).struct, impl_did};
|
||||
alt check ty::get(trait_ty).struct {
|
||||
match check ty::get(trait_ty).struct {
|
||||
ty::ty_trait(_, substs) => {
|
||||
vec::iter2(substs.tps, trait_tys,
|
||||
|a, b| demand::suptype(fcx, sp, a, b));
|
||||
|
|
@ -227,9 +227,9 @@ fn connect_trait_tps(fcx: @fn_ctxt, sp: span, impl_tys: ~[ty::t],
|
|||
|
||||
fn resolve_expr(ex: @ast::expr, &&fcx: @fn_ctxt, v: visit::vt<@fn_ctxt>) {
|
||||
let cx = fcx.ccx;
|
||||
alt ex.node {
|
||||
match ex.node {
|
||||
ast::expr_path(*) => {
|
||||
alt fcx.opt_node_ty_substs(ex.id) {
|
||||
match fcx.opt_node_ty_substs(ex.id) {
|
||||
some(substs) => {
|
||||
let did = ast_util::def_id_of_def(cx.tcx.def_map.get(ex.id));
|
||||
let item_ty = ty::lookup_item_type(cx.tcx, did);
|
||||
|
|
@ -248,11 +248,11 @@ fn resolve_expr(ex: @ast::expr, &&fcx: @fn_ctxt, v: visit::vt<@fn_ctxt>) {
|
|||
ast::expr_field(*) | ast::expr_binary(*) |
|
||||
ast::expr_unary(*) | ast::expr_assign_op(*) |
|
||||
ast::expr_index(*) => {
|
||||
alt cx.method_map.find(ex.id) {
|
||||
match cx.method_map.find(ex.id) {
|
||||
some({origin: method_static(did), _}) => {
|
||||
let bounds = ty::lookup_item_type(cx.tcx, did).bounds;
|
||||
if has_trait_bounds(*bounds) {
|
||||
let callee_id = alt ex.node {
|
||||
let callee_id = match ex.node {
|
||||
ast::expr_field(_, _, _) => ex.id,
|
||||
_ => ex.callee_id
|
||||
};
|
||||
|
|
@ -269,7 +269,7 @@ fn resolve_expr(ex: @ast::expr, &&fcx: @fn_ctxt, v: visit::vt<@fn_ctxt>) {
|
|||
}
|
||||
ast::expr_cast(src, _) => {
|
||||
let target_ty = fcx.expr_ty(ex);
|
||||
alt ty::get(target_ty).struct {
|
||||
match ty::get(target_ty).struct {
|
||||
ty::ty_trait(*) => {
|
||||
/*
|
||||
Look up vtables for the type we're casting to,
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ export resolve_type_vars_in_expr;
|
|||
fn resolve_type_vars_in_type(fcx: @fn_ctxt, sp: span, typ: ty::t) ->
|
||||
option<ty::t> {
|
||||
if !ty::type_needs_infer(typ) { return some(typ); }
|
||||
alt resolve_type(fcx.infcx, typ, resolve_all | force_all) {
|
||||
match resolve_type(fcx.infcx, typ, resolve_all | force_all) {
|
||||
result::ok(new_type) => return some(new_type),
|
||||
result::err(e) => {
|
||||
if !fcx.ccx.tcx.sess.has_errors() {
|
||||
|
|
@ -28,7 +28,7 @@ fn resolve_type_vars_for_node(wbcx: wb_ctxt, sp: span, id: ast::node_id)
|
|||
-> option<ty::t> {
|
||||
let fcx = wbcx.fcx, tcx = fcx.ccx.tcx;
|
||||
let n_ty = fcx.node_ty(id);
|
||||
alt resolve_type_vars_in_type(fcx, sp, n_ty) {
|
||||
match resolve_type_vars_in_type(fcx, sp, n_ty) {
|
||||
none => {
|
||||
wbcx.success = false;
|
||||
return none;
|
||||
|
|
@ -38,11 +38,11 @@ fn resolve_type_vars_for_node(wbcx: wb_ctxt, sp: span, id: ast::node_id)
|
|||
debug!{"resolve_type_vars_for_node(id=%d, n_ty=%s, t=%s)",
|
||||
id, ty_to_str(tcx, n_ty), ty_to_str(tcx, t)};
|
||||
write_ty_to_tcx(tcx, id, t);
|
||||
alt fcx.opt_node_ty_substs(id) {
|
||||
match fcx.opt_node_ty_substs(id) {
|
||||
some(substs) => {
|
||||
let mut new_tps = ~[];
|
||||
for substs.tps.each |subst| {
|
||||
alt resolve_type_vars_in_type(fcx, sp, subst) {
|
||||
match resolve_type_vars_in_type(fcx, sp, subst) {
|
||||
some(t) => vec::push(new_tps, t),
|
||||
none => { wbcx.success = false; return none; }
|
||||
}
|
||||
|
|
@ -80,7 +80,7 @@ fn visit_stmt(s: @ast::stmt, wbcx: wb_ctxt, v: wb_vt) {
|
|||
fn visit_expr(e: @ast::expr, wbcx: wb_ctxt, v: wb_vt) {
|
||||
if !wbcx.success { return; }
|
||||
resolve_type_vars_for_node(wbcx, e.span, e.id);
|
||||
alt e.node {
|
||||
match e.node {
|
||||
ast::expr_fn(_, decl, _, _) |
|
||||
ast::expr_fn_block(decl, _, _) => {
|
||||
do vec::iter(decl.inputs) |input| {
|
||||
|
|
@ -88,7 +88,7 @@ fn visit_expr(e: @ast::expr, wbcx: wb_ctxt, v: wb_vt) {
|
|||
|
||||
// Just in case we never constrained the mode to anything,
|
||||
// constrain it to the default for the type in question.
|
||||
alt (r_ty, input.mode) {
|
||||
match (r_ty, input.mode) {
|
||||
(some(t), ast::infer(_)) => {
|
||||
let tcx = wbcx.fcx.ccx.tcx;
|
||||
let m_def = ty::default_arg_mode_for_ty(t);
|
||||
|
|
@ -127,7 +127,7 @@ fn visit_local(l: @ast::local, wbcx: wb_ctxt, v: wb_vt) {
|
|||
if !wbcx.success { return; }
|
||||
let var_id = lookup_local(wbcx.fcx, l.span, l.node.id);
|
||||
let var_ty = ty::mk_var(wbcx.fcx.tcx(), var_id);
|
||||
alt resolve_type(wbcx.fcx.infcx, var_ty, resolve_all | force_all) {
|
||||
match resolve_type(wbcx.fcx.infcx, var_ty, resolve_all | force_all) {
|
||||
result::ok(lty) => {
|
||||
debug!{"Type for local %s (id %d) resolved to %s",
|
||||
pat_to_str(l.node.pat), l.node.id,
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ fn get_base_type(inference_context: infer_ctxt, span: span, original_type: t)
|
|||
-> option<t> {
|
||||
|
||||
let resolved_type;
|
||||
alt resolve_type(inference_context,
|
||||
match resolve_type(inference_context,
|
||||
original_type,
|
||||
resolve_ivar) {
|
||||
ok(resulting_type) if !type_is_var(resulting_type) => {
|
||||
|
|
@ -55,7 +55,7 @@ fn get_base_type(inference_context: infer_ctxt, span: span, original_type: t)
|
|||
}
|
||||
}
|
||||
|
||||
alt get(resolved_type).struct {
|
||||
match get(resolved_type).struct {
|
||||
ty_box(base_mutability_and_type) |
|
||||
ty_uniq(base_mutability_and_type) |
|
||||
ty_ptr(base_mutability_and_type) |
|
||||
|
|
@ -88,12 +88,12 @@ fn get_base_type_def_id(inference_context: infer_ctxt,
|
|||
original_type: t)
|
||||
-> option<def_id> {
|
||||
|
||||
alt get_base_type(inference_context, span, original_type) {
|
||||
match get_base_type(inference_context, span, original_type) {
|
||||
none => {
|
||||
return none;
|
||||
}
|
||||
some(base_type) => {
|
||||
alt get(base_type).struct {
|
||||
match get(base_type).struct {
|
||||
ty_enum(def_id, _) |
|
||||
ty_class(def_id, _) |
|
||||
ty_trait(def_id, _) => {
|
||||
|
|
@ -160,7 +160,7 @@ class CoherenceChecker {
|
|||
visit_item: |item| {
|
||||
debug!{"(checking coherence) item '%s'", *item.ident};
|
||||
|
||||
alt item.node {
|
||||
match item.node {
|
||||
item_impl(_, associated_traits, _, _) => {
|
||||
self.check_implementation(item, associated_traits);
|
||||
}
|
||||
|
|
@ -203,7 +203,7 @@ class CoherenceChecker {
|
|||
'%s'",
|
||||
*item.ident};
|
||||
|
||||
alt get_base_type_def_id(self.inference_context,
|
||||
match get_base_type_def_id(self.inference_context,
|
||||
item.span,
|
||||
self_type.ty) {
|
||||
none => {
|
||||
|
|
@ -235,7 +235,7 @@ class CoherenceChecker {
|
|||
// Add the implementation to the mapping from implementation to base
|
||||
// type def ID, if there is a base type for this implementation.
|
||||
|
||||
alt get_base_type_def_id(self.inference_context,
|
||||
match get_base_type_def_id(self.inference_context,
|
||||
item.span,
|
||||
self_type.ty) {
|
||||
none => {
|
||||
|
|
@ -253,7 +253,7 @@ class CoherenceChecker {
|
|||
|
||||
fn add_inherent_method(base_def_id: def_id, implementation: @Impl) {
|
||||
let implementation_list;
|
||||
alt self.crate_context.coherence_info.inherent_methods
|
||||
match self.crate_context.coherence_info.inherent_methods
|
||||
.find(base_def_id) {
|
||||
|
||||
none => {
|
||||
|
|
@ -271,7 +271,7 @@ class CoherenceChecker {
|
|||
|
||||
fn add_trait_method(trait_id: def_id, implementation: @Impl) {
|
||||
let implementation_list;
|
||||
alt self.crate_context.coherence_info.extension_methods
|
||||
match self.crate_context.coherence_info.extension_methods
|
||||
.find(trait_id) {
|
||||
|
||||
none => {
|
||||
|
|
@ -363,7 +363,7 @@ class CoherenceChecker {
|
|||
|
||||
visit_crate(*crate, (), mk_vt(@{
|
||||
visit_item: |item, _context, visitor| {
|
||||
alt item.node {
|
||||
match item.node {
|
||||
item_mod(module_) => {
|
||||
// First, gather up all privileged types.
|
||||
let privileged_types =
|
||||
|
|
@ -386,7 +386,9 @@ class CoherenceChecker {
|
|||
}
|
||||
}
|
||||
item_impl(_, associated_traits, _, _) => {
|
||||
alt self.base_type_def_ids.find(local_def(item.id)) {
|
||||
match self.base_type_def_ids.find(
|
||||
local_def(item.id)) {
|
||||
|
||||
none => {
|
||||
// Nothing to do.
|
||||
}
|
||||
|
|
@ -468,7 +470,7 @@ class CoherenceChecker {
|
|||
fn gather_privileged_types(items: ~[@item]) -> @dvec<def_id> {
|
||||
let results = @dvec();
|
||||
for items.each |item| {
|
||||
alt item.node {
|
||||
match item.node {
|
||||
item_class(*) | item_enum(*) | item_trait(*) => {
|
||||
results.push(local_def(item.id));
|
||||
}
|
||||
|
|
@ -486,7 +488,7 @@ class CoherenceChecker {
|
|||
|
||||
// Converts an implementation in the AST to an Impl structure.
|
||||
fn create_impl_from_item(item: @item) -> @Impl {
|
||||
alt item.node {
|
||||
match item.node {
|
||||
item_impl(ty_params, _, _, ast_methods) => {
|
||||
let mut methods = ~[];
|
||||
for ast_methods.each |ast_method| {
|
||||
|
|
@ -507,7 +509,7 @@ class CoherenceChecker {
|
|||
item_class(ty_params, _, class_members, _, _) => {
|
||||
let mut methods = ~[];
|
||||
for class_members.each |class_member| {
|
||||
alt class_member.node {
|
||||
match class_member.node {
|
||||
instance_var(*) => {
|
||||
// Nothing to do.
|
||||
}
|
||||
|
|
@ -538,7 +540,7 @@ class CoherenceChecker {
|
|||
|
||||
fn span_of_impl(implementation: @Impl) -> span {
|
||||
assert implementation.did.crate == local_crate;
|
||||
alt self.crate_context.tcx.items.find(implementation.did.node) {
|
||||
match self.crate_context.tcx.items.find(implementation.did.node) {
|
||||
some(node_item(item, _)) => {
|
||||
return item.span;
|
||||
}
|
||||
|
|
@ -562,7 +564,7 @@ class CoherenceChecker {
|
|||
for (*implementations).each |implementation| {
|
||||
// Make sure we don't visit the same implementation
|
||||
// multiple times.
|
||||
alt impls_seen.find(implementation.did) {
|
||||
match impls_seen.find(implementation.did) {
|
||||
none => {
|
||||
// Good. Continue.
|
||||
impls_seen.insert(implementation.did, ());
|
||||
|
|
@ -582,7 +584,7 @@ class CoherenceChecker {
|
|||
// types.
|
||||
|
||||
if associated_traits.len() == 0 {
|
||||
alt get_base_type_def_id(self.inference_context,
|
||||
match get_base_type_def_id(self.inference_context,
|
||||
dummy_sp(),
|
||||
self_type.ty) {
|
||||
none => {
|
||||
|
|
@ -601,7 +603,7 @@ class CoherenceChecker {
|
|||
|
||||
// Record all the trait methods.
|
||||
for associated_traits.each |trait_type| {
|
||||
alt get(trait_type).struct {
|
||||
match get(trait_type).struct {
|
||||
ty_trait(trait_id, _) => {
|
||||
self.add_trait_method(trait_id, implementation);
|
||||
}
|
||||
|
|
@ -617,7 +619,7 @@ class CoherenceChecker {
|
|||
// implementation to base type def ID, if there is a base
|
||||
// type for this implementation.
|
||||
|
||||
alt get_base_type_def_id(self.inference_context,
|
||||
match get_base_type_def_id(self.inference_context,
|
||||
dummy_sp(),
|
||||
self_type.ty) {
|
||||
none => {
|
||||
|
|
@ -645,7 +647,7 @@ class CoherenceChecker {
|
|||
|
||||
for each_path(crate_store, crate_number) |path_entry| {
|
||||
let module_def_id;
|
||||
alt path_entry.def_like {
|
||||
match path_entry.def_like {
|
||||
dl_def(def_mod(def_id)) => {
|
||||
module_def_id = def_id;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,14 +30,14 @@ fn collect_item_types(ccx: @crate_ctxt, crate: @ast::crate) {
|
|||
|
||||
for crate.node.module.items.each |crate_item| {
|
||||
if *crate_item.ident == ~"intrinsic" {
|
||||
alt crate_item.node {
|
||||
match crate_item.node {
|
||||
ast::item_mod(m) => {
|
||||
for m.items.each |intrinsic_item| {
|
||||
let def_id = { crate: ast::local_crate,
|
||||
node: intrinsic_item.id };
|
||||
let substs = {self_r: none, self_ty: none, tps: ~[]};
|
||||
|
||||
alt intrinsic_item.node {
|
||||
match intrinsic_item.node {
|
||||
ast::item_trait(*) => {
|
||||
let ty = ty::mk_trait(ccx.tcx, def_id, substs);
|
||||
ccx.tcx.intrinsic_defs.insert
|
||||
|
|
@ -83,7 +83,7 @@ impl of ast_conv for @crate_ctxt {
|
|||
if id.crate != ast::local_crate {
|
||||
csearch::get_type(self.tcx, id)
|
||||
} else {
|
||||
alt self.tcx.items.find(id.node) {
|
||||
match self.tcx.items.find(id.node) {
|
||||
some(ast_map::node_item(item, _)) => {
|
||||
ty_of_item(self, item)
|
||||
}
|
||||
|
|
@ -145,10 +145,10 @@ fn ensure_trait_methods(ccx: @crate_ctxt, id: ast::node_id) {
|
|||
|
||||
let tcx = ccx.tcx;
|
||||
let rp = tcx.region_paramd_items.contains_key(id);
|
||||
alt check tcx.items.get(id) {
|
||||
match check tcx.items.get(id) {
|
||||
ast_map::node_item(@{node: ast::item_trait(_, _, ms), _}, _) => {
|
||||
store_methods::<ast::trait_method>(ccx, id, ms, |m| {
|
||||
alt m {
|
||||
match m {
|
||||
required(ty_m) => {
|
||||
ty_of_ty_method(ccx, ty_m, rp)
|
||||
}
|
||||
|
|
@ -253,7 +253,7 @@ fn check_methods_against_trait(ccx: @crate_ctxt,
|
|||
ensure_trait_methods(ccx, did.node);
|
||||
}
|
||||
for vec::each(*ty::trait_methods(tcx, did)) |trait_m| {
|
||||
alt vec::find(impl_ms, |impl_m| trait_m.ident == impl_m.mty.ident) {
|
||||
match vec::find(impl_ms, |impl_m| trait_m.ident == impl_m.mty.ident) {
|
||||
some({mty: impl_m, id, span}) => {
|
||||
if impl_m.purity != trait_m.purity {
|
||||
ccx.tcx.sess.span_err(
|
||||
|
|
@ -271,13 +271,13 @@ fn check_methods_against_trait(ccx: @crate_ctxt,
|
|||
// implementation in the trait itself. If not, raise a
|
||||
// "missing method" error.
|
||||
|
||||
alt tcx.items.get(did.node) {
|
||||
match tcx.items.get(did.node) {
|
||||
ast_map::node_item(
|
||||
@{node: ast::item_trait(_, _, trait_methods), _}, _) => {
|
||||
let (_, provided_methods) =
|
||||
split_trait_methods(trait_methods);
|
||||
|
||||
alt vec::find(provided_methods, |provided_method|
|
||||
match vec::find(provided_methods, |provided_method|
|
||||
provided_method.ident == trait_m.ident) {
|
||||
some(m) => {
|
||||
// If there's a provided method with the name we
|
||||
|
|
@ -339,7 +339,7 @@ fn convert(ccx: @crate_ctxt, it: @ast::item) {
|
|||
let tcx = ccx.tcx;
|
||||
let rp = tcx.region_paramd_items.contains_key(it.id);
|
||||
debug!{"convert: item %s with id %d rp %b", *it.ident, it.id, rp};
|
||||
alt it.node {
|
||||
match it.node {
|
||||
// These don't define types.
|
||||
ast::item_foreign_mod(_) | ast::item_mod(_) => {}
|
||||
ast::item_enum(variants, ty_params) => {
|
||||
|
|
@ -449,7 +449,7 @@ fn convert_foreign(ccx: @crate_ctxt, i: @ast::foreign_item) {
|
|||
// type of the foreign item. We simply write it into the node type
|
||||
// table.
|
||||
let tpt = ty_of_foreign_item(ccx, i);
|
||||
alt i.node {
|
||||
match i.node {
|
||||
ast::foreign_item_fn(_, _) => {
|
||||
write_ty_to_tcx(ccx.tcx, i.id, tpt.ty);
|
||||
ccx.tcx.tcache.insert(local_def(i.id), tpt);
|
||||
|
|
@ -494,11 +494,11 @@ fn instantiate_trait_ref(ccx: @crate_ctxt, t: @ast::trait_ref, rp: bool)
|
|||
|
||||
let rscope = type_rscope(rp);
|
||||
|
||||
alt lookup_def_tcx(ccx.tcx, t.path.span, t.ref_id) {
|
||||
match lookup_def_tcx(ccx.tcx, t.path.span, t.ref_id) {
|
||||
ast::def_ty(t_id) => {
|
||||
let tpt = astconv::ast_path_to_ty(ccx, rscope, t_id, t.path,
|
||||
t.ref_id);
|
||||
alt ty::get(tpt.ty).struct {
|
||||
match ty::get(tpt.ty).struct {
|
||||
ty::ty_trait(*) => {
|
||||
(t_id, tpt)
|
||||
}
|
||||
|
|
@ -514,12 +514,12 @@ fn ty_of_item(ccx: @crate_ctxt, it: @ast::item)
|
|||
|
||||
let def_id = local_def(it.id);
|
||||
let tcx = ccx.tcx;
|
||||
alt tcx.tcache.find(def_id) {
|
||||
match tcx.tcache.find(def_id) {
|
||||
some(tpt) => return tpt,
|
||||
_ => {}
|
||||
}
|
||||
let rp = tcx.region_paramd_items.contains_key(it.id);
|
||||
alt it.node {
|
||||
match it.node {
|
||||
ast::item_const(t, _) => {
|
||||
let typ = ccx.to_ty(empty_rscope, t);
|
||||
let tpt = no_params(typ);
|
||||
|
|
@ -539,7 +539,7 @@ fn ty_of_item(ccx: @crate_ctxt, it: @ast::item)
|
|||
return tpt;
|
||||
}
|
||||
ast::item_ty(t, tps) => {
|
||||
alt tcx.tcache.find(local_def(it.id)) {
|
||||
match tcx.tcache.find(local_def(it.id)) {
|
||||
some(tpt) => return tpt,
|
||||
none => { }
|
||||
}
|
||||
|
|
@ -592,7 +592,7 @@ fn ty_of_item(ccx: @crate_ctxt, it: @ast::item)
|
|||
|
||||
fn ty_of_foreign_item(ccx: @crate_ctxt, it: @ast::foreign_item)
|
||||
-> ty::ty_param_bounds_and_ty {
|
||||
alt it.node {
|
||||
match it.node {
|
||||
ast::foreign_item_fn(fn_decl, params) => {
|
||||
return ty_of_foreign_fn_decl(ccx, fn_decl, params,
|
||||
local_def(it.id));
|
||||
|
|
@ -605,14 +605,14 @@ fn ty_param_bounds(ccx: @crate_ctxt,
|
|||
fn compute_bounds(ccx: @crate_ctxt,
|
||||
param: ast::ty_param) -> ty::param_bounds {
|
||||
@do vec::flat_map(*param.bounds) |b| {
|
||||
alt b {
|
||||
match b {
|
||||
ast::bound_send => ~[ty::bound_send],
|
||||
ast::bound_copy => ~[ty::bound_copy],
|
||||
ast::bound_const => ~[ty::bound_const],
|
||||
ast::bound_owned => ~[ty::bound_owned],
|
||||
ast::bound_trait(t) => {
|
||||
let ity = ast_ty_to_ty(ccx, empty_rscope, t);
|
||||
alt ty::get(ity).struct {
|
||||
match ty::get(ity).struct {
|
||||
ty::ty_trait(*) => {
|
||||
~[ty::bound_trait(ity)]
|
||||
}
|
||||
|
|
@ -629,7 +629,7 @@ fn ty_param_bounds(ccx: @crate_ctxt,
|
|||
}
|
||||
|
||||
@do params.map |param| {
|
||||
alt ccx.tcx.ty_param_bounds.find(param.id) {
|
||||
match ccx.tcx.ty_param_bounds.find(param.id) {
|
||||
some(bs) => bs,
|
||||
none => {
|
||||
let bounds = compute_bounds(ccx, param);
|
||||
|
|
|
|||
|
|
@ -249,8 +249,8 @@ fn single_type_contained_in(tcx: ty::ctxt, a: int_ty_set) ->
|
|||
fn convert_integral_ty_to_int_ty_set(tcx: ty::ctxt, t: ty::t)
|
||||
-> int_ty_set {
|
||||
|
||||
alt get(t).struct {
|
||||
ty_int(int_ty) => alt int_ty {
|
||||
match get(t).struct {
|
||||
ty_int(int_ty) => match int_ty {
|
||||
ast::ty_i8 => int_ty_set(INT_TY_SET_i8),
|
||||
ast::ty_i16 => int_ty_set(INT_TY_SET_i16),
|
||||
ast::ty_i32 => int_ty_set(INT_TY_SET_i32),
|
||||
|
|
@ -259,7 +259,7 @@ fn convert_integral_ty_to_int_ty_set(tcx: ty::ctxt, t: ty::t)
|
|||
ast::ty_char => tcx.sess.bug(
|
||||
~"char type passed to convert_integral_ty_to_int_ty_set()")
|
||||
}
|
||||
ty_uint(uint_ty) => alt uint_ty {
|
||||
ty_uint(uint_ty) => match uint_ty {
|
||||
ast::ty_u8 => int_ty_set(INT_TY_SET_u8),
|
||||
ast::ty_u16 => int_ty_set(INT_TY_SET_u16),
|
||||
ast::ty_u32 => int_ty_set(INT_TY_SET_u32),
|
||||
|
|
@ -335,7 +335,7 @@ enum fixup_err {
|
|||
}
|
||||
|
||||
fn fixup_err_to_str(f: fixup_err) -> ~str {
|
||||
alt f {
|
||||
match f {
|
||||
unresolved_int_ty(_) => ~"unconstrained integral type",
|
||||
unresolved_ty(_) => ~"unconstrained type",
|
||||
cyclic_ty(_) => ~"cyclic type of infinite size",
|
||||
|
|
@ -418,7 +418,7 @@ fn resolve_region(cx: infer_ctxt, r: ty::region, modes: uint)
|
|||
|
||||
fn resolve_borrowings(cx: infer_ctxt) {
|
||||
for cx.borrowings.each |item| {
|
||||
alt resolve_region(cx, item.scope, resolve_all|force_all) {
|
||||
match resolve_region(cx, item.scope, resolve_all|force_all) {
|
||||
ok(region) => {
|
||||
debug!{"borrowing for expr %d resolved to region %?, mutbl %?",
|
||||
item.expr_id, region, item.mutbl};
|
||||
|
|
@ -455,7 +455,7 @@ trait cres_helpers<T> {
|
|||
|
||||
impl methods<T:copy> of cres_helpers<T> for cres<T> {
|
||||
fn to_ures() -> ures {
|
||||
alt self {
|
||||
match self {
|
||||
ok(_v) => ok(()),
|
||||
err(e) => err(e)
|
||||
}
|
||||
|
|
@ -496,7 +496,7 @@ impl of to_str for ty::region {
|
|||
|
||||
impl<V:copy to_str> of to_str for bound<V> {
|
||||
fn to_str(cx: infer_ctxt) -> ~str {
|
||||
alt self {
|
||||
match self {
|
||||
some(v) => v.to_str(cx),
|
||||
none => ~"none"
|
||||
}
|
||||
|
|
@ -513,7 +513,7 @@ impl<T:copy to_str> of to_str for bounds<T> {
|
|||
|
||||
impl of to_str for int_ty_set {
|
||||
fn to_str(_cx: infer_ctxt) -> ~str {
|
||||
alt self {
|
||||
match self {
|
||||
int_ty_set(v) => uint::to_str(v, 10u)
|
||||
}
|
||||
}
|
||||
|
|
@ -521,7 +521,7 @@ impl of to_str for int_ty_set {
|
|||
|
||||
impl<V:copy vid, T:copy to_str> of to_str for var_value<V,T> {
|
||||
fn to_str(cx: infer_ctxt) -> ~str {
|
||||
alt self {
|
||||
match self {
|
||||
redirect(vid) => fmt!{"redirect(%s)", vid.to_str()},
|
||||
root(pt, rk) => fmt!{"root(%s, %s)", pt.to_str(cx),
|
||||
uint::to_str(rk, 10u)}
|
||||
|
|
@ -602,7 +602,7 @@ impl transaction_methods for infer_ctxt {
|
|||
|
||||
debug!{"try(tvbl=%u, rbl=%u)", tvbl, rbl};
|
||||
let r <- f();
|
||||
alt r {
|
||||
match r {
|
||||
result::ok(_) => debug!{"try--ok"},
|
||||
result::err(_) => {
|
||||
debug!{"try--rollback"};
|
||||
|
|
@ -681,14 +681,14 @@ impl methods for infer_ctxt {
|
|||
}
|
||||
|
||||
fn resolve_type_vars_if_possible(typ: ty::t) -> ty::t {
|
||||
alt resolve_type(self, typ, resolve_all) {
|
||||
match resolve_type(self, typ, resolve_all) {
|
||||
result::ok(new_type) => return new_type,
|
||||
result::err(_) => return typ
|
||||
}
|
||||
}
|
||||
|
||||
fn resolve_region_if_possible(oldr: ty::region) -> ty::region {
|
||||
alt resolve_region(self, oldr, resolve_all) {
|
||||
match resolve_region(self, oldr, resolve_all) {
|
||||
result::ok(newr) => return newr,
|
||||
result::err(_) => return oldr
|
||||
}
|
||||
|
|
@ -714,12 +714,12 @@ impl unify_methods for infer_ctxt {
|
|||
-> node<V, T> {
|
||||
|
||||
let vid_u = vid.to_uint();
|
||||
alt vb.vals.find(vid_u) {
|
||||
match vb.vals.find(vid_u) {
|
||||
none => {
|
||||
self.tcx.sess.bug(fmt!{"failed lookup of vid `%u`", vid_u});
|
||||
}
|
||||
some(var_val) => {
|
||||
alt var_val {
|
||||
match var_val {
|
||||
redirect(vid) => {
|
||||
let nde = self.get(vb, vid);
|
||||
if nde.root != vid {
|
||||
|
|
@ -744,7 +744,7 @@ impl unify_methods for infer_ctxt {
|
|||
debug!{"merge_bnd(%s,%s)", a.to_str(self), b.to_str(self)};
|
||||
let _r = indenter();
|
||||
|
||||
alt (a, b) {
|
||||
match (a, b) {
|
||||
(none, none) => ok(none),
|
||||
(some(_), none) => ok(a),
|
||||
(none, some(_)) => ok(b),
|
||||
|
|
@ -853,10 +853,10 @@ impl unify_methods for infer_ctxt {
|
|||
|
||||
// If both A's UB and B's LB have already been bound to types,
|
||||
// see if we can make those types subtypes.
|
||||
alt (a_bounds.ub, b_bounds.lb) {
|
||||
match (a_bounds.ub, b_bounds.lb) {
|
||||
(some(a_ub), some(b_lb)) => {
|
||||
let r = self.try(|| a_ub.sub(self, b_lb));
|
||||
alt r {
|
||||
match r {
|
||||
ok(()) => return result::ok(()),
|
||||
err(_) => { /*fallthrough */ }
|
||||
}
|
||||
|
|
@ -1022,7 +1022,7 @@ impl unify_methods for infer_ctxt {
|
|||
|
||||
debug!{"bnds(%s <: %s)", a.to_str(self), b.to_str(self)};
|
||||
do indent {
|
||||
alt (a, b) {
|
||||
match (a, b) {
|
||||
(none, none) |
|
||||
(some(_), none) |
|
||||
(none, some(_)) => {
|
||||
|
|
@ -1141,7 +1141,7 @@ impl methods for resolve_state {
|
|||
assert vec::is_empty(self.v_seen);
|
||||
let rty = indent(|| self.resolve_type(typ) );
|
||||
assert vec::is_empty(self.v_seen);
|
||||
alt self.err {
|
||||
match self.err {
|
||||
none => {
|
||||
debug!{"Resolved to %s (modes=%x)",
|
||||
ty_to_str(self.infcx.tcx, rty),
|
||||
|
|
@ -1155,7 +1155,7 @@ impl methods for resolve_state {
|
|||
fn resolve_region_chk(orig: ty::region) -> fres<ty::region> {
|
||||
self.err = none;
|
||||
let resolved = indent(|| self.resolve_region(orig) );
|
||||
alt self.err {
|
||||
match self.err {
|
||||
none => ok(resolved),
|
||||
some(e) => err(e)
|
||||
}
|
||||
|
|
@ -1166,7 +1166,7 @@ impl methods for resolve_state {
|
|||
indent(fn&() -> ty::t {
|
||||
if !ty::type_needs_infer(typ) { return typ; }
|
||||
|
||||
alt ty::get(typ).struct {
|
||||
match ty::get(typ).struct {
|
||||
ty::ty_var(vid) => {
|
||||
self.resolve_ty_var(vid)
|
||||
}
|
||||
|
|
@ -1201,7 +1201,7 @@ impl methods for resolve_state {
|
|||
|
||||
fn resolve_region(orig: ty::region) -> ty::region {
|
||||
debug!{"Resolve_region(%s)", orig.to_str(self.infcx)};
|
||||
alt orig {
|
||||
match orig {
|
||||
ty::re_var(rid) => self.resolve_region_var(rid),
|
||||
_ => orig
|
||||
}
|
||||
|
|
@ -1213,7 +1213,7 @@ impl methods for resolve_state {
|
|||
}
|
||||
let nde = self.infcx.get(self.infcx.rb, rid);
|
||||
let bounds = nde.possible_types;
|
||||
alt bounds {
|
||||
match bounds {
|
||||
{ ub:_, lb:some(r) } => { self.assert_not_rvar(rid, r); r }
|
||||
{ ub:some(r), lb:_ } => { self.assert_not_rvar(rid, r); r }
|
||||
{ ub:none, lb:none } => {
|
||||
|
|
@ -1226,7 +1226,7 @@ impl methods for resolve_state {
|
|||
}
|
||||
|
||||
fn assert_not_rvar(rid: region_vid, r: ty::region) {
|
||||
alt r {
|
||||
match r {
|
||||
ty::re_var(rid2) => {
|
||||
self.err = some(region_var_bound_by_region_var(rid, rid2));
|
||||
}
|
||||
|
|
@ -1251,7 +1251,7 @@ impl methods for resolve_state {
|
|||
let nde = self.infcx.get(self.infcx.tvb, vid);
|
||||
let bounds = nde.possible_types;
|
||||
|
||||
let t1 = alt bounds {
|
||||
let t1 = match bounds {
|
||||
{ ub:_, lb:some(t) } if !type_is_bot(t) => self.resolve_type(t),
|
||||
{ ub:some(t), lb:_ } => self.resolve_type(t),
|
||||
{ ub:_, lb:some(t) } => self.resolve_type(t),
|
||||
|
|
@ -1277,7 +1277,7 @@ impl methods for resolve_state {
|
|||
|
||||
// If there's only one type in the set of possible types, then
|
||||
// that's the answer.
|
||||
alt single_type_contained_in(self.infcx.tcx, pt) {
|
||||
match single_type_contained_in(self.infcx.tcx, pt) {
|
||||
some(t) => t,
|
||||
none => {
|
||||
if self.should(force_ivar) {
|
||||
|
|
@ -1351,9 +1351,9 @@ impl assignment for infer_ctxt {
|
|||
fn assign_tys(anmnt: assignment, a: ty::t, b: ty::t) -> ures {
|
||||
|
||||
fn select(fst: option<ty::t>, snd: option<ty::t>) -> option<ty::t> {
|
||||
alt fst {
|
||||
match fst {
|
||||
some(t) => some(t),
|
||||
none => alt snd {
|
||||
none => match snd {
|
||||
some(t) => some(t),
|
||||
none => none
|
||||
}
|
||||
|
|
@ -1364,7 +1364,7 @@ impl assignment for infer_ctxt {
|
|||
anmnt, a.to_str(self), b.to_str(self)};
|
||||
let _r = indenter();
|
||||
|
||||
alt (ty::get(a).struct, ty::get(b).struct) {
|
||||
match (ty::get(a).struct, ty::get(b).struct) {
|
||||
(ty::ty_bot, _) => {
|
||||
uok()
|
||||
}
|
||||
|
|
@ -1413,15 +1413,15 @@ impl assignment for infer_ctxt {
|
|||
let _r = indenter();
|
||||
|
||||
fn is_borrowable(v: ty::vstore) -> bool {
|
||||
alt v {
|
||||
match v {
|
||||
ty::vstore_fixed(_) | ty::vstore_uniq | ty::vstore_box => true,
|
||||
ty::vstore_slice(_) => false
|
||||
}
|
||||
}
|
||||
|
||||
alt (a_bnd, b_bnd) {
|
||||
match (a_bnd, b_bnd) {
|
||||
(some(a_bnd), some(b_bnd)) => {
|
||||
alt (ty::get(a_bnd).struct, ty::get(b_bnd).struct) {
|
||||
match (ty::get(a_bnd).struct, ty::get(b_bnd).struct) {
|
||||
(ty::ty_box(mt_a), ty::ty_rptr(r_b, mt_b)) => {
|
||||
let nr_b = ty::mk_box(self.tcx, {ty: mt_b.ty,
|
||||
mutbl: m_const});
|
||||
|
|
@ -1569,7 +1569,7 @@ fn super_substs<C:combine>(
|
|||
fn eq_opt_regions(infcx: infer_ctxt,
|
||||
a: option<ty::region>,
|
||||
b: option<ty::region>) -> cres<option<ty::region>> {
|
||||
alt (a, b) {
|
||||
match (a, b) {
|
||||
(none, none) => {
|
||||
ok(none)
|
||||
}
|
||||
|
|
@ -1625,7 +1625,7 @@ fn super_self_tys<C:combine>(
|
|||
// Note: the self type parameter is (currently) always treated as
|
||||
// *invariant* (otherwise the type system would be unsound).
|
||||
|
||||
alt (a, b) {
|
||||
match (a, b) {
|
||||
(none, none) => {
|
||||
ok(none)
|
||||
}
|
||||
|
|
@ -1677,7 +1677,7 @@ fn super_vstores<C:combine>(
|
|||
self: C, vk: ty::terr_vstore_kind,
|
||||
a: ty::vstore, b: ty::vstore) -> cres<ty::vstore> {
|
||||
|
||||
alt (a, b) {
|
||||
match (a, b) {
|
||||
(ty::vstore_slice(a_r), ty::vstore_slice(b_r)) => {
|
||||
do self.contraregions(a_r, b_r).chain |r| {
|
||||
ok(ty::vstore_slice(r))
|
||||
|
|
@ -1732,7 +1732,7 @@ fn super_tys<C:combine>(
|
|||
self: C, a: ty::t, b: ty::t) -> cres<ty::t> {
|
||||
|
||||
let tcx = self.infcx().tcx;
|
||||
alt (ty::get(a).struct, ty::get(b).struct) {
|
||||
match (ty::get(a).struct, ty::get(b).struct) {
|
||||
// The "subtype" ought to be handling cases involving bot or var:
|
||||
(ty::ty_bot, _) |
|
||||
(_, ty::ty_bot) |
|
||||
|
|
@ -1897,7 +1897,7 @@ impl of combine for sub {
|
|||
a.to_str(self.infcx()),
|
||||
b.to_str(self.infcx())};
|
||||
do indent {
|
||||
alt (a, b) {
|
||||
match (a, b) {
|
||||
(ty::re_var(a_id), ty::re_var(b_id)) => {
|
||||
do self.infcx().vars(self.rb, a_id, b_id).then {
|
||||
ok(a)
|
||||
|
|
@ -1929,7 +1929,7 @@ impl of combine for sub {
|
|||
return err(ty::terr_mutability);
|
||||
}
|
||||
|
||||
alt b.mutbl {
|
||||
match b.mutbl {
|
||||
m_mutbl => {
|
||||
// If supertype is mut, subtype must match exactly
|
||||
// (i.e., invariant if mut):
|
||||
|
|
@ -1965,7 +1965,7 @@ impl of combine for sub {
|
|||
a.to_str(*self), b.to_str(*self)};
|
||||
if a == b { return ok(a); }
|
||||
do indent {
|
||||
alt (ty::get(a).struct, ty::get(b).struct) {
|
||||
match (ty::get(a).struct, ty::get(b).struct) {
|
||||
(ty::ty_bot, _) => {
|
||||
ok(a)
|
||||
}
|
||||
|
|
@ -2077,7 +2077,7 @@ impl of combine for lub {
|
|||
m_const
|
||||
};
|
||||
|
||||
alt m {
|
||||
match m {
|
||||
m_imm | m_const => {
|
||||
self.tys(a.ty, b.ty).chain(|t| ok({ty: t, mutbl: m}) )
|
||||
}
|
||||
|
|
@ -2113,7 +2113,7 @@ impl of combine for lub {
|
|||
}
|
||||
|
||||
fn purities(f1: purity, f2: purity) -> cres<purity> {
|
||||
alt (f1, f2) {
|
||||
match (f1, f2) {
|
||||
(unsafe_fn, _) | (_, unsafe_fn) => ok(unsafe_fn),
|
||||
(impure_fn, _) | (_, impure_fn) => ok(impure_fn),
|
||||
(extern_fn, _) | (_, extern_fn) => ok(extern_fn),
|
||||
|
|
@ -2122,7 +2122,7 @@ impl of combine for lub {
|
|||
}
|
||||
|
||||
fn ret_styles(r1: ret_style, r2: ret_style) -> cres<ret_style> {
|
||||
alt (r1, r2) {
|
||||
match (r1, r2) {
|
||||
(ast::return_val, _) |
|
||||
(_, ast::return_val) => ok(ast::return_val),
|
||||
(ast::noreturn, ast::noreturn) => ok(ast::noreturn)
|
||||
|
|
@ -2140,7 +2140,7 @@ impl of combine for lub {
|
|||
b.to_str(self.infcx())};
|
||||
|
||||
do indent {
|
||||
alt (a, b) {
|
||||
match (a, b) {
|
||||
(ty::re_static, _) | (_, ty::re_static) => {
|
||||
ok(ty::re_static) // nothing lives longer than static
|
||||
}
|
||||
|
|
@ -2155,7 +2155,7 @@ impl of combine for lub {
|
|||
// at least as big as the block f_id". So, we can
|
||||
// reasonably compare free regions and scopes:
|
||||
let rm = self.infcx().tcx.region_map;
|
||||
alt region::nearest_common_ancestor(rm, f_id, s_id) {
|
||||
match region::nearest_common_ancestor(rm, f_id, s_id) {
|
||||
// if the free region's scope `f_id` is bigger than
|
||||
// the scope region `s_id`, then the LUB is the free
|
||||
// region itself:
|
||||
|
|
@ -2172,7 +2172,7 @@ impl of combine for lub {
|
|||
// subtype of the region corresponding to an inner
|
||||
// block.
|
||||
let rm = self.infcx().tcx.region_map;
|
||||
alt region::nearest_common_ancestor(rm, a_id, b_id) {
|
||||
match region::nearest_common_ancestor(rm, a_id, b_id) {
|
||||
some(r_id) => ok(ty::re_scope(r_id)),
|
||||
_ => ok(ty::re_static)
|
||||
}
|
||||
|
|
@ -2248,7 +2248,7 @@ impl of combine for glb {
|
|||
mt_to_str(tcx, a),
|
||||
mt_to_str(tcx, b)};
|
||||
|
||||
alt (a.mutbl, b.mutbl) {
|
||||
match (a.mutbl, b.mutbl) {
|
||||
// If one side or both is mut, then the GLB must use
|
||||
// the precise type from the mut side.
|
||||
(m_mutbl, m_const) => {
|
||||
|
|
@ -2310,7 +2310,7 @@ impl of combine for glb {
|
|||
}
|
||||
|
||||
fn purities(f1: purity, f2: purity) -> cres<purity> {
|
||||
alt (f1, f2) {
|
||||
match (f1, f2) {
|
||||
(pure_fn, _) | (_, pure_fn) => ok(pure_fn),
|
||||
(extern_fn, _) | (_, extern_fn) => ok(extern_fn),
|
||||
(impure_fn, _) | (_, impure_fn) => ok(impure_fn),
|
||||
|
|
@ -2319,7 +2319,7 @@ impl of combine for glb {
|
|||
}
|
||||
|
||||
fn ret_styles(r1: ret_style, r2: ret_style) -> cres<ret_style> {
|
||||
alt (r1, r2) {
|
||||
match (r1, r2) {
|
||||
(ast::return_val, ast::return_val) => {
|
||||
ok(ast::return_val)
|
||||
}
|
||||
|
|
@ -2337,7 +2337,7 @@ impl of combine for glb {
|
|||
b.to_str(self.infcx())};
|
||||
|
||||
do indent {
|
||||
alt (a, b) {
|
||||
match (a, b) {
|
||||
(ty::re_static, r) | (r, ty::re_static) => {
|
||||
// static lives longer than everything else
|
||||
ok(r)
|
||||
|
|
@ -2355,7 +2355,7 @@ impl of combine for glb {
|
|||
// is the scope `s_id`. Otherwise, as we do not know
|
||||
// big the free region is precisely, the GLB is undefined.
|
||||
let rm = self.infcx().tcx.region_map;
|
||||
alt region::nearest_common_ancestor(rm, f_id, s_id) {
|
||||
match region::nearest_common_ancestor(rm, f_id, s_id) {
|
||||
some(r_id) if r_id == f_id => ok(s),
|
||||
_ => err(ty::terr_regions_differ(b, a))
|
||||
}
|
||||
|
|
@ -2367,7 +2367,7 @@ impl of combine for glb {
|
|||
// these: so, if one of these scopes is a subscope of the
|
||||
// other, return it. Otherwise fail.
|
||||
let rm = self.infcx().tcx.region_map;
|
||||
alt region::nearest_common_ancestor(rm, a_id, b_id) {
|
||||
match region::nearest_common_ancestor(rm, a_id, b_id) {
|
||||
some(r_id) if a_id == r_id => ok(b),
|
||||
some(r_id) if b_id == r_id => ok(a),
|
||||
_ => err(ty::terr_regions_differ(b, a))
|
||||
|
|
@ -2475,7 +2475,7 @@ fn lattice_tys<L:lattice_ops combine>(
|
|||
b.to_str(self.infcx())};
|
||||
if a == b { return ok(a); }
|
||||
do indent {
|
||||
alt (ty::get(a).struct, ty::get(b).struct) {
|
||||
match (ty::get(a).struct, ty::get(b).struct) {
|
||||
(ty::ty_bot, _) => self.ty_bot(b),
|
||||
(_, ty::ty_bot) => self.ty_bot(a),
|
||||
|
||||
|
|
@ -2505,7 +2505,7 @@ fn lattice_tys<L:lattice_ops combine>(
|
|||
fn lattice_rvars<L:lattice_ops combine>(
|
||||
self: L, a: ty::region, b: ty::region) -> cres<ty::region> {
|
||||
|
||||
alt (a, b) {
|
||||
match (a, b) {
|
||||
(ty::re_var(a_id), ty::re_var(b_id)) => {
|
||||
lattice_vars(self, self.infcx().rb,
|
||||
a, a_id, b_id,
|
||||
|
|
@ -2558,9 +2558,9 @@ fn lattice_vars<V:copy vid, T:copy to_str st, L:lattice_ops combine>(
|
|||
// If both A and B have an UB type, then we can just compute the
|
||||
// LUB of those types:
|
||||
let a_bnd = self.bnd(a_bounds), b_bnd = self.bnd(b_bounds);
|
||||
alt (a_bnd, b_bnd) {
|
||||
match (a_bnd, b_bnd) {
|
||||
(some(a_ty), some(b_ty)) => {
|
||||
alt self.infcx().try(|| c_ts(a_ty, b_ty) ) {
|
||||
match self.infcx().try(|| c_ts(a_ty, b_ty) ) {
|
||||
ok(t) => return ok(t),
|
||||
err(_) => { /*fallthrough */ }
|
||||
}
|
||||
|
|
@ -2590,7 +2590,7 @@ fn lattice_var_t<V:copy vid, T:copy to_str st, L:lattice_ops combine>(
|
|||
a_id.to_str(), a_bounds.to_str(self.infcx()),
|
||||
b.to_str(self.infcx())};
|
||||
|
||||
alt self.bnd(a_bounds) {
|
||||
match self.bnd(a_bounds) {
|
||||
some(a_bnd) => {
|
||||
// If a has an upper bound, return the LUB(a.ub, b)
|
||||
debug!{"bnd=some(%s)", a_bnd.to_str(self.infcx())};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue